if (navigator.appName.indexOf("Microsoft")!=-1) {
	browser = "IE";
} else { if (navigator.appName.indexOf("Netscape")!=-1) {
	browser = "NS";
}}

SetCookie ("ref",document.referrer,null,"/");
var browserDate = new Date();
SetCookie ("hour",browserDate.getHours(),null,"/");
if ((GetCookie("userkey")==null) || (GetCookie("userkey")==""))
{	SetCookie ("userkey","anybody",null,"/"); }


var posName = window.parent.document.location.href.indexOf("#");
if (posName > -1)
{	var strName = window.parent.document.location.href.substr(posName);
	if (strName == "#visitor")
	{	SetCookie ("visitor","backdoor",null,"/"); }
	if (window.parent.document.location.href != window.document.location.href)
	{	window.document.location.href = window.document.location.href + strName; }
}

window.onerror = newError;
document.onmousedown = newEvent;
menuMItemOn = "";
menuItemOn = "";

msgArray = new Array();
urlArray = new Array();
lnoArray = new Array();

function Debug()
{	href=""+parent.main.document.location;
	if (href.indexOf("?")==-1)
	{	search="?"; }
	else
	{	search="&"; }
	pos=href.indexOf("debug");
	if (pos==-1)
	{	href = href+search+"debug=1"; }
	else
	{	href = href.substring(0,pos-1) }
	parent.main.document.location=href;
}

if (window.location.href.indexOf("site") == -1)	//not found
{	var flag = popup.location;
}

function reTarget(choice) 
{	window.parent.opener.parent.document.location.href=choice;
	window.parent.opener.parent.focus();
	window.parent.focus();
}

function trackGuide(action)
{	SetCookie ("SiteGuide",action,null,"/");
	if (action = "open")
	{	setTimeout("checkOpener('../index.htm')",500);
		var flag = window.top.opener.location.href;
	}
}

function checkStep()
{	setTimeout("alert('out')",1000);
}

function openFullscreen()
{	var siteRef = window.top.location.href;
	SetCookie ("SiteGuide",siteRef,null,"/");
	seat=window.open ("../../index.htm");
}

function checkOpener(hreference)
{	if (msgArray.length>0)
		if (checkError("opener"))
		{	var siteRef = window.top.location.href;
			SetCookie ("SiteGuide",siteRef,null,"/");
			seat=window.open (hreference);
		}
}

function SiteGuide(hreference)
{	if (msgArray.length>0)
	{	if (checkError("popup"))
		{	//alert(GetCookie("SiteGuide"));
			if (GetCookie("SiteGuide")=="open")
			{	if (confirm("Open another copy ot the Site Guide? (or Cancel and restore Site Guide from taskbar.)"))
				{	popup=window.open (hreference,'','resizable=yes,scrollbars=yes,toolbar=no,status=yes,height=440,width=360');
				}
			}
			else
			{	popup=window.open (hreference,'','resizable=yes,scrollbars=yes,toolbar=no,status=yes,height=440,width=360');
			}
		}
	}
	else
	{	if (GetCookie("SiteGuide")=="close")
		{	popup=window.open (hreference,'','resizable=yes,scrollbars=yes,toolbar=no,status=yes,height=440,width=360');
		}
		else
			popup.focus();
	}
}

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

function InterAccess(hreference)
{	popup=window.open (hreference,'','resizable=yes,scrollbars=yes,toolbar=no,status=yes,height=300,width=760');
	popup.moveTo(20,20);
}		

function Dataview(hreference)
{	if ((checkError("popup")))
	{	popup=window.open ("../../cgi-bin/mysql/interaccess.cgi",'','resizable=yes,scrollbars=yes,toolbar=no,status=yes,height=300,width=760');
		popup.moveTo(20,20);
		setTimeout("popup.main.location='" + hreference + "'",1000);
		
	}
	else
		popup.main.location=hreference;
		popup.focus();
}

servicesOn = ""

function Over(imgName) 
{	imgSource = document.images[imgName].src;
	if (imgSource.indexOf("_over")>-1)
		menuItemOn = imgName;
	else
	{	pos = imgSource.indexOf(".gif");
		document.images[imgName].src = imgSource.substr(0,pos)+"_over.gif";
	}
}

function Out(imgName)
{	if (menuItemOn != imgName)
	{	imgSource = document.images[imgName].src;
		pos = imgSource.indexOf("_over.gif");
		document.images[imgName].src = imgSource.substr(0,pos)+".gif";
	}
}

function OverM(item) 
{	imgSource = document.images[item + "A"].src;
	if (imgSource.indexOf("over")>-1)
	{	menuMItemOn = item;
	} else {
		document.images[item + "A"].src = "images/" + item + "A_over.gif";
	}
}

