
// -------------------------------------------------------------------
	//								trimAll
	// -------------------------------------------------------------------
  function trimAll(sString) {
                while (sString.substring(0,1) == ' ')    {
                  sString = sString.substring(1, sString.length);
                }
            		
                while (sString.substring(sString.length-1, sString.length) == ' ')    {
                  sString = sString.substring(0,sString.length-1);
                }
            		return sString;
            }

  var clicked = 0;		
	// -------------------------------------------------------------------
	//								IsSalesForceFormComplete
	// -------------------------------------------------------------------
	function IsSalesForceFormComplete(xxxx)
		{
			if (document.forms.frmsalesforce.first_name.value == '')
			 	{
						alert('Please enter your first name.');
						document.frmsalesforce.first_name.focus();
						return false;
				}
				
			if (document.frmsalesforce.last_name.value == '')
			 		{
						alert('Please enter your last name.');
						document.frmsalesforce.last_name.focus();
						return false;
					}			
					
			if (document.frmsalesforce.phone.value == '') 
			 		{
						alert('Please enter your telephone number.');
						document.frmsalesforce.phone.focus();
						return false;
					}
			
			if (document.frmsalesforce.email.value == '')			 	{
						alert('Please enter your email address.');
						document.frmsalesforce.email.focus();
						return false;
				}
				//alert(CheckEmail(document.frmsalesforce.frm_email));
			if (CheckEmail(document.frmsalesforce.email) == false )
			 	{
						alert('Please enter your email address.');
						document.frmsalesforce.email.focus();
						return false;
				}

			 document.forms['frmsalesforce'].submit();
							

			return;		
			}


	// -------------------------------------------------------------------
	//								IsFormComplete
	// -------------------------------------------------------------------
	function IsFormComplete(Enrollment_form)
		{
			if (document.forms[Enrollment_form].Q1A_PracticeName.value == '')
			 	{
						alert('Please enter your practice name.');
						document.forms[Enrollment_form].Q1A_PracticeName.focus();
						return false;
				}
				
			if (document.forms[Enrollment_form].Q1B_BillingAddress.value == '')
			 		{
						alert('Please enter your billing address.');
						document.forms[Enrollment_form].Q1B_BillingAddress.focus();
						return false;
					}			
					
			if (document.forms[Enrollment_form].Q1C_BillingAddressCity.value == '')
			 		{
						alert('Please enter your city.');
						document.forms[Enrollment_form].Q1C_BillingAddressCity.focus();
						return false;
					}			

	

			if (document.forms[Enrollment_form].Q1C_BillingZipCode.value == '')
			 		{
						alert('Please enter your mailing Zip Code.');
						document.forms[Enrollment_form].Q1C_BillingZipCode.focus();
						return false;
					}			

			if (document.forms[Enrollment_form].PrimaryTelephone.value == '') 
			 		{
						alert('Please enter your primary telephone number.');
						document.forms[Enrollment_form].PrimaryTelephone.focus();
						return false;
					}
			if (document.forms[Enrollment_form].PrimaryContact.value == '') 
			 		{
						alert('Please enter your primary contact.');
						document.forms[Enrollment_form].PrimaryContact.focus();
						return false;
					}	
					
		if (document.forms[Enrollment_form].Wireless_cb.checked==true && 
				document.forms[Enrollment_form].WirelessCellphoneServicesVerizon.checked==false       &&
				document.forms[Enrollment_form].WirelessCellphoneServicesATT.checked==false  )  
					{
						alert('Please select a wireless service.');
						document.forms[Enrollment_form].WirelessCellphoneServicesVerizon.focus();
						return false;
					}			   
						


					
			
			if (document.Enrollment_form.Signature.value.length < 6) 		
				{			 			
					alert("Please check your signature. It appears invalid.");
					document.Enrollment_form.Signature.focus();						
					document.Enrollment_form.Signature.select();
					return false;					
				}			

			return;		
			}

	// -------------------------------------------------------------------
	//								submitpage
	// -------------------------------------------------------------------
	function submitpage()
	{

	
		if ( IsFormComplete('Enrollment_form')==false )
			{
				return false;
				
			}
		else
		{
			document.forms['Enrollment_form'].submit();
			return true;
		}
	}
	// -------------------------------------------------------------------
	//								IsContactFormComplete - Enrollment Form
	// -------------------------------------------------------------------
		function IsContactFormComplete()		{		
		   
		   if (trimAll(document.contactemailform.e_name.value) == "") {
				alert("Please enter your name before you submit your message.");
				document.contactemailform.e_name.focus();		   
		   		return false;
		  }	

		   if ( CheckEmail2(document.contactemailform.e_email) == false )  
		   		return false;		   

		   if (trimAll(document.contactemailform.e_comments.value) == "") {
		   				alert("Please enter your question or comment.");
						document.contactemailform.e_comments.focus();
						
		   		return false;
		   }
		   return true;						
		}
	// -------------------------------------------------------------------
	//								submitpage
	// -------------------------------------------------------------------
	function SubmitPage()	{	
		if ( IsContactFormComplete() == false )
				return false;				
		else {
			//alert ("made it222");
			document.contactemailform.submit();
		}			
	}	
	// -------------------------------------------------------------------
	//								checkemail
	// -------------------------------------------------------------------
	function CheckEmail(curObj) 
	{
	 //alert("made it checkemail");
		var argvalue = new Object;
		argvalue = curObj.value;
		argvalue.toString();
				
		var valdot = argvalue.indexOf(".");
		var valat =	 argvalue.indexOf("@");
		var valdot = argvalue.indexOf(".", valat);
		var valdiff = valdot - valat;
		var vallen = argvalue.length - valdot;
		//alert (argvalue.length);
		//alert (vallen);
					
		if ( ( valdot == -1 ) || ( valat == -1 ) || ( valdot < valat )  || (valdiff < 2) )
			{			 			
				alert("Please check your email address. It appears invalid.");
				curObj.focus();						
				curObj.select();
				return false;						
			}
	  return true;			
		
	}
	// -------------------------------------------------------------------
	//								check email 2
	// -------------------------------------------------------------------

function CheckEmail2(tempp) {
	
	var field = new Object;
			
  field = tempp; // email field

	if (field.value != "") 
  	 var str = field.value; // email string
	else
		 var str = " ";
		 
  var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
  var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
  if (!reg1.test(str) && reg2.test(str)) { // if syntax is valid
    //alert("Thank your for your feedback."); // this is optional
    return true;
  }
  alert("\"" + str + "\" is an invalid email address.  Please review and enter a valid email address."); // this is also optional
  field.focus();
  field.select();
  return false;
}

	
	// -------------------------------------------------------------------
	//								isNum
	// -------------------------------------------------------------------
	function isNum(curObj) 
	{
		var argvalue = new Object;
		argvalue = curObj.value;
		argvalue.toString();

		if (argvalue.length == 0)
			{ curObj.value=0;
				return false;
			}
	
		decimalcount = 0
	
		for (var n = 0; n < argvalue.length; n++)
		{
			if (argvalue.substring(n, n+1) < "0" || argvalue.substring(n, n+1) > "9" )	
			{
			if (argvalue.substring(n, n+1) == "." && ++decimalcount < 2 ) 
					{ }
					else
					{	
						alert("Please enter a valid integer ( 0, 5, or a number quantity greater than 5 ).");
						curObj.focus();
						curObj.value = 0;
						return false;
						}
			}
		}
		return true;
	}
