
var selectedInput=null;
var last_selection_id="selection_1";
var last_selectionb_id="selectionb_1";
var last_selectionc_id="selectionc_1";
var time;
var time2;
var time3;
var hidetime=500;
var showtime=500;

$(document).ready(function(){

if($("#nos_selections > div").length>1){
$(".change_slide").click(function(){
	clearTimeout(time);
	$(".slideshowpause").attr("src","/media/images/play.png");
	$("#playpause").attr("class","slideshowplay");
	var h=1;
	var k=$(this).attr("id").split("_");
	var f=k.length;
	var e=last_selection_id.split("_");
	var j=e.length;
	var g=parseInt($("#nos_selections > div").length)-h;
	if(last_selection_id=="#selection_0"){
		$("#selection_"+g).hide(1,function(){
			for(var l=0;l<=g;l++){
				$("#selection_"+l).hide();
				$("#cpt_selection_"+l).css("background-color","transparent")
			}
			$("#selection_"+(parseInt(k[f-1]))).fadeIn(showtime);
			$("#cpt_selection_"+(parseInt(k[f-1]))).css("background-color","#fff");
			$("#titre_nos_selections").html($("#title_"+(parseInt(k[f-1]))).html())
		})
	}
	else{
		$("#selection_"+parseInt(e[j-1])).hide(1,function(){
			for(var l=0;l<=g;l++){
				$("#selection_"+l).hide();
				$("#cpt_selection_"+l).css("background-color","transparent")
			}
			$("#selection_"+(parseInt(k[f-1]))).fadeIn(showtime);
			$("#cpt_selection_"+(parseInt(k[f-1]))).css("background-color","#fff");
			$("#titre_nos_selections").html($("#title_"+(parseInt(k[f-1]))).html())
			})
	}
	last_selection_id=(parseInt(k[f-1])==g)?"#selection_0":"#selection_"+(parseInt(k[f-1]));
	return false
});

if(parseInt($("#auto_slide").attr("value"))>0){
	$(".liens_diapo_selection").append('<img src="/media/images/pause.png" class="slideshowpause" id="playpause">');
	time=setInterval("slideSwitch()",parseInt($("#auto_slide").attr("value"))+hidetime+showtime)
}
else{
	$(".liens_diapo_selection").append('<img src="/media/images/play.png" class="slideshowplay" id="playpause">')
}
$("#playpause").click(function(){
	if($("#playpause").attr("class")=="slideshowpause"){
		clearTimeout(time);
		$(".slideshowpause").attr("src","/media/images/play.png");
		$(".slideshowpause").attr("class","slideshowplay")
	}
	else{
		if($("#playpause").attr("class")=="slideshowplay"){
			$(".slideshowplay").attr("src","/media/images/pause.png");
			$(".slideshowplay").attr("class","slideshowpause");
			slideSwitch();
			time=setInterval("slideSwitch()",parseInt($("#auto_slide").attr("value"))+hidetime+showtime)
		}
	}
});

$(".contenu_nos_selections").click(function(){
	if($(".slideshowpause").attr("class")=="slideshowpause"){
		clearTimeout(time);
		$(".slideshowpause").attr("src","media/images/play.png");
		$("#playpause").attr("class","slideshowplay")
	}
})
}

if($("#nos_selectionsb > div").length>1){
$(".change_slideb").click(function(){
	clearTimeout(time2);
	$(".slideshowpauseb").attr("src","/media/images/play.png");
	$("#playpauseb").attr("class","slideshowplayb");
	var h=1;
	var k=$(this).attr("id").split("_");
	var f=k.length;
	var e=last_selectionb_id.split("_");
	var j=e.length;
	var g=parseInt($("#nos_selectionsb > div").length)-h;
	if(last_selectionb_id=="#selectionb_0"){
		$("#selectionb_"+g).hide(1,function(){
			for(var l=0;l<=g;l++){
				$("#selectionb_"+l).hide();
				$("#cpt_selectionb_"+l).css("background-color","transparent")
			}
			$("#selectionb_"+(parseInt(k[f-1]))).fadeIn(showtime);
			$("#cpt_selectionb_"+(parseInt(k[f-1]))).css("background-color","#fff");
			$("#titre_nos_selectionsb").html($("#title_"+(parseInt(k[f-1]))).html())
		})
	}
	else{
		$("#selectionb_"+parseInt(e[j-1])).hide(1,function(){
			for(var l=0;l<=g;l++){
				$("#selectionb_"+l).hide();
				$("#cpt_selectionb_"+l).css("background-color","transparent")
			}
			$("#selectionb_"+(parseInt(k[f-1]))).fadeIn(showtime);
			$("#cpt_selectionb_"+(parseInt(k[f-1]))).css("background-color","#fff");
			$("#titre_nos_selectionsb").html($("#title_"+(parseInt(k[f-1]))).html())
			})
	}
	last_selectionb_id=(parseInt(k[f-1])==g)?"#selectionb_0":"#selectionb_"+(parseInt(k[f-1]));
	return false
});

if(parseInt($("#auto_slideb").attr("value"))>0){
	$(".liens_diapo_selectionb").append('<img src="/media/images/pause.png" class="slideshowpauseb" id="playpauseb">');
	time2=setInterval("slideSwitchb()",parseInt($("#auto_slideb").attr("value"))+hidetime+showtime)
}
else{
	$(".liens_diapo_selectionb").append('<img src="/media/images/play.png" class="slideshowplayb" id="playpauseb">')
}
$("#playpauseb").click(function(){
	if($("#playpauseb").attr("class")=="slideshowpauseb"){
		clearTimeout(time2);
		$(".slideshowpauseb").attr("src","/media/images/play.png");
		$(".slideshowpauseb").attr("class","slideshowplayb")
	}
	else{
		if($("#playpauseb").attr("class")=="slideshowplayb"){
			$(".slideshowplayb").attr("src","/media/images/pause.png");
			$(".slideshowplayb").attr("class","slideshowpauseb");
			slideSwitchb();
			time2=setInterval("slideSwitchb()",parseInt($("#auto_slideb").attr("value"))+hidetime+showtime)
		}
	}
});

$(".contenu_nos_selectionsb").click(function(){
	if($(".slideshowpauseb").attr("class")=="slideshowpauseb"){
		clearTimeout(time2);
		$(".slideshowpauseb").attr("src","media/images/play.png");
		$("#playpauseb").attr("class","slideshowplayb")
	}
})
}


if($("#nos_selectionsc > div").length>1){
$(".change_slidec").click(function(){
	clearTimeout(time3);
	$(".slideshowpausec").attr("src","/media/images/play.png");
	$("#playpausec").attr("class","slideshowplayc");
	var h=1;
	var k=$(this).attr("id").split("_");
	var f=k.length;
	var e=last_selectionc_id.split("_");
	var j=e.length;
	var g=parseInt($("#nos_selectionsc > div").length)-h;
	if(last_selectionc_id=="#selectionc_0"){
		$("#selectionc_"+g).hide(1,function(){
			for(var l=0;l<=g;l++){
				$("#selectionc_"+l).hide();
				$("#cpt_selectionc_"+l).css("background-color","transparent")
			}
			$("#selectionc_"+(parseInt(k[f-1]))).fadeIn(showtime);
			$("#cpt_selectionc_"+(parseInt(k[f-1]))).css("background-color","#fff");
			$("#titre_nos_selectionsc").html($("#title_"+(parseInt(k[f-1]))).html())
		})
	}
	else{
		$("#selectionc_"+parseInt(e[j-1])).hide(1,function(){
			for(var l=0;l<=g;l++){
				$("#selectionc_"+l).hide();
				$("#cpt_selectionc_"+l).css("background-color","transparent")
			}
			$("#selectionc_"+(parseInt(k[f-1]))).fadeIn(showtime);
			$("#cpt_selectionc_"+(parseInt(k[f-1]))).css("background-color","#fff");
			$("#titre_nos_selectionsc").html($("#title_"+(parseInt(k[f-1]))).html())
			})
	}
	last_selectionc_id=(parseInt(k[f-1])==g)?"#selectionc_0":"#selectionc_"+(parseInt(k[f-1]));
	return false
});

if(parseInt($("#auto_slidec").attr("value"))>0){
	$(".liens_diapo_selectionc").append('<img src="/media/images/pause.png" class="slideshowpausec" id="playpausec">');
	time3=setInterval("slideSwitchc()",parseInt($("#auto_slidec").attr("value"))+hidetime+showtime)
}
else{
	$(".liens_diapo_selectionc").append('<img src="/media/images/play.png" class="slideshowplayc" id="playpausec">')
}
$("#playpausec").click(function(){
	if($("#playpausec").attr("class")=="slideshowpausec"){
		clearTimeout(time3);
		$(".slideshowpausec").attr("src","/media/images/play.png");
		$(".slideshowpausec").attr("class","slideshowplayc")
	}
	else{
		if($("#playpausec").attr("class")=="slideshowplayc"){
			$(".slideshowplayc").attr("src","/media/images/pause.png");
			$(".slideshowplayc").attr("class","slideshowpausec");
			slideSwitchc();
			time3=setInterval("slideSwitchc()",parseInt($("#auto_slidec").attr("value"))+hidetime+showtime)
		}
	}
});

$(".contenu_nos_selectionsc").click(function(){
	if($(".slideshowpausec").attr("class")=="slideshowpausec"){
		clearTimeout(time3);
		$(".slideshowpausec").attr("src","media/images/play.png");
		$("#playpausec").attr("class","slideshowplayc")
	}
})
}
});

