﻿$j(document).ready(function() {
    $j("#boxFocusContent div:nth-child(1)").addClass("selected");
    $j(".focusItemNbr").click(function() {
        var index = $j(this).html();
        $j("#boxFocusContent > div").removeClass("selected");
        $j("#boxFocusContent div:nth-child(" + index +")").addClass("selected");
    });
});


(function() {
    jQuery.extend(jQuery, {
        timer: function(settings, execFunc) {
            jQuery.setTimer(settings, execFunc, true);
        },
        setTimer: function(settings, execFunc, run) {
            settings = jQuery.extend({
                name: "timer" + (jQuery.timers.length + 1),
                interval: 1,
                end: false
            }, settings);
            var t_end = "unlimited";
            var t_name = settings.name;
            if (!isNaN(parseInt(settings.end, 10))) t_end = parseInt(settings.end, 10);
            jQuery.timers[settings.name] = {
                cycle: 0,
                interval: settings.interval,
                end: t_end,
                state: "stopped",
                timer: "",
                func: execFunc
            };
            if (run) {
                jQuery.runTimer(settings.name);
            }
        },
        runTimer: function(name) {
            jQuery.timers[name].timer = window.setInterval(function() {
                jQuery.timers[name].func();
                jQuery.timers[name].cycle++;
                if (jQuery.timers[name].end != "unlimited" && jQuery.timers[name].cycle >= jQuery.timers[name].end) {
                    jQuery.stopTimer(name);
                }
            }, jQuery.timers[name].interval * 1000);
            jQuery.timers[name].state = "run";
        },
        stopTimer: function(name) {
            clearInterval(jQuery.timers[name].timer);
            jQuery.timers[name].state = "stopped";
        }
    });
})();


$j(document).ready(function() {

    var flashIndex = 1;
    $j("#topSideTabs li:first").addClass("selected");
    $j("#topSideTabs li").click(function() {
        var index = $j(this).find('a').html();
        $j("#divFlashInfos").animate({ "marginLeft": -(index - 1) * 400 + "px" }, "slow");
        $j("#topSideTabs li").removeClass("selected");
        $j(this).addClass("selected");
        flashIndex = index - 1;
    });


 


    $j.timer({ name: "flashInfoTimer", interval: 5 }, function() {
        if (flashIndex >= MaxFlashInfos) {
            flashIndex = 0;
        }
        $j("#divFlashInfos").animate({ "marginLeft": -(flashIndex) * 400 + "px" }, "slow");
        $j("#topSideTabs li").removeClass("selected");
        $j("#topSideTabs li:eq(" + flashIndex + ")").addClass("selected");
        flashIndex++;
    });
});