$(document).ready(function(){

    if($("div#posts").length > 0){
        $("div#posts .post").each(function(){
            var leftElm = $(this).find(".row3 .left");
            var rightElm = $(this).find(".row3 .right");
            if(rightElm.height() > leftElm.height()){
                leftElm.height(rightElm.height());
            }
        });
    }

    //register and recover password forms
    $(".modalform .form input").focus(function(){
        $(this).nextAll(".alt").show();
        $(this).nextAll(".error").hide();
    });

    $(".modalform .form input").blur(function(){
        $(this).nextAll(".alt").hide();
        //$(this).nextAll(".error").show();
    });

    $(".registerFormLink").click(function(){
        $(".modalform").hide();
        $("#registerForm").show();
        return false;
    });

    $(".recoverFormLink").click(function(){
        $(".modalform").hide();
        $("#recoverForm").show();
        return false;
    });

    $(".loginFormLink").click(function(){
        $(".modalform").hide();
        $("#loginForm").show();
        return false;
    });

    $("#recover_close").click(function(){
        $("#recoverForm").hide();
        return false;
    });

    $("#registration_close").click(function(event){
        $("#registerForm").hide();
        return false;
    });

    $("#login_close").click(function(event){
        $("#loginForm").hide();
        return false;
    });

    $(".button .disabled-login").click(function(){
        customAlert('Това действие изисква да сте влезли в профила си!', 3);
        return false;
    });

    // visual feedback
    var loginFeedback = $("#jsFeedback");
    var loginFeedbackText = loginFeedback.text();
    if(loginFeedbackText != ''){
        var classname = loginFeedback.get(0).className;
        var type = parseInt(classname.replace('error_type_', ''));
        customAlert(loginFeedbackText, type);
    }

    $("#checkAll").change(function(){
        if($(this).attr("checked") == true){
            $(".controlled_check").attr("checked", true);
        }else{
            $(".controlled_check").attr("checked", false);
        }
    });

});
