	var req;
	var taxRate = null;
	var syncer = "";
	var szipTimeout;
	var zipTimeout;
	var taxTimeout;
	var priceTimeout;
	var cookieTimeout;
	var validZip = true;
	var zipValidated = true;
	var validsZip = true;
	var szipValidated = true;
	var shipUpdated = true;
	var cityDownloaded = false;
	var scityDownloaded = false;
	
	if(!cookiesEnabled())
	{
		window.location = "/cookies_required.html";
	}

	function decWithComma(value)  // Expecting a string comming in.
	{
		var valueParts = value.split(".");
		var reverse = '';
		for(i = valueParts[0].length; i > -1; i--)
		{
			reverse += valueParts[0].charAt(i);
		}
		reverse = reverse.replace(/(\d{3})/g, "$1,");
		if(reverse.charAt(reverse.length-1) == ',')
		{
			reverse = reverse.slice(0,-1);
		}
		var finalValue = '';
		for(i = reverse.length; i > -1; i--)
		{
			finalValue += reverse.charAt(i);
		}
		if(valueParts.length > 1)
		{
			return finalValue + "." + valueParts[1];
		}
		else
		{
			return finalValue;
		}
	}
	
	function removeComma(value)
	{
		return value.replace(/[,]/g, '');
	}
	
	function clearTimeouts()
	{
		clearTimeout(zipTimeout);
		clearTimeout(taxTimeout);
		clearTimeout(priceTimeout);
		clearTimeout(cookieTimeout);
	}

	function ValidateCC()
	{

	  var checkStr = document.getElementById("CredCardNum").value;
	  var selectedCard;
	  i = 0
	  while(document.getElementById("CredCard"+i))
	  {
	  	if(document.getElementById("CredCard"+i).checked)
	  	{
	  		selectedCard = document.getElementById("CredCard"+i).value;
	  	}
	  	i++;
	  }
	  var CrValid = true;
	  var checksum=0;
	  var ddigit=0;
	  var kdig = 0;
	  if (!(checkStr.length == 16 &&
	  		selectedCard != 'American Express') &&
	  	  !( checkStr.length == 15 &&
	  		selectedCard == 'American Express') &&
	  		checkStr.search(/^\s*\d{15,16}\s*$/))
	  {
			 alert ('Invalid Credit Card information.');
			 document.getElementById("CredCardNum").focus();
			 return false;
	  }
	
	  if( !(selectedCard == 'American Express' &&
	  		checkStr.charAt(0) == '3') &&
		  !(selectedCard == 'Visa' &&
	  		checkStr.charAt(0) == '4') &&
	  	  !(selectedCard == 'Master Card' &&
	  		checkStr.charAt(0) == '5') &&
	  	  !(selectedCard == 'Discover' &&
	  		checkStr.charAt(0) == '6') )
	  {
			 alert ('Invalid Credit Card information.');
			 document.getElementById("CredCardNum").focus();
			 return false;
	  }  		
	  for (i = checkStr.length-1;  i >= 0;  i--)
	  {
	    kdig++;
	    ch = checkStr.charAt(i);
	    if ((kdig % 2) != 0)
	       checksum=checksum+parseInt(ch)
	    else {
	       ddigit=parseInt(ch)*2;
	       if (ddigit >= 10)
	          checksum=checksum+1+(ddigit-10)
	       else
	          checksum=checksum+ddigit;
	    }

	  }
	  if ((checksum % 10) != 0){
	       alert('Invalid Credit Card information.');
	       document.getElementById("CredCardNum").focus();
	       return false;
	  }
	  else
	  {
		   expireDate = document.getElementById("CredCardExpDate");
		   month = expireDate.value.split("/")[0];
		   year = expireDate.value.split("/")[1];
		   if(month == null || year == null ||
		   	isNaN(parseInt(month,10)) || isNaN(parseInt(year,10)) ||
		   	parseInt(month,10) < 1 || parseInt(month,10) > 12 || parseInt(year,10) > 80)
		   {
		      alert("Invalid Credit Card information.");
		      document.getElementById("CredCardExpDate").focus();
		      return false;
		   }
		   today = new Date();
		   thisMonth = today.getMonth() + 1;
		   thisYear = today.getFullYear() - 2000;
	  	   if(thisYear > parseInt(year, 10) ||
	  	     (thisYear == parseInt(year, 10) &&
	  	       thisMonth > parseInt(month, 10)))
	  	   {
		      alert("Invalid Credit Card information.");
		      document.getElementById("CredCardExpDate").focus();
		      return false;
	  	   }
	  	   if(expireDate.value.length < 5)
	  	   {
	  	   		var newMonth = month;
	  	   		if(month.length < 2)
	  	   		{
	  	   			newMonth = '0'+ month;
	  	   		}
	  	   		var newYear = year;
	  	   		if(year.length < 2)
	  	   		{
	  	   			newYear = '0'+ year;
	  	   		}
	  	   		expireDate.value = newMonth + '/' + newYear;
	  	   }
	       return true;
	  }
	}
	
	function disallowChars(event)
	{
		if (!event) {event = window.event;}
		if(event.preventDefault)
		{
			if(isNaN(String.fromCharCode(event.charCode)) && event.keyCode == 0)
			{
				event.preventDefault();
			}
		}
		else
		{
			if(isNaN(String.fromCharCode(window.event.keyCode)))
			{
				event.returnValue = false;
			}
		}
	}
	
	function forwardError(failurePoint)
	{
		
		var errorInput = document.createElement("input");
		errorInput.name = "Error";
		errorInput.type = "hidden";
		errorInput.value = failurePoint;
		document.getElementById('theform').appendChild(errorInput);
		var prevAction = document.getElementById('theform').action;
		var action = prevAction.substr(0, prevAction.indexOf("/apps/xwrpub/"))+"/apps/xwrpub/HndError";
		document.getElementById('theform').action = action;
		document.getElementById('theform').submit();
	}

	function requestXML(paramKeys,paramValues,writerFunc)
	{
	    if (window.XMLHttpRequest) 
	    {
	        req = new XMLHttpRequest();
	    } 
	    else if (window.ActiveXObject) 
	    {
	        req = new ActiveXObject("Microsoft.XMLHTTP");
	    }
	    else
	    {
	    	alert("Your browser is not supported. Please contact sales at: (800) 424-XACT (9228) or xsales@xactware.com ");
	    }
	    req.onreadystatechange = eval(writerFunc);
	    var paramKeysArray = paramKeys.split(",");
	    var paramValuesArray = paramValues.split(",");
	    var url = "/apps/xwrpub/HndXMLRequest?"+ paramKeysArray[0] + "=" + paramValuesArray[0];
	    for(var i = 1; i < paramKeysArray.length; i++)
	    {
			url+= "&" + paramKeysArray[i] + "=" + paramValuesArray[i];
		}
	    req.open("GET", url, true);
	    req.send(null);
	}
	
	function updateAddress()
	{
	    // only if req shows "complete"
	    if (req != null && req.readyState == 4) 
	    {
	    // only if "OK"
		    if (req.status == 200) 
		    {
				response  = req.responseXML.documentElement;
				var zipPrefix;
				if(response != null &&
					response.getElementsByTagName("billingShiping").length > 0)
				{
					if(response.getElementsByTagName("billingShiping")[0].getAttribute("which") == "shipping")
					{
						zipPrefix = "s";
						resetCityZip(zipPrefix);
					}
					else
					{
						zipPrefix = "";
						resetCityZip(zipPrefix);
					}
				}
				else
				{
			    	forwardError('updateAddress:230');
					return;
				}
				if(response != null && 
					response.getElementsByTagName("CitiesQueryResponse").length > 0 &&
					response.getElementsByTagName("CitiesQueryResponse")[0].getAttribute("status") == "success")
				{
					var cityList = response.getElementsByTagName("City");
					var citySpan = document.getElementById(zipPrefix+"city");
					var countrySpan = document.getElementById(zipPrefix+"country");
					if(cityList.length > 1)
					{
						var citySelect = document.createElement("select");
						citySelect.id = zipPrefix+"cityInput";
						citySelect.name = zipPrefix+"city";
						var cityOption;
						
						//empty top
						cityOption = document.createElement("option");
						cityOption.value = '';
						if(cityOption.innerText != null)
						{
							cityOption.innerText = '';
						}
						cityOption.text = '';
						citySelect.appendChild(cityOption);
						for( i = 0; i < cityList.length; i++)
						{
							cityOption = document.createElement("option");
							cityOption.value = cityList[i].getAttribute("city")+"|"+
								cityList[i].getAttribute("county")+"|"+
								cityList[i].getAttribute("state");
							if(cityOption.innerText != null)
							{
								cityOption.innerText = cityList[i].getAttribute("city")+","+
								cityList[i].getAttribute("county")+","+
								cityList[i].getAttribute("state");
							}
							cityOption.text = cityList[i].getAttribute("city")+","+
								cityList[i].getAttribute("county")+","+
								cityList[i].getAttribute("state");
							citySelect.appendChild(cityOption);
						}
						citySpan.appendChild(citySelect);
						if(citySelect.addEventListener)
						{
							citySelect.addEventListener("change",getTaxRate, false);
						}
						else
						{
							citySelect.onchange = getTaxRate;
						}
					}
					else
					{
						var cityInput = document.createElement("input");
						cityInput.id = zipPrefix+"cityInput";
						cityInput.name = zipPrefix+"city";
						cityInput.type = "hidden";
						cityInput.value = cityList[0].getAttribute("city")+"|"+
								cityList[0].getAttribute("county")+"|"+
								cityList[0].getAttribute("state");
						document.getElementById('theform').appendChild(cityInput);
						citySpan.appendChild( document.createTextNode(cityList[0].getAttribute("city")+","+
								cityList[0].getAttribute("county")+","+
								cityList[0].getAttribute("state")));
					}
					var countryVal;
					countryVal = "US";
					var countryInput = document.createElement("input");
					countryInput.id = zipPrefix+"countryInput";
					countryInput.name = zipPrefix+"country";
					countryInput.type = "hidden";
					countryInput.value = countryVal;
					document.getElementById('theform').appendChild(countryInput);
					countrySpan.appendChild( document.createTextNode(countryVal+"A"));
					req = null;
					eval(zipPrefix+"zipValidated = true;");
				}
				else
				{
					alert("Invalid Zip/Postal Code");
					clearTimeouts();
					eval("valid"+zipPrefix+"Zip = false;");
					document.getElementById(zipPrefix+"zip").value = "";
					document.getElementById(zipPrefix+"zip").focus();
					eval(zipPrefix+"zipValidated = true;");
				}
				eval(zipPrefix+"cityDownloaded = true;");
			    syncer = "";
			    req = null;
			    getTaxRate();
		    } 
		    else
		    {
		    	forwardError('updateAddress:314,http response:'+req.status);
				return;
		    }
	    }
    }
        
    function updateTax()
    {
 	    // only if req shows "complete"
 	    if (req != null && req.readyState == 4 && req.status == 200) 
	    {
			response  = req.responseXML.documentElement;
			if(response != null && 
				response.getElementsByTagName("SalesTaxRate").length > 0 &&
				response.getElementsByTagName("SalesTaxRate")[0].getAttribute("sales_tax_rate") != null)
			{
				taxRate = parseFloat(response.getElementsByTagName("SalesTaxRate")[0].getAttribute("sales_tax_rate"));
			}
			else
			{
		    	forwardError("updateTax:334");
		    	return;
			}
		    syncer = "";
		    req = null;
		}
	    else if(req != null && req.readyState == 4 && req.status > 200)
	    {
	    	forwardError("updateTax:342, http response:"+req.status);
	    	return;
	    }
		i = 0;
		total = 0;
		clearAll = true;
		while(document.getElementById("itemCost"+i) != null ||
			document.getElementById("itemCount"+i) != null)
		{
			td = document.getElementById("itemCost"+i);
			if(td != null && td.hasChildNodes())
			{
				for(j=td.childNodes.length-1; j > -1; j--)
				{
					td.removeChild(td.childNodes[j]);
				}
			}
			if(document.getElementById("itemSelect"+i) != null)
			{
				var itemSelect =document.getElementById("itemSelect"+i);
				var itemIdInput = document.getElementById("itemId"+ i);
				eval("itemIdInput.value = itemids"+i+"["+itemSelect.selectedIndex+"]");
				var itemPriceInput = document.getElementById("itemPrice"+ i);
				eval("itemPriceInput.value = itemPrice"+i+"["+itemSelect.selectedIndex+"]");
				if(!isNaN(parseInt(itemSelect.value),10) && 
					parseInt(itemSelect.value, 10) != 0)
				{
					clearAll = false;
					if(td != null)
					{
						td.appendChild(document.createTextNode(
							decWithComma(""+(eval("parseFloat(itemPrice"+i+"["+itemSelect.selectedIndex+"]).toFixed(2)")))));	
					}
				}
			}
			else if(!isNaN(parseInt(document.getElementById("itemCount"+i).value),10) && 
				parseInt(document.getElementById("itemCount"+i).value, 10) != 0)
			{
				clearAll = false;
				if(td != null)
				{
					td.appendChild(document.createTextNode(decWithComma(""+(eval("itemPrice"+i)*
					parseFloat(document.getElementById("itemCount"+i).value)).toFixed(2))));	
				}
			}
			i++;
		}
		td = document.getElementById("shippingCost");
		if(td != null && td.hasChildNodes())
		{
			for(j=td.childNodes.length-1; j > -1; j--)
			{
				td.removeChild(td.childNodes[j]);
			}
		}

		var countryInput = null;
		shipSelect = document.getElementById("shippingPreference");
		if(shipSelect == null || shipSelect.selectedIndex > -1) 
		{
			if(document.getElementById("sameShipping").checked ||
				document.getElementById("sameShipping").type == "hidden")
			{
				countryInput = document.getElementById("countryInput");
			}
			else
			{
				countryInput = document.getElementById("scountryInput");
			}
		}
		if(clearAll || taxRate == null || countryInput == null)
		{
			i = 0;
			while(document.getElementById("itemCost"+i))
			{
				td = document.getElementById("itemCost"+i);
				if(td.hasChildNodes())
				{
					for(j=td.childNodes.length-1; j > -1; j--)
					{
						td.removeChild(td.childNodes[j]);
					}
				}
				i++;
			}
			subtotalTD = document.getElementById("subtotalCost");
			if(subtotalTD != null && subtotalTD.hasChildNodes())
			{
				for(var i = subtotalTD.childNodes.length-1; i > -1; i--)
				{
					subtotalTD.removeChild(subtotalTD.childNodes[i]);
				}
			}
			taxTD = document.getElementById("tax");
			if(taxTD != null && taxTD.hasChildNodes())
			{
			for(var i = taxTD.childNodes.length-1; i > -1; i--)
				{
					taxTD.removeChild(taxTD.childNodes[i]);
				}
			}
			i = 0;
			totalTD = document.getElementById("totalCost");
			if(totalTD != null && totalTD.hasChildNodes())
			{
				for(var i = totalTD.childNodes.length-1; i > -1; i--)
				{
					totalTD.removeChild(totalTD.childNodes[i]);
				}
			}
			if(document.getElementById("dollarSign") != null)
			{
				document.getElementById("dollarSign").style.display = "none";
			}
		}
		else
		{
			i = 0;
			while(document.getElementById("itemCost"+i))
			{
				td = document.getElementById("itemCost"+i);
				if(td.childNodes.length == 1)
				{
					thisCost = parseFloat(removeComma(td.childNodes[0].nodeValue));
					if(!isNaN(thisCost))
					{
						total += thisCost;
					}
				}
				i++;
			}
			if(shipSelect != null)
			{
				var shipPrice;			
				if(countryInput.value == "CA")
				{
					shipPrice = parseFloat(shipPrices[shipSelect.selectedIndex].split("|")[1]);
				}
				else
				{
					shipPrice = parseFloat(shipPrices[shipSelect.selectedIndex].split("|")[0]);
				}
				if(!isNaN(parseFloat(shipPrice)))
				{
					document.getElementById("shippingCost").appendChild(document.createTextNode(decWithComma(shipPrice.toFixed(2))));
				}
		
				total += parseFloat(removeComma(document.getElementById("shippingCost").childNodes[0].nodeValue));
				if(document.getElementById("shipDesc"))
				{
					document.getElementById("shipDesc").value = shipSelect.options[shipSelect.selectedIndex].text;
				}
				else
				{
					var shipNameInput = document.createElement("input");
					shipNameInput.type = "hidden";
					shipNameInput.id = "shipDesc";
					shipNameInput.name = "shipPref";
					shipNameInput.value = shipSelect.options[shipSelect.selectedIndex].text;
					document.getElementById('theform').appendChild(shipNameInput);
					
				}
				if(document.getElementById("shipCost"))
				{
					document.getElementById("shipCost").value = decWithComma(shipPrice.toFixed(2));					
				}
				else
				{
					var shipPriceInput = document.createElement("input");
					shipPriceInput.type = "hidden";
					shipPriceInput.id = "shipCost";
					shipPriceInput.name = "shipCost";
					shipPriceInput.value = decWithComma(shipPrice.toFixed(2));
					document.getElementById('theform').appendChild(shipPriceInput);
				}
			}			
			var subtotal = total;
			
			taxRater = 0.01 * parseFloat(taxRate);
			taxTotal = decWithComma((taxRater * total).toFixed(2));
			total += parseFloat(removeComma(taxTotal));
			taxTD = document.getElementById("tax");
			if(taxTD != null )
			{
				if(taxTD.hasChildNodes())
				{
					for(var i = taxTD.childNodes.length-1; i > -1; i--)
					{
						taxTD.removeChild(taxTD.childNodes[i]);
					}
				}
				taxTD.appendChild(document.createTextNode(taxTotal));
			}
			if(document.getElementById("taxInput"))
			{
				document.getElementById("taxInput").value = taxTotal;					
			}
			else
			{
				var taxInput = document.createElement("input");
				taxInput.type = "hidden";
				taxInput.id = "taxInput";
				taxInput.name = "tax";
				taxInput.value = taxTotal;
				document.getElementById('theform').appendChild(taxInput);
			}
			
			subtotalTD = document.getElementById("subtotalCost");
			if(subtotalTD != null)
			{
				if(subtotalTD.hasChildNodes())
				{
					for(var i = subtotalTD.childNodes.length-1; i > -1; i--)
					{
						subtotalTD.removeChild(subtotalTD.childNodes[i]);
					}
				}
				subtotalTD.appendChild(document.createTextNode(decWithComma(subtotal.toFixed(2))));
			}
			if(document.getElementById("subtotalInput"))
			{
				document.getElementById("subtotalInput").value = decWithComma(subtotal.toFixed(2));					
			}
			else
			{
				var subtotalInput = document.createElement("input");
				subtotalInput.type = "hidden";
				subtotalInput.id = "subtotalInput";
				subtotalInput.name = "subtotalCost";
				subtotalInput.value = decWithComma(subtotal.toFixed(2));
				document.getElementById('theform').appendChild(subtotalInput);
			}
			
			totalTD = document.getElementById("totalCost");
			if(totalTD != null)
			{
				if(totalTD.hasChildNodes())
				{
					for(var i = totalTD.childNodes.length-1; i > -1; i--)
					{
						totalTD.removeChild(totalTD.childNodes[i]);
					}
				}
				totalTD.appendChild(document.createTextNode(decWithComma(total.toFixed(2))));
			}
			if(document.getElementById("totalInput"))
			{
				document.getElementById("totalInput").value = decWithComma(total.toFixed(2));					
			}
			else
			{
				var totalInput = document.createElement("input");
				totalInput.type = "hidden";
				totalInput.id = "totalInput";
				totalInput.name = "totalCost";
				totalInput.value = decWithComma(total.toFixed(2));
				document.getElementById('theform').appendChild(totalInput);
			}
			if(document.getElementById("dollarSign") != null)
			{
				document.getElementById("dollarSign").style.display = "";
			}
			
		}
    }
    
	function updateItemPrice()
	{
 	    // only if req shows "complete"
	    if (req != null && req.readyState == 4) 
	    {
	    // only if "OK"
		    if (req.status == 200) 
		    {
				response  = req.responseXML.documentElement;
				if(response != null &&
					response.getElementsByTagName("ItemPriceResponse").length > 0 &&
					response.getElementsByTagName("ItemPriceResponse")[0].getAttribute("status") == "success")
				{
					it = response.getElementsByTagName("Item");
					count = parseInt(response.getElementsByTagName("ItemIter")[0].getAttribute("count"), 10);
					if(it.length == 1)
					{
						it = (response.getElementsByTagName("Item"))[0];
						eval("itemPrice"+count+" = parseFloat(it.getAttribute('price'))");
						itemDesc = document.getElementById("itemDesc"+count);
						if(itemDesc != null && itemDesc.hasChildren)
						{
							for(var i = itemDesc.childNodes.length-1; i > -1; i--)
							{
								itemDesc.removeChild(itemDesc.childNodes[i]);
							}
						}
						var priceListing;
						if(it.getAttribute("price") == "0.0")
						{
							priceListing = "Free";
						}
						else
						{
							priceListing = "$"+parseFloat(it.getAttribute("price")).toFixed(2);
						}
						
						if(itemDesc != null)
						{
							itemDesc.appendChild(document.createTextNode(it.getAttribute("description")+" ("+priceListing+")"));
						}
						var itemIdInput = document.createElement("input");
						itemIdInput.type = "hidden";
						itemIdInput.name = "itemId"+count;
						itemIdInput.value = it.getAttribute("item_id");
						document.getElementById('theform').appendChild(itemIdInput);
						
						var itemDescInput = document.createElement("input");
						itemDescInput.type = "hidden";
						itemDescInput.name = "itemDesc"+count;
						itemDescInput.value = it.getAttribute("description");
						document.getElementById('theform').appendChild(itemDescInput);
						
						var itemPriceInput = document.createElement("input");
						itemPriceInput.type = "hidden";
						itemPriceInput.name = "itemPrice"+count;
						itemPriceInput.value = it.getAttribute("price");
						document.getElementById('theform').appendChild(itemPriceInput);

						var itemShortNameInput = document.createElement("input");
						itemShortNameInput.type = "hidden";
						itemShortNameInput.name = "itemShortName"+count;
						itemShortNameInput.value = it.getAttribute("item_short_name");
						document.getElementById('theform').appendChild(itemShortNameInput);
					}
					else
					{
						var itemIdInput = document.createElement("input");
						itemIdInput.type = "hidden";
						itemIdInput.name = "itemId"+count;
						itemIdInput.id = "itemId"+count;
						if(window["setItemId"+count] != null)
						{
							itemIdInput.value = window["setItemId"+count];
						}
						else
						{
							itemIdInput.value = it[0].getAttribute("item_id");
						}
						document.getElementById('theform').appendChild(itemIdInput);
						
						if(document.getElementById("itemCount"+count) == null)
						{
							var itemCountInput = document.createElement("input");
							itemCountInput.type = "hidden";
							itemCountInput.name = "itemCount"+count;
							itemCountInput.id = "itemCount"+count;
							itemCountInput.value = '1';
							document.getElementById('theform').appendChild(itemCountInput);
						}
						else
						{
							document.getElementById("itemCount"+count).value = '1';
						}
						
						var itemPriceInput = document.createElement("input");
						itemPriceInput.type = "hidden";
						itemPriceInput.name = "itemPrice"+count;
						itemPriceInput.id = "itemPrice"+count;
						if(window["itemPrice"+ count] &&
							!isNaN(window["itemPrice"+count]))
						{
							itemPriceInput.value = window["itemPrice"+count];
						}
						else
						{
							itemPriceInput.value = it[0].getAttribute("price");
						}
						document.getElementById('theform').appendChild(itemPriceInput);						
						
						if(document.getElementById("itemSelect"+count) != null)
						{
							for( i = 0; i < it.length; i++)
							{
								var itemOption
								itemOption = document.createElement("option");
								itemOption.value = it[i].getAttribute("description")
								eval("itemPrice"+count+"["+i+"] = it["+i+"].getAttribute('price')");
								if(itemOption.innerText != null)
								{
									itemOption.innerText = it[i].getAttribute("description") + " ($"+
										parseFloat(it[i].getAttribute('price')).toFixed(2)+ ")";
								}
								itemOption.text = it[i].getAttribute("description")+ " ($"+
										parseFloat(it[i].getAttribute('price')).toFixed(2)+ ")";
								document.getElementById("itemSelect"+count).appendChild(itemOption);
								eval("itemids"+count+"["+i+"] = it["+i+"].getAttribute('item_id')");
							}
						}
					}
				}
				else
				{
			    	forwardError("updateItemPrice:626");
					return;
				}
			}
		    else
		    {
		    	forwardError("updateItemPrice:632");
				return;
		    }
  		    syncer = "";
  		    req = null;
		    getTaxRate();
	    }
	}

	function updateShippingPrice()
	{
 	    // only if req shows "complete"
	    if (req != null && req.readyState == 4) 
	    {
	    // only if "OK"
		    if (req.status == 200) 
		    {
				response  = req.responseXML.documentElement;
				if(response != null &&
					response.getElementsByTagName("ItemPriceResponse").length > 0 &&
					response.getElementsByTagName("ItemPriceResponse")[0].getAttribute("status") == "success")
				{
					shipSelect = document.getElementById("shippingPreference");
					if(shipSelect != null)
					{
						//Delete options.
						for( i = 0; i < shipSelect.options.length; j++)
						{
							shipSelect.remove(i);
							shipPrince[i] = null;
						}
						
						//Repopulate options.
						ship = response.getElementsByTagName("Item");
						var shipOption;
						for( i = 0; i < ship.length; i++)
						{
							//See if the shipping is already in the list. ie the description is already there.
							var optionIndex = -1;
							for( j = 0; j < shipSelect.options.length; j++ )
							{
								if(shipSelect.options[j].text == ship[i].getAttribute("description"))
								{
									optionIndex = j;
									break;
								}
							}
							if(optionIndex == -1)
							{
								shipOption = document.createElement("option");
								shipOption.value = ship[i].getAttribute("item_id")+"|"+
									ship[i].getAttribute("item_id");
								shipPrices[shipSelect.options.length] = ship[i].getAttribute("price")+"|"+
									ship[i].getAttribute("price");
								if(shipOption.innerText != null)
								{
									shipOption.innerText = ship[i].getAttribute("description");
								}
								shipOption.text = ship[i].getAttribute("description");
								shipSelect.appendChild(shipOption);
							}
							else
							{
								shipOption = shipSelect.options[optionIndex];
								if(ship[i].getAttribute("category_hierarchy") == shippingCat+".SHIPPING_CDN")
								{
									shipOption.value = shipOption.value.split("|")[0]+"|"+
										ship[i].getAttribute("item_id");
									shipPrices[optionIndex] = shipPrices[optionIndex].split("|")[0]+"|"+
										ship[i].getAttribute("price");
								}
								else
								{
									shipOption.value = ship[i].getAttribute("item_id")+"|"+
										shipOption.value.split("|")[1];
									shipPrices[optionIndex] = ship[i].getAttribute("price")+"|"+
										shipPrices[optionIndex].split("|")[1];
								}
							}
						}
					}
				}
				else
				{
		    		forwardError("updateShippingPrice:716");
					return;
				}
			}
		    else
		    {
		    	forwardError("updateShippingPrice:722");
				return;
		    }
  		    syncer = "";
  		    req = null;
		    getTaxRate();
	    }
	}
	
	function validateZip(zipId)
	{
		var zipPrefix;
		input = document.getElementById(zipId);
		if(input.name == "szip")
		{
			zipPrefix = "s";
		}				
		else
		{
			zipPrefix = "";
		}
		eval(zipPrefix+"zipValidated = false;");
		if(input.value != "")
		{
			if(isNaN(input.value.split("-")[0]))
			{
				//Presumed Canadian
				if(input.value.search(/^\s*[A-Za-z]\d[A-Za-z]\s*-*\s*\d[A-Za-z]\d\s*$/) == -1)
				{
					alert("Invalid Zip/Postal Code");
					eval( "valid"+zipPrefix+"Zip = false");
					input.value = "";
					input.focus();
					return;
				}
				countryVal = "CA";
				var cityValue = "";
				if(document.getElementById(zipPrefix+"cityInput") != null &&
					document.getElementById(zipPrefix+"cityInput").type == "text")
				{
					cityValue = document.getElementById(zipPrefix+"cityInput").value;
				}				
				resetCityZip(zipPrefix);
				var citySpan = document.getElementById(zipPrefix+"city");
				var cityInput = document.createElement("input");
				cityInput.id = zipPrefix+"cityInput";
				cityInput.type = "text";
				cityInput.name = zipPrefix+"city";
				cityInput.size = 30;
				cityInput.maxLength = "59";
				cityInput.value = cityValue;
				document.getElementById("theform").appendChild(cityInput);
				citySpan.appendChild(cityInput);
				if(cityInput.addEventListener)
				{
					cityInput.addEventListener("change",getTaxRate, false);
				}
				else
				{
					cityInput.onchange = getTaxRate;
				}


				var countrySpan = document.getElementById(zipPrefix+"country");
				var countryInput = document.createElement("input");
				countryInput.id = zipPrefix+"countryInput";
				countryInput.type = "hidden";
				countryInput.name = zipPrefix+"country";
				countryInput.value = countryVal;
				document.getElementById('theform').appendChild(countryInput);
				countrySpan.appendChild( document.createTextNode(countryVal+"NADA"));
				eval(zipPrefix+"zipValidated = true;");
				taxRate = 0.0;
				document.getElementById(zipPrefix+"cityInput").focus();
				eval(zipPrefix+"cityDownloaded = true;");
			    getTaxRate();
			}
			else
			{
				if(input.value.search(/^\s*\d\d\d\d\d(\-\d\d\d\d){0,1}\s*$/) == -1)
				{
					alert("Invalid Zip/Postal Code");
					eval("valid"+zipPrefix+"Zip = false;");
					document.getElementById(zipPrefix+"zip").value = "";
					document.getElementById(zipPrefix+"zip").focus();
					eval(zipPrefix+"zipValidated = true;");
					return;
				}
				//Can't handle 9 digit zips.
				input.value = 
					document.getElementById(zipPrefix+"zip").value.split("-")[0];

				if(syncer != "")
				{
					eval ("clearTimeout("+zipPrefix+"zipTimeout);");
					if(eval("valid"+zipPrefix+"Zip"))
					{
						eval (zipPrefix+"zipTimeout = setTimeout('validateZip(\""+zipId+"\")', 50);");
					}
					return;
				}
				syncer = "zip";
				var sbaddress;
				if(input.name == "szip")
				{
					sbaddress = "shipping";
				}
				else
				{
					sbaddress = "billing";	
				}
				requestXML("xmlRequest,zip,shipBill", "zip,"+input.value.split("-")[0]+","+sbaddress, 'updateAddress');
			}
		}
		else
		{
			eval(zipPrefix+"cityDownloaded = true;");
			resetCityZip(zipPrefix);
			var enterZipPhrase = document.createTextNode("Enter Zip/Postal Code first");
			var enterZipNode = document.createElement("em");
			enterZipNode.appendChild(enterZipPhrase);
			var citySpan = document.getElementById(zipPrefix+"city");
			citySpan.appendChild(enterZipNode);
			eval(zipPrefix+"zipValidated = true;");
		    getTaxRate();
		}
	}
	
	function resetCityZip(prefix)
	{
		var citySpan = document.getElementById(prefix+"city");
		var countrySpan = document.getElementById(prefix+"country");
		if(citySpan.hasChildNodes())
		{
			for(var i = citySpan.childNodes.length-1; i > -1; i--)
			{
				citySpan.removeChild(citySpan.childNodes[i]);
			}
		}
		if(countrySpan.hasChildNodes())
		{
			for(i =  countrySpan.childNodes.length -1; i > -1; i--)
			{
				countrySpan.removeChild(countrySpan.childNodes[i]);
			}
		}
		for(i= document.getElementById('theform').length -1; i > -1; i--)
		{
			if(document.getElementById('theform').elements[i].name == prefix+"city" ||
				document.getElementById('theform').elements[i].name == prefix+"country")
			{
				if(document.getElementById('theform').elements[i].removeNode)
				{
					document.getElementById('theform').elements[i].removeNode(true);
				}
				else
				{
					document.getElementById('theform').removeChild(document.getElementById('theform').elements[i]);
				}
			}	
		}
		if(prefix == "" ||
			document.getElementById("sameShipping").checked == false)
		{
			taxRate = null;
		}	
	}
