$(document).ready(function () {
    $("a[rel=external]").each(function (i) {
        this.target = "_blank";
    });
    $("a[rel=popup]").each(function (i) {
        this.target = "_blank";
    });
    var height = $("div#content").height() + 100;
    if (height > 1000) {
        $("div#wrapper-center").css("height", height + "px");
        $("div#wrapper-left").css("height", height + "px");
        $("div#wrapper-right").css("height", height + "px");
    }

    $('#content p img').css('filter', 'alpha(opacity=50)');
    $('#content p img').css('opacity', 0.5);
    $('#content h2 img').css('filter', 'alpha(opacity=50)');
    $('#content h2 img').css('opacity', 0.5);

    $('#content p img').bind('mouseenter', function () {
        $(this).css('filter', 'alpha(opacity=100)');
        $(this).css('opacity', 1);
    });

    $('#content p img').bind('mouseleave', function () {
        $(this).css('filter', 'alpha(opacity=50)');
        $(this).css('opacity', 0.5);
    });

    $('#content h2 img').bind('mouseenter', function () {
        $(this).css('filter', 'alpha(opacity=100)');
        $(this).css('opacity', 1);
    });

    $('#content h2 img').bind('mouseleave', function () {
        $(this).css('filter', 'alpha(opacity=50)');
        $(this).css('opacity', 0.5);
    });

    $('table').find('img').css('filter', 'alpha(opacity=50)');
    $('table').find('img').css('opacity', 0.5);

    $('table').find('img').bind('mouseenter', function () {
        $(this).css('filter', 'alpha(opacity=100)');
        $(this).css('opacity', 1);
    });

    $('table').find('img').bind('mouseleave', function () {
        $(this).css('filter', 'alpha(opacity=50)');
        $(this).css('opacity', 0.5);
    });

    if ($("#letter").val()) {
        sAL($("#letter").val());
    }

    $("li.pid-active").find("li:last").css('margin-bottom', "-2px");
    $("li.p-active").find("li:last").css('margin-bottom', "-2px");

    $.doTimeout(2000, function () {
        var height = $("div#content").height() + 50;
        if (height > 1065) {
            $("div#wrapper-left").css("height", height + "px");
            $("div#wrapper-right").css("height", height + "px");
        }
    });
});

function getBanner(u_current, u_step) {
    u_list = $("#list").val();
    $.post('/skins/default/ajax/dispatcher.php',
        {
            action:'getbanner',
            mode:'select',
            step:u_step,
            list:u_list,
            current:u_current,
        },
        function (data) {
            if (u_step == 0) {
                $("#content-top").html(data).animate({opacity:1}, 2000, function () {
                    $.doTimeout(5000, function () {
                        getBanner($("#current").val(), 1);
                    });
                });
            }
            else {
                $("#content-top").animate({opacity:0}, 500, function () {
                    $("#content-top").html(data).animate({opacity:1}, 2000, function () {
                        $.doTimeout(5000, function () {
                            getBanner($("#current").val(), 1);
                        });
                    });
                });
            }
        }
    );
}


