
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FILE LOCATION: /2008_templates/scripts/global.js
DESCRIPTION: Globally used functions and variables
DATE of LAST EDIT: August 28, 2008 
CHANGE LOG: 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

//Find the root folder of the current site and saves it to the sSiteRoot variable
var sSiteRoot = new String();
setPath();
function setPath() {
	var sLinkHref = document.getElementById("mainCSS").getAttribute("href");
	var sPathToRoot = sLinkHref.substring(0,sLinkHref.indexOf("2008_templates"));
	var sLocHref = location.href.substring(0,location.href.lastIndexOf("/")+1);
	sSiteRoot = sLocHref + sPathToRoot;
}


//Generic Cookie Code
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=/";
	//alert(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);
}
