/*
	ShowHideLayer Script
	Author: Warwick Adderley: warwick@pretzel.com.au
	Version: 2.3
	Version History:
		2.1 - Added function mouseOff() and var popup.mouseOffAnchor
		2.2 - Added var doc to increase performance.
		2.3 - Added function _resetMenu for dropmenu.js compatibility
		2.4 - Added cascade property and modified menuClose() and hide() functions
*/
var lshowhide = true;

var doc = document;
var isNav = (!(!doc.layers));
var version = parseFloat(navigator.appVersion);
var isIE = (!(!doc.all));
var hasLayers = ((isNav && version >= 4.04) || isIE);
var _definedpopUps = new Array();
var mouseX, mouseY;

if (isIE)
	doc.onmousemove = updateCursor;

if (isNav) {
	window.captureEvents(Event.MOUSEMOVE);
	window.onmousemove = updateCursor;
	}

function updateCursor(e) {
	mouseX = (isNav) ? e.pageX : event.clientX + doc.body.scrollLeft;
	mouseY = (isNav) ? e.pageY : event.clientY + doc.body.scrollTop;
	}

function hideAll() {
	if (hasLayers) {
		if (!(!popUp.prototype.hideAll)) {
			popUp.prototype.hideAll();
			}
		}
	}

function showHide(theLayer) {
	if (hasLayers) {
		if (!(!_definedpopUps[theLayer])) {
	 		_definedpopUps[theLayer].showHide();
	 		}
		}
	}

function mouseOff(theLayer) {
	if (hasLayers) {
		if (!(!_definedpopUps[theLayer])) {
	 		_definedpopUps[theLayer].mouseOffAnchor = true;
	 		}
		}	
	}

function menuClose(thePopUp) {
	var mw = thePopUp.mouseWithin();
	
	if (thePopUp.mouseOffAnchor) {
		if (mw == -1) {
			thePopUp.hide();
			}
		else if (thePopUp.cascade) {
			thePopUp.hide(mw + 1);
			}
		}
	}

function applyFilters(theElement) {
	if (theElement.filters.length > 0) {
		for (var e in theElement.filters) {
			if (typeof(theElement.filters[e]) == "object" && typeof(theElement.filters[e].Apply) != "undefined") {
				theElement.filters[e].Apply();
				theElement.filters[e].Play();
				}
			}
		}
	}

function _showHide() {
	this.hideAll();
	
	this.show();
	}
	
function _show() {
	for (var i in this.elements) {
		if (isIE)
			applyFilters(this.elements[i].el);
		
		this.elements[i].st.visibility = 'visible';
		
		if (this.menu)
			this.menuClose();
		}
	}

function _hide(fromIndex) {
	var fi = (fromIndex) ? fromIndex : 0;
	
	for (var i = fi; i < this.elements.length; i++) {
		if (this.elements[i].st.visibility != 'hidden' && this.elements[i].st.visibility != 'hide') {
			if (isIE)
				applyFilters(this.elements[i].el);
			
			this.elements[i].st.visibility = 'hidden';
			}
		}
	
	if (this.menu && !this.cascade || this.cascade && fi == 0)
		this.resetMenu();
	}

function _resetMenu() {
	clearInterval(this.timer);
	this.mouseOffAnchor = false;	
	}

function _hideAll() {
	for (var i in _definedpopUps) {
		if (!(!_definedpopUps[i])) {
			_definedpopUps[i].hide();
			}
		}
	}

function _menuClose() {
	this.timer = setInterval("menuClose(_definedpopUps['" + this.name + "'])", 700);
	}

function _mouseWithin() {
	var retVal = -1;
	
	for (var i in this.elements) {
		var e = this.elements[i];
		var x, y, w, h;
		
		x = (isNav) ? e.st.left : e.st.pixelLeft;
		y = (isNav) ? e.st.top : e.st.pixelTop;
		r = (isNav) ? e.el.document.width + x : e.el.clientWidth + x;
		b = (isNav) ? e.el.document.height + y : e.el.clientHeight + y;
		
		if (x < mouseX && y < mouseY && r > mouseX && b > mouseY)
			retVal = parseInt(i);
		}
	
	return retVal;
	}

function getLayerName(theString) {
	var retStr = new String();
	
	if (theString.indexOf(".") != -1)
		retStr = theString.substring(theString.lastIndexOf(".") + 1);
	else
		retStr = theString;
	
	return retStr;
	}
	
function popUp() {
	if (hasLayers) {
		this.elements = new Array();
		this.name = null;
		this.menu = false;
		this.cascade = false;
		this.timer;
		this.mouseOffAnchor = false;
		
		for (var i = 0; i < popUp.arguments.length; i++) {
			this.elements[i] = new Object();
			
			if (isNav) {
				this.elements[i].st = (typeof(popUp.arguments[i]) == "string") ? eval('doc.layers.' + popUp.arguments[i]) : popUp.arguments[i];
				this.elements[i].el = this.elements[i].st;
				}
			else {
				this.elements[i].st = (typeof(popUp.arguments[i]) == "string") ? doc.all[getLayerName(popUp.arguments[i])].style : popUp.arguments[i].style;
				this.elements[i].el = (typeof(popUp.arguments[i]) == "string") ? doc.all[getLayerName(popUp.arguments[i])] : popUp.arguments[i];
				}
			}
		
		this.name = (isNav) ? this.elements[0].el.id : this.elements[0].el.id;
		
		_definedpopUps[this.name] = this;
		
		popUp.prototype.showHide = _showHide;
		popUp.prototype.hideAll = _hideAll;
		popUp.prototype.hide = _hide;
		popUp.prototype.show = _show;
		popUp.prototype.menuClose = _menuClose;
		popUp.prototype.mouseWithin = _mouseWithin;
		popUp.prototype.resetMenu = _resetMenu;
		}
	}