// JavaScript Document
/*function switchPage(typePage){
	
	switch (typePage)
		{
		case 'MA':
			switchDataFile("../top_pictures/0/",27);
			break; 
		case 'EN':
			switchDataFile("../top_pictures/EE/",18);
			break; 
		case '00':
			switchDataFile("../top_pictures/0/",27);
			break; 
		case 'SD':
			switchDataFile("../top_pictures/SD/",27);
			break;
		case 'RE':
			switchDataFile("../top_pictures/RE/",15);
			break; 
		case 'IN':
			switchDataFile("../top_pictures/IN/",18);
			break; 
		default: alert('Page type non définie');
		} 
	
}

function switchDataFile(pathFile,nbPhotos)		
{
	//-----------------------------------------
	var varArray = new Array();
 
	varArray["img1"] = "idImg_01"
	varArray["img2"] = "idImg_02"
	varArray["filename"] = pathFile
	varArray["width"] = 780
	varArray["height"] = 126
	varArray["bgcolor"] = "FFF" 
	varArray["opc"] = 0
	varArray["vitesse"] = 4000
	varArray["vtsVisible"] = 0.008
	varArray["indImg"] = 0
	varArray["maxImg"] = nbPhotos//ImgArray.length
 
	var obj1 = new Oimage(varArray);
	obj1.init();
	obj1.start();

}


		
		
function getObject(objectId) {
    // cross-browser function to get an object'skill style object given its
    if(document.getElementById && document.getElementById(objectId)) 
	{
	// W3C DOM
//	alert("FF")
	return document.getElementById(objectId);
    } 
	else if (document.all && document.all(objectId)) 
	{
//	alert("IE")		
	// MSIE 4 DOM
	return document.all(objectId);
    } 
	else 
	{
	return false;
    }
} // getStyleOb

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject

//-----------------------------------------------
//		Déclaration de l’objet Oimage 
//-----------------------------------------------

var Oimage = function(vars){
	
		this.I = new Array();
		this.v = vars;
		
		this.init = function(){//initialisation des images
			 for (i=0; i<=(this.v["maxImg"] - 1); i++){
				 this.I[i] = this.v["filename"] + (i+1) +".jpg"
//				 alert(this.I[i])
			 }
			 //css div image 1
			this.rnd();
 			var img=getObject(this.v["img1"]);

			var newImage = "url("+this.I[this.v["indImg"]]+")";
			img.style.backgroundImage  = newImage;			
			
			img.style.width = this.v["width"] + "px";
			img.style.height = this.v["height"] + "px";
			img.style.position = "relative";
			img.style.backgroundColor = "#" + this.v["bgcolor"] + "";
			img.style.backgroundRepeat = "no-repeat";
			
			 //css div image 2			
 			img=getObject(this.v["img2"]);
			newImage = "url("+this.I[this.v["indImg"]]+")";
			img.style.backgroundImage  = newImage;
			img.style.width = this.v["width"] + "px";
			img.style.height = this.v["height"] + "px";
			img.style.position = "relative";
			img.style.backgroundColor = "#" + this.v["bgcolor"] + "";
			img.style.backgroundRepeat = "no-repeat";

			var newImage = "url("+this.I[this.v["indImg"]]+")";
			img.style.backgroundImage  = newImage;

				
		}
		
		this.start = function(){
			var monContexte = this;
			setTimeout(function (){monContexte.defilImg();},this.v["vitesse"])
		}

		this.rnd = function(){
			var value = Math.round(Math.random()*(this.v["maxImg"]-1));
			while (value == this.v["indImg"]){
				var value = Math.round(Math.random()*(this.v["maxImg"]-1));
			}			
			this.v["indImg"]= value
		}

		this.invisible = function (){

			var cur=getObject(this.v["img2"]);
			this.v["opc"] -= parseFloat(this.v["vtsVisible"]);
			cur.style.opacity = this.v["opc"];
			cur.style["filter"] = "Alpha(opacity="+(this.v["opc"]*100)+")";
			if (cur.style.opacity>0) {
				var monContexte = this;
				setTimeout(function (){monContexte.invisible();},10)
			}
			else {
				var monContexte = this;
				setTimeout(function (){monContexte.defilImg();},this.v["vitesse"])
			}

		}
	
		this.defilImg = function (){

			var imgOject = getObject(this.v["img2"]);
//			this.v["indImg"] += 1;//ici remplacer par le random
			this.rnd();
			if ((this.v["indImg"])> this.v["maxImg"] - 1) this.v["indImg"] = 0;
			//passer à l'image suivente
			var newImage = "url("+this.I[this.v["indImg"]]+")";
			imgOject.style.backgroundImage  = newImage;
//			alert(this.v["indImg"])
			this.visible();
		}			
		
		this.visible = function(){

			var cur=getObject(this.v["img2"]);
			this.v["opc"] += parseFloat(this.v["vtsVisible"]);
			cur.style.opacity = this.v["opc"];
			cur.style["filter"] = "Alpha(opacity="+(this.v["opc"]*100)+")";
			if (cur.style.opacity<1) {
				var monContexte = this;				
				setTimeout(function (){monContexte.visible();},10);	
			}
			else{
				var monContexte = this;
				setTimeout(function (){monContexte.invisible();},10)
				var imgOject = getObject(this.v["img1"]);
				var imgSuivente = this.v["indImg"] //+ 1
				if ((imgSuivente)> this.v["maxImg"] - 1) imgSuivente = 0
				//image suivente
				var newImage = "url("+this.I[imgSuivente]+")";
				imgOject.style.backgroundImage  = newImage;
			}
	}
}

//			declaration de l'objet opacite image


//Script utilisé dans main.asp pour faire 
//fondre les images au passage de la souri
*/
var varArray
function SetVar(i){
	
	if (varArray == null) varArray = new Array();
	
	if (varArray[i] == null) 
		varArray[i] = new SwitchOpacity('img'+i+'');
	}
		
var SwitchOpacity = function(imgId){


	this.id = imgId
	this.opc = 1;
	this.raport = 0.05;
	this.vitesse = 50
	this.show;
	this.hide;

	this.init = function(){
//			alert(this.id)
/*		this.opc = 1;
		this.raport = 0.05;
		this.vitesse = 10*/
//		alert(this.raport)
		clearTimeout (this.show);
		clearTimeout (this.hide);
		this.MouseOver();
	 }
			 
	this.MouseOver = function (){

		this.opc -= this.raport;
		this.vitesse -= 1
		var cur=getObject(this.id);
		cur.style.opacity = this.opc;
		cur.style["filter"] = "Alpha(opacity="+(this.opc*100)+")";
		if (this.opc > 0.5) {
				var monContexte = this;
				this.show = setTimeout(function (){monContexte.MouseOver();},this.vitesse)
			}
//		else{clearTimeout (this.show);}			
	}


	this.MouseOut = function (){

		this.opc += this.raport;
		this.vitesse += 1
		var cur=getObject(this.id);
		cur.style.opacity = this.opc;
		cur.style["filter"] = "Alpha(opacity="+(this.opc*100)+")";
		clearTimeout(this.show);
		if (this.opc <= 1) {
				var monContexte = this;
				setTimeout(function (){monContexte.MouseOut();},this.vitesse)
			}
		else{clearTimeout (this.hide);}
	}


}

