
$(document).ready(function(){
		
	//baseUrl
	base_url = $('#homelink').attr("href");
	
	//liens en blank
	$("a.blank").each(function(i){$(this).attr("target","_blank");});
	
	/* rollover discover */
	$('#slidehp').mouseover(function(){
		$('#slidehp img').hide();
		$("#slidehp").css({ background: 'url(/wp-content/themes/ysl/images/discover1-on' + ($(this).hasClass('en') ? '_en' : '') + '.png)' });
		return false;
	});
	$('#slidehp').mouseout(function(){
		$('#slidehp img').show();
		$("#slidehp").css({ background: 'none' });
		return false;
	});
	$('#discover2').mouseover(function(){
		$(this).attr({ src :  '/wp-content/themes/ysl/images/discover2-on' + ($(this).hasClass('en') ? '_en' : '') + '.png' });
		return false;
	});
	$('#discover2').mouseout(function(){
		$(this).attr({ src :  '/wp-content/themes/ysl/images/discover2.png' });
		return false;
	});
	$('#discover3').mouseover(function(){
		$(this).attr({ src :  '/wp-content/themes/ysl/images/discover3-on' + ($(this).hasClass('en') ? '_en' : '') + '.png' });
		return false;
	});
	$('#discover3').mouseout(function(){
		$(this).attr({ src :  '/wp-content/themes/ysl/images/discover3.png' });
		return false;
	});
	$('#slideshow').mouseover(function(){
		$('#slideshow img').hide();
		$("#slideshow").css({ background: 'url(' +  '/wp-content/themes/ysl/images/discover4-on' + ($(this).hasClass('en') ? '_en' : '') + '.png)' });
		return false;
	});
	$('#slideshow').mouseout(function(){
		$('#slideshow img').show();
		$("#slideshow").css({ background: 'none' });
		return false;
	});
	$('#discover5').mouseover(function(){
		$(this).attr({ src :  '/wp-content/themes/ysl/images/discover5-on' + ($(this).hasClass('en') ? '_en' : '') + '.png' });
		return false;
	});
	$('#discover5').mouseout(function(){
		$(this).attr({ src :  '/wp-content/themes/ysl/images/discover5.png' });
		return false;
	});
	
	/* rollover footer partenaires 
	$('#part1').mouseover(function(){
		$(this).attr({ src :  '/wp-content/themes/ysl/images/part1-on.png' });
		return false;
	});
	$('#part1').mouseout(function(){
		$(this).attr({ src :  '/wp-content/themes/ysl/images/part1.png' });
		return false;
	});
	
	$('#part2').mouseover(function(){
		$(this).attr({ src :  '/wp-content/themes/ysl/images/part2-on.png' });
		return false;
	});
	$('#part2').mouseout(function(){
		$(this).attr({ src :  '/wp-content/themes/ysl/images/part2.png' });
		return false;
	});
	
	$('#part3').mouseover(function(){
		$(this).attr({ src :  '/wp-content/themes/ysl/images/part3-on.png' });
		return false;
	});
	$('#part3').mouseout(function(){
		$(this).attr({ src :  '/wp-content/themes/ysl/images/part3.png' });
		return false;
	});
	
	$('#part4').mouseover(function(){
		$(this).attr({ src :  '/wp-content/themes/ysl/images/part4-on.png' });
		return false;
	});
	$('#part4').mouseout(function(){
		$(this).attr({ src :  '/wp-content/themes/ysl/images/part4.png' });
		return false;
	});
	
	$('#part5').mouseover(function(){
		$(this).attr({ src :  '/wp-content/themes/ysl/images/part5-on.png' });
		return false;
	});
	$('#part5').mouseout(function(){
		$(this).attr({ src :  '/wp-content/themes/ysl/images/part5.png' });
		return false;
	});
	
	$('#part6').mouseover(function(){
		$(this).attr({ src :  '/wp-content/themes/ysl/images/part6-on.png' });
		return false;
	});
	$('#part6').mouseout(function(){
		$(this).attr({ src :  '/wp-content/themes/ysl/images/part6.png' });
		return false;
	});
	
	$('#part7').mouseover(function(){
		$(this).attr({ src :  '/wp-content/themes/ysl/images/part7-on.png' });
		return false;
	});
	$('#part7').mouseout(function(){
		$(this).attr({ src :  '/wp-content/themes/ysl/images/part7.png' });
		return false;
	});
	
	$('#part8').mouseover(function(){
		$(this).attr({ src :  '/wp-content/themes/ysl/images/part8-on.png' });
		return false;
	});
	$('#part8').mouseout(function(){
		$(this).attr({ src :  '/wp-content/themes/ysl/images/part8.png' });
		return false;
	});*/
	
	/* rollover footer reseaux sociaux*/
	$('#footer a.facebook').mouseover(function(){
		$(this).children().attr({ src :  '/wp-content/themes/ysl/img/btn-facebook-on.png' });
		return false;
	});
	$('#footer a.facebook').mouseout(function(){
		$(this).children().attr({ src :  '/wp-content/themes/ysl/img/btn-facebook.png' });
		return false;
	});

	$('#footer a.twitter').mouseover(function(){
		$(this).children().attr({ src :  '/wp-content/themes/ysl/img/btn-twitter-on.png' });
		return false;
	});
	$('#footer a.twitter').mouseout(function(){
		$(this).children().attr({ src :  '/wp-content/themes/ysl/img/btn-twitter.png' });
		return false;
	});

	//lancement flash depuis html
	$('#slideshow').click(function(){
		$.scrollTo( 0, 10 );
		getMovieName("yslflash").startSlideshow(); 
		return false;
	});
	$('#slidehp').click(function(){
		$.scrollTo( 0, 10 );
		getMovieName("yslflash").startSlideshow(); 
		return false;
	});
	
	//diapo exposition
    $('#slideshow').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});
	//diapo hp
    $('#slidehp').cycle({
		fx:      'fade', 
		timeout:  4000, 
	});
	
	//nice titles
	$("#partenaires a").niceTitle({showLink: false});
	$("#footer .gauche a").niceTitle({showLink: false});
	
	//scroll mentions
	init_col2height();
	
	$(window).scroll(function(){
		var top = $(window).scrollTop();
		var margin = top - distFromTop;
		if(margin >= marginMax) margin = marginMax;
		else if(margin <= 0) margin = 0;
		$('.mentions').css('margin-top',margin+'px');
	});	
	
	 $("#credits").click(function(){  
		window.open("/credits.html","credits","menubar=no, status=no, scrollbars=no, menubar=no, width=300, height=670");
		return false;
	 }); 
  
});


function getMovieName(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
   }
   else {
       return document[movieName]
   }
}

function init_col2height(){
	colHeight = $('#col2').height();
	marginMax = colHeight;
	if(marginMax<0) marginMax = 0;
	distFromTop = $('#header').height() + 680;
}
