$(document).ready(function(){
        $('#contactform').submit(function(){
                action = $(this).attr('action');

                $('#submit').after('<img src="/tmp/loading.gif" style="position:absolute;margin:3px 0px 0px 5px;width:20px;height:20px;">')
                                        .attr('disabled','disabled');

                $("input,textarea").removeClass("error");

                $.post(action,$("#contactform").serialize(),function(data){
                        if(data=='Ok') {
                                $('#contactform').slideUp(600,function(){
                                        $(".success").fadeIn(600)
                                });
                        } else if(data=='Error_1') {
                                $('input#fbname').animate({opacity:"0"},200).addClass("error").animate({opacity:"1"},200).animate({opacity:"0"},200).animate({opacity:"1"},200);
                        } else if(data=='Error_2') {
                                $('input#fbemail').animate({opacity:"0"},200).addClass("error").animate({opacity:"1"},200).animate({opacity:"0"},200).animate({opacity:"1"},200);
                        } else if(data=='Error_3') {
                                $('input#fbtitle').animate({opacity:"0"},200).addClass("error").animate({opacity:"1"},200).animate({opacity:"0"},200).animate({opacity:"1"},200);
                        } else if(data=='Error_4') {
                                $('textarea#fbmessage').animate({opacity:"0"},200).addClass("error").animate({opacity:"1"},200).animate({opacity:"0"},200).animate({opacity:"1"},200);
                        }
                        $('#contactform #submit').attr('disabled','');
                        $('#contactform img.loading').fadeOut(500,function(){$(this).remove()});
                });

        return false;
        });
});