function Checkout_ValidateInputForms()
{
	//NOTE: Zip code javascript validation is only done if the input boxes have a value.

	if(document.getElementById("zip").value.length > 0)
	{
		if(false == Checkout_ValidateZipInputBoxFormat("zip", "Personal Zip Code"))
		{
			return false;
		}
	}
	
	if(document.getElementById("shipping_zip").value.length > 0)
	{
		if(false == Checkout_ValidateZipInputBoxFormat("shipping_zip", "Shipping Zip Code"))
		{
			return false;
		}
	}
	
	return true;
}

function Checkout_ValidateZipInputBoxFormat(zip_code_input_box_id, friendly_name_of_input_box)
{
	var zip_code_input_box = document.getElementById(zip_code_input_box_id);
	var zip_text = zip_code_input_box.value;
	
	var valid_character_string = "0123456789-";
	var hyphencount = 0;

	if(zip_text.length < 1) 
	{
		alert("Please enter your 5 digit or 5 digit+4 zip code.");
		return false;
	}
	else if(zip_text.length!=5 && zip_text.length!=10) 
	{
		zip_code_input_box.style.backgroundColor = "red";
		alert('Invalid zip-code format ('+friendly_name_of_input_box+').'+"\r\n\r\n"+'Please enter a 5 digit code (e.g. 12345) or 5 digit+4 zip code (e.g. 12345-9999).');
		zip_code_input_box.style.backgroundColor = "";
		zip_code_input_box.select();
		return false;
	}
	for(var i=0; i < zip_text.length; i++) 
	{
		var cur_char = "" + zip_text.substring(i, i+1);
		if(cur_char == "-")
		{
			hyphencount++;
		}
		
		if(valid_character_string.indexOf(cur_char) == "-1") 
		{
			zip_code_input_box.style.backgroundColor = "red";
			alert('Invalid "'+friendly_name_of_input_box+'": "'+cur_char+'" is not a valid character for a zip code.'+"\r\n\r\n"+'Please try again.');
			zip_code_input_box.style.backgroundColor = "";
			zip_code_input_box.select();
			return false;
		}
		if((hyphencount > 1) || ((zip_text.length==10) && ""+zip_text.charAt(5)!="-")) 
		{
			zip_code_input_box.style.backgroundColor = "red";
			alert('Invalid "'+friendly_name_of_input_box+'": The hyphen character should be used with a properly formatted 5 digit+four zip code (e.g. "12345-6789")'+"\r\n\r\n"+'Please try again.');
			zip_code_input_box.style.backgroundColor = "";
			zip_code_input_box.select();
			return false;
		}
	}
	return true;
}