isLoading = function(b){
    if(b)$("#progress").fadeIn('fast');
    else $("#progress").fadeOut('fast');
    $("input[type=submit]").attr("disabled", b);
};
preRequest = function(){isLoading(true)};
callback2 = function(res){
    try {
        if(res.type == "login"){
            if(res.success == "true" && res.redirect != null){
                window.location = res.redirect;
            }
            else alert("Login e/ou senha inválido(s).");
        }
    }
    catch(e){alert(data);}
    isLoading(false);
};
$(document).ready(function(){
    $(".ax").ajaxForm({dataType:'json',beforeSubmit:preRequest,success:callback2});
    $(".btn").hover(
        function(){
            var ref = $(this).attr("src");
            $(this).attr("src", ref.replace(/\.(jpg|gif)/gi, "-over.$1"));
        },
        function(){
            var ref = $(this).attr("src");
            $(this).attr("src", ref.replace("-over", ""));
        }
    );
    $("#boxTestemunhos li.item a").click(function(){
        var rel = $(this).attr("rel");
        $("#boxTestemunhos .container div").css("display", "none");
        $("#tst"+rel).fadeIn();
        $("#boxTestemunhos li.item a").removeClass("selected");
        $(this).addClass("selected");
        return false;
    });
    $("#boxCanalNoticias li.item a").click(function(){
        var rel = $(this).attr("rel");
        $("#boxCanalNoticias .container div p").css("display", "none");
        $("#ne"+rel).fadeIn();
        $("#boxCanalNoticias li.item").removeClass("selected");
        $(this).parent().addClass("selected");
        return false;
    });
});