function Validateform()
{
		if (document.Table2FORM.movetype[0].checked)
		{

				if (document.Table2FORM.txtFromZip.value=='')
				{
					alert("Please enter a valid From zip.");
					document.Table2FORM.txtFromZip.focus();
					return false;
				}
				


				if (document.Table2FORM.txtToCity.value=='')
				{
					alert("Please select a To City.");
					document.Table2FORM.txtToCity.focus();
					return false;
				}
				if (document.Table2FORM.cboToState.options[document.Table2FORM.cboToState.selectedIndex].value=="Select One")
				{
					alert("Please select a To State.");
					document.Table2FORM.cboToState.focus();
					return false;
				}

		}
		else
		{
				if (document.Table2FORM.txtFromZipi.value=='')
				{
					alert("Please enter a valid zip code.");
					document.Table2FORM.txtFromZipi.focus();
					return false;
				}
				


				if (document.Table2FORM.txtToCityi.value=='')
				{
					alert("Please enter a To City.");
					document.Table2FORM.txtToCityi.focus();
					return false;
				}

				if (document.Table2FORM.txttoCountryi.value=='')
				{
					alert("Please enter destination country.");
					document.Table2FORM.txttoCountryi.focus();
					return false;
				}
		}

		if (document.Table2FORM.name.value=='')
		{
			alert("Please enter name.");
			document.Table2FORM.name.focus();
			return false;
		}
		if (document.Table2FORM.dayphone.value=='')
		{
			alert("Please enter Phone Number.");
			document.Table2FORM.dayphone.focus();
			return false;
		}

		var phonerrormsg = validatePhone(document.Table2FORM.dayphone);

		if (phonerrormsg.length > 0 )
		{
			alert(phonerrormsg);
			document.Table2FORM.dayphone.focus();
			return false;
		}


		if (document.Table2FORM.email.value=='')
		{
			alert("Please enter a valid email.");
			document.Table2FORM.email.focus();
			return false;
		}
		if (!isEmailAddr(document.Table2FORM.email.value))
		  {
			alert("Please enter a complete valid email address in the format: yourname@yourdomain.com");
			document.Table2FORM.email.focus();
			return (false);
		  }

		if (document.Table2FORM.mdate.value=='')
		{
			alert("Please enter a valid moving date.");
			document.Table2FORM.mdate.focus();
			return false;
		}


		document.Table2FORM.submit.disabled=true;
		document.Table2FORM.action="thankstest.php";
					return true;
}

function Validatecform()
{
		if (document.Table2FORM.name.value=='')
		{
			alert("Please enter name.");
			document.Table2FORM.name.focus();
			return false;
		}
		if (document.Table2FORM.dayphone.value=='')
		{
			alert("Please enter Phone Number.");
			document.Table2FORM.dayphone.focus();
			return false;
		}

		var phonerrormsg = validatePhone(document.Table2FORM.dayphone);

		if (phonerrormsg.length > 0 )
		{
			alert(phonerrormsg);
			document.Table2FORM.dayphone.focus();
			return false;
		}


		if (document.Table2FORM.email.value=='')
		{
			alert("Please enter a valid email.");
			document.Table2FORM.email.focus();
			return false;
		}
		if (!isEmailAddr(document.Table2FORM.email.value))
		  {
			alert("Please enter a complete valid email address in the format: yourname@yourdomain.com");
			document.Table2FORM.email.focus();
			return (false);
		  }

		

		document.Table2FORM.submit.disabled=true;
		document.Table2FORM.action="thankscontact.php";
					return true;
}


function validatePhone(fld) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');    

   if (fld.value == "") {
        error = "Please enter a valid phone number with area code.\n";
        //fld.style.background = 'Yellow';
    } else if (isNaN(parseInt(stripped))) {
        error = "Please enter a valid phone number with area code.\n";
        //fld.style.background = 'Yellow';
    } else if (!(stripped.length == 10)) {
        error = "Please enter a valid phone number with area code.\n";
        //fld.style.background = 'Yellow';
    }
    return error;
}

function check_usphone(phonenumber,useareacode)
{
	if(!useareacode)useareacode=1;
	if((phonenumber.match(/^[ ]*[(]{0,1}[ ]*[0-9]{3,3}[ ]*[)]{0,1}[-]{0,1}[ ]*[0-9]{3,3}[ ]*[-]{0,1}[ ]*[0-9]{4,4}[ ]*$/)==null) && ((useareacode!=1) && (phonenumber.match(/^[ ]*[0-9]{3,3}[ ]*[-]{0,1}[ ]*[0-9]{4,4}[ ]*$/)==null))) 
	{
		alert("false");
		return false;
	}
	
	return true;
} 

function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

