var keyboard_count=0;var deplacement_max=0;var position_start=0;var position_stop=0;var dragstart=false;var sensdeplacement="";var divgauche="";var divreference="";var divdroite="";var tuyau="";var count=0;var positionTuyauLeft_on=2;$(window).resize(function(){$('#frise_vignette').css('width',$(window).width()+'px')});$(function(){creation_bloc(0)});$(document).ready(function(){divgauche=$('.first_bloc');divreference=$('.principal_bloc');divdroite=$('.last_bloc');tuyau=$('#tuyau');$('#tuyau').draggable({axis:'x',start:function(event,ui){

$('.active_hover').unbind('click');$('.active_hover').unbind();

$(".active_hover").bind("click",function(e){return false});position_start=$(this).position();position_start=position_start.left;dragstart=true;$('#tuyau').stop();$('.hover_black').css({'opacity':'0'});$('.hover_title').css({'opacity':'0'})},drag:function(event,ui){$('.active_hover').unbind('click');$('.active_hover').unbind();$('.hover_black').css({'opacity':'0'});$('.hover_title').css({'opacity':'0'});

$(".active_hover").bind("click",function(e){return false})},stop:function(event,ui){$('.active_hover').unbind('click');$('.active_hover').unbind();$(".active_hover").bind("click",function(e){return false});position_stop=$(this).position();position_stop=position_stop.left;dropRepose()}});startkeyboard();startmousewheel();setInterval("listenerLauncher()",50)});function creation_bloc(tri_actif){var resolution_ecran=screen.width+100;var nb_li_origine=$('.callage li').size();width_ul_one=nb_li_origine*132;$('#frise_vignette').css('width',$(window).width()+'px');deplacement_max=width_ul_one;var nb_boucle=Math.ceil(resolution_ecran/width_ul_one);$('.callage').css('width',width_ul_one*nb_boucle+'px');var count_data_id=1;for(i=1;i<nb_boucle;i++){var clone_li=$('.callage ul li:lt('+nb_li_origine+')').clone();if(tri_actif==0){$('.callage ul').append(clone_li);$('.callage ul li').attr('data-id','')}else{$('.callage ul').append(clone_li);clone_li.hide();$('.principal_bloc li').each(function(index){$(this).delay(index*50).fadeIn(100)});var last_dataID=$('.callage ul li').eq(nb_li_origine-1).attr('data-id');last_dataID=last_dataID.replace('id-','');nb_index=nb_li_origine-1;$('.callage ul li:gt('+nb_index+')').attr('data-id','');last_dataID=parseInt(last_dataID)+1;$('.callage li:gt('+nb_index+')').each(function(index){var data_id="id-"+last_dataID;$(this).attr('data-id',data_id);last_dataID++})}if(tri_actif==0){$('.callage li').each(function(index){var data_id="id-"+count_data_id;$(this).attr('data-id',data_id);count_data_id++})}if(i==(nb_boucle-1)){clone_bloc_double()}}if(nb_boucle==1){clone_bloc_double()}}function clone_bloc_double(){var width_ul_origine=$('.callage').width();$('.bloc').css('width',width_ul_origine+'px');var width_total=width_ul_origine*3;$('.callage').css('width',width_total+'px');var clone_ul=$('.callage ul').first().clone().addClass('first_bloc').removeClass('principal_bloc');var clone_ul_2=$('.callage ul').last().clone().addClass('last_bloc').removeClass('principal_bloc');$('.callage').prepend(clone_ul);$('.callage').append(clone_ul_2);$('.first_bloc').css('left',-width_ul_origine+'px');$('.principal_bloc').css('left',0+'px');$('.last_bloc').css('left',width_ul_origine+'px');$('.first_bloc li').show();$('.last_bloc li').show()}function listenerLauncher(){var divref_pos=divreference.position();var tuyau_pos=tuyau.position();count++;if(divref_pos.left+tuyau_pos.left<0&&(divref_pos.left+tuyau_pos.left+divreference.width()<$(window).width())){var divmove=divgauche;divgauche=divreference;divreference=divdroite;divref_pos=divreference.position();divmove.css('left',divref_pos.left+divreference.width()+'px');divdroite=divmove}else if(divref_pos.left+tuyau_pos.left>0&&(divref_pos.left+tuyau_pos.left-divreference.width()>0)){var divmove=divdroite;divdroite=divreference;divreference=divgauche;divref_pos=divreference.position();divmove.css('left',divref_pos.left-divreference.width()+'px');divgauche=divmove}}function startkeyboard(){if($.browser.mozilla){$(document).keypress(keyboard_checkKey)}else{$(document).keydown(keyboard_checkKey)}}function startmousewheel(){tuyau.bind('mousewheel',function(event,delta){$('#content_main').jScrollPaneRemove();if(delta>0){vignette_deplacementgauche(delta)}else if(delta<0){vignette_deplacementdroite(-delta)}})}function keyboard_checkKey(e){switch(e.keyCode){case 37:vignette_deplacementgauche(1);break;case 39:vignette_deplacementdroite(1);break}}function vignette_deplacementgauche(ecart){if(keyboard_count<0)keyboard_count=0;keyboard_count=keyboard_count+ecart;var deplacement=132*keyboard_count;if(deplacement>deplacement_max)deplacement=deplacement_max;tuyau.stop().animate({left:'+='+deplacement+'px'},1200,function(){keyboard_count=0;$('#content_main').jScrollPane();


$(".active_hover").bind("click", function(e){
		var id_projet=$(this).attr('id');
		id_projet=id_projet.replace("projet_","");	
		var url = "#/projet/";
		url = url.replace(/^.*#/, '');
		$('#projet_actuel').val(id_projet);
		$.history.load(url); 
		$('#projet_actuel').val(id_projet);
		$('.select_vignette').css({'opacity':'0'});
		$(this).find('.select_vignette').stop().show().animate({'opacity':'1'},400);		
		var projet_en_cours = $('#projet_en_cours').val();		
		if(projet_en_cours==1){
			var id_actuel=$('#projet_actuel').val();
			if(id_actuel==""){id_actuel=$('#projet_actuel_direct').val();}
			affiche_projet_2(id_actuel);
		}		
		$('#projet_en_cours').val('1');
		return false;
	});

	$(".select_click").bind("click", function(e){	
		$('#projet_en_cours').val('1');
		var id_projet=$(this).find('input').attr('value');
		id_projet=id_projet.replace("projet_","");	
		var url = "#/projet/";
		url = url.replace(/^.*#/, '');
		$('#projet_actuel').val(id_projet);
		$.history.load(url); 
		$('#projet_actuel').val(id_projet);
		$('.select_vignette').css({'opacity':'0'});
		var id_projet_select = "li#projet_"+id_projet;
		$(id_projet_select).find('.select_vignette').stop().show().animate({'opacity':'1'},400);
		var projet_en_cours = $('#projet_en_cours').val();		
		if(projet_en_cours==1){
			var id_actuel=$('#projet_actuel').val();
			if(id_actuel==""){id_actuel=$('#projet_actuel_direct').val();}
			affiche_projet_2(id_actuel);
		}	
		$('#projet_en_cours').val('1');
	});

$(".active_hover").hover(function(){$(this).find('.hover_black').stop().show().animate({'opacity':'1'},400);$('#frise_vignette').css('height','137px');$(this).find('.hover_title').show().stop().animate({'opacity':'1'},400)},function(){$(this).find('.hover_black').stop().animate({'opacity':'0'},400);$(this).find('.hover_title').stop().animate({'opacity':'0'},400).hide()})})}function vignette_deplacementdroite(ecart){if(keyboard_count>0)keyboard_count=0;keyboard_count=keyboard_count-ecart;var deplacement=132*keyboard_count;if(deplacement<-deplacement_max)deplacement=-deplacement_max;tuyau.stop().animate({left:'+='+deplacement+'px'},1200,function(){keyboard_count=0;$('#content_main').jScrollPane();

$(".active_hover").bind("click", function(e){
		var id_projet=$(this).attr('id');
		id_projet=id_projet.replace("projet_","");	
		var url = "#/projet/";
		url = url.replace(/^.*#/, '');
		$('#projet_actuel').val(id_projet);
		$.history.load(url); 
		$('#projet_actuel').val(id_projet);
		$('.select_vignette').css({'opacity':'0'});
		$(this).find('.select_vignette').stop().show().animate({'opacity':'1'},400);		
		var projet_en_cours = $('#projet_en_cours').val();		
		if(projet_en_cours==1){
			var id_actuel=$('#projet_actuel').val();
			if(id_actuel==""){id_actuel=$('#projet_actuel_direct').val();}
			affiche_projet_2(id_actuel);
		}		
		$('#projet_en_cours').val('1');
		return false;
	});

$(".active_hover").hover(function(){$(this).find('.hover_black').stop().animate({'opacity':'0.6'},400);$('#frise_vignette').css('height','137px');$(this).find('.hover_title').stop().animate({'opacity':'1'},400)},function(){$(this).find('.hover_black').stop().animate({'opacity':'0'},400);$(this).find('.hover_title').stop().animate({'opacity':'0'},400)})})}function dropRepose(){if(position_start<position_stop)sensdeplacement="droite";else sensdeplacement="gauche";dragstart=false;var difference=position_start-position_stop;difference=-(difference);if(difference>2000){difference=2000}if(difference<-2000){difference=-2000}tuyau.stop().animate({left:"+="+difference+"px"},1500,function(){

$(".active_hover").bind("click", function(e){
		var id_projet=$(this).attr('id');
		id_projet=id_projet.replace("projet_","");	
		var url = "#/projet/";
		url = url.replace(/^.*#/, '');
		$('#projet_actuel').val(id_projet);
		$.history.load(url); 
		$('#projet_actuel').val(id_projet);
		$('.select_vignette').css({'opacity':'0'});
		$(this).find('.select_vignette').stop().show().animate({'opacity':'1'},400);		
		var projet_en_cours = $('#projet_en_cours').val();		
		if(projet_en_cours==1){
			var id_actuel=$('#projet_actuel').val();
			if(id_actuel==""){id_actuel=$('#projet_actuel_direct').val();}
			affiche_projet_2(id_actuel);
		}		
		$('#projet_en_cours').val('1');
		return false;
	});
	$(".select_click").bind("click", function(e){	
		$('#projet_en_cours').val('1');
		var id_projet=$(this).find('input').attr('value');
		id_projet=id_projet.replace("projet_","");	
		var url = "#/projet/";
		url = url.replace(/^.*#/, '');
		$('#projet_actuel').val(id_projet);
		$.history.load(url); 
		$('#projet_actuel').val(id_projet);
		$('.select_vignette').css({'opacity':'0'});
		var id_projet_select = "li#projet_"+id_projet;
		$(id_projet_select).find('.select_vignette').stop().show().animate({'opacity':'1'},400);
		var projet_en_cours = $('#projet_en_cours').val();		
		if(projet_en_cours==1){
			var id_actuel=$('#projet_actuel').val();
			if(id_actuel==""){id_actuel=$('#projet_actuel_direct').val();}
			affiche_projet_2(id_actuel);
		}	
		$('#projet_en_cours').val('1');
	});$(".active_hover").hover(function(){$(this).find('.hover_black').stop().show().animate({'opacity':'1'},400);$('#frise_vignette').css('height','137px');$(this).find('.hover_title').show().stop().animate({'opacity':'1'},400)},function(){$(this).find('.hover_black').stop().animate({'opacity':'0'},400);$(this).find('.hover_title').stop().animate({'opacity':'0'},400).hide()})})}
