function SetCookieTmp(name,thevalue)
{
  document.cookie = name + "=" + thevalue;
}


function GetCookie(name)
{
  var result = null;
  var myCookie = " " + document.cookie + ";";
  var searchName = " " + name + "=" ;
  var startOfCookie = myCookie.indexOf(searchName);
  var endOfCookie;
  if (startOfCookie != -1)
  {
    startOfCookie += searchName.length;
    endOfCookie = myCookie.indexOf(";", startOfCookie);
    result = unescape(myCookie.substring(startOfCookie,endOfCookie));
  }
  return result;
}


function NewVisitor()
{
  storedcookie = GetCookie("known");
  if (storedcookie=="yes")
  {
    return false;
  }
  else
  {
    SetCookieTmp("known","yes");
    return true;
  }
}


function MakeSafeGet(val)
{
  val = val.replace(/&/g, "_amp_");
  val = val.replace(/\?/g, "_que_");
  return val;
}


function GenerateBottomPart()
{
  var countersrc = "/getcounter.php?";
  if (NewVisitor())
  {
    countersrc += "new=true&";
  }
  if (document.referrer!="")
  {
    countersrc += "from=" + MakeSafeGet(document.referrer) + "&";
  }

  countersrc += "source="+window.location.pathname;
  BottomString = '<iframe frameborder="0" src="'+countersrc+'" marginheight="0" marginwidth="0" scrolling="no" height="16" width="60" align="center">&nbsp;</iframe>';
  document.write(BottomString);
}