jQuery(function( $ ){
	/**
	 * Demo binding and preparation, no need to read this part
	 */
	//borrowed from jQuery easing plugin
	//http://gsgd.co.uk/sandbox/jquery.easing.php
	$.easing.elasout =  function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	};
	
	
	$.easing.easeInOutBounce= function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	}


});


$('.sumup1 a').click(function(){
	$('html, body').animate({ scrollTop: $('#sumup1').offset().top  }, 1000);					
//	$.scrollTo( $('#rute'), 1500, {axis:'y', easing:'elasout' });
	//$("#rute").animate({"scrollTop": $("#rute").scrollTop() + 100}); 
	//+=100px
	return false;
});


$('.sumup2 a').click(function(){
	$('html, body').animate({ scrollTop: $('#sumup2').offset().top - 130 },  1000);	
//$.scrollTo( '#bloc', 1500, { easing:'elasout' });  
	//$.scrollTo( $('#rute'), 1500, {axis:'y' , easing:'elasout' });
	//$("#rute").animate({"scrollTop": $("#rute").scrollTop() + 100}); 
	//+=100px
	return false;
});

$('.sumup3 a').click(function(){
	$('html, body').animate({ scrollTop: $('#sumup3').offset().top - 130 }, 1000);					
	//$.scrollTo( $('#rute'), 1500, {axis:'y', easing:'elasout' });
	//$("#rute").animate({"scrollTop": $("#rute").scrollTop() + 100}); 
	//+=100px
	return false;
});



$('.LINK1 a').click(function(){
	$('html, body').animate({ scrollTop: $('#PRESTA01').offset().top - 130 }, 1000);
	return false;
});
$('.LINK2 a').click(function(){
	$('html, body').animate({ scrollTop: $('#PRESTA02').offset().top - 130 }, 1000);
	return false;
});
$('.LINK3 a').click(function(){
	$('html, body').animate({ scrollTop: $('#PRESTA03').offset().top - 130 }, 1000);
	return false;
});
$('.LINK4 a').click(function(){
	$('html, body').animate({ scrollTop: $('#PRESTA04').offset().top - 130 }, 1000);
	return false;
});
$('.LINK5 a').click(function(){
	$('html, body').animate({ scrollTop: $('#PRESTA05').offset().top - 130 }, 1000);
	return false;
});
$('.LINK6 a').click(function(){
	$('html, body').animate({ scrollTop: $('#PRESTA06').offset().top - 130 }, 1000);
	return false;
});
$('.LINK7 a').click(function(){
	$('html, body').animate({ scrollTop: $('#PRESTA07').offset().top - 130 }, 1000);
	return false;
});
$('.LINK8 a').click(function(){
	$('html, body').animate({ scrollTop: $('#PRESTA08').offset().top - 130 }, 1000);
	return false;
});


$('.basBOUTON1 a').click(function(){
	$('html, body').animate({ scrollTop: $('#presta_esthetique').offset().top - 130 }, 1000);
	return false;
});

$('.basBOUTON2 a').click(function(){
	$('html, body').animate({ scrollTop: $('#presta_maquillage').offset().top - 130 }, 1000);
	return false;
});

$('.topBOUTON2 a').click(function(){
	$('html, body').animate({ scrollTop: $('#presta_coiffage').offset().top - 130 }, 1000);
	return false;
});


$('.basBOUTON3 a').click(function(){
	$('html, body').animate({ scrollTop: $('#presta_onglerie').offset().top - 130 }, 1000);		
	return false;
});

$('.topBOUTON3 a').click(function(){
	$('html, body').animate({ scrollTop: $('#presta_esthetique').offset().top - 130 }, 1000);
	return false;
});


$('.basBOUTONonglerie a').click(function(){
	$('html, body').animate({ scrollTop: $('#presta_bienetre').offset().top - 130 }, 1000);		
	return false;
});

$('.topBOUTONonglerie a').click(function(){
	$('html, body').animate({ scrollTop: $('#presta_maquillage').offset().top - 130 }, 1000);
	return false;
});

$('.basBOUTON4 a').click(function(){
	$('html, body').animate({ scrollTop: $('#presta_amincissement').offset().top - 130 }, 1000);		
	return false;
});

$('.topBOUTON4 a').click(function(){
	$('html, body').animate({ scrollTop: $('#presta_onglerie').offset().top - 130 }, 1000);
	return false;
});

$('.basBOUTON5 a').click(function(){
	$('html, body').animate({ scrollTop: $('#presta_conseil').offset().top - 130 }, 1000);		
	return false;
});

$('.topBOUTON5 a').click(function(){
	$('html, body').animate({ scrollTop: $('#presta_bienetre').offset().top - 130 }, 1000);
	return false;
});

