/* =========================================================================

JavaScript Source File -- Created with SAPIEN Technologies PrimalSCRIPT (TM)

NAME: place_order.js

AUTHOR: Rustom Rawat, Access Web Solutions
DATE  : 9/7/03
COPYRIGHT: (c) 2003 Access Web Solutions.
COMMENT: AWS grants you a royalty free license to use or modify this 
		 software provided that this copyright notice appears on all copies.
 		 This software is provided "AS IS," without a warranty of any kind.

============================================================================ */

function placeorder()
{
var form = window.document.frmPlaceOrder
	if (form.FName.value == "" || form.FName.value.length < 3)
	{
	alert("Please enter your first name in the \"First Name\" field.");
	form.FName.focus();
	return false;
	}
	if (form.LName.value == "" || form.LName.value.length < 3)
	{
	alert("Please enter your last name in the \"Last Name\" field.");
	form.LName.focus();
	return false;
	}
	if (form.Address.value == "" || form.Address.value.length < 8)
	{
	alert("Please enter your address in the \"Street Address\" field.");
	form.Address.focus();
	return false;
	}
	if (form.City.value == "" || form.City.length < 5)
	{
	alert("Please enter your city in the \"City\" field.");
	form.City.focus();
	return false;
	}
	if (form.State.value == "" || form.State.value.length < 2)
	{
	alert("Please enter your state in the \"Province\/State\" field.");
	form.State.focus();
	return false;
	}
	if (form.Zip.value == "" || form.Zip.value.length < 5)
	{
	alert("Please enter your zip code in the \"Zip Code\" field.");
	form.Zip.focus();
	return false;
	}
	if (form.Zip.value)
	{
  	if (!isNum(form.Zip.value))
	  {
	  alert("Please enter only valid numbers.");
	  form.Zip.focus();
	  return false;
	  }
	}
	if (form.phone_area.value == "" || form.phone_area.value.length < 3)
	{
	alert("Please enter your area code in the \"Phone\" field.");
	form.phone_area.focus();
	return false;
	}
	if (form.phone_area.value)
	{
  	if (!isNum(form.phone_area.value))
	  {
	  alert("Please enter only valid numbers.");
	  form.phone_area.focus();
	  return false;
	  }
	}
	if (form.phone_exch.value == "" || form.phone_exch.value.length < 3)
	{
	alert("Please enter your exchange code in the \"Phone\" field.");
	form.phone_exch.focus();
	return false;
	}
	if (form.phone_exch.value)
	{
  	if (!isNum(form.phone_exch.value))
	  {
	  alert("Please enter only valid numbers.");
	  form.phone_exch.focus();
	  return false;
	  }
	}
	if (form.phone_num.value == "" || form.phone_num.value.length < 4)
	{
	alert("Please enter your phone number in the \"Phone\" field.");
	form.phone_num.focus();
	return false;
	}
	if (form.phone_num.value)
	{
  	if (!isNum(form.phone_num.value))
	  {
	  alert("Please enter only valid numbers.");
	  form.phone_num.focus();
	  return false;
	  }
	}
	if (form.Email.value == "" || form.Email.value.length < 8)
	{
	alert("Please enter your email in the \"Email\" field.");
	form.Email.focus();
	return false;
	}
	if (form.HostPlan.value == "")
	{
	alert("Please opt for hosting plan from \"Hosting Plan\" field.");
	form.HostPlan.focus();
	return false;
	}
	if (form.Quantity.value == "")
	{
	alert("Please enter number of plans you want to buy from \"How many Plans\" field.");
	form.Quantity.focus();
	return false;
	}
	if (form.Quantity.value)
	{
  	if (!isNum(form.Quantity.value))
	  {
	  alert("Please enter only valid numbers.");
	  form.Quantity.focus();
	  return false;
	  }
	}
	if (form.MOP.value == "")
	{
	alert("Please select mode of payment from \"Payment Method\" field.");
	form.MOP.focus();
	return false;
	}
	if (form.Contract.value == "No")
	{
	alert("You must accept the contract terms for opening account with us.");
	form.Contract.focus();
	return false;
	}
return true;
}


// Check for numerical data only
function isNum(passedVal) 
{
	if (passedVal == "") 
	{
	   return false;
	}
	for (i=0; i<passedVal.length; i++) {
	    if (passedVal.charAt(i) <"0") {
/*			if (passedVal.charAt(i)!=".")
			{
				return false;
			} */
			return false;
	    }
	    if (passedVal.charAt(i) > "9") {
/*			if (passedVal.charAt(i)!=".")
			{
				return false;
			} */
		return false;
	    }
	}
	return true;
}