function strTrim(tmpStr)
{
	tmpStr = tmpStr.replace(/^\s+/,"");//remove leading
	tmpStr = tmpStr.replace(/\s+$/,"");//remove trailing
	return tmpStr;
}
function Validate()
{
	if(document.frmZipcode.zip_code.value == "")
	{
		alert("Please enter your zip code.");
		document.frmZipcode.zip_code.focus();
	}
	else
	{
		ajax.getRequest("ajax.php", "opt=zipval&fromzip="+document.frmZipcode.zip_code.value, showResult);
	}
	return false;
}
//Response handler for http request object
function showResult(retVal)
{
	if(strTrim(retVal) == "pass")
		self.location = document.frmZipcode.target_page.value;
	else
		document.getElementById("show_error").innerHTML = '<span class="text-orangeBold">We\'re sorry, we are not currently servicing you area.<br>  We\'re growing fast. but we\'re not there yet!!!  UsedCardboardBoxes.com<br> is a venture capital funded company that will be servicing your area soon.<br>  Please <a href="contact_us.php">click here</a> so we can contact you when we\'re in your city.</span>';
}
function chkEmail(tmpStr)
{
	var i;
	var posAt = 0;
	var posDot = 0
	var count = 0;
	for(i=0;i<tmpStr.length;++i)
	{
		if(tmpStr.charAt(i) == "@")
		{
			posAt = i;
			count++;
		}
		if(tmpStr.charAt(i) == ".")
		{
			posDot = i;
		}
		if (!((tmpStr.charAt(i) >= "0" && tmpStr.charAt(i) <= "9")
				||(tmpStr.charAt(i) >= "a" && tmpStr.charAt(i) <= "z")
				|| (tmpStr.charAt(i)>= "A" && tmpStr.charAt(i) <= "Z")
				|| (tmpStr.charAt(i) == "-")
				|| (tmpStr.charAt(i) == "_")
				|| (tmpStr.charAt(i) == "@")
				|| (tmpStr.charAt(i) == ".")
			)) return false;
	}
	if(count>1) return false;
	if(eval(posAt) > 1 && posAt != tmpStr.length-1 && posDot > posAt && posDot != tmpStr.length-1) return true;
	return false;
}
function show_hide_shipping(val)
{
	if(val)
	{
		document.getElementById("shipping_box").style.visibility = "hidden";
		document.getElementById("shipping_box").style.display = "none";
		document.getElementById("pickupcall_box").style.visibility = "visible";
		document.getElementById("pickupcall_box").style.display = "inline";
		document.getElementById("sameasshipping_box").style.visibility = "hidden";
		document.getElementById("sameasshipping_box").style.display = "none";
	}
	else
	{
		document.getElementById("shipping_box").style.visibility = "visible";
		document.getElementById("shipping_box").style.display = "inline";
		document.getElementById("pickupcall_box").style.visibility = "hidden";
		document.getElementById("pickupcall_box").style.display = "none";
		document.getElementById("sameasshipping_box").style.visibility = "visible";
		document.getElementById("sameasshipping_box").style.display = "inline";
	}
}