function gettingShippingInfo() {
	newDiv = document.createElement("div");
	newDiv.id = "loadingShippingInfo";
	newDiv.innerHTML = "Retrieving Shipping Information, Please Wait.";
	document.body.appendChild(newDiv);
}
function waitPopUp(text) {
	newDiv = document.createElement("div");
	newDiv.id = "loadingShippingInfo";
	newDiv.innerHTML = text;
	document.body.appendChild(newDiv);
}
function addItemToQuickList(item, qty, uom) {
	var url='quicklistAdd.php?productID=' + item + '&qty=' + qty + '&uom=' + uom;
	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, override) {
	var url=BaseURL+'viewOrder.php?type=' + type + '&options=' + options + '&orderid=' + orderid + '&override=' + override;
	var x = window.open( url, 'orderWindow', 'width=800,height=550,scrollbars=1,resizable=1');
}

function viewTerms(BaseURL) {
	var url=BaseURL+'terms.php';
	var x = window.open( url, 'orderWindow', 'width=800,height=550,scrollbars=1,resizable=1');
}
function viewReturnsPolicy(BaseURL) {
	var url=BaseURL+'terms.php';
	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) {
		navRoot = document.getElementById("categorylisting");
		if (navRoot) {
		  for (i=0; i<navRoot.childNodes.length; i++) {
			  node = navRoot.childNodes[i];
			  if (node.nodeName=="LI") {
				  node.onmouseover=function() {
				  	this.className+=" over";
			  	}
				  node.onmouseout=function() {
				  	this.className=this.className.replace(" over", "");
			  	}
		  	}
		  }
		}
	}
}

/* used in changeorder.tpl */
function check() {
	if (document.changeorderform.reqdate.value == '') {
		alert("Please enter a request date.");
		return false;
	} else {
		return true;
	}
}

function setHiddenAction(id, val) {
  document.getElementById(id).value = val;
  return true;
}

window.onload= function() {
	startList();
}


