function statGaya()
{
 pageSelf = escape(window.location.href);
 pageReferer = document.referrer;
 pageReferer = (pageReferer=="" && parent!=this)? escape(parent.window.location.href):escape(pageReferer);

 colorScreen = (navigator.appName != "Netscape")? screen.colorDepth : screen.pixelDepth;
 widthScreen = screen.width;

 visitorID = getCookieGaya("_visitorID", 0);
 if (visitorID == 0)
   visitorID = Math.floor(Math.random()*0x10000000000000000); // negative name space is for guests.
 setCookieGaya("_visitorID", visitorID, 43200, "/");

 sessionID = getCookieGaya("_SessID", 0); // store session in cookie: reduce server load
 if (sessionID == 0)
   sessionID = Math.floor(Math.random()*0x10000000000000000);
 setCookieGaya("_SessID", sessionID, 15, "/");

 curTime = new Date();
 zoneOffset = -curTime.getTimezoneOffset()/60;
 speedResponse = curTime.getTime()-_time_stamp;

 strParam = "?page=" + pageSelf + "&referer=" + pageReferer + "&color=" + colorScreen + "&width=" + widthScreen + "&visitor=" + escape(visitorID) + "&session=" + sessionID + "&zone=" + escape(zoneOffset) + "&speed=" + speedResponse + "&java=" + navigator.javaEnabled() + "&site=1467";
 //debug: document.write(strParam);
 document.write("<script language='javascript' src='http://stat.gaya.cn/stat.php" + strParam + "'><\/script>");
}

function setCookieGaya(name, value, mins, path)
{
  var expdate = new Date();
  expdate.setTime(expdate.getTime() + (60 * 1000 * mins));
  document.cookie = name + "=" + escape(value) + "; expires=" + expdate.toGMTString() +  "; path=" + path;
}

function getCookieGaya(name, defaultValue)
{
  var offset = document.cookie.indexOf(name);
  if (offset != -1)
  {
    offset += name.length + 1;
    var end = document.cookie.indexOf(";", offset);
    if (end == -1)
       end = document.cookie.length;
    return unescape(document.cookie.substring(offset, end));
  }
  else
    return defaultValue;
}

statGaya();