var gallery_transitionCycle = 20;		// Determines how many cycles for any transition. Higher the number, the smoother transition, but also the higher the processor strain. Default = 10
var gallery_transitionSpeed = 50;		// Transition speed for the gallery slideshow. This variable is directly affected by gallery_transitionCycle. Default = 50
var gallery_clickSpeed = 10;				// Transition speed for a click from the navigation. This variable is directly affected by gallery_transitionCycle. Default = 2
var gallery_slideshowSpeed = 3500;		// Time between tranisitions in the slideshow, in miliseconds. Default = 3500
var gallery_transitionOn = true;
var isOkTimeout          = 1;

function winopen(nomfile,idw,dx,dy)
{
	var fichier=nomfile;
	myWin = open(fichier, idw, 'toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width='+dx+',height='+dy+' ,top=50,left=50');
	myWin.focus();
}

function affichePage(page)
{
	idwin="VIP";
	winopen(page,idwin,640,400);
}

function prec(nbTotal){
	
	if (isOkTimeout) {
		
		clearInterval(slideTimeout);
	}
	var cur = null;
	var next = null;
	for (var i = 1; i<=nbTotal; i++) {
		if (document.getElementById('slide'+i).style.display == 'block') {
				(i == 1)? next = nbTotal:next = i-1;
				openImg(i, next, gallery_clickSpeed, nbTotal);
				break;
		}
	}
}

function suiv(nbTotal){
	
	if (isOkTimeout) {
		clearInterval(slideTimeout);
	}

	autonext(gallery_clickSpeed,nbTotal);
}

function init(nbTotal){

	gallery_transitionOn = true;
	if (BrowserDetect.OS == "Windows") {
		if (BrowserDetect.browser == "Mozilla") {
			if (BrowserDetect.version < 2) {
				gallery_transitionOn = true;
			}
		}
		if (BrowserDetect.browser == "Firefox") {
			if (BrowserDetect.version < 2) {
				gallery_transitionOn = true;
			}	
		}
	}

	var versionBrowser = navigator.appVersion;
	if (versionBrowser.indexOf('MSIE') != -1) {
		ieversion = 0;
		t = versionBrowser.split('MSIE');
		ieversion = parseFloat(t[1]);
		
		if (ieversion < 7) {
			gallery_transitionOn = false;
			/*isOkTimeout = 0;*/
		}
	}
	
	document.getElementById('slide1').style.display = "block";
	for(i=2;i<(nbTotal+1);i++)
		document.getElementById('slide'+i).style.display = "none";
	if (isOkTimeout) {
		slideTimeout = setTimeout("autonext(" + gallery_transitionSpeed + ", '"+nbTotal+"')", gallery_slideshowSpeed);
	}	
}

function autonext(speed,nbTotal) {
	var cur = null;
	var next = null;
	for (var i = 1; i<=nbTotal; i++) {
		if (document.getElementById('slide'+i).style.display == 'block') {
				(i == nbTotal)? next = 1:next = i+1;
				
				if (isOkTimeout) {
				
					openImg(i, next, speed, nbTotal);
				} else {
					for (var j = 1; j<=nbTotal; j++) {
						if (j == next) {
							document.getElementById('slide' + j).style.display = 'block';
						} else {
							document.getElementById('slide' + j).style.display = 'none';
						}
					}
				}
				break;
		}
	}
}

function openImg(i, j, speed, nbTotal) {
    var divid_next = document.getElementById('slide'+j);
	divid_next.style.display='block';
	
	
	if (gallery_transitionOn == false) {
		document.getElementById('slide'+j).style.display = 'block';
		document.getElementById('slide'+i).style.display = 'none';
   		
   		slideTimeout = setTimeout("autonext(" + gallery_transitionSpeed + ", '"+nbTotal+"')", gallery_slideshowSpeed);	
   		
	} else {
		changeOpac(1, j);
		
		for(k = 1; k <= gallery_transitionCycle; k++) {
			setTimeout("changeOpac(" + (100 - (k * (100 / gallery_transitionCycle))) + ",'" + i + "','"+nbTotal+"')",(k * speed));
			setTimeout("changeOpac(" + (k * (100 / gallery_transitionCycle)) + ",'" + j + "','"+nbTotal+"')",(k * speed));
		}
	}
}

function changeOpac(opacity, id, nbTotal) {
    var object = document.getElementById('slide' + id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
    if (opacity <= 0) {
    	object.display = 'none';
   		if (isOkTimeout) {
   			slideTimeout = setTimeout("autonext(" + gallery_transitionSpeed + ", '"+nbTotal+"')", gallery_slideshowSpeed);
   		}
    }
} 

function slide1_ie(){

		var versionBrowser = navigator.appVersion;
		if (versionBrowser.indexOf('MSIE') != -1) {
			ieversion = 0;
			t = versionBrowser.split('MSIE');
			ieversion = parseFloat(t[1]);
			
			if (ieversion < 7) {
			document.getElementById('slide1').style.position = 'relative';
			document.getElementById('slide1').style.marginTop = '0';
			}
		}



}

function feedback(val1,val2){
		// effet id1
		//alert(15);
		document.getElementById("zoneFeed").style.height = val1+"px";
		document.getElementById("feedBloc").style.display = val2;
		document.getElementById("bigbarfermer").style.display = val2;
}