function OutM(item)
{	if (menuMItemOn != item)
	{	document.images[item+"A"].src = "images/" + item + "A.gif";
	}
}

function animate(imgName)
{	imgSource = parent.banner.document.images[imgName].src;
	if (imgSource.indexOf("_over") == -1)
	{	pos = imgSource.indexOf(".gif");
		parent.banner.document.images[imgName].src = imgSource.substr(0,pos)+"_over.gif";
	}
}

function checkError(msgFlag)
{	var chkError = false
	for (var i = 0; i < msgArray.length; i++) 
	{	if(msgArray[i].indexOf(msgFlag)>-1)
		{	if (i == msgArray.length-1)
			{	msgArray = new Array();
				urlArray = new Array();
				lnoArray = new Array();
			}
			else
			{	msgArray = msgArray.slice(i,i+1);
				urlArray = urlArray.slice(i,i+1);
				lnoArray = lnoArray.slice(i,i+1);
			}
			chkError = true;
		}
	}
	return chkError;
}

function newError(msg, url, lno)
{   	msgArray[msgArray.length] = msg;  
	urlArray[urlArray.length] = url;
	lnoArray[lnoArray.length] = lno;
	return true;
}

function newEvent(evnt) {
	if (browser == "IE") {
		evnt = window.event;
		if (evnt.type == "mousedown") {
			if (evnt.shiftKey) {
				listErrors();
				window.status = "";
			} else {if (evnt.ctrlKey) {
				obj = prompt ("object: (document/history/location/navigator/screen/window)","");
				listProperties(obj);
			}}
		}
	} else { if (browser == "NS") {
		if (evnt.type == "mousedown") {
			if (evnt.modifiers == "4") {
				listErrors();
				window.status = "";
			} else {if (evnt.modifiers == "2") {
				obj = prompt ("object: (document/history/location/navigator/screen/window)","");
				alert ("" + obj);
				listProperties(obj);
			}}
		}
	}}
	return true;	
}

function listProperties (obj) {
	width = 40;
	depth = 2;
	var list = new Array("deeper","normal","empty");
	var prop;
	var val;
	winList=window.open('','newWindow','scrollbars=yes,resizable=yes,toolbar=no,height=320,width=400');
	winList.document.writeln('<H2>Properties of <b>' + obj + '</B></H2>');
	obj = eval(obj);
	for (cat in list) {
		winList.document.writeln("<B><H3>" + list[cat] + ":</H3></B>");
		for (i in obj) {
			prop = "" + i;
			val = "" + obj[i];
			if (val.indexOf("object") == 1) {
				if (list[cat] != "deeper")
					continue;
				else 
					prop = "<b>" + prop + "</b>";
			} else { if ((val == "null") | (val == "")) {
				if (list[cat] != "empty") 
					continue;
			} else {
				if (list[cat] != "normal")
					continue;
			}}
			if (val.length >width)
				val = val.substr(0,width) + " . . .";
			winList.document.writeln(prop + ' = ' + val + '<BR>');
			if (list[cat] == "deeper")
				nextLevel(obj[i],1);
		}
	}
	winList.document.close();
	winList.focus();
}

function nextLevel(obj, level) {
	if (level < 2) {
		var tab = "-----"
		var col = width - level*5;
		for (var i=1; i<level; i++) {
			tab = tab + "-----";
		}
		for (i in obj) {
			val = "" + obj[i];
				if (val.length > col) {
					val = val.substr(0,col) + " . . .";
				}	
				winList.document.writeln(tab + i + ' = ' + val + '<BR>');
			if (val.indexOf("object")== 1) {
				nextLevel (obj[i],level+1);
			} 
		}
	}
}
            
function listErrors() {   
	winList=window.open('','window2','scrollbars=yes,resizable=yes,toolbar=no,height=320,width=400');
	winList.document.writeln('<B>Error Report</B><P>');
	for (var i=0; i < msgArray.length; i++) {      
		winList.document.writeln('<B>Error in file:</B> ' + urlArray[i] + '<BR>');
		winList.document.writeln('<B>Line number:</B> ' + lnoArray[i] + '<BR>');
		winList.document.writeln('<B>Message:</B> ' + msgArray[i] + '<P>');
	}
	winList.document.close();
	winList.focus();
	msgArray = new Array();
	urlArray = new Array();
	lnoArray = new Array();
	if (window.location.href.indexOf("sitecontents.htm") == -1)	//not found
		var flag = popup.location;
}

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 "";
}

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 DeleteCookie (name,path,domain) 
{  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}
