﻿// JScript File
/*<script type="text/javascript" SRC="FormChk.js">
		</script>*/
		
		/*<script type="text/javascript" language="javascript" >*/
				<!--
				var MasterContentId = "ctl00_ContentPlaceHolder1_";
				/* 11/08 no more country selection or howhear friend name
				function correctState() 
				{
					if (getSelectValue(document.daform.Contact_Country) == 'USA') 
						document.daform.Contact_State.selectedIndex=1;
					else 
						{ 
							document.daform.Contact_State.selectedIndex=0; 
						}
				}
				
				function correctHow() 
				{
					document.getElementById(MasterContentId + 'HowHear').Value;
					document.daform.HowHear_Name.value=document.daform.HowHear.options[document.daform.HowHear.selectedIndex].text;
				}
				*/
				function SubmitFormOnce()
                {
                    if (this.submitted)
                    { 
                        //alert('Patience'); 
                        return false;
                    }
                    else
                    {   
                         //alert('submitted ...');
                        var ctl;
                        ctl = document.getElementById(MasterContentId + "Submit");
                        if (ctl == null) { return;}
                        //ctl00_ContentPlaceHolder1_Submit
                        //08/25/2009 TSchroeder modify to reset button on validation
                        //failure. 
                        if (formchks())
                        {
                        ctl.disabled = true;
                        ctl.value = "Saving...";
                        
                        this.submitted = true;
                        return true;
                        }
                        else
                        {
                        return false;
                        }
                        /*if (ctl == null) { return;}
                        ctl.value = "Saving...";
                        ctl.disabled = true;
                          
                        this.submitted = true; 
                        return true;*/
                    }
                }
                
				function formchks()
				{
				    /*8/31/09 TSchroeder set variable to determine return value at end of function
				    var bValid;
				    bValid = true;*/
					/*var country=getSelectValue(document.getElementById(daform.Contact_Country);
					
					Add call to Trim() TEG 12/7/2005. See FormChk.js for this fn
					
					if (!isZIPCode(Trim(document.daform.Contact_ZipCode.value)) && (country=='USA'))
						{
							alert("You must provide a valid Zip Code since you indicated you live in the USA");
							return false; 
						}
					
					if (!isEmpty(document.daform.Contact_ZipCode.value) && (country!='USA')) 
						{
							alert("You have data in the Zip Code field but you indicated you live outside the USA.\n Please correct this inconsistency.");
							return false; 
						}
					*/					
					if (document.getElementById(MasterContentId + 'RespondByMail').checked == false 
						&&
						document.getElementById(MasterContentId + 'RespondByPhone').checked == false
						&&
						document.getElementById(MasterContentId + 'RespondByEmail').checked == false
						&&
						document.getElementById(MasterContentId + 'RespondByLocal').checked == false
						&&
						document.getElementById(MasterContentId + 'ProvideNewsLetter').checked == false)
						{
							alert("Please select a checkbox indicating how you would like us to respond.");
							return false;
							//bValid = false;
						}
					if ((document.getElementById(MasterContentId + 'RespondByEmail').checked || document.getElementById(MasterContentId + 'ProvideNewsLetter').checked) && (!isEmail(document.getElementById(MasterContentId + 'Email').value))) 
						{
							alert("You must provide a valid Email so that we may respond via Email or send a News Letter.");
							return false;
							//bValid = false;
						}
				    
				    var HomePhoneInput = document.getElementById(MasterContentId + 'HomePhone');//.value;
					
					if ((document.getElementById(MasterContentId + 'RespondByPhone').checked) && (!checkUSPhone(HomePhoneInput,false))) 
						{
							alert("You must provide a valid phone number so that we may respond via phone.");
							if(document.getElementById('PhoneError') )
							{
							document.getElementById('PhoneError').innerHTML = '<br />Please provide a phone number';
							}
							return false;
							//bValid = false;
						}
					//08/31/2009 Validation is not working correctly.  Should display error if line1 is empty.
					//Address can't be determined without line 1
					/*if (    document.getElementById(MasterContentId + 'RespondByMail').checked 
					        && 
					        (
					            isEmpty(document.getElementById(MasterContentId + 'L1P').value) 
					            && 
					            isEmpty(document.getElementById(MasterContentId + 'ZipP').value)
					        )
					        &&
					        (
					            isEmpty(document.getElementById(MasterContentId + 'L1P').value) 
					            && 
					            isEmpty(document.getElementById(MasterContentId + 'CityP').value) 
					            && 
					            isEmpty(document.getElementById(MasterContentId + 'StateP').value)
					        )
					   ) 
						{
							alert("You must provide an address so that we may respond via mail.");
							return false;
						}*/
					
					if (    (document.getElementById(MasterContentId + 'RespondByMail').checked )
					        && 
					        (isEmpty(document.getElementById(MasterContentId + 'L1P').value))
					        && 
					        (
					        (isEmpty(document.getElementById(MasterContentId + 'ZipP').value))
					            ||
					        (isEmpty(document.getElementById(MasterContentId + 'CityP').value) 
					            && 
					        isEmpty(document.getElementById(MasterContentId + 'StateP').value))
					        ) 
					    )
						{
							alert("You must provide an address so that we may respond via mail.");
							return false;
							//bValid = false;
						}
					/*
					   No validation if RespondByEmail is not selected.													
					if (!isEmpty(document.getElementById(MasterContentId + 'Email').value) && (!isEmail(document.getElementById(MasterContentId + 'Email').value))) 
						{
						    / / isEmail() provides error message
							return false;
						}
					*/
					/*
					Zip code is required even if no mail response requested.
					*/
					/*08/04/09 TSchroeder require city and state, along with zip code*/
					if (isEmpty(document.getElementById(MasterContentId + 'ZipP').value) || isEmpty(document.getElementById(MasterContentId + 'CityP').value) || isEmpty(document.getElementById(MasterContentId + 'StateP').value))
					{
							alert("Please enter a city, state, and zip code.");
							return false;
							//bValid = false;
					}
					
					/*if (isEmpty(document.getElementById(MasterContentId + 'ZipP').value)) 
						{
						    alert('Please enter a ZIP code.')
							return false;
						}*/
					/* No validation if check box not set 
					if (!isEmpty(HomePhoneInput.value) && (!checkUSPhone(HomePhoneInput,false))) 
						{
							alert('Phone number is incomplete or invalid:' + HomePhoneInput.value);
							return false;
						}
					*/
					/* No validation w/o check box being set					
					if( 
					        (   
					            //  provides Line 1 but no zip or no city, state
					            !isEmpty(document.getElementById(MasterContentId + 'L1P').value) 
					            && (    
					                    isEmpty(document.getElementById(MasterContentId + 'ZipP').value) 
					                    && 
					                    (
					                        isEmpty(document.getElementById(MasterContentId + 'CityP').value) 
					                        || 
					                        isEmpty(document.getElementById(MasterContentId + 'StateP').value)
					                    ) 
					                )
					        )
					        ||
					        (
					            //zip, city or state but no line 1  // entry of Zip does not required completing address document.getElementById(MasterContentId + 'ZipP').value +
					            !isEmpty(document.getElementById(MasterContentId + 'StateP').value + document.getElementById(MasterContentId + 'CityP').value)
					            && isEmpty(document.getElementById(MasterContentId + 'L1P').value)
					        )
					   ) 
						{
							alert("Please complete your address entry.");
							return false;
						}
					*/
					if (isEmpty(document.getElementById(MasterContentId + 'LP_FirstName').value) || isEmpty(document.getElementById(MasterContentId + 'LP_LastName').value))
					{
							alert("Please enter both a first name and a last name.");
							return false;
							//bValid = false;
					}
					
			
					
				    /*
					var bboxck=0;
					if (Trim(document.daform.Contact_Address1.value) == "" && document.daform.respMail.checked)
						{
						bboxck = bboxck + 1;
						}
					if (Trim(document.daform.Contact_HomePhone.value) == "" && document.daform.respPhone.checked)
						{
						bboxck = bboxck + 3;
						}
					if (Trim(document.daform.Contact_Email.value) == "" && document.daform.respEmail.checked)
						{
						bboxck = bboxck + 5;
						}
					if (bboxck== 1)
						{	alert("If you would like us to mail you information please provide a complete street address including city, state and zip. If you are providing an international address, please be sure to select your country and provide your address information in the comments section. If you do not wish to submit your address over the internet, you can call 1-800-22-UNITE.");
							return false;
						}
					else 
					if (bboxck== 3) {
							alert("If you would like us to contact you by phone, please provide a phone number or call 1-800-22-UNITE.");
						 	return false;
							}
					else 
					if (bboxck== 5) {
							alert("If you would like us to email you information, please provide an email address or call 1-800-22-UNITE.");
							return false;
						 }
					else 
					if (bboxck == 4) {
							alert("If you would like us to contact you by mail or phone please fill in those fields or call 1-800-22-UNITE.");
							return false;
						 }
					else 
					if (bboxck== 6) {
							alert("If you would like us to contact you by email or postal mail, please fill in those fields.");
							return false;
						 }
					else 
					if (bboxck == 8) {
							alert("If you would like us to contact you by phone or email, please fill in those fields.");
							return false;
						  }
					if (bboxck == 9) {
							alert("If you would like us to contact you by phone, email or postal mail, please fill in those fields.");
							return false;
							}
					if (Trim(document.getElementById("fn").value) == '' || Trim(document.getElementById("ln").value) == '')
					{
							alert("Please enter both a first and last name.");
							return false;
					}
					*/
					//08/31/09 TSchroeder return true if validations pass
					
					return true;
					
				}
				//-->
		/*</script>*/
