(function($)
{
    /*
     * $.import() helper (for javascript importing within javascript).
     */

    $.extend(true,
    {
        import_js_imported : [],
        
        import_js : function(script)
        {
            var found = false;
            for (var i = 0; i < $.import_js_imported.length; i++)
                if ($.import_js_imported[i] == script) {
                    found = true;
                    break;
                }
            
            if (found == false) {
                $("head").append('<script type="text/javascript" src="' + script + '"></script>');
                $.import_js_imported.push(script);
            }
        }
    });

    
    $(function()
    {
        $.import_js('/scripts/jquery.timers-1.2.js');
        $.import_js('/scripts/styled_radios_&_checkboxes.1.0.js');
        
        // Styled radios & checkboxes
        //$.styledRadios();
        $.styledCheckboxes();
        
        // Firefox .btn style fix
        if ($.browser.mozilla)
            $("input[type='submit'], input[type='button']").css('padding-bottom', '3px');
        
        /*
         * Homepage
         */
        var banners_change_interval = 5000;
        function home_show_banner(holder)
        {
            $("#home_banner_choosers .item_active:visible").each(function()
            {
                var current_index   = $(this).attr('id')
                    .replace('home_banner_chooser_active_', '');
                $("#home_banner_holder_"+current_index).removeClass('holder_active')
                $("#home_banner_holder_"+current_index + " .item_active").fadeOut();
                $("#home_banner_holder_"+current_index + " .item").fadeIn();
                $("#home_banner_"+current_index).fadeOut();
            });
            
            var next_index      = $(holder).attr('id').replace('home_banner_holder_', '');
            $("#home_banner_holder_"+next_index).addClass('holder_active')
            $("#home_banner_holder_"+next_index + " .item").fadeOut();
            $("#home_banner_holder_"+next_index + " .item_active").fadeIn();
            $("#home_banner_"+next_index).fadeIn();
        }
        if ($("#home_banner_choosers .holder").length > 0) {
            $("#home_banner_choosers").everyTime(banners_change_interval, function() {
                if ($(".holder_active", this).nextAll(".holder").length) {
                    home_show_banner($(".holder_active", this).nextAll(".holder"));
                } else {
                    home_show_banner($(".holder:eq(0)", this));
                }
            });
            
            $("#home_banner_choosers .holder").each(function()
            {
                var holder = this;
                $(".item", this).click(function()
                {
                    $("#home_banner_choosers").stopTime(); 
                    home_show_banner(holder);
                });
            });
        }
        

    });
})(jQuery);



