

function validate(form){
	var errormessage = '';
	var elem_surname = document.getElementById("err_surname");		
	var elem_firstname = document.getElementById("err_firstname");
	var elem_house = document.getElementById("err_house");
	var elem_district = document.getElementById("err_district");
	var elem_street = document.getElementById("err_street");
	var elem_city = document.getElementById("err_city");
	var elem_county = document.getElementById("err_county");
	var elem_postcode = document.getElementById("err_postcode");
	var elem_dob = document.getElementById("err_dob");
	var elem_sex = document.getElementById("err_sex");	
	var elem_hometel = document.getElementById("err_hometel");
	var elem_mobtel = document.getElementById("err_mobtel");
	var elem_faxtel = document.getElementById("err_faxtel");
	var elem_prompt = document.getElementById("err_prompt");
	
		if(document.myform.Inp_customerSurnameAnswer.value =='')
   				{
     		    			document.myform.Inp_customerSurnameAnswer.focus();					
					errormessage=errormessage + 'Please enter your Surname \n'; 				
					elem_surname.style.display = '';					
					document.myform.Inp_customerSurnameAnswer.style.background = 'MistyRose'; 								    		    
    				}
				else{
					elem_surname.style.display = 'none';
					document.myform.Inp_customerSurnameAnswer.style.background = '#ffffff'; 											
				}		
					 
					
		if(document.myform.Inp_customerFirstNameAnswer.value =='')
   					{
     		    	document.myform.Inp_customerFirstNameAnswer.focus();
     		   			errormessage=errormessage + 'Please enter your First Name \n'; 
					elem_firstname.style.display = ''; 	
					document.myform.Inp_customerFirstNameAnswer.style.background = 'MistyRose'; 								    		    
	    
    				}
				else{
					elem_firstname.style.display = 'none';	
					document.myform.Inp_customerFirstNameAnswer.style.background = '#ffffff'; 												
				}		

					
		if(document.myform.Inp_customerAddressHouseNoAnswer.value =='')
   					{
     		    	document.myform.Inp_customerAddressHouseNoAnswer.focus();
     		   			errormessage=errormessage + 'Please enter your house number or house name \n';
					elem_house.style.display = '';     
					document.myform.Inp_customerAddressHouseNoAnswer.style.background = 'MistyRose'; 								    		    
  		    
    				}
				else{
					elem_house.style.display = 'none';	
					document.myform.Inp_customerAddressHouseNoAnswer.style.background = '#ffffff'; 								    		    										
				}		
					
		//LIVE DATE CHECKS
    
    					if(DDMMYYYYValid(document.myform.Inp_customerDobDayAnswer.value, document.myform.Inp_customerDobMonthAnswer.value, document.myform.Inp_customerDobYearAnswer.value) == false)
    						{							
    							errormessage=errormessage + "Please enter a valid date of birth \n";
							elem_dob.style.display = '';     
							document.myform.Inp_customerDobDayAnswer.style.background = 'MistyRose'; 	
    							document.myform.Inp_customerDobMonthAnswer.style.background = 'MistyRose'; 	
							document.myform.Inp_customerDobYearAnswer.style.background = 'MistyRose'; 	
						}
						else{
							elem_dob.style.display = 'none';	
							document.myform.Inp_customerDobDayAnswer.style.background = '#ffffff'; 	
    							document.myform.Inp_customerDobMonthAnswer.style.background = '#ffffff'; 	
							document.myform.Inp_customerDobYearAnswer.style.background = '#ffffff'; 								    		    										
				}		
								
		
				
		if(document.myform.Inp_customerAddressStreetAnswer.value =='')
   			{
     		    	document.myform.Inp_customerAddressStreetAnswer.focus();
     		   			errormessage=errormessage + 'Please enter your Street name \n';   
					elem_street.style.display = '';
					document.myform.Inp_customerAddressStreetAnswer.style.background = 'MistyRose'; 								    		    
        		    
    				}
				else{
					elem_street.style.display = 'none';	
					document.myform.Inp_customerAddressStreetAnswer.style.background = '#ffffff'; 								    		    										
				}		

					
			if(document.myform.Inp_customerAddressCityAnswer.value =='')
   					{
     		    			document.myform.Inp_customerAddressCityAnswer.focus();
     		   			errormessage=errormessage + 'Please enter a Town or City \n'; 
					elem_city.style.display = '';
     		    			document.myform.Inp_customerAddressCityAnswer.style.background = 'MistyRose'; 		
    				}
				else{
					elem_city.style.display = 'none';	
					document.myform.Inp_customerAddressCityAnswer.style.background = '#ffffff'; 								    		    										
				}	



			if(document.myform.customerAddressCountyAnswer.value =='')
   					{
     		    	document.myform.customerAddressCountyAnswer.focus();
     		   			errormessage=errormessage + 'Please enter a county \n'; 
					elem_county.style.display = '';
     		    			document.myform.customerAddressCountyAnswer.style.background = 'MistyRose'; 		
    				}
				else{
					elem_county.style.display = 'none';	
					document.myform.customerAddressCountyAnswer.style.background = '#ffffff'; 								    		    										
				}	

			if(document.myform.customerAddressPostcodeInnerAnswer.value == '')   {
							
     		    			document.myform.customerAddressPostcodeInnerAnswer.focus();
     		   			errormessage=errormessage + 'Please enter a postcode \n'; 
					elem_postcode.style.display = '';
     		    			document.myform.customerAddressPostcodeInnerAnswer.style.background = 'MistyRose'; 		
    				}
				else{	
					if(postcodeValid(document.myform.customerAddressPostcodeInnerAnswer)==false)  {
						
						document.myform.customerAddressPostcodeInnerAnswer.focus();
     		   				errormessage=errormessage + 'Please enter a postcode \n'; 
						elem_postcode.style.display = '';
     		    				document.myform.customerAddressPostcodeInnerAnswer.style.background = 'MistyRose'; 		
					}				
					else {					
 						
						elem_postcode.style.display = 'none';
     		    				document.myform.customerAddressPostcodeInnerAnswer.style.background = '#ffffff'; 		
    					}

				}			
					
			if(document.myform.customerTelephoneHomeCodeAnswer.value != '' || document.myform.Inp_customerTelephoneHomeNumberAnswer.value != '')
   			{ 				
					if(checkNumeric(document.myform.customerTelephoneHomeCodeAnswer.value)==false || checkNumeric(document.myform.Inp_customerTelephoneHomeNumberAnswer.value)==false )
   					{
     		    			document.myform.customerTelephoneHomeCodeAnswer.focus();
     		    			errormessage=errormessage + 'Please enter a valid area code - Numerical input only \n';
					elem_hometel.style.display = '';
					document.myform.customerTelephoneHomeCodeAnswer.style.background = 'MistyRose'; 
					document.myform.Inp_customerTelephoneHomeNumberAnswer.style.background = 'MistyRose'; 		
    				}	
				else{
					elem_hometel.style.display = 'none';	
					document.myform.customerTelephoneHomeCodeAnswer.style.background = '#ffffff'; 
					document.myform.Inp_customerTelephoneHomeNumberAnswer.style.background = '#ffffff'; 		
    				}
				 						    		    										
			}	
			else{
					elem_hometel.style.display = 'none';	
					document.myform.customerTelephoneHomeCodeAnswer.style.background = '#ffffff'; 
					document.myform.Inp_customerTelephoneHomeNumberAnswer.style.background = '#ffffff'; 
			}			


					
			if(document.myform.customerTelephoneMobNumberAnswer.value != '')
   			{ 				
					if(checkNumeric(document.myform.customerTelephoneMobNumberAnswer.value)==false )
   					{
     		    			document.myform.customerTelephoneMobNumberAnswer.focus();
     		    			errormessage=errormessage + 'Please enter a valid area code - Numerical input only \n';
					elem_mobtel.style.display = '';
					document.myform.customerTelephoneMobNumberAnswer.style.background = 'MistyRose'; 		
    				}	
				else{
					elem_mobtel.style.display = 'none';	
					document.myform.customerTelephoneMobNumberAnswer.style.background = '#ffffff'; 		
    				}
				 						    		    										
			}	
			else{
					elem_mobtel.style.display = 'none';						
					document.myform.customerTelephoneMobNumberAnswer.style.background = '#ffffff'; 
			}


			////////////////////////////////////////////////////////////////////////////


			if(document.myform.customerTelephoneFaxCodeAnswer.value != '' || document.myform.customerTelephoneFaxNumberAnswer.value != '')
   			{ 				
					if(checkNumeric(document.myform.customerTelephoneFaxCodeAnswer.value)==false || checkNumeric(document.myform.customerTelephoneFaxNumberAnswer.value)==false )
   					{
     		    			document.myform.customerTelephoneFaxCodeAnswer.focus();
     		    			errormessage=errormessage + 'Please enter a valid area code - Numerical input only \n';
					elem_faxtel.style.display = '';
					document.myform.customerTelephoneFaxCodeAnswer.style.background = 'MistyRose'; 
					document.myform.customerTelephoneFaxNumberAnswer.style.background = 'MistyRose'; 		
    					}	
				
					else
					{
					elem_faxtel.style.display = 'none';	
					document.myform.customerTelephoneFaxCodeAnswer.style.background = '#ffffff'; 
					document.myform.customerTelephoneFaxNumberAnswer.style.background = '#ffffff'; 		
    					}
				 						    		    										
			}	
			else{
					elem_faxtel.style.display = 'none';	
					document.myform.customerTelephoneFaxCodeAnswer.style.background = '#ffffff'; 
					document.myform.customerTelephoneFaxNumberAnswer.style.background = '#ffffff'; 
			}


					
								
    if(errormessage != '') {
					elem_prompt.style.color = 'red';    					  	   
    				}
				else {
					elem_prompt.style.color = '#0038A8';    
					document.myform.submit();  	 
				}  
					
    				
}

