// Contents Cover Check Box & Text field control
function contentsBox(theBox){
  var theSpan = theBox.parentNode;
  theSpan = theSpan.getElementsByTagName("span")[0];
  theSpan.style.display=(theBox.checked)?"inline":"none";
  
  var textBox = document.getElementById("contents_cover");

  if(contentsBox.checked) {
    textBox.value = filtedNum(textBox.value);
  }else{
    textBox.value = "";
  }

};

// Personal Items Cover Check Box & Text field control
function personalBox(theBox){
  var theSpan = theBox.parentNode;
  theSpan = theSpan.getElementsByTagName("span")[0];
  theSpan.style.display=(theBox.checked)?"inline":"none";
  
  var textBox = document.getElementById("personal_cover");

  if(personalBox.checked) {
    textBox.value = filtedNum(textBox.value);
  }else{
    textBox.value = "";
  }

};

 $(function() {
	
  $(".submit").click(function() {
		// validate and process form
		// first hide any error messages
    
	  var Title = $("input#Title").val();
		if (Title == "") {
            alert('Please enter your Title!');
            $("input#Title").focus();
            return false;
        }

	  var Fname = $("input#Fname").val();
		if (Fname == "") {
            alert('Please enter your Forename!');
            $("input#Fname").focus();
            return false;
        }        

	  var Sname = $("input#Sname").val();
		if (Sname == "") {
            alert('Please enter your Surname!');
            $("input#Sname").focus();
            return false;
        }
        
	  var Dob = $("input#Dob").val();
		if (Dob == "") {
            alert('Please enter your Date of Birth!');
            $("input#Dob").focus();
            return false;
        }
        
 	  var Telno = $("input#Telno").val();
		if (Telno == "") {
            alert('Please enter your Telephone Number!');
            $("input#Telno").focus();
            return false;
        }
        
 	  var occupation = $("input#occupation").val();
		if (occupation == "") {
            alert('Please enter your Occupation!');
            $("input#occupation").focus();
            return false;
        }

  	  var firstTime_buyer = $("select#firstTime_buyer").val();
		if (firstTime_buyer == "") {
            alert('Are you a first time buyer?');
            $("select#firstTime_buyer").focus();
            return false;
        }
        
  	  var buildings_claims = $("select#buildings_claims").val();
		if (buildings_claims == "") {
            alert('Please complete number of claim free years for buildings insurance!');
            $("select#buildings_claims").focus();
            return false;
        }
        
  	  var contents_claims = $("select#contents_claims").val();
		if (contents_claims == "") {
            alert('Please complete number of claim free years for contents insurance!');
            $("select#contents_claims").focus();
            return false;
        }                 
        
 	  var property_type = $("select#property_type").val();
		if (property_type == "") {
            alert('Please select your Property Type!');
            $("select#property_type").focus();
            return false;
        }
 
  	  var post_code = $("input#post_code").val();
		if (post_code == "") {
            alert('Please enter your Post Code!');
            $("input#post_code").focus();
            return false;
        }
        
  	  var bedrooms = $("input#bedrooms").val();
		if (bedrooms == "") {
            alert('Please enter number of Bedrooms!');
            $("input#bedrooms").focus();
            return false;
        }

  	  var construct_yr = $("input#construct_yr").val();
		if (construct_yr == "") {
            alert('Please enter Approx year of Construction!');
            $("input#construct_yr").focus();
            return false;
        }   
        
  	  var buy_let = $("select#buy_let").val();
		if (buy_let == "") {
            alert('Please select your Buy to Let status!');
            $("select#buy_let").focus();
            return false;
        }
        
   	  var door_lock = $("select#door_lock").val();
		if (door_lock == "") {
            alert('Please select your Final exit door lock type!');
            $("select#door_lock").focus();
            return false;
        }
        
  	  var window_lock = $("select#window_lock").val();
		if (window_lock == "") {
            alert('Please select your Window lock type!');
            $("select#window_lock").focus();
            return false;
        }                
        
 });
});