	var err_count = 1;
	
	function displayErrors(str) {
		if (err_count==1) {
			document.getElementById("errors").innerHTML = "Error: <b>There were submission errors on the page:</b> <br>" + str.replace(/~l/g,"&lt;").replace(/!e/g,"&gt;") + "<br>"; err_count = 0;
		}
		else {
			document.getElementById("errors").innerHTML = "Error: <b>There were submission errors on the page.</b><br><br>"; err_count = 1;
		}
	} /*displays the errors on forms that have post errors*/
	
	function toogleElementDisplay(currentElement, callingElement)
	{	
		document.getElementById(callingElement).src = "./images/option_1.gif";
		
		if (document.getElementById)	
			var currentElementStyles = document.getElementById(currentElement);
		else
			if (document.all)
				var currentElementStyles = document.all[currentElement];
			else
				var currentElementStyles = new Object();
		
		if (currentElementStyles.style) 
			currentElementStyles = currentElementStyles.style;	
		
		if (currentElementStyles.display=="none")
		{
			document.getElementById(callingElement).src = "./images/option_0.gif";
			currentElementStyles.display = "inline";
		}
		else
			currentElementStyles.display = "none";
	} /*hides or displays a current element based on its current display style*/

	function displayCategoryTreeInformation(id)
	{
		currentInformationElement = "information_" + id;
	
		if (document.getElementById) {
			var currentInformationElementStyles = document.getElementById(currentInformationElement);
		} else {
			if (document.all) {
				var currentInformationElementStyles = document.all[currentInformationElement];
			} else {
				var currentInformationElementStyles = new Object();
			}
		}
		
		if (currentInformationElementStyles.style) {
			currentInformationElementStyles = currentInformationElementStyles.style;	
		}
		
		if (currentInformationElementStyles.display=="none")
			currentInformationElementStyles.display = "inline";
		else
			currentInformationElementStyles.display = "none";	
	} /*displays the current children of the current tree element*/
	
	function resetProductAttributeOptions()
	{
		document.forms["inputform"].price_variance[0].checked = true;
		document.forms["inputform"].price_affect[0].checked = true;
		document.forms["inputform"].amount.value = "0";
	} /*resets the product attribute's additional options*/
	
	function displayAttributeTypeLink(document_self)
	{
		document.getElementById("typelink").innerHTML = "&nbsp;"; 
		if (document.forms["inputform"].a_id.selectedIndex!=0)
			document.getElementById("typelink").innerHTML = "<a href=\"" +document_self + "?module=ws_cart&action=list_attributes&id=" +document.forms["inputform"].a_id.options[document.forms["inputform"].a_id.selectedIndex].value + "\" target=\"blank\">Click Here to See Type Information</a>";		
	} /*displays a link to the current attribute type description*/
	
	function displayProductAttributesOptions(currentElement, source)
	{
		if (document.getElementById) {
			var currentElementStyles = document.getElementById(currentElement);
		} else {
			if (document.all) {
				var currentElementStyles = document.all[currentElement];
			} else {
				var currentElementStyles = new Object();
			}
		}
		
		if (currentElementStyles.style) {
			currentElementStyles = currentElementStyles.style;	
		}
		
		if (source=="inherit") {
			if (document.forms["inputform"].inherit.checked==true && document.forms["inputform"].a_id.selectedIndex!=0) {
				currentElementStyles.display = "none";
				resetProductAttributeOptions();
			} else				
				currentElementStyles.display = "inline";	
			if (document.forms["inputform"].a_id.selectedIndex==0)
				document.forms["inputform"].inherit.checked = false;
		} else {
			if (document.forms["inputform"].inherit.checked==true && document.forms["inputform"].a_id.selectedIndex!=0) {
				currentElementStyles.display = "none";
				resetProductAttributeOptions();
			} else {
				currentElementStyles.display = "inline";
				document.forms["inputform"].inherit.checked = false;
			}
		}
	} /*toggles display of the product attribute's additional options*/
	
	function insertCategoryInformation(id, name, parent_window, branch)
	{
		parent_window.document.inputform.p_id_value.value = name;
		parent_window.document.inputform.p_id.value = id;
		parent_window.document.getElementById("breadcrumb").innerHTML = branch;
	} /*inserts category information into the current parent form*/
	
	function changeMemberPricingURL(url, page, member)
	{
		location = url + page + "?module=ws_cart&action=add_member_pricing&id=" + member + "&category=" + document.forms["inputform"].category.options[document.forms["inputform"].category.selectedIndex].value + "&category_name=" + document.forms["inputform"].category.options[document.forms["inputform"].category.selectedIndex].text;
	} /*changes the URL of the member pricing page*/
	
	function displayPreview(str)
	{
		document.getElementById("preview_area").innerHTML = "<img src='" + str + "' border='0' style='cursor: pointer;' onclick='javascript:insertImage(\"" + str + "\"); window.close();'/>";
	} /*displays an image to the current preview area element*/
	
	function insertImage(str)
	{		
		window.opener.document.inputform.image_source.value = str.substring(str.indexOf("files"),str.length);
	} /*inserts the current image to the parent form's image field*/	
	
	function captureCharacterInput(e)
	{
		var keynum;
		if(window.event)
			keynum = e.keyCode;
		else if(e.which)
			keynum = e.which;

		if (keynum==8 || keynum==46 || keynum==9 || (keynum>=96 && keynum<=105))
			return(true);
			
		var numcheck = /\d/;
		return(numcheck.test(String.fromCharCode(keynum)));
	} /*captures the keystroke and only allows numeric values, tab, backspace, and delete*/
		
	function GetXmlHttpObject()
	{
		var xmlHttp = null;
		try {
	  		xmlHttp = new XMLHttpRequest();
		} catch (e) {  
	  		try {
	    		xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	  		} catch (e) {
	    		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
	  	}
		return(xmlHttp);
	} /*used to detect if the current browser supports the XMLHttpRequest object (used for Ajax functionality)*/
		
	function addProductShoppingCart(session, product_id, category_id, quantity, price, p_name)
	{
	  	var xmlHttp;
		xmlHttp = GetXmlHttpObject();
		
		document.getElementById("shopping_cart").innerHTML = "Loading...";
		if (xmlHttp!=null)
		{
		 	xmlHttp.onreadystatechange = function()
		    {
				if (xmlHttp.readyState==4)
					document.getElementById("shopping_cart").innerHTML = xmlHttp.responseText;
			}
				
		    xmlHttp.open("GET","admin/_modules/shoppingcart/front/ajax/cart.php?session_id=" +session + "&product_id=" +product_id +"&category_id=" +category_id +"&quantity=" +quantity +"&price=" +price +"&p_name=" +p_name +"&mode=add",true);
		    xmlHttp.send(null);			
		}
		else
			document.getElementById("shopping_cart").innerHTML = "Your current browser is not compatible with this shopping cart. You should consider upgrading before proceeding.";
	} /*adds a product to the shopping cart, Ajax functionality encapsulated in admin/_modules/shoppingcart/front/ajax/cart.php*/
	
	function deleteProductShoppingCart(session, current_id, current_page)
	{
	  	var xmlHttp;
		xmlHttp = GetXmlHttpObject();
		
		document.getElementById("shopping_cart").innerHTML = "Loading...";
		if (xmlHttp!=null)
		{
		 	xmlHttp.onreadystatechange = function()
		    {
				if (xmlHttp.readyState==4)
					document.getElementById("shopping_cart").innerHTML = xmlHttp.responseText;
			}
				
			if (current_page=="checkout")
				xmlHttp.open("GET","admin/_modules/shoppingcart/front/ajax/cart.php?session_id=" +session + "&current_id=" +current_id +"&mode=delete&page=checkout",true);
			else
			    xmlHttp.open("GET","admin/_modules/shoppingcart/front/ajax/cart.php?session_id=" +session + "&current_id=" +current_id +"&mode=delete",true);
		    xmlHttp.send(null);			
		}
		else
			document.getElementById("shopping_cart").innerHTML = "Your current browser is not compatible with this shopping cart. You should consider upgrading before proceeding.";
	} /*deletes a product from the shopping cart, Ajax functionality encapsulated in admin/_modules/shoppingcart/front/ajax/cart.php*/
	
	
	function updateProductShoppingCart(session, current_id, current_page)
	{
	  	var xmlHttp;
		var new_quantity = document.getElementById("qty_" +current_id).value;
		
		xmlHttp = GetXmlHttpObject();
		
		document.getElementById("shopping_cart").innerHTML = "Loading...";
		if (xmlHttp!=null)
		{
		 	xmlHttp.onreadystatechange = function()
		    {
				if (xmlHttp.readyState==4)
					document.getElementById("shopping_cart").innerHTML = xmlHttp.responseText;
			}
			
			if (current_page=="checkout")
				xmlHttp.open("GET","admin/_modules/shoppingcart/front/ajax/cart.php?session_id=" +session + "&new_quantity=" +new_quantity  +"&current_id=" +current_id +"&mode=update&page=checkout",true);
			else
		    	xmlHttp.open("GET","admin/_modules/shoppingcart/front/ajax/cart.php?session_id=" +session + "&new_quantity=" +new_quantity  +"&current_id=" +current_id +"&mode=update",true);
		    xmlHttp.send(null);			
		}
		else
			document.getElementById("shopping_cart").innerHTML = "Your current browser is not compatible with this shopping cart. You should consider upgrading before proceeding.";
				
	} /*updates a product's quantity in the shopping cart, Ajax functionality encapsulated in admin/_modules/shoppingcart/front/ajax/cart.php*/
	
	function recalcuateProductShoppingCart(session, ids)
	{
		var xmlHttp;
		var current_ids = new String(ids);
		var current_ids_array = new Array();
		var query_string = "";
		current_ids_array = current_ids.split(",");
		
		for (i = 0; i < current_ids_array.length; i++)
			query_string += "&" +current_ids_array[i] +"=" +document.getElementById("qty_" +current_ids_array[i]).value;
		
		xmlHttp = GetXmlHttpObject();
		
		document.getElementById("shopping_cart").innerHTML = "Loading...";
		if (xmlHttp!=null)
		{
		 	xmlHttp.onreadystatechange = function()
		    {
				if (xmlHttp.readyState==4)
					document.getElementById("shopping_cart").innerHTML = xmlHttp.responseText;
			}
			
		    xmlHttp.open("GET","admin/_modules/shoppingcart/front/ajax/cart.php?session_id=" +session + "&ids=" +ids  +query_string +"&mode=recalculate",true);
		    xmlHttp.send(null);			
		}
		else
			document.getElementById("shopping_cart").innerHTML = "Your current browser is not compatible with this shopping cart. You should consider upgrading before proceeding.";		
	} /*recalculates product quantities in the shopping cart, Ajax functionality encapsulated in cart.php*/
	
	function checkContentsShoppingCart(session, current_page)
	{
	  	var xmlHttp;
		xmlHttp = GetXmlHttpObject();
		
		document.getElementById("shopping_cart").innerHTML = "Loading...";
		if (xmlHttp!=null)
		{
		 	xmlHttp.onreadystatechange = function()
		    {
				if (xmlHttp.readyState==4)
					document.getElementById("shopping_cart").innerHTML = xmlHttp.responseText;
			}
			
			if (current_page=="checkout")
				xmlHttp.open("GET","admin/_modules/shoppingcart/front/ajax/cart.php?session_id=" +session + "&mode=check&page=checkout",true);			   
			else
				xmlHttp.open("GET","admin/_modules/shoppingcart/front/ajax/cart.php?session_id=" +session + "&mode=check",true);
		    xmlHttp.send(null);			
		}
		else
			document.getElementById("shopping_cart").innerHTML = "Your current browser is not compatible with this shopping cart. You should consider upgrading before proceeding.";
	} /*checks for the current contents of the shopping cart, Ajax functionality encapsulated in cart.php*/
