// JavaScript Document
$(document).ready(function() {
				$("#suite_lien").click(function() { // si le lien ayant pour id "monLien" est cliqué, on exécute le code à la suite
							//document.getElementById("suite").style.border = '2px solid #666666';
							//document.getElementById("suite").style.borderTop = '3px solid #666666';
							$("#suite").css("border", "#c00 2px solid");
						$("#suite").css("border-top", "#eee 2px solid");
						
						$("#saas").hide("normal");
						$("#sign").hide("normal");
						$("#keyvelop").hide("normal");
						$("#pea").hide("normal");
						$("#suite").show("normal");
						
						
						$("#pea_lien").css("width","184px");
						$("#pea_lien").css("background-position","0px 0px");
						$("#saas_lien").css("width","184px");
						$("#saas_lien").css("background-position","0px 0px");
						$("#sign_lien").css("width","184px");
						$("#sign_lien").css("background-position","0px 0px");
						$("#keyvelop_lien").css("width","184px");
						$("#keyvelop_lien").css("background-position","0px 0px");
						
						document.getElementById("to_the_top").style.display = 'block';
					
							 
                  });		   
						   
						   
                  $("#pea_lien").click(function() { // si le lien ayant pour id "monLien" est cliqué, on exécute le code à la suite
						//document.getElementById("pea").style.border = '2px solid #566C38';
					//document.getElementById("pea").style.borderTop = '3px solid #566C38';
						$("#pea").css("border", "#76903e 2px solid");
						$("#pea").css("border-top", "#eee 2px solid");
						
						$("#saas").hide("normal");
						$("#sign").hide("normal");
						$("#keyvelop").hide("normal");
						$("#suite").hide("normal");
						$("#pea").show("normal");
						
						$("#pea_lien").css("width","277px");
						$("#pea_lien").css("background-position","-184px");
						$("#saas_lien").css("width","153px");
						$("#saas_lien").css("background-position","-461px");
						$("#sign_lien").css("width","153px");
						$("#sign_lien").css("background-position","-461px");
						$("#keyvelop_lien").css("width","153px");
						$("#keyvelop_lien").css("background-position","-461px");
						
						document.getElementById("to_the_top").style.display = 'none';
						
							 
                  });
				
				   $("#saas_lien").click(function() { // si le lien ayant pour id "monLien" est cliqué, on exécute le code à la suite 
							 
						//document.getElementById("saas").style.border = '2px solid #362562';
						//document.getElementById("saas").style.borderTop = '3px solid #362562';
						$("#saas").css("border", "#3f2a70 2px solid");
						$("#saas").css("border-top", "#eee 2px solid");
						
						$("#pea").hide("normal");
						$("#sign").hide("normal");
						$("#keyvelop").hide("normal");
						$("#suite").hide("normal");
						$("#saas").show("normal");
							  
							  
						$("#saas_lien").css("width","277px");
						$("#saas_lien").css("background-position","-184px");
						$("#pea_lien").css("width","153px");
						$("#pea_lien").css("background-position","-461px");
						$("#sign_lien").css("width","153px");
						$("#sign_lien").css("background-position","-461px");
						$("#keyvelop_lien").css("width","153px");
						$("#keyvelop_lien").css("background-position","-461px");
						document.getElementById("to_the_top").style.display = 'none';
                  });
				   $("#sign_lien").click(function() { // si le lien ayant pour id "monLien" est cliqué, on exécute le code à la suite     
						//document.getElementById("sign").style.border = '2px solid #77ADDE';
						//document.getElementById("sign").style.borderTop = '3px solid #77ADDE';
						$("#sign").css("border", "#0095da 2px solid");
						$("#sign").css("border-top", "#eee 2px solid");
						
						$("#pea").hide("normal");
						$("#saas").hide("normal");
						$("#keyvelop").hide("normal");
						$("#suite").hide("normal");
						$("#sign").show("normal");
						
						$("#sign_lien").css("width","277px");
						$("#sign_lien").css("background-position","-184px");
						$("#saas_lien").css("width","153px");
						$("#saas_lien").css("background-position","-461px");
						$("#pea_lien").css("width","153px");
						$("#pea_lien").css("background-position","-461px");
						$("#keyvelop_lien").css("width","153px");
						$("#keyvelop_lien").css("background-position","-461px");
						document.getElementById("to_the_top").style.display = 'none';
                  });
				    $("#keyvelop_lien").click(function() { // si le lien ayant pour id "monLien" est cliqué, on exécute le code à la suite                 
						//document.getElementById("keyvelop").style.border = '2px solid #cc0000';
						//document.getElementById("keyvelop").style.borderTop = '3px solid #cc0000';
						$("#keyvelop").css("border", "#f47721 2px solid");
						$("#keyvelop").css("border-top", "#eee 2px solid");
						
						$("#pea").hide("normal");
						$("#sign").hide("normal");
						$("#saas").hide("normal");
						$("#suite").hide("normal");
						$("#keyvelop").show("normal");
						$("#keyvelop_lien").css("width","277px");
						$("#keyvelop_lien").css("background-position","-184px");
						$("#saas_lien").css("width","153px");
						$("#saas_lien").css("background-position","-461px");
						$("#sign_lien").css("width","153px");
						$("#sign_lien").css("background-position","-461px");
						$("#pea_lien").css("width","153px");
						$("#pea_lien").css("background-position","-461px");
						document.getElementById("to_the_top").style.display = 'none';
                  });
					
});



