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;
}

function Validateform()
{
		if (document.HomePageFastQuoteForm.firstname.value=='')
		{
			alert("Please enter First name.");
			document.HomePageFastQuoteForm.firstname.focus();
			return false;
		}
		if (document.HomePageFastQuoteForm.Phone.value=='')
		{
			alert("Please enter Phone Number.");
			document.HomePageFastQuoteForm.Phone.focus();
			return false;
		}

		var phonerrormsg = validatePhone(document.HomePageFastQuoteForm.Phone);

		if (phonerrormsg.length > 0 )
		{
			alert(phonerrormsg);
			document.HomePageFastQuoteForm.Phone.focus();
			return false;
		}


		if (document.HomePageFastQuoteForm.email.value=='')
		{
			alert("Please enter a valid email.");
			document.HomePageFastQuoteForm.email.focus();
			return false;
		}
		if (!isEmailAddr(document.HomePageFastQuoteForm.email.value))
		  {
			alert("Please enter a complete valid email address in the format: yourname@yourdomain.com");
			document.HomePageFastQuoteForm.email.focus();
			return (false);
		  }

		if (document.HomePageFastQuoteForm.City.value=='')
		{
			alert("Please enter a valid City.");
			document.HomePageFastQuoteForm.City.focus();
			return false;
		}
		


		if (document.HomePageFastQuoteForm.State.value==' ')
		{
			alert("Please select a state.");
			document.HomePageFastQuoteForm.State.focus();
			return false;
		}

		if (document.HomePageFastQuoteForm.ServiceDate.value=='')
		{
			alert("Please enter Service Date");
			document.HomePageFastQuoteForm.ServiceDate.focus();
			return false;
		}
		
		if (document.HomePageFastQuoteForm.AdditionalServices.value==' ')
		{
			alert("Please select additional Services");
			document.HomePageFastQuoteForm.AdditionalServices.focus();
			return false;
		}

		document.HomePageFastQuoteForm.submit.disabled=true;
		document.HomePageFastQuoteForm.action="email_thanks_quotes.asp";
}



function LaunchForm(id)
{
		document.formfields.carryfields.value=document.formfields.carryfields.value + ",id=" + id;
		document.formfields.coid.value=id;		
		//alert("value=:" + document.formfields.carryfields.value);
		document.formfields.action="MovingCompanyProfile.asp";
		document.formfields.submit();
		//this.form.submit();
		//Set_Cookie( 'SetCompanyId', id, '', '/', 'gpseway.com', '' );
}

function LaunchQuoteForm()
{
		//document.formfields.carryfields.value=document.formfields.carryfields.value + ",id=" + id;
		//document.formfields.coid.value=id;		
		//alert("value=:" + document.formfields.carryfields.value);
		document.formfields.action="http://gpseway.com/test/movequotes.aspx";
		document.formfields.submit();
		//this.form.submit();
		//Set_Cookie( 'SetCompanyId', id, '', '/', 'gpseway.com', '' );
}

function LaunchCarQuoteForm()
{
		//document.formfields.carryfields.value=document.formfields.carryfields.value + ",id=" + id;
		//document.formfields.coid.value=id;		
		//alert("value=:" + document.formfields.carryfields.value);
		document.formfields.action="http://gpseway.com/test/car-move-quotes.aspx";
		document.formfields.submit();
		//this.form.submit();
		//Set_Cookie( 'SetCompanyId', id, '', '/', 'gpseway.com', '' );
}

function LaunchIntnQuoteForm()
{
		document.formfields.action="http://gpseway.com/test/international-move-quotes.aspx";
		document.formfields.submit();
}
