function getCookie(NameOfCookie){
    if (document.cookie.length > 0) { 
		//alert(document.cookie);
    begin = document.cookie.indexOf(NameOfCookie+"=");       
    if (begin != -1) {           
      begin += NameOfCookie.length+1;       
      end = document.cookie.indexOf(";", begin);
      if (end == -1) end = document.cookie.length;
        return unescape(document.cookie.substring(begin, end));
    } 
  }
  return null;
}

function setCookie(NameOfCookie, value, expiredays) {
var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

var theCookie = NameOfCookie + "=" + escape(value)+";";
theCookie= theCookie + ((expiredays == null) ? "" : " expires=" + ExpireDate.toGMTString());
theCookie = theCookie + " path=/";
//theCookie = theCookie + " domain=localhost:8080;";
//alert (theCookie);
document.cookie = theCookie;
}

function delCookie (NameOfCookie) {
  if (getCookie(NameOfCookie)) 
  {
	var now = new Date();
	var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);
	setCookie(NameOfCookie, '', yesterday);
  
	//var theCookie = NameOfCookie + "=" + escape(value)+";";
	//theCookie= theCookie + ((expiredays == null) ? "" : " expires=" + ExpireDate.toGMTString());
	//theCookie = theCookie + " path=/";  
    
	//document.cookie = NameOfCookie + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

