function getValue(varname){
   // First, we load the URL into a variable
   var url = window.location.href;

   // Next, split the url by the ?
   var qparts = url.split("?");

   // Check that there is a querystring, return "" if not
   if (qparts.length == 0){
      return "";
   }

   // Then find the querystring, everything after the ?
   var query = qparts[1];

   // Split the query string into variables (separates by &s)
   var vars = query.split("&");

   // Initialize the value with "" as default
   var value = "";

   // Iterate through vars, checking each one for varname
   for (i=0;i<vars.length;i++){
      // Split the variable by =, which splits name and value
      var parts = vars[i].split("=");
      if (parts[0] == varname){
         value = parts[1];
         break;
      }
   }

   // Convert escape code
   value = unescape(value);

   // Convert "+"s to " "s
   value.replace(/\+/g," ");

   // Return the value
   return value;
}

function getVar(varname){
   var url = window.location.href;
   var qparts = url.split("?");
   var query = qparts[1];
   return unescape(query);
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


