
var aryMenus = new Array();
var intHideTimeID = new String();

function validateSearchForm() {
	var strSearch = document.frmSearch.search.value;
	if (strSearch != '' && strSearch.charCodeAt(0) != 32) {
		return true;
	} else {
		alert('Please enter a search term before attempting to search.');
		return false;
	}
}

function checkBrowser() {
	var strBrowser = navigator.appName;
	if (strBrowser == 'Netscape') {
		this.browser = 'ns';
	} else if (strBrowser == 'Microsoft Internet Explorer') {
		this.browser = 'ie';
	} else {
		this.browser = 'unknown';
	}
	var intVersion = parseInt(navigator.appVersion);
	if (intVersion >= 4 && this.browser == 'ns') {
		this.version = intVersion;
		this.doMenu = true;
	} else if (this.browser == 'ie' && navigator.userAgent.indexOf('MSIE ') > 0) {
		var strAgent = new String(navigator.userAgent);
		intVersion = parseInt(strAgent.substr(strAgent.indexOf('MSIE ') + 5,1));
		this.version = intVersion;
		if (this.version >= 4) {
			this.doMenu = true;
		} else {
			this.doMenu = false;
		}
	} else {
		this.doMenu = false;
	}
}

function ddMenu(strName,strParent) {
	this.id = strName;
	if (browser.version == 4 && browser.browser == 'ns') {
		this.dhtmlement = document.layers[strName];
		this.style = document.layers[strName];
		this.height = this.style.clip.height;
		this.width = this.style.clip.width;
		this.top = this.style.top;
		this.left = this.style.left;
	} else {
		this.dhtmlement = document.getElementById(strName);
		this.style = this.dhtmlement.style;
		this.height = (browser.version == 4 && browser.browser == 'ie')? this.css.pixelHeight : this.dhtmlement.offsetHeight;
		this.width = (browser.version == 4 && browser.browser == 'ie')? this.css.pixelWidth : this.dhtmlement.offsetWidth;
		this.top = this.dhtmlement.offsetTop;
		this.left = this.dhtmlement.offsetLeft;
	}
	this.intID = 0;
	this.dhtmlement.onMouseOver = clearHideTimer;
	this.dhtmlement.onMouseOut = initHideTimer;
}

function showSubMenu(strName,strParent) {
	if (browser.doMenu) {
		clearHideTimer();
		hideAllMenus(strParent);
		var menuToShow;
		var ref;
		for (var i=0; i < aryMenus.length; i++) {
			var tempMenu = aryMenus[i];
			if (tempMenu.id == strName) {
				menuToShow = tempMenu;
			}
		}
		menuToShow.style.visibility = 'visible';
	}
}

function showMenu(strName) {
	if (browser.doMenu) {
		clearHideTimer();
		hideAllMenus(null);
		var menuToShow;
		var ref;
		for (var i=0; i < aryMenus.length; i++) {
			var tempMenu = aryMenus[i];
			if (tempMenu.id == strName) {
				menuToShow = tempMenu;
				ref = i;
			}
		}
		
		if (!(browser.version == 4 && browser.browser == 'ns')) {
			menuToShow.style.height = '0px';
			menuToShow.IsSliding = true;
			menuToShow.style.visibility = (browser.browser == 'ns' && browser.version == 4)? 'show' : 'visible';
			menuToShow.intID = setInterval("slideMenu(" + ref + ")",10);
		} else {
			menuToShow.style.visibility = (browser.browser == 'ns' && browser.version == 4)? 'show' : 'visible';
		}
	}
}

function slideMenu(intAryRef) {
	var menuToSlide = aryMenus[intAryRef];
	if (menuToSlide.IsSliding) {
		intHeight = parseFloat(menuToSlide.style.height);
		if (intHeight < menuToSlide.height) {
			menuToSlide.style.height = (intHeight + 5) +'px';
		} else {
			menuToSlide.IsSliding = false;
		}
	} else {
		clearInterval(menuToSlide.intID);
		return;
	}
}

function hideAllMenus(strExcept) {
	if (browser.doMenu) {
		for (var i=0; i < aryMenus.length; i++) {
			var tempMenu = aryMenus[i];
			if (tempMenu.id != strExcept) {
				if (!tempMenu.intID.isNaN) clearInterval(tempMenu.intID);
				tempMenu.IsSliding = false;
				tempMenu.style.visibility = (browser.browser == 'ns' && browser.version == 4)? 'hide' : 'hidden';
			}
		}
	}
}

function hideSubMenu(strMenuToHide) {
	if (browser.doMenu) {
		for (var i=0; i < aryMenus.length; i++) {
			var tempMenu = aryMenus[i];
			if (tempMenu.id == strMenuToHide) {
				if (!tempMenu.intID.isNaN) clearInterval(tempMenu.intID);
				tempMenu.style.visibility = 'hidden';
			}
		}
	}
}

function initHideTimer() {
	if (browser.doMenu) {
		clearHideTimer();
		intHideTimeID = setTimeout("hideAllMenus(null)",500);
	}
}

function clearHideTimer() {
	if (browser.doMenu) {
		if (!intHideTimeID.isNaN) clearTimeout(intHideTimeID);
	}
}

function initMenus() {
	if (browser.doMenu) {
		if (browser.browser == 'ie') {
			for (var i=0; i<document.all.tags("DIV").length; i++) {
				var divname = document.all.tags("DIV")[i].id;
				eval('obj' + divname + ' = new ddMenu("' + divname + '")');				aryMenus[aryMenus.length] = eval('obj' + divname);			}
		} else if (browser.browser == 'ns' && browser.version >= 5) {
			for (var i=0; i<document.getElementsByTagName("DIV").length; i++) {
				var divname = document.getElementsByTagName("DIV").item(i).id;
				eval('obj' + divname + ' = new ddMenu("' + divname + '")');				aryMenus[aryMenus.length] = eval('obj' + divname);
			}
			
		} else if (browser.browser == 'ns' && browser.version == 4) {
			for (var i=0; i< document.layers.length; i++) {
				var divname = document.layers[i].name;
				eval('obj' + divname + ' = new ddMenu("' + divname + '")');				aryMenus[aryMenus.length] = eval('obj' + divname);
			}
		}
	}
}

var browser = new checkBrowser();