var nbmax = 5 ;                    // Nombre d'images
var ImageEnCours = -1;             // Image affichée
var timeout = 0 ;                  // Timer
var Vitesse = 3000 ;
var indsec = 1;
function arret(){
	clearTimeout(timeout);
	ImageEnCours = -1;
	indsec = 6;
}
function imageSuivante(){
	ImageEnCours++
	if (ImageEnCours > nbmax-1 ) {
		ImageEnCours = 0
	}
	document.getElementById("imgsec").style.backgroundImage = "url(images/" + section + "/img" + indsec + ImageEnCours + ".jpg)";
}
function imageContinu(){
	imageSuivante()
	timeout = setTimeout("imageContinu()", Vitesse)
}
function getrnd(nb){
	return Math.round(nb*Math.random())
}

function setImg(){
	document.getElementById("aleat").style.backgroundImage = "url(images/aleatoire_" + getrnd(3) + ".jpg)";
}
function mout(who){
	if(who.id != smselected){
		who.className = who.id.substring(0,who.id.length -1);
		if(who.className == "menup"){
			who.style.paddingTop = "2px";
			
		}
		else
			document.getElementById("__" + who.id).style.display = "none";
	}
}
function mover(who){
	if(who.className == "menup"){
		who.style.paddingTop = "1px";
		
	}
	else
		document.getElementById("__" + who.id).style.display = "inline";
	who.className += " select" + who.id.substring(0,who.id.length -1);
}
function hideAll(){
	for(i=1;i<=nbsm;i++){
		document.getElementById("data" + i).style.display = "none";
	}
}
function deselectAll(){
	for(i=1;i<=nbsm;i++){
		document.getElementById("sm" + i).className = "sm";
		document.getElementById("__sm" + i).style.display = "none";
	}
}
function selectMenu(indice){
	deselectAll();
	if(document.getElementById("sm" + indice)){
	document.getElementById("sm" + indice).className += " selectsm";
	document.getElementById("__sm" + indice).style.display = "inline";
	}
	hideAll();
	if(document.getElementById("sm" + indice)){
	document.getElementById("data" + indice).style.display = "inline";
	document.getElementById("data" + indice).style.top = "268px";
	document.getElementById("data" + indice).style.left = "194px";
	}
	smselected = "sm" + indice;
	if(section != ""){
		arret();
		if(section != "partenaire" && section != "joindre")
        	document.getElementById("divflash").innerHTML = '<embed src="images/' + section + '/flash' + indice + '.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"' + 'type="application/x-shockwave-flash" width="496" height="148"></embed>' ;
		if(indice != "6"){
			if(section == "partenaire"){
				indsec = 1;
				nbmax = 2;
				imageContinu();
			}
			else
				document.getElementById("imgsec").style.backgroundImage = "url(images/" + section + "/img" + indice + ".jpg)";
		}
		else
			imageContinu();
	}
	
}
function getURLParam(){
	var strReturn = null;
	var strHref = window.location.href;  
	if ( strHref.indexOf("?") > -1 ){
		var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();	
		var aQueryString = strQueryString.split("=");
		strReturn = aQueryString[1];
	}
	return strReturn;
}
function setVar(){
	if(navigator.appName.toLowerCase().indexOf("microsoft") != -1 && nbsm>0){
		for(i=1;i<=nbsm;i++){
			document.getElementById("sm" + i).style.width = "100%";
		}
	}
	if(section != ""){
		if(section == "service"){
			nbmax = 4;
			imageContinu();
		}
		else if(section == "partenaire"){
			nbmax = 2;
			imageContinu();
		}
		else
			document.getElementById("imgsec").style.backgroundImage = "url(images/" + section + "/img1.jpg)";
	}
	else{
		if(getURLParam() != null){
			selectMenu(getURLParam());
		}
		if(navigator.userAgent.toLowerCase().indexOf("mac") != -1 && navigator.appName.toLowerCase().indexOf("microsoft") != -1){
			for(i=1;i<=3;i++){
				if(document.getElementById("menus" + i).className.indexOf("selectmenus") != -1){
					document.getElementById("menus" + i).style.paddingTop = "2px";
					break;
				}
			}
		}
	}
}
function openWin(url){
	window.open(url,"_self");
}


