// This JavaScript code should run under Netscape Navigator 3.0 
// and Microsoft Internet Explorer 3.0 and above. 
//
// STANDARD COOKIE ROUTINES
//
// GetCookie - Returns the value of the specified cookie or null
//             if the cookie doesn't exist 
// 
function GetCookie(name) 
{
  var result = null;
  var myCookie = " " + document.cookie + ";"; // a string of the whole cookie + a bit more.
  var searchName = " " + name + "=";
  var startOfCookie = myCookie.indexOf(searchName); // a number = position of the name string.
  var endOfCookie;
  if (startOfCookie != -1) 
  {
    startOfCookie += searchName.length; // skip past cookie name 
    endOfCookie = myCookie.indexOf(";",startOfCookie);
    result = unescape(myCookie.substring(startOfCookie,endOfCookie));
    // result = myCookie.substring(startOfCookie,endOfCookie);
  }
  return result;
}

//
// SetCookieTemp - Quickly sets a cookie which will last until the
//               user shuts down his browser
//
function SetCookieTemp(name,value) 
{
  document.cookie = name + "=" + escape(value);
}


//
// SetCookie - Adds or replaces a cookie. Use null for parameters
//             that you don't care about//
function SetCookie(name,value,expires,path,domain,secure)
{
  var expString = ((expires == null) ? "" : ("; expires=" + expires.toGMTString()))
  var pathString = ((path == null) ? "" : ("; path=" + path))
  var domainString = ((domain == null) ? "" : ("; domain=" + domain))
  var secureString = ((secure == true) ? "; secure" : "")
  document.cookie = name + "=" + escape(value) +
  expString + pathString + domainString + secureString;
}


//
// ClearCookie  - Removes a cookie by setting an expiration date
//                three days in the past
//

function ClearCookie(name)
{
  var ThreeDays = 3 * 24 * 60 * 60 * 1000;
  var expDate = new Date();
  expDate.setTime(expDate.getTime() - ThreeDays);
  document.cookie = name + "=NA; expires=" + expDate.toGMTString();
}

function FindData(teststr) 
{
//
var searchstr = window.location.search;
//
// find the beginning of our special URL variable
//
var startOfSource = searchstr.indexOf(teststr); // a number.
//
// if it's there, find the end of it
//
if (startOfSource != -1) 
{
  var datastart = startOfSource + teststr.length;
  var dataend = searchstr.indexOf("&", datastart);
  if (dataend != -1)
  {
    var result = searchstr.substring(datastart, dataend);
  }
  else
  {  
    var result = searchstr.substring(datastart, searchstr.length);
  }
} 
else var result = null;

return result;
}

function access() 
{
  accesscode=GetCookie("access")|0;
  var fromdata =FindData("from=");
  if (fromdata == "englmus") accesscode|=255;
  else if (fromdata == "phil") accesscode|=255;
  else if (fromdata == "tech1") accesscode|=255;
  else if (fromdata == "folkorg") accesscode|=255;
  else if (fromdata == "musicroot") accesscode|=255;
  var endure = 7 * 24 * 60 * 60 * 1000; // 7 days. 
  var expDate = new Date();
  expDate.setTime (expDate.getTime() + endure );
  if (accesscode>0) SetCookie("access", accesscode, expDate, null, null, false);
  return accesscode;
}

function etz() 
{
  var now = new Date();
// offset is in minutes
  var offset = (now.getTimezoneOffset());

  var europe=1;

  if (offset >90) europe=0;
  if (offset < -90 )  europe=0;
  return europe;
}

