function SetCookie(name,value)
{
var epd=new Date();
epd.setTime(epd.getTime()+(24*60*60*1000*30));
document.cookie=" "+name + "=" + value+"; expires="+ epd.toGMTString()+"; path=/";
}

function getCookieVal (offset)
{
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0)
break;
}
return "null";
}

function GetURLFrom()
{
  URL = document.URL.toLowerCase();
  SC = URL.indexOf('?',0);
  if (SC==-1) 
  { return "none"; }
  else
  { return URL.substring(SC+1,URL.length); }
}

function Set()
{
  CName = "USERFROM";
  if (GetCookie(CName)=="null")
  {
    SetCookie(CName,GetURLFrom());
  }
}

function SetP(Page)
{
  CName = "USERFROM";
  if (GetCookie(CName)=="null")
  {
    SetCookie(CName,Page + "."+GetURLFrom());
  }
}

function Get()
{
  CName = "USERFROM"
  return GetCookie(CName);
}  
