//<!--
// Library for swapping images 

// mouse onclick  start swapping then onclik freez swapping
// usage ImgSwap.AddIMGset('IMG1.src','IMG2.src',....,IMGn.src);
//
// first argument should be src of IMG tag
//	no repetition of first src allowed
//first argument used as IMG name  
//
//Example: <a href="" onclick="
//          ImgSwap.AddIMGtoSwap('IMG1.jpg','IMG2.jpg','IMG3.jpg','IMG4.jpg');
//         return false;"><img name="IMG1.jpg" src="'IMG1.jpg' > </a>
// -->


function SwapImages(){

	this.NumberOfImges=0;
	this.swIMG= new Array();
	this.AddIMGtoSwap=AddIMGset;
	this.Animate=Animate;
}


// **** first argument should be src of IMG tag****** 
//***** no repetition of first src allow
//***** first argument used as ID/name identifier for IMG ***

function AddIMGset(){

	 // check if we alredy have this image in swap
	for (i=0;i<this.swIMG.length;i++)
	 if (this.swIMG[i].IMG[0]==AddIMGset.arguments[0]) 
	 	{this.swIMG[i].blFlag=!this.swIMG[i].blFlag; return;}

	IMG= new  objIMG();	
	//setting up src
	 for (i=0; i<AddIMGset.arguments.length; i++) 
		IMG.IMG[i]=AddIMGset.arguments[i];
		IMG.blFlag=	!IMG.blFlag;

 	//adding new IMG sequence
 	this.swIMG[this.NumberOfImges++]=IMG;
return false;
} 

 
function objIMG(){

	this.blFlag=false;
	this.CurrNumb=0; // current img #
	this.IMG=new Array(); // src repository
	this.Swap=Swap; // swap function
}

function Animate(){
 for (i=0; i<this.NumberOfImges;i++)
 	if (this.swIMG[i].blFlag){
 		 this.swIMG[i].blFlag=false;
 		 this.swIMG[i].Swap();
 		 this.swIMG[i].blFlag=true;
	}
}



function Swap(){ 
	document.images[this.IMG[0]].src=this.IMG[this.CurrNumb++];
		if (this.CurrNumb>this.IMG.length-1) this.CurrNumb=0;
}

ImgSwap= new SwapImages();
 window.setInterval('ImgSwap.Animate()',4000);