//galerie bannieres
$(document).ready(function(){

	var currentPos=new Number(1);
	var totWidth=new Number(0);
	var totBanner=new Number(0);
	var positions=new Array();
	
	$('#galerie .banner').each(function(i){
		totBanner+=1;
		positions[i+1]= totWidth;
		//totWidth += $(this).width()+20;
		totWidth += $(this).width();
	});

	$('#slideshow').prepend('<div id="left" class="controle" style="display:none;">&laquo;</div><div id="right" class="controle">&raquo;</div>');
	$('#galerie').width(totWidth);
	$('#galerie').after('<ul id="thumbs"></ul>');
	for (var y=1;y<=totBanner;y++) {
		$('#thumbs').append('<li id="'+y+'">+</li>');
		
	};
	
	var direct = function() {
		//alert('direct1-' + currentPos + typeof currentPos);
		$('#thumbs li').removeClass('survol');
		currentPos = parseInt($(this).attr('id'));
		$(this).addClass('survol');
		$('#galerie').stop().animate({marginLeft:-positions[currentPos]+'px'},1000);
		//$('#galerie').animate({marginLeft:-positions[currentPos]+'px'},1000);
		$('.controle').fadeIn();
		if(currentPos==1) $('#left').fadeOut();
		if(currentPos==totBanner) $('#right').fadeOut();
		//alert('direct2-' + currentPos + typeof currentPos);
		
	};
	
	var animation = function() {
		//alert('anim1-' + currentPos + typeof currentPos);
		$('#thumbs li').removeClass('survol');
		$('.controle').unbind('click', animation);
		//currentPos+=1;
		($(this).attr('id')=='right') ? currentPos+=1 : currentPos-=1;
		$('#galerie').stop().animate({marginLeft:-positions[currentPos]+'px'},1000,function(){
			$('.controle').bind('click', animation);
		});
		$('#'+(currentPos)).addClass('survol');
		$('.controle').fadeIn();
		if(currentPos==1) $('#left').fadeOut();
		if(currentPos==totBanner) $('#right').fadeOut();
		//alert('anim2-' +currentPos + typeof currentPos);
	};
	
	$('.controle').bind('click', animation);
	$('#thumbs li').bind('click', direct);
	$('#thumbs li:first').addClass('survol');
	
	$(window).load(function(){
	// The window.load event guarantees that
	// all the images are loaded before the
	// auto-advance begins.
	var timeOut = null;
	
	$('#slideshow .controle, #slideshow #thumbs').click(function(e,simulated){
		// The simulated parameter is set by the trigger method.
		if(!simulated){
			// A real click occured. Cancel the auto advance animation.
			clearTimeout(timeOut);
		}
	});
	// A self executing named function expression:
	(function autoAdvance(){
		// Simulating a click on the next arrow.
		//alert(totBanner);
		if(currentPos==totBanner){
			$('#slideshow #1').trigger('click',[true]);
		}
		else{
			$('#slideshow #right').trigger('click',[true]);
		}
		// Schedulling a time out in 10 seconds.
		timeOut = setTimeout(autoAdvance,10000);
	})();
});
});


