// JavaScript Document
jQuery(document).ready(function() {
	
	var validator = jQuery("#planner").validate({
		rules: {
			roomwidth: {
				required: true,
				number: true
			},
			roomlength: {
				required: true,
				number: true
			},
			first_select: "required",
			second_select: "required"
		},
		messages: {
			roomwidth: {
				required: "Please enter the room width in mm",
				number: "Please enter a number"
			},
			roomlength: {
				required: "Please enter the room length in mm",
				number: "Please enter a number"
			},
			first_select: "Please select the flooring type",
			second_select: "Please select the product"
		},

        // the errorPlacement has to take the table layout into account 
        errorPlacement: function(error, element) { 
            if ( element.is(":radio") ) {
                error.appendTo( element.parent() );
			} else {
				error.appendTo( element.next() );
			}
        }

	});
	
	$("#btn").click(function() {
  		if(validator.form()){
			//alert('form ok');
			processData();
		}
	});
	
});

