// GLOBAL javascript functions

//Timed Redirect Funtion
//Time in seconds
function goTo(url,time) 
{
	time = time * 1000;
	url = "http://www.RoundtopRiders.com" + url;
	setTimeout("window.location='"+url+"'",time);
	return true;
}

/******************************** Fade Block Item ********************************/

	
	function fadeBlock(myElement,command) {
		
		if(command == "close") {
			new Effect.Fade(document.getElementById(myElement));
		}
		if(command == "open") {
			new Effect.Appear(document.getElementById(myElement));	 
		}
		return true;   
	}


/******************************** Sidebar****************************************/

	function whenClicked(myElement) {
		var str = "cookie" + myElement.substr(7);
		var hotspot = "hotspot" + myElement.substr(7);
		var value = readCookie(str);
		
		if(value == 1){
			new Effect.Fade(document.getElementById(myElement));
			document.getElementById(hotspot).className = "sidebar_hotspot_open";	
			createCookie(str,"0",100);
		} else {
			new Effect.Appear(document.getElementById(myElement));
			document.getElementById(hotspot).className = "sidebar_hotspot_close";	
			createCookie(str,"1",100);			 
		}
		return true;   
	}
	
	function initSidebar() {
	
		//Check to see if cookies exist
		var cookie_quickLinks = readCookie("cookie_quickLinks");
		var cookie_updates = readCookie("cookie_updates");
		var cookie_photo = readCookie("cookie_photo");
		var cookie_links = readCookie("cookie_links");
	
		//If cookies don't exist, create them!
		if(!cookie_quickLinks) createCookie("cookie_quickLinks","1",100);
		if(!cookie_updates) createCookie("cookie_updates","1",100);
		if(!cookie_photo) createCookie("cookie_photo","1",100);
		if(!cookie_links) createCookie("cookie_links","1",100);
			
		//Assign cookie values
		cookie_quickLinks = readCookie("cookie_quickLinks");
		cookie_updates = readCookie("cookie_updates");
		cookie_photo = readCookie("cookie_photo");
		cookie_links = readCookie("cookie_links");
		
		//Load current configuration
		if(cookie_quickLinks == "0") {
			document.getElementById("sidebar_quickLinks").style.display = "none";
			document.getElementById("hotspot_quickLinks").className = "sidebar_hotspot_open";	
		}
		if(cookie_updates == "0") {
			document.getElementById("sidebar_updates").style.display = "none";
			document.getElementById("hotspot_updates").className = "sidebar_hotspot_open";
		}
		if(cookie_photo == "0") {
			document.getElementById("sidebar_photo").style.display = "none";
			document.getElementById("hotspot_photo").className = "sidebar_hotspot_open";
		}
		if(cookie_links == "0") {
			document.getElementById("sidebar_links").style.display = "none";
			document.getElementById("hotspot_links").className = "sidebar_hotspot_open";
		}
	}
	
	
/******************************** Cookies *****************************************/
	
	function createCookie(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}
	
	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
	
	function eraseCookie(name) {
		createCookie(name,"",-1);
	}

