var showRightpanel = function(){
    $('.l-rightpanel').unbind('click', showRightpanel);
    $('.l-rightpanel').bind('click', closeRightpanel);
    $('.l-rightpanel').stop().animate({width: '461'}, 'slow', function(){
        $('.l-rightpanel').addClass('act');
    });
};
var closeRightpanel = function(){
    $('.l-rightpanel').unbind('click', closeRightpanel);
    $('.l-rightpanel').bind('click', showRightpanel);
    $('.l-rightpanel').stop().animate({width: '41'}, 'slow', function(){
        $('.l-rightpanel').removeClass('act');
    });
};

$(function() {
    // Watermarks

    $('.b-input input, .b-input textarea').each(function (i) {
        if ($(this).val() == "") {
            $(this).prev("label").removeClass('hidden');
        };
    });

    $('.b-input input, .b-input textarea').focus(function () {
        $(this).prev("label").addClass('hidden');
    });
    $('.b-input input, .b-input textarea').blur(function () {
        if ($(this).val() == "")
            $(this).prev("label").removeClass('hidden');
    });

    // Dropdown

    $('.b-dropdown__value').click(function () {
        $(this).closest('.b-dropdown').addClass('opened');
    });

    $('.b-dropdown__catlist').mouseleave(function () {
        $(this).closest('.b-dropdown').removeClass('opened');
    });

    $('.b-dropdown__catlist li').click(function () {
        $(this).closest('.b-dropdown').removeClass('opened');
        $("div.dd-content").hide();
        var target = 'div#' + $(this).attr('id') + '-content';
        $(target).show();

        if (!$(this).closest('.b-dropdown').hasClass("b-dropdown_usermenu")) {
            $('.b-dropdown__value').html($(this).html());
            $.cookie("lastAuthMethod", $(this).attr('id'));
        }
    });

    // Right panel - About ePythia

    $('.l-rightpanel').click(function(){
        showRightpanel();
    });

});
