var cL = new Object();
cL.files = browser.filecount;
cL.browser = 1; 
cL.x = 0; 
cL.nextTime = 5000; 

setTimeout("Cloak('img_0', 100, 0, 2000, 'loop')", cL.nextTime);

/*************************************************************
* Cloaking Device
*************************************************************/

function Cloak(ID, START, END, TIME, ACT) { 

	if (document.getElementById(ID)) { 

	// Element
	cL.element = document.getElementById(ID).style; 
	cL.START 			= START;
	cL.END 				= END;
	cL.TIME 			= TIME;
	cL.ACT 				= ACT;

	// Frame Speed
	TIME = Math.round(TIME);
	var speed = Math.round(TIME / 100); 
	var timer = 0; 

	//determine the direction for the blending, if start and end are the same nothing happens 
	if (START > END) { 

		for(i = START; i >= END; i--) { 
			cL.timer = setTimeout("CloakRun('"+ID+"', "+i+")", (timer * speed)); 
			timer++; 
		} 

	} else if (START < END) { 

		for(i = START; i <= END; i++) { 
			cL.timer = setTimeout("CloakRun('"+ID+"', "+i+")", (timer * speed)); 
			timer++; 
		} 

	} 

	}

} 

function CloakRun(ID, OPACITY) { 

	if (browser.IE == 1) { cL.element.filter = "alpha(opacity="+OPACITY+")"; } else { cL.element.opacity = (OPACITY / 100); }

	if (cL.END == OPACITY && cL.ACT) {  

		if (cL.ACT == 'loop') { 

			cL.x++;
			clearTimeout(cL.timer);
			cL.timer = setTimeout("Cloak('img_"+cL.x+"', cL.START, cL.END, cL.TIME, 'loop')", cL.nextTime);
			if (cL.x == cL.files) { 

				for(i = 0; i < cL.files; i++) { 

					if (browser.IE == 1) {

						document.getElementById('img_'+i).style.filter = "alpha(opacity=100)";

					} else { 

						document.getElementById('img_'+i).style.opacity = '1.0'; 

					}

				}

				cL.x = 0; 
				clearTimeout(cL.timer);
				cL.timer = setTimeout("Cloak('img_0', 100, 0, 2000, 'loop');", cL.nextTime); 

			}

		}

	}

}