/*	function resetAll()
	{
		var citySpan = document.getElementById("city");
		var countrySpan = document.getElementById("country");

		if(document.getElementById("zip").value == "")
		{
			if(citySpan.hasChildNodes())	
			{
				for(var i = citySpan.childNodes.length -1; i > -1; i--)
				{
					citySpan.removeChild(citySpan.childNodes[i]);
				}
			}
			if(countrySpan.hasChildNodes())
			{
				for(i = countrySpan.childNodes.length -1; i > -1; i--)
				{
					countrySpan.removeChild(countrySpan.childNodes[i]);
				}
			}
			for(i= document.getElementById('theform').length -1; i > -1; i--)
			{
				if(document.getElementById('theform').elements[i].name == "city" ||
					document.getElementById('theform').elements[i].name == "country")
				{
					document.getElementById('theform').removeChild(document.getElementById('theform').elements[i]);
				}	
			}
		}		
	}
*/	
	function getTaxRate()
	{
		if(!document.getElementById('retrys'))
		{
			clearTimeout(taxTimeout);
			taxTimeout = setTimeout("getTaxRate()", 50);
			return;
		}
		
		zipInput = document.getElementById("szip");
		cityInput = document.getElementById("scityInput");
		countryInput = document.getElementById("scountryInput");
		if(document.getElementById('firstName').value == null)
		{
			return;
		}
		if(document.getElementById("sameShipping").type == "hidden" ||
			document.getElementById("sameShipping").checked)
		{
			zipInput = document.getElementById("zip");
			cityInput = document.getElementById("cityInput");
			countryInput = document.getElementById("countryInput");
		}
		
		if(document.getElementById("tax") != null &&
			document.getElementById("tax").hasChildNodes())
		{
			for(i=document.getElementById("tax").childNodes.length-1; i > -1; i--)
			{
				document.getElementById("tax").removeChild(document.getElementById("tax").childNodes[i]);
			}
		}
		i = 0;
		while(document.getElementById("itemCost"+i) != null && 
			document.getElementById("itemCost"+i))
		{
			td = document.getElementById("itemCost"+i);
			if(td.hasChildNodes())
			{
				for(j=td.childNodes.length-1; j > -1; j--)
				{
					td.removeChild(td.childNodes[j]);
				}
			}
			i++;
		}
		td = document.getElementById("shippingCost");
		if(td != null && td.hasChildNodes())
		{
			for(j=td.childNodes.length-1; j > -1; j--)
			{
				td.removeChild(td.childNodes[j]);
			}
		}

		subtotalTD = document.getElementById("subtotalCost");
		if(subtotalTD != null && subtotalTD.hasChildNodes())
		{
			for(var i = subtotalTD.childNodes.length-1; i > -1; i--)
			{
				subtotalTD.removeChild(subtotalTD.childNodes[i]);
			}
		}
		i = 0;
		totalTD = document.getElementById("totalCost");
		if(totalTD != null && totalTD.hasChildNodes())
		{
			for(var i = totalTD.childNodes.length-1; i > -1; i--)
			{
				totalTD.removeChild(totalTD.childNodes[i]);
			}
		}
		if(document.getElementById("dollarSign") != null )
		{
			document.getElementById("dollarSign").style.display = "none";
		}

		if(!zipInput ||
			!cityInput ||
			!countryInput)
		{
			clearTimeout(taxTimeout);
			taxTimeout = setTimeout("getTaxRate()", 50);
			return;
		}
		if( validZip &&
			zipInput.value != "" &&
			countryInput &&
			countryInput.value == "US" &&
			cityInput &&
			cityInput.value != '')
		{
			if(syncer != "")
			{
				clearTimeout(taxTimeout);
				taxTimeout = setTimeout("getTaxRate()", 50);
				return;
			}
			syncer = "tax";
			requestXML("xmlRequest,zip,city,county,state", 
				"tax,"+zipInput.value.split('-')[0]+","+cityInput.value.split('|')[0]+","+cityInput.value.split('|')[1]+","+ cityInput.value.split('|')[2], 'updateTax');
		}
		else if(countryInput && (countryInput.value == "US" || countryInput.value == ""))
		{
			taxRate = null;
		}
		else
		{
			if(countryInput && countryInput.value == "CA")
			{
				taxRate = 0.0;
			}
			if(syncer != "")
			{
				clearTimeout(taxTimeout);
				taxTimeout = setTimeout("getTaxRate()", 50);
				return;
			}
			updateTax();
		}
	}
	
	function getItemPrice(cat, item, position)
	{
			if(syncer != "")
			{
				clearTimeout(priceTimeout);
				priceTimeOut = setTimeout("getItemPrice('"+cat+"','"+item+"', '"+position+"')", 50);
				return;
			}
			syncer = "price";
		requestXML("xmlRequest,cat,"+(item==null?"":"item,")+"number", "price,"+cat+","+(item==null?"":(item+","))+position, 'updateItemPrice');
	}
	
	function getShippingPrice(cat)
	{
			if(syncer != "")
			{
				clearTimeout(priceTimeout);
				priceTimeOut = setTimeout("getShippingPrice('"+cat+"')", 50);
				return;
			}
			syncer = "price";
		requestXML("xmlRequest,cat", "price,"+cat, 'updateShippingPrice');
	}

	function changeShipping()
	{
		if(document.getElementById("sameShipping") != null &&
		   document.getElementById("sameShipping").type != "hidden")
		{
			if(document.getElementById("sameShipping").checked == true)
			{
				document.getElementById("saddress").value = "";
				document.getElementById("saddress").disabled = true;
				if(document.getElementById("scityInput"))
				{
					document.getElementById("scityInput").value = "";
					document.getElementById("scityInput").disabled = true;
				}
				document.getElementById("szip").value = "";
				document.getElementById("szip").disabled = true;
				if(document.getElementById("scountryInput"))
				{
					document.getElementById("scountryInput").value = "";
					document.getElementById("scountryInput").disabled = true;
				}
				document.getElementById("shippingRow").style.visibility = "hidden";
			}
			else
			{
				document.getElementById("saddress").disabled = false;
				if(document.getElementById("scityInput"))
				{
					document.getElementById("scityInput").disabled = false;
				}
				document.getElementById("szip").disabled = false;
				if(document.getElementById("scountryInput"))
				{
					document.getElementById("scountryInput").disabled = false;
				}
				document.getElementById("shippingRow").style.visibility = "visible";
			}
		}
	}

	function clearTextInput(form)
	{
		for(var j = 0; j < document.forms.length; j++)
		{
			form = document.forms[j];
			for(var i = 0; i < form.elements.length; i++)
			{
				if(form.elements[i].tagName == "INPUT" &&
					form.elements[i].type != "hidden" &&
					form.elements[i].type != "submit")
				{
					form.elements[i].value = "";
				}
				if(form.elements[i].tagName == "SELECT")
				{
					form.elements[i].selectedIndex = 0;
				}
			}		
		}
	}
	
	function checkItemCount(input)
	{
		if(isNaN(parseInt(input.value)) || parseInt(input.value) < 1)
		{
			input.value = '1';
		}
		else
		{
			input.value =  parseInt(input.value);
		}
	}
	function recalcAll()
	{
		if(!emptyForm() && document.getElementById("firstName") != null ){
			shipUpdated = false;
			updateFromCookies();
			validZip = true;
			validateZip("zip");
			validsZip = true;
			if(document.getElementById("szip") != null)
			{
				validateZip("szip");
			}
			else
			{
				scityDownloaded = true;
			}
			changeShipping();
		}
	}
	
	function emptyForm()
	{
		for(var j = 0; j < document.forms.length; j++)
		{
			form = document.forms[j];
			for(var i = 0; i < form.elements.length; i++)
			{
				if( (form.elements[i].tagNane == "TEXTAREA" ||
						(form.elements[i].tagName == "INPUT" &&
						 (form.elements[i].type == "text" ||
						  form.elements[i].type == "password"))) &&
					form.elements[i].value != "")
				{
					if(form.elements[i].id.substr(0, 9) != "itemCount" ||
						form.elements[i].value != "1")
					{
						return false;
					}
				}
			
				if(form.elements[i].tagName == "INPUT" &&
					(form.elements[i].type == "RADIO" ||
					 form.elements[i].type == "CHECKBOX") &&
					form.elements[i].check == true)
				{
					return false;
				}

				if(form.elements[i].tagName == "SELECT" &&
					form.elements[i].selectedIndex != -1)
				{
					return false;
				}
			}		
		}
		return true;
	}

	function clearForm()
	{
		for(var j = 0; j < document.forms.length; j++)
		{
			form = document.forms[j];
			for(var i = 0; i < form.elements.length; i++)
			{
				if( (form.elements[i].tagName == "TEXTAREA" ||
						(form.elements[i].tagName == "INPUT" &&
						 (form.elements[i].type == "text" ||
						  form.elements[i].type == "password"))) &&
					form.elements[i].value != "")
				{
					form.elements[i].value = "";
				}
			
				if(form.elements[i].tagName == "INPUT" &&
					(form.elements[i].type == "radio" ||
					 form.elements[i].type == "checkbox") &&
					form.elements[i].check == true)
				{
					form.elements[i].check == false;
				}

				if(form.elements[i].tagName == "SELECT" &&
					form.elements[i].selectedIndex != -1)
				{
					form.elements[i].selectedIndex = 0;
				}
			}		
		}
		return true;
	}

	function saveData()
	{
		if(document.getElementById("shippingPreference") != null)
		{
			shippingSelect = document.getElementById("shippingPreference").selectedIndex;
			setCookie("shippingPreference",shippingSelect);
		}
		if(document.getElementById("zip").value != "" &&
			document.getElementById("cityInput") != null)
		{
			if(document.getElementById("countryInput").value == "CA" )
			{
				cityValue = document.getElementById("cityInput").value;
				setCookie("cityInput", cityValue);
			}
			else if(document.getElementById("cityInput").selectedIndex)
			{
				cityValue = document.getElementById("cityInput").selectedIndex;
				setCookie("cityInput", cityValue);
			}
		}
		if(document.getElementById("scityInput") != null &&
			document.getElementById("szip").value != "")
		{
			if(document.getElementById("scountryInput").value == "CA" )
			{
				cityValue = document.getElementById("scityInput").value;
				setCookie("scityInput", cityValue);
			}
			else if(document.getElementById("scityInput").selectedIndex)
			{
				cityValue = document.getElementById("scityInput").selectedIndex;
				setCookie("scityInput", cityValue);
			}
		}
		var i = 0;
		while(document.getElementById("itemCost"+i))
		{
			if(document.getElementById("itemSelect"+i) != null)
			{
				var selectValue = document.getElementById("itemSelect"+i).selectedIndex;
				setCookie("itemSelect"+i, selectValue);
			}
			i++;
		}
	}
	
	function updateFromCookies()
	{
		if(syncer != "" || !cityDownloaded  || !scityDownloaded ||
			( document.getElementById("shippingPreference") != null && 
			  document.getElementById("shippingPreference").selectedIndex == -1))
		{
			clearTimeout(cookieTimeout);
			cookieTimeout = setTimeout(updateFromCookies, 50);
			return;
		}
		if(document.getElementById("shippingPreference") != null &&
			getCookie("shippingPreference") && !emptyForm())
		{
			shipValue = getCookie("shippingPreference");
			shipSelect = document.getElementById("shippingPreference");
			if(isNaN(shipValue))
			{
				for(var i=0; i < shipSelect.options.length; i++)
				{
					if(shipSelect.options[i].value ==  shipValue)
					{
						shipSelect.selectedIndex = i;
						break;
					}
				
				}
			}
			else
			{
				shipSelect.selectedIndex = shipValue;
			}
		}
		deleteCookie("shippingPreference");
		if(document.getElementById("zip").value != "" &&
			document.getElementById("cityInput") &&
			getCookie("cityInput"))
		{
			if(document.getElementById("countryInput").value == "CA" )
			{
				document.getElementById("cityInput").value = getCookie("cityInput");
			}
			else if(document.getElementById("cityInput").selectedIndex != null)
			{
				var citySelect = document.getElementById("cityInput");
				var cityValue = getCookie("cityInput");
				if(cityValue != null)
				{
					if(isNaN(cityValue))
					{
						for(var i=0; i < citySelect.options.length; i++)
						{
							if(citySelect.options[i].value ==  cityValue)
							{
								citySelect.selectedIndex = i;
								break;
							}
						}
					}
					else
					{			
						citySelect.selectedIndex = cityValue;
					}
				}
			}
			deleteCookie("cityInput");
		}
		var i = 0;
		while(document.getElementById("itemCost"+i))
		{
			if(document.getElementById("itemSelect"+i) != null)
			{
				var itemSelect = document.getElementById("itemSelect"+i);
				var itemValue = getCookie("itemSelect"+i);
				if(itemValue == null)
				{
					itemValue = getCookie("itemDesc"+i);
					if(isNaN(itemValue))
					{
						for(var i=0; i < itemSelect.options.length; i++)
						{
							if(itemSelect.options[i].value ==  itemValue)
							{
								itemSelect.selectedIndex = i;
								break;
							}
						}
					}
				}
				else
				{
					itemSelect.selectedIndex = itemValue;
				}
				deleteCookie("itemSelect"+i);
			}
			i++;
		}
		if(document.getElementById("szip") != null &&
		    document.getElementById("szip").value != "" &&
			document.getElementById("scityInput")  != null &&
			getCookie("scityInput"))
		{
			if(document.getElementById("scountryInput").value == "CA" )
			{
				document.getElementById("scityInput").value = getCookie("scityInput");
			}
			else if(document.getElementById("scityInput").selectedIndex != null)
			{
				document.getElementById("scityInput").selectedIndex = getCookie("scityInput");
			}
			deleteCookie("scityInput");
		}
		shipUpdated = true;
		getTaxRate();
	}
	
	
	function validateForm()
	{
		for(var i=0; i < arguments.length; i++)
		{
			var valKey = arguments[i].split("|");
			if(	(document.getElementById(valKey[0]) != null &&
				document.getElementById(valKey[0]).value == ""))
			{
				alert("Please enter your "+valKey[1]+".");
				document.getElementById(valKey[0]).focus();
				return false;
			}
		}
		if(	(document.getElementById("demoTerms") != null &&
			document.getElementById("demoTerms").checked == false))
		{
			alert("You must aggree to the terms of agreement.");
			document.getElementById("demoTerms").focus();
			return false;
		}
		if(	(document.getElementById("firstName") != null &&
			document.getElementById("firstName").value == ""))
		{
			alert("Please enter your First Name.");
			document.getElementById("firstName").focus();
			return false;
		}
		if(	(document.getElementById("lastName") != null &&
			document.getElementById("lastName").value == ""))
		{
			alert("Please enter your Last Name.");
			document.getElementById("lastName").focus();
			return false;
		}
		if( (document.getElementById("company") != null &&
			document.getElementById("company").value == ""))
		{
			alert("Please enter your Company.");
			document.getElementById("company").focus();
			return false;
		}
		if( (document.getElementById("phone") != null &&
			document.getElementById("phone").value == ""))
		{
			alert("Please enter your Phone Number.");
			document.getElementById("phone").focus();
			return false;
		}
		if( document.getElementById("email") != null &&
			(document.getElementById("email").value == "" ||
			document.getElementById("email").value.search(/^\s*([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+\s*$/) == -1)
			)
		{
			alert("Please enter a correct Email address.");
			document.getElementById("email").focus();
			return false;
		}
		if( (document.getElementById("address") != null &&
			document.getElementById("address").value == ""))
		{
			alert("Please enter your Address.");
			document.getElementById("address").focus();
			return false;
		}
		if( (document.getElementById("cityInput") != null &&
			document.getElementById("cityInput").value == ""))
		{
			alert("Please enter your  City, (County) State/Province.");
			document.getElementById("cityInput").focus();
			return false;
		}
		if( (document.getElementById("zip") != null &&
			document.getElementById("zip").value == ""))
		{
			alert("Please enter your  Zip/Postal Code.");
			document.getElementById("zip").focus();
			return false;
		}
		if(document.getElementById("zip") != null &&
			document.getElementById("zip").value != "" &&
			document.getElementById("cityInput") == null)
		{
			zipValidated = false;
			validateZip("zip");
		}
		if( document.getElementById("sameShipping") != null &&
			document.getElementById("sameShipping").type != "hidden" &&
			document.getElementById("sameShipping").checked == false)
		{
			if( document.getElementById("saddress").value == "")
			{
				alert("Please enter your Shipping Address.");
				document.getElementById("saddress").focus();
				return false;
			}
			if( (document.getElementById("scityInput") != null &&
				document.getElementById("scityInput").value == ""))
			{
				alert("Please enter your Shipping City, (County) State/Province.");
				document.getElementById("scityInput").focus();
				return false;
			}
			if( document.getElementById("szip").value == "" )
			{
				alert("Please enter your Shipping Zip/Postal Code.");
				document.getElementById("szip").focus();
				return false;
			}
			if(document.getElementById("szip") != null &&
				document.getElementById("szip").value != "" &&
				document.getElementById("scityInput") == null)
			{
				szipValidated = false;
				validateZip("szip");
			}
		}
		if(!zipValidated || !szipValidated )
		{
			alert("City information is still downloading from our server.\n"+
			      "Once it is complete, please review the address information and " +
			      "click Continue.");
			return false;
		}
		totalInput = document.getElementById("totalInput");
		if(!shipUpdated || totalInput == null || isNaN(parseFloat(totalInput.value)))  //Last thing to be updated with cost and inputs.
		{
			alert("Still downloading product information.\n"+
			      "Once it displays, please review the information and " +
			      "click Continue.");
			return false;
		}
		if(document.getElementById("countryInput") != null &&
			document.getElementById("countryInput").value == "CA" &&
			document.getElementById("cityInput") != null &&
			document.getElementById("cityInput").value.split(",")[1] == null)
		{
			alert("Incorrect city and province format (City, Province)");
			document.getElementById("cityInput").focus();
			return false;
		}
		if(document.getElementById("sameShipping") != null &&
			document.getElementById("sameShipping").type != "hidden" &&
			document.getElementById("sameShipping").checked == false &&
			document.getElementById("scountryInput").value == "CA" &&
			document.getElementById("scityInput") != null &&
			document.getElementById("scityInput").value.split(",")[1] == null)
		{
			alert("Incorrect city and province format (City, Province)");
			document.getElementById("scityInput").focus();
			return false;
		}
		var credCardChecked = false;
		var needsCard = false;
		var i = 0;
		while(document.getElementById("CredCard"+i))
		{
			needsCard = true;
			if(document.getElementById("CredCard"+i).checked)
			{
				credCardChecked = true;
				break;
			}
			i++;
		}
		if(needsCard && !credCardChecked)
		{
			alert("Please select a credit card type.");
			document.getElementById('CredCard0').focus();
			return false;
		}
		if(document.getElementById("CredCardNum") != null &&
		   document.getElementById("CredCardNum").value == "")
		{
			alert("Please enter your credit card number.");
			document.getElementById("CredCardNum").focus();
			return false;
		}
		if(document.getElementById("CredCardExpDate") != null &&
		   document.getElementById("CredCardExpDate").value == "")
		{
			alert("Please enter your credit card expiration date.");
			document.getElementById("CredCardExpDate").focus();
			return false;
		}
		if(document.getElementById("NameOnCard") &&
		   document.getElementById("NameOnCard").value == "")
		{
			alert("Please enter the name printed on your credit card.");
			document.getElementById("NameOnCard").focus();
			return false;
		}
		if(document.getElementById("CredCardNum") == null ||
		   ValidateCC())
		{
			saveData();
			if(window.addEventListener)
			{
				window.removeEventListener("unload",saveData, false);
			}
			else
			{
				window.onunload = null;
			}
			document.getElementById("theform").submit();
			
		}
		else
		{
			return false;
		}
	}
	
	function verifyFinalSubmit()
	{
		document.getElementById('submitter').value = 'Processing ...';
		document.getElementById('submitter').disabled = true;
		document.getElementById('back').disabled = true;
		document.getElementById('wait').appendChild(
			document.createTextNode(
				'This process may take several minutes. Please do not navigate away from this page.'
			)
		);
		return true;
	}
	
function startOver()
{
	deleteCookie('shippingPreference');
	deleteCookie('cityInput');
	deleteCookie('scityInput');
	window.location = document.getElementById('referer').value;
}

	