
/**
 * Browser sniffer
 */
function browserChecker () {

	this.agent = navigator.userAgent.toLowerCase ();

	this.major = parseInt (navigator.appVersion);
	this.minor = parseFloat (navigator.appVersion);

	this.dom = document.getElementById ? 1 : 0;

	// Opera spoofs IE
	this.op5 = (this.agent.indexOf ("opera 5") != -1 || this.agent.indexOf ("opera/5") != -1 && window.opera);
	this.op6 = (this.agent.indexOf ("opera 6") != -1 || this.agent.indexOf ("opera/6") != -1 && window.opera);

	this.ie5 = (this.agent.indexOf ("msie 5") != -1 && !this.op5 && !this.op6);
	this.ie55 = (this.ie5 && this.agent.indexOf ("msie 5.5") != -1);

	this.ie6 = (this.agent.indexOf ("msie 6") != -1 && !this.op5 && !this.op6)
	this.ie4 = (this.agent.indexOf ("msie") != -1 && document.all && !this.ie5 && !this.ie6);

	this.ie45 = (this.ie4 || this.ie5 || this.ie55);

	this.mac = (this.agent.indexOf ("mac") != -1);

	this.ns6 = (this.agent.indexOf ("gecko") != -1 || window.sidebar);

	// Netscape 4 doesn't support the DOM.
	this.ns4 = (!this.dom && document.layers) ? 1 : 0;

	// The list of supported browsers for this file.
	this.supported = (this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.op5 || this.op6);

	this.useDom = this.ns6 || this.ie5 || this.ie55 || this.ie6;
	this.reuseLayers = this.ie || this.useDom;

	return this;
}

var onloadFuncArray = new Array ();
var onloadWaitArray = new Array ();

var brwCheck = new browserChecker ();

var brwDim = new encDimensions ();

addToOnLoadList (encInit, 0);

// the last layer that was set to visible
var curVisibleLayer;

var encOverDiv = false;
var encDivTimer = null;

var secondsVisible = 1;

var winWidth;
var snavXPos, snavYPos;

function encInit () {

	pageOnload ();

	encMoveLayerTo ('crumb', 6, 152);
	encShowLayer ('crumb');

	encMoveLayerTo ('pageLinks', 603, 490);
	encShowLayer ('pageLinks');
}

function encShowLayer (name) {
	curVisibleLayer = name;
	if (brwCheck.ns4 && document.layers[name]) {
		document.layers[name].visibility = "show";
	}
	if (brwCheck.ie5 && document.all[name]) {
		document.all[name].style.visibility = "visible";
		curVisibleLayer = name;
	}
	if (brwCheck.ns6 || brwCheck.ie6) {
		var elem = document.getElementById (name);
		if (elem) {
			elem.style.visibility = "visible";
		}
	}
}

function encHideLayer (name) {
	if (brwCheck.ns4 && document.layers[name]) {
		document.layers[name].visibility = "hide";
	}
	if (brwCheck.ie5 && document.all[name]) {
		document.all[name].style.visibility = "hidden";
	}
	if (brwCheck.ns6 || brwCheck.ie6) {
		var elem = document.getElementById (name);
		if (elem) {
			elem.style.visibility = "hidden";
		}
	}
	curVisibleLayer = "";
}

function encMoveLayerTo (name, x, y) {

    if (brwCheck.ns4 && document.layers[name]) {
        document.layers[name].left = x;
        document.layers[name].top = y;
    }
    if (brwCheck.ie45 && document.all[name]) {
        document.all[name].style.left = x;
        document.all[name].style.top = y;
    }
	if (brwCheck.ns6 || brwCheck.ie6) {
		var elem = document.getElementById (name);
		if (elem) {
			elem.style.left = x + "px";
			elem.style.top = y + "px";
		}
	}
}

function encMoveLayerBy (name, x, y) {

    if (brwCheck.ns4 && document.layers[name]) {
        document.layers[name].left += x;
        document.layers[name].top += y;
    }
    if (brwCheck.ie45 && document.all[name]) {
		var temp = parseInt (document.all[name].style.left) + x;
        document.all[name].style.left = temp;
		temp = parseInt (document.all[name].style.top) + y;
        document.all[name].style.top = temp;
    }
	if (brwCheck.ns6 || brwCheck.ie6) {
		var elem = document.getElementById (name);
		if (elem) {
			var temp = parseInt (elem.style.left) + x;
			elem.style.left = (temp + "px");
			temp = parseInt (elem.style.top) + y;
			elem.style.top = (temp + "px");
		}
	}
}

function encHideCurrent () {
	encHideLayer (curVisibleLayer);
}

function encDivOver () {
	encOverDiv = true;
	clearTimeout (encDivTimer);
}

function encDivOut () {
	encOverDiv = false;
	encDivTimer = setTimeout ("encHideCurrent ();", secondsVisible * 1000);
}

function encGetElementHeight (name) {
	var height = 50;
	if (brwCheck.ns4 && document.layers[name]) {
		height = document.layers[name].clip.bottom;
	}
	if (brwCheck.ie5) {
		height = document.all[name].clientHeight;
	}
	return height;
}

function encGetElement (name) {
	var elem;
	if (brwCheck.ns4) {
		elem = document.layers[name];
	}
	if (brwCheck.ie45) {
		elem = document.all[name];
	}
	if (brwCheck.ns6 || brwCheck.ie6) {
		elem = document.getElementById (name);
	}
	return elem;
}

function addToOnLoadList (fname, waitInSecs) {

	if (brwCheck.ie45 && brwCheck.isMac) {
		window.onload = encOnLoad;
		onloadFuncArray[onloadFuncArray.length] = fname;
		onloadWaitArray[onloadWaitArray.length] = waitInSecs;
	} else {

		if (window.onload) {
			// onload script exists. add it to the array after the current addition
			if (window.onload != encOnLoad) {

				onloadFuncArray[onloadFuncArray.length] = window.onload;
				onloadWaitArray[onloadWaitArray.length] = 0;

				onloadFuncArray[onloadFuncArray.length] = fname;
				onloadWaitArray[onloadWaitArray.length] = waitInSecs;

				window.onload = encOnLoad;
			} else {
				onloadFuncArray[onloadFuncArray.length] = fname;
				onloadWaitArray[onloadWaitArray.length] = waitInSecs;
			}
		} else {
			onloadFuncArray[onloadFuncArray.length] = fname;
			onloadWaitArray[onloadWaitArray.length] = waitInSecs;

			window.onload = encOnLoad;
		}

	}
}

function encOnLoad () {
	for (var i = 0; i < onloadFuncArray.length; i++) {
		if (onloadWaitArray[i] && onloadWaitArray[i] > 0) {
			// there is a timer.
			var timer = setTimer (onloadFuncArray [i] + "();", onloadWaitArray[i] * 1000);
		} else { 
			onloadFuncArray[i] ();
		}
	}
}

function encDimensions () {
	var temp = 0;
	/*
	if (brwCheck.ns4) {
		temp = window.innerWidth;
	} 
	if (document.all) {
		temp = document.body.clientWidth + 18;
	}
	*/
	this.windowWidth = temp;
}

function encRemoveClickBorder (object) {
	if (brwCheck.ie45) {
		if (object.blur) {
			object.blur ();
		}
	}
}

