$(document).ready(function() {
		
		
		$('.required').each(function(index) {	
									  var id = $(this).attr("id");
									   if( $(this).val().length < 2) {			
										$(this).removeClass("correct");} else {$(this).addClass("correct");
										}
									 
									 });
		$(".required").keyup(function() {
								 
								 id =  $(this).val();
								 
								 if( $(this).val().length > 2) {$(this).addClass("correct");} else {$(this).removeClass("correct");}								 								 
								 
								 
								 });
	

		$('#contact_form, #valuation_form').submit(function () { 										 
		
		$('.required').each(function(index) {	
		 error=0;
		 var id = $(this).attr("id");
    	 if( $(this).val().length == 0) {			
										alert("A required field has been left empty, the field will be highlighted with a red border.");
										$("#"+id).focus();										
										error=1
										return false;										
										}
	 
  		});
		
		if (error==0) {return true; }
			return false;								 
			
		});		
 
 
 		$('#enquiry_send_button').click(function () { 
												   
												   $('#info_form .required').each(function(index) {	
												 error=0;
												 var id = $(this).attr("id");
										    	 if( $(this).val().length == 0) {			
															alert("A required field has been left empty, the field will be highlighted with a red border. "+id);
															$("#"+id).focus();										
															error=1
															return false;										
															}
	 
  													});
											
											if (error==0) {$('#info_form').submit(); }
			return false;				
											

											
											});
		
		
		 		$('#friend_send_button').click(function () { 
												   
												  $('div.emailfriend .required').each(function(index) {	
												 error=0;
												 var id = $(this).attr("id");
										    	 if( $(this).val().length == 0) {			
															alert("A required field has been left empty, the field will be highlighted with a red border. 2");
															$("#"+id).focus();										
															error=1
															return false;										
															}
	 
  													});
											
											if (error==0) {$('#friend_form').submit(); }
			return false;				
											

											
											});
 
 
 
 });		
