// Set cookie with specified name
function SetCookie(sName, sValue, sExpire ) {
  document.cookie = sName +"="+ escape(sValue) + ((typeof sExpire== "undefined")? "" : "; expires=" + sExpire );
}
// Delete cookie with specified name
function DelCookie(sName) {
  document.cookie = sName +"=; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}
// returns value of specified cookie var, or null if not set
function GetCookie(sName) {
	var sCookie = document.cookie;
	var aCookieNameValPairs = sCookie.split(";");
	var i, aNameValPair;

	for(i in aCookieNameValPairs) {
		aNameValPair = aCookieNameValPairs[i].split("=");
		// DEBUG: alert("["+ Trim(aNameValPair[0]) +"] = \""+ Trim(aNameValPair[0]) + "\"");
		if(Trim(aNameValPair[0]) == sName) return Trim(aNameValPair[1]);
	}
	return null;
}
// get expiry date for cookie (31 days from now)
function GetExpireDate() {
	var dDate = new Date();
  dDate.setTime(dDate.getTime() + (1000*60*60*24*31));	// increment expiry date by # milliseconds in 31 days
  return dDate.toGMTString();
}

function Trim(sText) {
	return sText.replace(/ /g, "");
}