function slideShow(divid,imageid,imageFiles,displaySecs,delayStart,options){
	this.durationFade=0;
	this.fixedSize=0;
	
	this.slideCache = new Array(); 
	this.divid=divid;
	this.imageid=imageid;
	this.imageFiles=imageFiles;
	this.displaySecs=displaySecs ;
	
	this.slideOK=true;
	
	this.numImage=0
	
	this.TestImage=divid + "TestImage"
	
	this.VarTimeOut
	
	// gerer le parametre options
	
	if(typeof options != 'undefined') { this.options = options; } else { this.options = {}; }
	if(this.options.durationFade) {this.durationFade = this.options.durationFade; }
	if(this.options.fixedSize) {this.fixedSize = this.options.fixedSize;}
	
	var self = this; 
		setTimeout(function(){ 
			self.RunSlideShow(); 
		}, 100 + (delayStart*1000)); 
	
	this.GoToImageSrc = function(src){
		var bContinue=true
		this.cacheImage(src)
		clearTimeout(this.VarTimeOut);	
		var nbreImages=this.imageFiles.split(";").length
		while (bContinue && nbreImages-- >-1 ){
			var imageSeparator = this.imageFiles.indexOf(";"); 
			var nextImage = this.imageFiles.substring(0,imageSeparator); 
			bContinue = (nextImage != src)
			//alert(nbreImages +"-----"+ nextImage +"--"+ src  +'---'+ bContinue)
			if (bContinue){
				//alert("coucou")
				var futureImages= this.imageFiles.substring(imageSeparator+1,this.imageFiles.length)+ ';' + nextImage; 
				this.imageFiles=futureImages
			}
		}	
		if(!bContinue){
			this.RunSlideShow()
		}
		
	}
	
	this.StopSlideShow = function() {
		clearTimeout(this.VarTimeOut);
	}
	
	this.RunSlideShow = function(NoStart) { 
		//document.getElementsByTagName('img')
		clearTimeout(this.VarTimeOut);	
		var isSafari = (navigator.userAgent.indexOf("Safari") >= 0) ? 1 : 0;
		var isMac = (navigator.userAgent.toLowerCase().indexOf("mac") >= 0) ? 1 : 0;
		if(typeof(NoStart)=="undefined" )NoStart=""
		var imageSeparator = this.imageFiles.indexOf(";"); 
		var nextImage = this.imageFiles.substring(0,imageSeparator); 
		

		this.cacheImage(nextImage)
		
		var self = this; 
		// && isSafari==0 && isMac==0
		if(true ){
			if(this.slideCache[nextImage] && this.slideCache[nextImage].width){
				this.blendimage(nextImage,this.durationFade); 
			}else{
				this.VarTimeOut=setTimeout(function(){ self.RunSlideShow(NoStart); } ,1000)
				return
			}
		}else{
			document.getElementById(this.divid).style.backgroundImage ="url("+ nextImage +")"; 
			document.getElementById(this.imageid).src=nextImage;
			if(this.slideCache[nextImage] && this.slideCache[nextImage].width){
				if (!this.fixedSize) {
					document.getElementById(this.imageid).width=this.slideCache[nextImage].width
					document.getElementById(this.imageid).height=this.slideCache[nextImage].height
					document.getElementById(divid).style.width=this.slideCache[nextImage].width
					document.getElementById(divid).style.height=this.slideCache[nextImage].height
				}
			}else{
				this.VarTimeOut=setTimeout(function(){ self.RunSlideShow(NoStart); } ,1000)
				return
			}
		}					

		var futureImages= this.imageFiles.substring(imageSeparator+1,this.imageFiles.length)+ ';' + nextImage; 
		this.imageFiles=futureImages	
		
		
		if(typeof(NoStart)=="undefined" || NoStart=="")this.VarTimeOut=setTimeout(function(){ self.RunSlideShow(); }, (this.displaySecs+ this.durationFade)*1000); 
		this.durationFade=(this.durationFade==0)?2:this.durationFade;

			
		// Cache the next image to improve performance. 
		imageSeparator = futureImages.indexOf(";"); 
		nextImage = futureImages.substring(0,imageSeparator); 
		this.cacheImage(nextImage)
		
	}

	this.cacheImage=function(nextImage){
		
		if (this.slideCache[nextImage] == null) 
		{ 
			this.slideCache[nextImage] = new Image; 
			this.slideCache[nextImage].src = nextImage; 
		} 
	}

	this.imageBigComplete=function(num){
		if(this.slideCache[num] && this.slideCache[num].complete){
			if (!document.getElementById(this.TestImage)) {
				var img=document.createElement('img');
				img.name=this.TestImage
				img.id=this.TestImage
				img.border=0
				img.style.visibility='hidden';
				img.style.position='absolute';
				img.style.top="-2000px"
				document.getElementById(divid).parentNode.insertBefore(img,document.getElementById(divid).nextSibling)
			}		
			
			document.getElementById(this.TestImage).src=this.slideCache[num].src
			this.slideCache[num].width=document.getElementById(this.TestImage).width
			this.slideCache[num].height=document.getElementById(this.TestImage).height
		}else{
			if(this.slideCache[num])this.cacheImage(this.slideCache[num] )
		}
	}

	
	this.changeOpac = function(opacity) { 
		var object = document.getElementById(this.imageid).style; 
		object.opacity = (opacity / 100); 
		object.MozOpacity = (opacity / 100); 
		object.KhtmlOpacity = (opacity / 100); 
		object.filter = "alpha(opacity=" + opacity + ")"; 
	} 
	
	this.noError= function (){
		this.slideOK=false;
		var self = this; 
		clearTimeout(this.VarTimeOut);	
		this.VarTimeOut=setTimeout(function(){ self.RunSlideShow(); }, (this.displaySecs+ this.durationFade)*1000); 
		return true
	}	
	
	this.blendimage = function(imagefile, millisec) { 
		
		oldimagefile=document.getElementById(this.imageid).src.replace(  "http://"+document.domain ,"");
		if (this.slideOK) this.numImage++
		if (this.slideOK && navigator.appName.indexOf("Microsoft",0)>=0)  {
			document.getElementById(this.imageid).style.filter="blendTrans(duration="+ (this.durationFade) +")";
			window.onerror=this.noError
			if (document.getElementById(this.imageid).filters ){
					document.getElementById(this.imageid).filters.blendTrans.Apply();
					document.getElementById(this.imageid).filters.blendTrans.Play();
			}
			
			document.getElementById(this.imageid).src=imagefile;
			
			if (this.slideCache[imagefile] && !this.slideCache[imagefile].width) this.slideCache[imagefile].width=document.getElementById(this.imageid).width
			if (this.slideCache[imagefile] && !this.slideCache[imagefile].height) this.slideCache[imagefile].height=document.getElementById(this.imageid).height
			
			
			self=this
			if (!this.fixedSize) this.modifSize(imagefile ,  oldimagefile , 5 , millisec ); 
			
			document.getElementById(this.divid).style.backgroundImage = ""; 
			
		}else{
		
			var speed = Math.round(millisec*1000 / 150); 		
			//make new image 
			//set the current image as background 
			document.getElementById(this.divid).style.backgroundImage = "url(" + document.getElementById(this.imageid).src + ")"; 
			
			//make image transparent 
			this.changeOpac(0); 

			eval("var self = this; setTimeout(function(){ document.getElementById('"+ self.imageid +"').src ='"+ imagefile +"'; }, "+ speed +") ")
			
			if(this.numImage>1)eval("var self = this; setTimeout(function(){ document.getElementById('" +this.divid +"').style.backgroundImage = ''; }, "+ speed*100 +") ")
			
			//fade in image 
			var step=2
		
			for(var i=100-step; i>=0; i-=step) 
			{ 
				eval("var self = this; setTimeout(function(){ self.changeOpac("+ (i) +"); }, "+ (i) * speed +"); ")
			} 
			
			if (this.slideCache[imagefile] && !this.slideCache[imagefile].width) this.slideCache[imagefile].width=document.getElementById(this.imageid).width
			if (this.slideCache[imagefile] && !this.slideCache[imagefile].height) this.slideCache[imagefile].height=document.getElementById(this.imageid).height
			
			self=this
			if (!this.fixedSize) this.modifSize(imagefile ,  oldimagefile , 5 , millisec ); 
		}
	} 
	
	this.modifSize=function (imagefile ,  oldimagefile , i , millisec){
		if(this.slideCache[imagefile] && this.slideCache[oldimagefile]){
			if(!this.slideCache[imagefile].height) this.imageBigComplete(imagefile)
			if(!this.slideCache[oldimagefile].height) this.imageBigComplete(oldimagefile)
			
			var speed = Math.round(millisec*1000 / 150); 
			var step=5
			var newHeight=this.slideCache[imagefile].height
			var newWidth=this.slideCache[imagefile].width
			var oldHeight=this.slideCache[oldimagefile].height
			var oldWidth=this.slideCache[oldimagefile].width
			
			document.getElementById(this.imageid).height=parseInt(oldHeight + (((newHeight-oldHeight) * i)/100))
			document.getElementById(this.imageid).width=parseInt(oldWidth + (((newWidth-oldWidth) * i)/100))
			i+=step
			self=this
			if(i<=100){
				setTimeout(function(){ 
							self.modifSize(imagefile ,  oldimagefile , i ); 
						}, ( 15) ); 
			}
		}
	}
}

