function CheckCookie()
{
	var cname = "SiteVisited";
	var data ="NowBaked";  
	var cpath = location.pathname;
	var cdomain = location.host;
  if( !ExistsCookie(cname) )
  {

	now= new Date();  // get current date and time
	expiry = new Date();
    expiry.setTime((now.getTime() + 14*24*60*60*1000));
    
    WriteCookie(cname,data,expiry,cpath,cdomain); 
    
    return true;
  }
  
  // The user has already visited
  return false;
}  




// Writes the specified data to the cookie file
function WriteCookie(name,data,expiryDate,path,domain)
{  
  // The name and data arguments are compulsory  
  if( name==null || name=="" || data==null || data=="")
  {
     alert("Cookie name & data values MISSING!");
     return false;
  }

  
  var Cookie = name + "=" + escape(data);
        //+";expires="+expiryDate.toGMTString();
         
   //Set cookie
   alert('write cookie'+Cookie);
   document.cookie = Cookie;
   
   return true;
}

//gets value of  specified cookie 
function ReadCookie(name)
 { 
  var result=null;
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  
  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair is separated by an = sign
    var aCrumb = aCookie[i].split("=");
    alert('aCrumb'+aCrumb[0]+","+aCrumb[1]);
    if (name == aCrumb[0]) {
        result=  aCrumb[1];
	  }
  }
  return result;
}

//Checks if the specified cookie exists or not
function ExistsCookie(name)
 { 
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  
  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair is separated by an = sign
    var aCrumb = aCookie[i].split("=");
    if (name == aCrumb[0]) {
      
	  return true;}
  }
	
  // a cookie with the requested name does not exist
  return false;
}
