$(document).ready(function(){
    $("input[name*='contact-form-type']").live('change',(function(){
        var typeForm = $(this).val();
        switch(typeForm){
            case 'tech':
                hideBudgetOptions();
                //showComments();
                break;
            case 'demo':
                hideBudgetOptions();
                //showComments();
                break;
            case 'budget':
                //hideComments();
                showBudgetOptions();
                break;
        }
    }));    
    
    $("button#contact-form-send").live('click',function(){
        if($("#contact-form-email").val().length<3){
            if(lang=='esp') alert('Introducir un email válido por favor');
            if(lang=='eng') alert('Please enter a valid email');
            return false;
        }
        if($("input[name='contact-form-type']:checked").val()==null){
            if(lang=='esp') alert('Por favor elija una opción: Soporte técnico, vuelo de demostracion, presupuesto');
            if(lang=='eng') alert('Please choose an option: Technical questions, demo flight, budget');
            return false;
        }
        
        $(this).html('SENDING...');
        $.ajax({
            type: "POST",
            url: baseUrl + "/contact/ajax-submit",
            data: {
                email: $("#contact-form-email").val(),
                country: $("#contact-form-country").val(),
                type: $("input[name*='contact-form-type']:checked").val(),
                cockpit: $("input[name*='contact-form-cockpit']:checked").val(),
                instructor: $("input[name*='contact-form-instructor']:checked").val(),
                comments: $("#contact-form-comments").val(),
                kindInstruments: $("input[name*='contact-form-digital']:checked").val()
            },
            success: function(data){
                window.location.href = baseUrl + '/contact/success';
            }

        });
        
    });
    $("button#contact-form-send-complete").live('click',function(){
        $(this).html('SENDING...');
        $.ajax({
            type: "POST",
            url: baseUrl + "/contact/ajax-submit-complete",
            data: {
                name:$("#contact-form-name").val(),
                lastName:$("#contact-form-last-name").val(),
                address:$("#contact-form-address").val(),
                city:$("#contact-form-city").val(),
                zipCode:$("#contact-form-zip").val(),
                phone:$("#contact-form-phone").val(),
                receiveCall:$("input[name*='contact-form-receive-call']:checked").val()
                    
            },
            success: function(data){
                window.location.href = baseUrl + '/contact/finish';
            }

        });
        
    });    
    $("form#contact-form").live('submit',function(){
        return false;
    })
});

var showComments = function(){
    $("div.row-contact-form-comments").show(100);
}
var hideComments = function(){
    $("div.row-contact-form-comments").hide(100);
}

var showBudgetOptions = function(){
    $("div#content div.staticPage").animate({
       minHeight: '675' 
    },200);
    $("div.row-contact-form-cockpit").show(100);
    $("div.row-contact-form-instructor").show(100);
}
var hideBudgetOptions = function(){
    $("div#content div.staticPage").animate({
       minHeight: '485' 
    },200);    
    $("div.row-contact-form-cockpit").hide(100);
    $("div.row-contact-form-instructor").hide(100);
}


