$.preloadImages = function() {
    var argLength = arguments.length;
    for (var i=0; i < argLength; i++) {
        img = new Image;
        img.src = arguments[i];
    }
}

$(document).ready(function() {
    /*menu opisowe*/
    $('#box_menu a.head').click(function(){
        $('#kredyty, #leasing').removeClass('active');
        $(this).parent().addClass('active');
        $('#box_close').css('display', 'block');
        return false;
    });
    $('#box_close a').click(function(){
        $('#box_close').css('display', 'none');
        $('#kredyty, #leasing').removeClass('active');
        return false;
    });

    $("#box_menu .box_element").hover(
        function () {
            $(this).find('.img_curtain').animate({opacity: 0}, 500).css('z-index', 1);
        },
        function () {
            $(this).find('.img_curtain').animate({opacity: 1.0}, 500).css('z-index', 2000);
        }
    );
    $('#box_menu .box_element').not('#kredyty-3').click(function() {
        document.location =  $(this).find('.more a').attr('href');
    });


    
    /*pole wyszukiwarki*/
    var searchVal = 'wpisz frazę...';
    $('#header .textbox').val(searchVal);
    $('#header .textbox').focus(function() {
        $('#header .textbox').val('');
    });
    $('#header .textbox').blur(function() {
        if ($(this).val() == '')
            $(this).val(searchVal)
    });

    /*scroll to top*/
    $('#btn_top').click(function(){
        $('html, body').animate({scrollTop:0}, 'slow');
        return false;
    });

    // preload images
    $.preloadImages(
        'public/img/box.png'
    );
});
