//ExpiresDays and Path are optional.
//ExipiresDays = the number of days this cookie should live for
//set ExipiresDays = 0 if you want it to expire after this session (the default)
//The default Path is "/"

function SetCookie(sName, sValue, nExpiresDays, sPath){
	sName = document.location.host + '_' + sName; //HACK- saves cookies with the servername prefix
	var sCookie = new String(UrlEncode(sName.toString()) + "=" + UrlEncode(sValue.toString()) + ";");
	if ((arguments.length >= 3) && (nExpiresDays != 0)){	// add the expiresMS
		var dExpires = new Date();
		dExpires.setTime(dExpires.getTime() + nExpiresDays * 24 * 60 * 60 * 1000);
		sCookie += "expires=" + dExpires.toGMTString() + ";";
	}

	if (arguments.length >= 4){	//set the path
		sCookie += "path=" + sPath + ";";
	} else {	//the default path
		sCookie += "path=/;";
	}
	document.cookie = sCookie;
}

function GetCookie(sName){
	sName = document.location.host + '_' + sName; //HACK- saves cookies with the servername prefix
	var sCookie = new String(document.cookie);
	var arrCookies = sCookie.split('; ');
	for (var i=0; i<arrCookies.length; i++) {
		if (unescape(arrCookies[i].substring(0, arrCookies[i].indexOf('='))).toLowerCase() == UrlDecode(sName.toLowerCase())) {
			return unescape(arrCookies[i].substr(arrCookies[i].indexOf('=')+1));
			break;
		}
	}
	return '';
}