function valReset(form){
	var elem_surname = document.getElementById("err_surname");		
	var elem_firstname = document.getElementById("err_firstname");
	var elem_house = document.getElementById("err_house");
	var elem_district = document.getElementById("err_district");
	var elem_street = document.getElementById("err_street");
	var elem_city = document.getElementById("err_city");
	var elem_county = document.getElementById("err_county");
	var elem_postcode = document.getElementById("err_postcode");
	var elem_dob = document.getElementById("err_dob");
	var elem_sex = document.getElementById("err_sex");	
	var elem_hometel = document.getElementById("err_hometel");
	var elem_mobtel = document.getElementById("err_mobtel");
	var elem_faxtel = document.getElementById("err_faxtel");
	var elem_prompt = document.getElementById("err_prompt");

	elem_prompt.style.color = '#0038A8';    
	elem_faxtel.style.display = 'none';	
	document.myform.customerTelephoneFaxCodeAnswer.style.background = '#ffffff'; 
	document.myform.customerTelephoneFaxNumberAnswer.style.background = '#ffffff'; 
	elem_mobtel.style.display = 'none';	
	document.myform.customerTelephoneMobNumberAnswer.style.background = '#ffffff'; 
	elem_hometel.style.display = 'none';	
	document.myform.customerTelephoneHomeCodeAnswer.style.background = '#ffffff'; 
	document.myform.Inp_customerTelephoneHomeNumberAnswer.style.background = '#ffffff'; 
	elem_postcode.style.display = 'none';
   document.myform.customerAddressPostcodeInnerAnswer.style.background = '#ffffff'; 
	elem_county.style.display = 'none';	
	document.myform.customerAddressCountyAnswer.style.background = '#ffffff'; 
	elem_city.style.display = 'none';	
	document.myform.Inp_customerAddressCityAnswer.style.background = '#ffffff'; 
	elem_street.style.display = 'none';	
	document.myform.Inp_customerAddressStreetAnswer.style.background = '#ffffff'; 
	elem_dob.style.display = 'none';	
	document.myform.Inp_customerDobDayAnswer.style.background = '#ffffff'; 	
   document.myform.Inp_customerDobMonthAnswer.style.background = '#ffffff'; 	
	document.myform.Inp_customerDobYearAnswer.style.background = '#ffffff'; 
	elem_house.style.display = 'none';	
	document.myform.Inp_customerAddressHouseNoAnswer.style.background = '#ffffff'; 
	elem_firstname.style.display = 'none';	
	document.myform.Inp_customerFirstNameAnswer.style.background = '#ffffff'; 
	elem_surname.style.display = 'none';
	document.myform.Inp_customerSurnameAnswer.style.background = '#ffffff';        									
}