function addItemToQuickList( item, qty ) {
	var url='quicklistAdd.php?productID=' + item + '&qty=' + qty;
	var x = window.open( url, 'QuickWindow', 'width=400,height=400,scrollbars=no');
}

function validateUSNumber( item ) {
	var CleanedString="";
	var index = 0;
	var LimitCheck;
	var InitialString = item.value

	if (item.value == '') return true;
	//Get the length of the inputted string, to know how many characters to check
	LimitCheck = InitialString.length;

	//Walk through the inputted string and collect only number characters, appending them to CleanedString
	while (index != LimitCheck) {
		if (isNaN(parseInt(InitialString.charAt(index)))) { }
		else { CleanedString = CleanedString + InitialString.charAt(index); }
		index = index + 1;
	}

	//If CleanedString is exactly 10 digits long, then format it and allow form submission
	if (CleanedString.length == 10) {
		item.value = CleanedString.substring(0,3) + "-" + CleanedString.substring(3,6) + "-" + CleanedString.substring(6,10);
	}
	//If CleanedString is not 10 digits longs, show an alert and cancel form submission
	else {
		CleanedString = InitialString;
		alert("Please enter only your ten digit phone number.");
		if (document.all) {
			item.focus();
			item.select();
		}
		return false
	}
}

//
function viewOrder( type, options, orderid ) {
	var url=BaseURL+'viewOrder.php?type=' + type + '&options=' + options + '&orderid=' + orderid;
	var x = window.open( url, 'orderWindow', 'width=800,height=550,scrollbars=1,resizable=1');
}

function removeItem( id ) {
	if (confirm('Really remove this category from the database?')) {
		document.rmItemForm.remove.value = "Remove";
		document.rmItemForm.submit();
	} else {
		return false;
	}
}

/* provides hover support for li elements in #categorylisting */
function startList() {
	if (document.all&&document.getElementById("categorylisting")) {
		navRoot = document.getElementById("categorylisting");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" hover";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" hover", "");
				}
			}
		}
	}
}

function startList2() {
	if (document.all&&document.getElementById("buyingguidecategorylisting")) {
		navRoot = document.getElementById("buyingguidecategorylisting");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" hover";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" hover", "");
				}
			}
		}
	}
}


/* used in changeorder.tpl */
function check() {
	if (document.changeorderform.reqdate.value == '') {
		alert("Please enter a request date.");
		return false;
	} else {
		return true;
	}
}

function fixFFlayout()
{
	if(!document.all){
		if(document.getElementById("content").offsetWidth>"825"){
			document.getElementById("container").style.width=document.getElementById("container").offsetWidth+180+"px";
			document.getElementById("container").style.maxWidth=document.getElementById("container").offsetWidth+180+"px";
			document.getElementById("maincontent").style.width=document.getElementById("content").offsetWidth+"px";
			document.getElementById("maincontent").style.maxWidth=document.getElementById("content").offsetWidth+"px";
		}
	}
}


window.onload= function() {
	startList();
	startList2();
	fixFFlayout();
}



//// start htmlarea stuff

//this code allows you to dynamically add scripts to the page
function includeJavascript(url) {
	var e = document.createElement("script");
	e.src = url;
	e.type="text/javascript";
	document.getElementsByTagName("head")[0].appendChild(e);
}

//Define function and establish listener to convert textareas to htmlarea
function getHTMLEditors() {
	var editors = document.getElementsByClassName("htmleditor");
	if(editors.length>0) {
		includeJavascript(BaseURL+"script/htmlarea/htmlarea.js");
		includeJavascript(BaseURL+"script/htmlarea/htmlareaconfig.js");
	} else {
		return false
	}
}
Event.observe(window, 'load', getHTMLEditors);

//// end htmlarea stuff