/* Usage :

<div style="background-repeat: no-repeat;" id="slideshow1Div">
    <img src="http://www.macommunevueduciel.com/documents/FTP/211/173487_Small.jpg" style="border: 0 none; filter: alpha(opacity=0); -moz-opacity: 0; opacity: 0;" alt="" 
    id="slideshow1Image" />
</div> 
<script>
var slideshow1=new slideShow('slideshow1Div','slideshow1Image','http://www.macommunevueduciel.com/documents/FTP/211/173487_Small.jpg;http://www.macommunevueduciel.com/documents/FTP/211/173497_Small.jpg;http://www.macommunevueduciel.com/documents/FTP/211/173496_Small.jpg;http://www.macommunevueduciel.com/documents/FTP/211/173495_Small.jpg;http://www.macommunevueduciel.com/documents/FTP/211/173494_Small.jpg;http://www.macommunevueduciel.com/documents/FTP/211/173493_Small.jpg;http://www.macommunevueduciel.com/documents/FTP/211/173492_Small.jpg;http://www.macommunevueduciel.com/documents/FTP/211/173491_Small.jpg;http://www.macommunevueduciel.com/documents/FTP/211/173490_Small.jpg;http://www.macommunevueduciel.com/documents/FTP/211/173489_Small.jpg;http://www.macommunevueduciel.com/documents/FTP/211/173488_Small.jpg;http://www.macommunevueduciel.com/documents/FTP/211/173486_Small.jpg;http://www.macommunevueduciel.com/documents/FTP/211/173485_Small.jpg',3,0); 
</script>

*/
