function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}

function eraseCookie(name) {
	//alert("Cookie erased");
		 setCookie(name,"null",-1);
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
//alert('cname ' + c_name);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
//alert(document.cookie);
}

function checkCookie()
{
locale=getCookie('CountryName');
if (locale!=null && locale!="")
  {
   window.location=locale;
  //alert('Welcome again '+locale+'!');
  }
 
 }


function getCookieValue(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 "true";
  }
  // Then find the querystring, everything after the ?
  var query = qparts[1];
  
  if(query==undefined)
{
return "true";
}
  var vars = query.split("=");
  
  if(vars[1]==undefined)
  {
  return "true";
  }
var cookieValue ="true";
if(vars[0]==varname)
{
  cookieValue = vars[1];
  
  // Convert escape code
  cookieValue = unescape(cookieValue);

  // Convert "+"s to " "s
  cookieValue.replace(/\+/g," ");

  // Return the cookieValue
 
  return cookieValue;

}
else
{
return "true";
}

}