<!--
// checks if a text element is filled in a form
function isFilled(element) {
	if ((element.value == "") || (element.value == null)) { return false; }
	else { return true; }
}
// checks if an object exists
function isObject(obj) {
	if (obj == null || obj == undefined) { return false; }
	return true;
}
// checks to see if string is number
function isNumber(value) {
	var pattern = /^(\d{1,5})$/;
	if (pattern.test(value)) { return true; }
	return false;
}
// checks to see if string is a number between min and max
function isNumeric(value, minimum, maximum) {
	var pattern = eval("/^\\d{" + minimum + "," + maximum + "}$/");
	if (pattern.test(value)) { return true; }
	return false;
}
// checks to see if string is a monetary value
function isPrice(value) {
	var pattern = /^(\d{1,5})(\.\d{2})?$/; // above 1
	var pattern2 = /^(\.\d{2})$/;
	if (pattern.test(value) || pattern2.test(value)) { return true; }
	return false;
}
// checks to see if string is an exp date
function isExpDate(value) { 
	var pattern = /^[0-9]{2}\/[0-5][0-9]$/;
	if (pattern.test(value)) { return true; }
	return false;
}		

function randomNumber(arrayLength) {
	return Math.round(Math.random()*(arrayLength - 1));
}
function changeCatalogLimit(total, value) {
	location = "./index_scripts/catalog_limit.php?total=" + total + "&limit=" + value;
}
function changeCatalogSort(value) {
	location = "./index_scripts/catalog_sort.php?sort_by=" + value;
}

// redirects user to thumbnail page by category id
function viewThumbPage(category_id) {
	location = "./index.php?section=catalog&category_id=" + category_id;
	return false; // false so click doesn't move page to top
}

// general window opener function
function openWindow(url) {
	var newwin = window.open(url, "newwin", "location=no,toolbar=no,status=yes,scrollbars=yes,resizable=yes,width=600,height=400");
	newwin.opener = window;
}

// sets sidenav to height of content div
function initFooter() { 
	if (document.getElementById("footer")) { 
		
		navHeight 	  = document.getElementById("sidenav").offsetHeight;
		contentHeight = document.getElementById("content").offsetHeight;

		// alert(contentHeight);
		if (contentHeight < navHeight) {
			document.getElementById("content").style.height = navHeight + "px";
			// alert(navHeight);
		}
		document.getElementById("footer").style.display = "block";
	}
	return true;
}
// sets sidenav to height of 450 if lower, for template #2
function initSideNav() {
	if (document.getElementById("sidenav")) { 
		if (document.getElementById("sidenav").offsetHeight < 450) {
			document.getElementById("sidenav").style.height = "450px";
		} 
	}
	return true;
}

// function to initialize drop downs for IE
function startList() {
	if (document.all && document.getElementById) {
		navRoot = document.getElementById("categories");

		// cycle through all li's in second tier (2)
		for (i = 0; i < navRoot.childNodes.length; i++) {
			
			// cycle through all li's in second tier (2)
			node = navRoot.childNodes[i];
			if (node.nodeName == "LI") {
			
				// if node is an LI apply class
				node.onmouseover = function() { this.className += " over"; }
 				node.onmouseout = function() { this.className = this.className.replace(" over", ""); }

				// cycle through classes li's
				for (j = 0; j < node.childNodes.length; j++) {
					node2 = node.childNodes[j];
					
					// if it's the third tier UL (3)
					if (node2.nodeName == "UL") {
						
						// cycle through nodes
						for (k = 0; k < node2.childNodes.length; k++) {
							node3 = node2.childNodes[k];
							
							// if node is an LI apply class
							if (node3.nodeName == "LI") {
								node3.onmouseover = function() { this.className += " over"; }
								node3.onmouseout = function() { this.className = this.className.replace(" over", ""); }
								
								// cycle through classes li's (4)
								for (l = 0; l < node3.childNodes.length; l++) {
									node4 = node3.childNodes[l];
									
									// if it's the fourth tier UL (4)
									if (node4.nodeName == "UL") {
									
										// cycle through nodes
										for (m = 0; m < node4.childNodes.length; m++) {
											node5 = node4.childNodes[m];
											
											// if node is an LI apply class
											if (node5.nodeName == "LI") {
												node5.onmouseover = function() { this.className += " over"; }
												node5.onmouseout = function() { this.className = this.className.replace(" over", ""); }
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

var currID = 0;
function showMenu(id, parentOn) {
	if (document.getElementById && document.body.style) {
		curMenu = eval('document.getElementById("' + id + '")');
		curMenu.style.visibility  = "visible";
		
		curMenu = eval('document.getElementById("' + parentOn + '")');
		curMenu.style.backgroundColor = '#c3e4ed';
	}
	return id;
}
function hideMenu(id, parentOn) {
	if (id != 0) {
		if (document.getElementById && document.body.style) {
			curMenu = eval('document.getElementById("' + id + '")');
			curMenu.style.visibility  = "hidden";
			
			curMenu = eval('document.getElementById("' + parentOn + '")');
			curMenu.style.backgroundColor = 'transparent';
		}
	}
}
//-->

