	
$(document).ready(function() {
						   
				 

$("#send_button").attr('disabled', 'disabled');
//$("input#name").focus();
submit_check();



$("#contact_form").submit(function() {
if( $("#fname").val().length < 3 ) {alert("Your first name is either missing or is too short!"); $("input#fname").focus(); return false;}
if( $("#lname").val().length < 3 ) {alert("Your last name is either missing or is too short!"); $("input#lname").focus(); return false;}
//if( $("#company_name").val().length < 3 ) {alert("Your company name is either missing or is too short!"); $("input#company_name").focus(); return false;}	
//if( $("#einno").val().length < 3 ) {alert("Your EIN Number is either missing or is too short!"); $("input#einno").focus(); return false;}	
if( $("#email").val().length < 3 ) {alert("Your email address is either missing or is too short!"); $("input#email").focus(); return false;}	
if( $("#emailcon").val().length < 3 ) {alert("Your email address is either missing or is too short!"); $("input#emailcon").focus(); return false;}
if( $("#phone").val().length < 3 ) {alert("Your telephone number is either missing or is too short!"); $("input#phone").focus(); return false;}

var spamcode= $("#spam").val().toLowerCase(); 
if( spamcode !="7jqm9" ) {alert("You need to enter the anti spam code!"); $("input#spam").focus(); return false;}
					//alert("Form Validation Passed");			   
						return true;	
							//alert ("Form Submitted !"); 	return false; // remove this line after testing, remove comments from remeove  true
								   });




function submit_check(){ 
//alert("checking form"); 
var points=0;
								
						if ( $("#country").val().length >2 ) {$("#country").addClass("correct"); points=points+1; } 
						else {$("#country").addClass("required"); $("#send_button").attr('disabled', 'disabled');}
						
						if ( $("#fname").val().length >2 ) {$("#fname").addClass("correct"); points=points+1; } 
						else {$("#fname").addClass("required"); $("#send_button").attr('disabled', 'disabled');}
						
						if ( $("#lname").val().length >2 ) {$("#lname").addClass("correct"); points=points+1; } 
						else {$("#lname").addClass("required"); $("#send_button").attr('disabled', 'disabled');}
						
						if ( $("#title").val().length >1 ) {$("#title").addClass("correct"); points=points+1; } 
						else {$("#title").addClass("required"); $("#send_button").attr('disabled', 'disabled');}
						
						//if ( $("#company_name").val().length >1 ) {$("#company_name").addClass("correct"); points=points+1; } 
						//else {$("#company_name").addClass("required"); $("#send_button").attr('disabled', 'disabled');}
						
						if ( $("#state").val().length >1 ) {$("#state").addClass("correct"); points=points+1; } 
						else {$("#state").addClass("required"); $("#send_button").attr('disabled', 'disabled');}
						
						//if ( $("#einno").val().length >2 ) {$("#einno").addClass("correct"); points=points+1; } 
						//else {$("#einno").addClass("required"); $("#send_button").attr('disabled', 'disabled');}
						
						//if ( $("#address").val().length >10 ) {$("#address").addClass("correct"); points=points+1; } 
						//else {$("#address").removeClass("correct"); $("#address").addClass("required"); $("#send_button").attr('disabled', 'disabled');}

						//if ( $("#town").val().length >2 ) {$("#town").addClass("correct"); points=points+1; } 
						//else {$("#town").addClass("required"); $("#send_button").attr('disabled', 'disabled');}
						
						//if ( $("#postcode").val().length >5 ) {$("#postcode").addClass("correct"); points=points+1; } 
						//else {$("#postcode").removeClass("correct"); $("#postcode").addClass("required"); $("#send_button").attr('disabled', 'disabled');}
						
						//if ( $("#einno").val().length >2 ) {$("#einno").addClass("correct"); points=points+1; } 
						//else {$("#einno").removeClass("correct"); $("#einno").addClass("required"); $("#send_button").attr('disabled', 'disabled');}
						
						if ( $("#phone").val().length >5 ) {$("#phone").addClass("correct"); points=points+1; } 
						else {$("#phone").removeClass("correct"); $("#phone").addClass("required"); $("#send_button").attr('disabled', 'disabled');}
						
						//if ( $("#fax").val().length >5 ) {$("#fax").addClass("correct"); points=points+1; } 
						//else {$("#fax").removeClass("correct"); $("#fax").addClass("required"); $("#send_button").attr('disabled', 'disabled');}
						
						if ( $("#email").val().length >5 ) {$("#email").addClass("correct"); points=points+1;} 
						else {$("#email").removeClass("correct"); $("#email").addClass("required"); $("#send_button").attr('disabled', 'disabled');}
						
						if ( $("#emailcon").val().length >5 ) {$("#emailcon").addClass("correct"); points=points+1;} 
						else {$("#emailcon").removeClass("correct"); $("#emailcon").addClass("required"); $("#send_button").attr('disabled', 'disabled');}
						
						if ($("#emailcon").val() != "" ){
								if ( $("#email").val() != $("#emailcon").val() ) {$("#emailcon").removeClass("correct");  $("#emailcon").addClass("required");
								$("#send_button").attr('disabled', 'disabled'); $("#required_emailcon").show(); return false;} else {$("#required_emailcon").hide(); }			
						
						}
						
						if ( $("#info").val().length >2 ) {$("#info").addClass("correct"); points=points+1;} 
						else {$("#info").removeClass("correct"); $("#info").addClass("required"); $("#send_button").attr('disabled', 'disabled');}
						
						var spamcode= $("#spam").val().toLowerCase();  //alert(spamcode);
						
						if (spamcode == "7jqm9") {$("#spam").addClass("correct"); points=points+1;} 
							else {$("#spam").removeClass("correct"); $("#spam").addClass("required"); $("#send_button").attr('disabled', 'disabled');}
						
		//alert("Validation points: "+points);				
						

if (points == 10){$("#send_button").removeAttr('disabled');}	
}

$("#fname, #lname, #title, #phone, #email, #emailcon, #info, #spam").keyup(function() { 						  						 
						 	if( $(this).val().length > 2) {$(this).removeClass("required"); $(this).addClass("correct");}
							else {$(this).removeClass("correct"); $(this).addClass("required");}
							submit_check();
							});


$("#country, #state, #service").change(function() {      
							if( $(this).val().length > 1) {$(this).removeClass("required"); $(this).addClass("correct"); }
							else {$(this).removeClass("correct"); $(this).addClass("required");}
							submit_check();									 
									 });

$("#clrfrm").click(function() {     							
		submit_check();	 //alert("clear form");	
		$("#fname, #lname, #title, #country, #state, #industry, #service, #phone, #email, #emailcon, #info, #spam").removeClass("correct");
		$("#fname, #lname, #title, #country, #state, #industry, #service, #phone, #email, #emailcon, #info, #spam").addClass("required");					
									 });


});