function showForm(){
  if($('input[name=radio]:checked').val() != null){

    $("#default").css("display", "none");
   
    if($('input[name=radio]:checked').val() == "option1"){
      $("input[name=selected_option]").val("option1");
      
      $("#option1").css("display", "block");
      $("#contactForm").attr("action","option1.php");
    }
    if($('input[name=radio]:checked').val() == "option2"){
      $("input[name=selected_option]").val("option2");
      $("#option2").css("display", "block");
      $("#contactForm").attr("action","option2.php"); 
    }
    if($('input[name=radio]:checked').val() == "option3"){
      $("input[name=selected_option]").val("option3");
      $("#option3").css("display", "block");
      $("#contactForm").attr("action","option3.php"); 
    }
    if($('input[name=radio]:checked').val() == "option4"){
      $("input[name=selected_option]").val("option4");
      $("#option4").css("display", "block");
      $("#contactForm").attr("action","option4.php"); 
    }
    if($('input[name=radio]:checked').val() == "option5"){
      $("input[name=selected_option]").val("option5");
      $("#option5").css("display", "block");
      $("#contactForm").attr("action","option5.php"); 
    }
     if($('input[name=radio]:checked').val() == "option6"){
      $("input[name=selected_option]").val("option6");
      $("#option6").css("display", "block");
      $("#contactForm").attr("action","option6.php"); 
    }
   
    $("#lado22").css("display", "block");
    $("#lado22a").css("display", "none");
    
  }else{
    
    $('#optionAdvice').html("Deve seleccionar uma opcção!");
  }
}
$.validator.setDefaults({
  submitHandler: function() { /*alert("submitted!");*/ }
});

// wait for the DOM to be loaded 
$(document).ready(function() {
  // bind 'myForm' and provide a simple callback function 
  var options = {
    target: '#advice', // target element(s) to be updated with server response
    beforeSubmit: function() {
            return $('#contactForm').validate({
          		rules: {
          			name: {
                  required: true,
			           	minlength: 2
                },
                email: {
          				required: true,
          				email: true
          			},
                gender: {
          				required: true
          			},
          			day: {
          				required: true
          			},
          			month: {
          				required: true
          			},
          			year: {
          				required: true
          			},
          			postalcode1: {
          				required: true,
          				digits: true,
          				minlength: 4
          			},
          			postalcode2: {
          				required: true,
          				digits: true,
          				minlength: 3
          			}
          			
              },
              errorElement: "div"
              }).form()
          },// pre-submit callback // this is a callback function to prevent form of beeing submited or call showRequest, 
        
    success: showResponse // post-submit callback
    
    // other available options:
    //url: 'test.php' // override for form's 'action' attribute //type: type // 'get' or 'post', override for form's 'method' attribute
    //dataType: null // 'xml', 'script', or 'json' (expected server response type)
    //clearForm: true // clear all form fields after successful submit
    //resetForm: true // reset the form after successful submit
    
    // $.ajax options can be used here too, for example:
    //timeout: 3000
  };
  // bind to the form's submit event
  $('#contactForm').submit(function() {
    // inside event callbacks 'this' is the DOM element so we first
    // wrap it in a jQuery object and then invoke ajaxSubmit 
    $(this).ajaxSubmit(options);
    
    // !!! Important !!!
    // always return false to prevent standard browser submit and page navigation
    return false;
  });

  // pre-submit callback
  function showRequest(formData, jqForm, options) {
    // formData is an array; here we use $.param to convert it to a string to display it
    // but the form plugin does this for you automatically when it submits the data
    var queryString = $.param(formData);
    
    // jqForm is a jQuery object encapsulating the form element. To access the
    // DOM element for the form do this:
    // var formElement = jqForm[0];
    
    //alert("You are sendind this data to server "+queryString);
   
    
    $('#advice').append("You are sendind this data to server "+queryString);
    
    // here we could return false to prevent the form from being submitted;
    // returning anything other than false will allow the form submit to continue
    return true;
  }

  // post-submit callback
  function showResponse(responseText, statusText) {
    // for normal html responses, the first argument to the success callback
    // is the XMLHttpRequest object's responseText property
    
    // if the ajaxForm method was passed an Options Object with the dataType
    // property set to 'xml' then the first argument to the success callback
    // is the XMLHttpRequest object's responseXML property
    
    // if the ajaxForm method was passed an Options Object with the dataType
    // property set to 'json' then the first argument to the success callback
    // is the json data object returned by the server
    
    //$('#advice').append("answer "+responseText);
  }



});