function slideSwitch(){
var c=1;
var a=last_selection_id.split("_");
var e=a.length;
var b=parseInt($("#nos_selections > div").length)-c;
var d=(parseInt(a[e-1])+1);
if(last_selection_id=="#selection_0")
{
	$("#selection_"+b).fadeOut(hidetime,function(){$("#selection_"+d).fadeIn(showtime);
	$("#cpt_selection_"+b).css("background-color","transparent");
	$("#cpt_selection_"+d).css("background-color","#fff");
	$("#titre_nos_selections").html($("#title_"+d).html())})
}
else{
	if (document.getElementById('selection_2')){
	$("#selection_"+parseInt(a[e-1])).fadeOut(hidetime,function(){$("#selection_"+d).fadeIn(showtime);
	$("#cpt_selection_"+parseInt(a[e-1])).css("background-color","transparent");
	$("#cpt_selection_"+d).css("background-color","#fff");
	$("#titre_nos_selections").html($("#title_"+d).html())})
	}
}
last_selection_id=(parseInt(a[e-1])+1==b)?"#selection_0":"#selection_"+d;
return false
}

function slideSwitchb(){
var c=1;
var a=last_selectionb_id.split("_");
var e=a.length;
var b=parseInt($("#nos_selectionsb > div").length)-c;
var d=(parseInt(a[e-1])+1);
if(last_selectionb_id=="#selectionb_0")
{
	$("#selectionb_"+b).fadeOut(hidetime,function(){$("#selectionb_"+d).fadeIn(showtime);
	$("#cpt_selectionb_"+b).css("background-color","transparent");
	$("#cpt_selectionb_"+d).css("background-color","#fff");
	$("#titre_nos_selectionsb").html($("#title_"+d).html())})
}
else{
	if (document.getElementById('selectionb_2')){
	$("#selectionb_"+parseInt(a[e-1])).fadeOut(hidetime,function(){$("#selectionb_"+d).fadeIn(showtime);
	$("#cpt_selectionb_"+parseInt(a[e-1])).css("background-color","transparent");
	$("#cpt_selectionb_"+d).css("background-color","#fff");
	$("#titre_nos_selectionsb").html($("#title_"+d).html())})
	}
}
last_selectionb_id=(parseInt(a[e-1])+1==b)?"#selectionb_0":"#selectionb_"+d;
return false
}


function slideSwitchc(){
var c=1;
var a=last_selectionc_id.split("_");
var e=a.length;
var b=parseInt($("#nos_selectionsc > div").length)-c;
var d=(parseInt(a[e-1])+1);
if(last_selectionc_id=="#selectionc_0")
{
	$("#selectionc_"+b).fadeOut(hidetime,function(){$("#selectionc_"+d).fadeIn(showtime);
	$("#cpt_selectionc_"+b).css("background-color","transparent");
	$("#cpt_selectionc_"+d).css("background-color","#fff");
	$("#titre_nos_selectionsc").html($("#title_"+d).html())})
}
else{
	if (document.getElementById('selectionc_2')){
	$("#selectionc_"+parseInt(a[e-1])).fadeOut(hidetime,function(){$("#selectionc_"+d).fadeIn(showtime);
	$("#cpt_selectionc_"+parseInt(a[e-1])).css("background-color","transparent");
	$("#cpt_selectionc_"+d).css("background-color","#fff");
	$("#titre_nos_selectionsc").html($("#title_"+d).html())})
	}
}
last_selectionc_id=(parseInt(a[e-1])+1==b)?"#selectionc_0":"#selectionc_"+d;
return false
}