$(document).ready(function() { 
    $('#content_middle a.lightboxLink').lightBox();
    
    //init form angebot
    if( $("#first_choice input[@name='value[customer_type]']:checked").val() == 'new' ) customer_new();
    else if( $("#first_choice input[@name='value[customer_type]']:checked").val() == 'exists' ) customer_exists();
}); 


function ajax_calculate()
{
    var param = $('#car_select_form').formSerialize();
  
    //ajax
    $.ajax({
        data: param,
        url: 'fileadmin/scripts/calculate.php',
        type: "GET",
        cache: false,
        success: function(html){
            $("#table_calculated").html(html);
    $("#calculateBox").slideDown("normal");
        }
    });
}

 
function customer_exists()
{
    $("#form_new").hide("slow"); 
    $("#form_exists").show("slow");
}                   

function customer_new()
{
    $("#form_exists").hide("slow"); 
    $("#form_new").show("slow");
    zip_check();
}

function zip_check()
{
    oZipCode = $("#zipCode");
    valZipCode = String( oZipCode.val() );
    if( $("#country").val() == "at" )
    {
        oZipCode.attr("maxlength",4);
        oZipCode.val(valZipCode.substr(0,4));
    }
    else $("#zipCode").attr("maxlength",5);
}