//get a cookie value by name
function get_cookie(Name) {
  var search = Name + "=";
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search);
    if (offset != -1) { // if cookie exists
      offset += search.length;
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1)
        end = document.cookie.length;
      	returnvalue=unescape(document.cookie.substring(offset, end));
      }
   }
  return returnvalue;
}

//set cookie or change values of current cookie
function setCookie(name, value, days, path) {
	if (!days) {
		days = 1; // default to 1 day if empty
	}
	var expdate = new Date();
	expdate.setTime(expdate.getTime() + days*24*60*60*1000);
	//dc = name + "=" + escape(value) + "; expires=" + expdate.toGMTString() + "; path=" + path;
	document.cookie=name + "=" + value + "; path=" + path + "; expires=" + expdate.toGMTString();
}
	
//delete a cookie	
function deleteCookie(name) {
	// set the cookie date to 10 years ago
	var ckyDate = new Date;
	ckyDate.setFullYear(ckyDate.getFullYear( ) -10);
	document.cookie=name + "=; path=; expires=" + ckyDate.toGMTString();
}