var lcReplace = /(<a)([^>]*)(class=\"_blank\")|(class=_blank)([^>]*)/ig;
function setLinks() {
	if(document.getElementById && window.RegExp) {
		document.body.innerHTML = document.body.innerHTML.replace(lcReplace, "$1$2$3$5 onclick=\"javascript:window.open(this.getAttribute('href'));return false;\"");
	};
};
function startList() {
	if (document.all && document.getElementById) {
		setList(document.getElementById("menu-nav"));
		setList(document.getElementById("products-nav"));
		if(document.getElementById("search")) {
			document.getElementById("search").onmouseover = function() {
				this.className = "over";
			};
			document.getElementById("search").onmouseout = function() {
				this.className = "";
			};
		};
	};
};
function setList(navRoot) {
	var node;
	for (var i = 0; i < navRoot.childNodes.length; i++) {
		node = navRoot.childNodes[i];
		if (node.nodeName == "LI") {
			if (node.innerHTML.toUpperCase().indexOf("<UL") >= 0) {
				node.onmouseover = function() {
					this.className = "over";
					this.style.marginBottom = "-3px";
				};
				node.onmouseout = function() {
					this.className = "";
					this.style.marginBottom = "0px";
				};
				setList(node.childNodes[2]);
			} else {
				node.onmouseover = function() {
					this.className = "over";
				};
				node.onmouseout = function() {
					this.className = "";
				};
			};
		};
	};
};
function submitForm(form) {
	if(form.name.value == "" || form.company.value == "" || form.email.value == "" || form.message.value == "") {
		if(document.getElementById && !document.getElementById("error")) {
			form.innerHTML += "<h3 id=\"error\">Please fill in all fields!</h3>";
		};
		return false;
	};
	return true;
};
function setGallery() {
	if(String(document.location).substring(String(document.location).indexOf(".htm") - 7, String(document.location).indexOf(".htm")) == "gallery") {
		var node;
		var root = document.getElementById("gallery");
		for (var i = 0; i < root.childNodes.length; i++) {
			node = root.childNodes[i].childNodes[0];
			if (node.nodeName.toLowerCase() == "a") {
				node.onclick = function() {
					document.getElementById("galleryimage").src = this.getAttribute("href");
					document.getElementById("gallerydisplay").style.display = "block";
					document.location = "#page";
					return false;
				};
			};
		};
	};
};
window.onload = function() {
	setLinks();
	startList();
	setGallery();
};