if (window.location.host == "www.mergetel.com")
{	var oldPage = window.location.pathname.substr(10);
	newPage = "http://www.jubileecrc.org/" + oldPage + "?!!" + document.referrer;
	window.location.href = newPage;
}
else
{	var ref = window.location.href.indexOf("!!");
	if ( ref < 0 )
	{	if (GetCookie("ref")==null)
		{	SetCookie ("ref",document.referrer,null,"/"); }
		preload();
	}
	else
	{	SetCookie ("ref",window.location.search,null,"/");
		newPage = window.location.pathname;
		window.location.href  = newPage;
	}
}

var browserDate = new Date();
FixCookieDate (browserDate); 
SetCookie ("hour",browserDate.getHours(),null,"/");

function Showcase(hreference)
{	popup1=window.open (hreference,'','resizable=yes,scrollbars=yes,toolbar=no,status=yes,height=440,width=550');
}

function preload()
{	if (GetCookie("preload")!="done")
	{	count=0;
		if (location.host == "localhost")
		{	baseURL = "http://localhost/jubilee/"; }
		else
		{	baseURL = "http://www.jubileecrc.org/"; }
		sources = new Array (
			"images/bnjubilee_on.gif",
			"images/bnjubilee_over.gif",
			"images/bnnews_on.gif",
			"images/bnnews_over.gif",
			"images/bninter_on.gif",
			"images/bninter_over.gif",
			"images/bnforum_on.gif",
			"images/bnforum_over.gif",
			"images/bnresource_on.gif",
			"images/bnresource_over.gif",
			"images/bnlinks_on.gif",
			"images/bnlinks_over.gif",
			"images/bnphotos_on.gif",
			"images/bnphotos_over.gif"
		);	
		images = new Array ();	
		for (i=0; i<sources.length; i+=1)
		{	images[i] = new Image();
			images[i].onload = loadCheck;
			images[i].src = baseURL + sources[i];
		}
	}
}

function loadCheck()
{   count++;
    if(count == sources.length-1) 
    {	SetCookie ("preload","done",null,"/");
    }
}

function backdoor()
{	SetCookie ("entry","backdoor",null,"/");
}

function SetCookie (name,value,expires,path,domain,secure)
{  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function FixCookieDate (date) {
  var base = new Date(0);
  var skew = base.getTime(); // dawn of (Unix) time - should be 0
  if (skew > 0)  // Except on the Mac - ahead of its time
    date.setTime (date.getTime() - skew);
}

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 turnOver()
{	what = window.event.srcElement;
	if ((what.tagName == "IMG") && (what.src.indexOf("_on") < 1))
	{	what.src = what.src.substring(0,(what.src.indexOf(".gif"))) + "_over.gif";
		window.event.cancelBubble = true;
	}
}

function turnOff()
{	what = window.event.srcElement
	if ((what.tagName == "IMG") && (what.src.indexOf("_on") < 1))
	{	what.src = what.src.substring(0,(what.src.indexOf("_over.gif"))) + ".gif";
		window.event.cancelBubble = true;
	}
}