$('.topBOUTON6 a').click(function(){
	$('html, body').animate({ scrollTop: $('#presta_amincissement').offset().top - 130 }, 1000);
	return false;
});
$('.doubleBOUTON5 a').click(function(){
	$('html, body').animate({ scrollTop: $('#presta_coiffage').offset().top - 130 }, 1000);		
	return false;
});

$('.doubleBOUTON1 a').click(function(){
	$('html, body').animate({ scrollTop: $('#presta_conseil').offset().top - 130 }, 1000);		
	return false;
});


$('.PRESTABOUTON1 a').click(function(){
var anchor = $(this).attr("href");
$('html, body').animate({ scrollTop: $('anchor').offset().top - 130 }, 1000);
									 
//$('html, body').animate({"top" : + 350 }, 1000);
//$.scrollTo('+=350px', 800, { axis:'y', easing:'elasout' }); 

//$.scrollTo( $('html, body'), 1500, {axis:'y' , easing:'elasout' });
	//$('html, body').animate({ scrollTop: $('html, body').scrollTop() - 350 }, 1000);
//$('html, body').animate({ scrollTop: $('#').offset().y - 350 }, 1000);
//	$('html, body').animate({ scrollTop: $('#presta_bienetre').offset().top - 120 }, 1000);
		//$('html, body').animate({ scrollTop: $('#presta_bienetre').offset().top - 120 }, 1000);	

	return false;
	
});






$('#CLOSE').click(function() {     
$('#FENETRE').fadeOut();
}); 

$('#NEWSLETTER_OPEN').click(function() {     
$('#NEWSLETTER_FENETRE').fadeIn();
}); 

$('#NEWSLETTER_CLOSE').click(function() {     
$('#NEWSLETTER_FENETRE').fadeOut();
}); 



$('#RECHERCHE_OPEN').click(function() {     
$('#RECHERCHE_FENETRE').fadeIn();
}); 

$('#RECHERCHE_CLOSE').click(function() {     
$('#RECHERCHE_FENETRE').fadeOut();
}); 


/*
$(document).ready(function(){
$("ul.topnav li a").click(function(){
$("ul.topnav li a").removeClass('current');
$(this).addClass('current');
});
});
*/
$(document).ready(function(){
	$('#NEWSLETTER_FENETRE').hide();
	$('#RECHERCHE_FENETRE').hide();
// $("#NEWSLETTER_FENETRE").css('display','none');
	$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav

//$("ul.topnav li a").click(function(){
//$("ul.topnav li a").removeClass('current');
//$(this).addClass('current');
//});
	
	$("ul.topnav li a").mouseover(function() { //When trigger is clicked...
		//Following events are applied to the subnav itself (moving subnav up and down)
		//$(this).addClass('current');
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

//$('ul.topnav li').removeClass('current');

		$(this).parent().hover(function() {
		}, function(){	
			$(this).parent().find("ul.subnav").slideUp('medium'); //When the mouse hovers out of the subnav, move it back up
		});
		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() { 
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});
	


});
//fadeIn()

//$('.CLOSE a').click(function(){
//	jQuery("#FENETRE").hide();
//});


$(document).ready(function() {

	//Set Default State of each portfolio piece
	$(".paging").show();
	$(".paging a:first").addClass("active");
		
	//Get size of images, how many there are, then determin the size of the image reel.
	var imageWidth = $(".window").width();
	var imageSum = $(".image_reel img").size();
	var imageReelWidth = imageWidth * imageSum;
	
	//Adjust the image reel to its new size
	$(".image_reel").css({'width' : imageReelWidth});
	
	//Paging + Slider Function
	rotate = function(){	
		var triggerID = $active.attr("rel") - 1; //Get number of times to slide
		var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide

		$(".paging a").removeClass('active'); //Remove all active class
		$active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)
		
		//Slider Animation
		$(".image_reel").animate({ 
			left: -image_reelPosition
		}, 500 );
		
	}; 
	
	//Rotation + Timing Event
	rotateSwitch = function(){		
		play = setInterval(function(){ //Set timer - this will repeat itself every 3 seconds
			$active = $('.paging a.active').next();
			if ( $active.length === 0) { //If paging reaches the end...
				$active = $('.paging a:first'); //go back to first
			}
			rotate(); //Trigger the paging and slider function
		}, 7000); //Timer speed in milliseconds (3 seconds)
	};
	
	rotateSwitch(); //Run function on launch
	
	//On Hover
	$(".image_reel").hover(function() {
		clearInterval(play); //Stop the rotation
	}, function() {
		rotateSwitch(); //Resume rotation
	});	
	
	//On Click
	$(".paging a").click(function() {	
		$active = $(this); //Activate the clicked paging
		//Reset Timer
		clearInterval(play); //Stop the rotation
		rotate(); //Trigger rotation immediately
		rotateSwitch(); // Resume rotation
		return false; //Prevent browser jump to link anchor
	});	
	
});


