
 $("#form2_button").click(function() {
      $("#form2_content").slideToggle("slow");
    });


 $('#form2_close').click(function(){$('#form2_content').slideUp("slow")});

 $('#preventivo1').click(function(){
     $('#form_1').hide();
     $('#operation_progress1').show();
     registration('1');
 });

 $('#ric_preventivo2').click(function(){
     $('#form_2').hide();
     $('#operation_progress2').show();
     registration('2');
 });

//bottoni della pagina richieste
$('#preventivo1_button').click(function(){
    $('#preventivo1_ric table').hide();
    $('#operation_progress1').show();
    ric_registration('1');
});
$('#preventivo2_button').click(function(){
    $('#preventivo2_ric table').hide();
    $('#operation_progress2').show();
    ric_registration('2');
});
$('#richiesta_button').click(function(){
    $('#preventivo3_ric table').hide();
    $('#operation_progress3').show();
    ric_registration('3');
});


function registration(value){
    data=$('#form_'+value+'').serialize();
    $.ajax({
        url:'actions.php',
        type:'post',
        data:'action=go&'+data,
        success:function(response){
        $('#operation_progress'+value).hide();
            if(response == ''){
                $('#success'+value).show();
            }else{
                $('#fail'+value).html(response).show();
            }
        setTimeout('showForm('+value+')', 5000);

        }
    });
}

function ric_registration(value){
    data=$('#preventivo'+value+'_ric').serialize();
    $.ajax({
        url:'actions.php',
        type:'post',
        data:'action=go&'+data,
        success:function(response){
        $('#operation_progress'+value).hide();
            if(response == ''){
                $('#success'+value).show();
            }else{
                $('#fail'+value).html(response).show();
            }
        setTimeout('showFormRic('+value+')', 5000);

        }
    });
}

function showForm(value){
    $('#success'+value).hide();
    $('#fail'+value).hide();
    $('#form_'+value).show();    
}

function showFormRic(value){
    $('#success'+value).hide();
    $('#fail'+value).hide();
    $('#preventivo'+value+'_ric table').show();
}

$(document).ready(
    function(){
        $('#accordion').accordion({autoHeight:true});
    });
