/** gallery()
 * Creates and fires rotation on a gallery included on a page. Relies on gallery images being written to the page 
 * as hidden elements -- init function makes the 'currImg' image visible and hides the rest each time the init 
 * function is called.
 * gID = string; gallery identifier (generally the gallery rec ID, but can be anything unique)
 * maxImg = int; total number of images/content blocks
 * returns nothing
 **/
function initSponsorGallery(gID, maxImg, speed) {
	//config
	var currImg = parseInt( getGalleryCookie(gID) );
	if (currImg==maxImg) { currImg = 0; }
	if (!speed || speed==0) { speed=3000; }
	
	//loop over all images in set, showing the 'currImg' and hiding all others
	var obj;
	for (var i=0; i<maxImg; i++) {
		obj = document.getElementById(gID+'_'+i);
		obj.style.visibility = (i==currImg) ? 'visible' : 'hidden' ;
		obj.style.display = (i==currImg) ? 'block' : 'none' ; 
	}
	
	setGalleryCookie(gID,(currImg+1));
	setTimeout("initSponsorGallery('"+gID+"', "+maxImg+", "+speed+")", speed);
}

function setGalleryCookie(name,value){
	document.cookie = name + "=" + value;
}

function getGalleryCookie(Name){ 
	var re = new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
	if (document.cookie.match(re)) {
		return document.cookie.match(re)[0].split("=")[1]; 
	}
	return '0';
}

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 