/* Cookie-related scripts */
function setCookie(strName, strValue) {
  document.cookie = strName + "=" + escape(strValue) + "; path=/";
} // setCookie

function setExpiringCookie(strName, strValue, iDays) {
  var strExpires = "";
  if(iDays) {
    var tDate = new Date();
	  tDate.setTime(tDate.getTime()+(iDays*24*60*60*1000));
    strExpires = "; expires=" + tDate.toGMTString();
  }    
  document.cookie = strName + "=" + escape(strValue) + "; path=/" + strExpires;
}
  
function getCookie(strName) {
  var strResult = "";
  var strCookie = " " + document.cookie + ";";
  var strSearchName = " " + strName + "=";
  var iStartOfCookie = strCookie.indexOf(strSearchName);
  var iEndOfCookie;
  if(iStartOfCookie != -1) {
    iStartOfCookie += strSearchName.length; // skip past cookie name
    iEndOfCookie = strCookie.indexOf( ";", iStartOfCookie );
    strResult = unescape( strCookie.substring( iStartOfCookie, iEndOfCookie ));
    if(strResult == "null") strResult = "";
  }
  return strResult;
} // getCookie
