function setCount(n)
{
  theDay = 30;
  setDay = new Date();
  setDay.setTime(setDay.getTime()+(theDay*1000*60*60*24));
  expDay = setDay.toGMTString();
  document.cookie = "count="+n+";expires="+expDay;
}
function getCount()
{
  theName = "count=";
  theCookie = document.cookie+";"
  start = theCookie.indexOf(theName);
  if (start != -1)
  {
     end = theCookie.indexOf(";", start);
     count = eval(unescape(theCookie.substring(start+theName.length, end)));
     document.write("君は");
     document.write(count+"回訪問です");
     setCount(count+1);
  } else {
     document.write("君は初回訪問です");
     setCount(2);
  }
}
getCount();
