

function getData(){
    return jQuery("form#mcformf").serialize();
}

function createPostCallback(){
    var data = getData();
    jQuery.post("/formmc", data, function(data){
        if(data=="error"){
            jQuery("#mcform .errors").show();
            alert("The postcode entered is not valid or has not been found on our system. Please try again.");
            return false;
        }

        //var me = ;
        jQuery("#mcform").hide();
        jQuery("#mcres").show();
        //alert(data);
        jQuery("#mcres").replaceWith(jQuery(data));
        jQuery("#startagain").click(function(){
            location.reload(true);
        });
    }, "html");
}
jQuery(function(){
    var form = jQuery("form#mcformf");
    form.submit(function(){
        if(jQuery("input[name=from]",form).val() != "" && jQuery("input[name=to]",form).val() != ""){
            //alert("HEllo");
            createPostCallback();
            return false;
        }
        return false;
    });

});


