//var activeSub=0;
//var SubNum=0;

//Define global variables

var timerID = null;
var timerOn = false;
var timecount = 500;
//var startdelay = 1250;
var startdelay = 0;
var starttime;
var what = null;
var newbrowser = true;
var check = false;

var subtimer1 = null;
var subtimer2 = null;
var subtimer3 = null;
var subtimer4 = null;
var subtimer5 = null;

var d = new Date();

function reDo(){ window.location.reload() }
    window.onresize = reDo;

var d_n;

function DDClass()
{
        var d_n = navigator.userAgent.toLowerCase(), d_i;
        this.db = (document.compatMode && document.compatMode.toLowerCase() != "backcompat")?
                document.documentElement
                : (document.body || null);
        this.op = (window.opera && document.getElementById);
        this.op6 = (this.op && !(this.db && this.db.innerHTML));
        if (this.op && !this.op6) document.onmousedown = new Function('e',
                'if (((e = e || window.event).target || e.srcElement).tagName == "IMAGE") return false;'
        );
	//        this.ie = d_n.indexOf("msie") != -1 && document.all && this.db && !this.op;
        this.ie = d_n.indexOf("msie") != -1;
        this.iemac = this.ie && d_n.indexOf("mac")!=-1;
        this.ie4 = this.ie && !document.getElementById;
        this.n4 = (document.layers && typeof document.classes != "undefined");
        this.kq = (d_i = d_n.indexOf("konqueror")) > -1 && parseInt(d_n.substring(d_i+0x0a)) > 0x02;
                this.kq_new = this.kq && d_n.substring(d_i+0x0a, d_i+0x0d) != "3.0";
        this.n6 = !this.op && !this.kq && !this.ie && document.defaultView && typeof document.defaultView.getComputedStyle != "undefined";
        this.n7 = this.n6 && parseInt(d_n.substring((d_i = d_n.indexOf('gecko'))+6, d_i+0x0c)) > 200209;
        this.ce = document.captureEvents && document.releaseEvents;
        this.px = (this.n4 || this.op6)? '' : 'px';
        this.elements = new Array();
}

function init(){
	//alert ("Running Init");
	starttime = d.getTime();
	/*
	var dd = new DDClass();
	if (dd.iemac) {
		alert ("Running IE on MAC");
		layerRef="document.all";
		styleSwitch="";
		visibleVar="show";
		screenSize = document.body.clientWidth + 18;
		what ="ie";
	}else*/ if (document.layers) {
		// alert ("Running Netscape 4");
		layerRef="document.layers";
		styleSwitch="";
		visibleVar="show";
		screenSize = window.innerWidth;
		what ="ns4";
	}else if(document.getElementById){
		// alert ("Running Netscape 6");
		layerRef="document.getElementByID";
		styleSwitch=".style";
		visibleVar="visible";
		what="moz";
	}else if(document.all){
		// alert ("Running IE");
		layerRef="document.all";
		styleSwitch=".style";
		visibleVar="visible";
		screenSize = document.body.clientWidth + 18;
		what ="ie";
	}else{
		// alert("Older than 4.0 browser.");
		what="none";
		newbrowser = false;
	}
	//window.status='status bar text to go here';
	check = true;
}

function rollover (imgsrc, imgname) {
	var dn = new Date();
	thistime = dn.getTime();
	if ((thistime - starttime) < startdelay) {
		return;
	}
        //if (what == "ie"){
	//	document.getElementById(imgsrc).src=imgname;
	//}
	//else{
		document[imgsrc].src = imgname;
        //}
}

// Turns the layers on and off
function showLayer(layerName){
	var dn = new Date();
	thistime = dn.getTime();
	//alert ("show layer");
	if ((thistime - starttime) < startdelay) {
		alert ("< startdelay");
		return;
	}
	if(check){
		if (what =="none"){
			alert ("what = none");
			return;
		}
        else if (what == "moz"){
			//alert (layerName);
			document.getElementById(layerName).style.visibility="visible";
		}
		else{
			alert ("what = else");
			eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
		}
	}
	else {// alert ("Please wait for the page to finish loading.");
		return;
	}
}

function hideLayer(layerName){
	if(check){
		if (what =="none"){
			return;
			}
		else if (what == "moz"){
			document.getElementById(layerName).style.visibility="hidden";
			}
		else{
			eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
		}
	}
	else {// alert ("Please wait for the page to finish loading.");
		return;
	}
}

function startTime() {
	if (timerOn == false) {
		timerID=setTimeout( "hideAll()" , timecount);
		timerOn = true;
	}
}


function stopTime() {
	if (timerOn) {
		clearTimeout(timerID);
		timerID = null;
		timerOn = false;
	}
}

function onLoad(){
	init();
}

function hideLayers(except){
	// if (except!='submenu1') hideLayer('submenu1');
	if (except!='submenu2') hideLayer('submenu2');
	if (except!='submenu3') hideLayer('submenu3');
	if (except!='submenu4') hideLayer('submenu4');
	//if (except!='submenu5') hideLayer('submenu5');
}

function highlight(layerName){
	if(check){
		if (what =="none"){
			return;
			}
		else if (what == "moz"){
			document.getElementById(layerName).style.color='#cc5500';
			document.getElementById(layerName).style. cursor='pointer';
			}
		else{
			eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.color="#cc5500"');
			eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.cursor="pointer"');
		}
	}
	else {// alert ("Please wait for the page to finish loading.");
		return;
	}
}

function lowlight(layerName){
	if(check){
		if (what =="none"){
			return;
			}
		else if (what == "moz"){
			document.getElementById(layerName).style.color='#000000';
			document.getElementById(layerName).style. cursor='default';
			}
		else{
			eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.color="#000000"');
			eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.cursor="default"');
		}
	}
	else {// alert ("Please wait for the page to finish loading.");
		return;
	}
}

function lowlightwhite(layerName){
	if(check){
		if (what =="none"){
			return;
			}
		else if (what == "moz"){
			document.getElementById(layerName).style.color='#ffffff';
			document.getElementById(layerName).style. cursor='default';
			}
		else{
			eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.color="#ffffff"');
			eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.cursor="default"');
		}
	}
	else {// alert ("Please wait for the page to finish loading.");
		return;
	}
}
