//hotnews animation
var hst;
var hotSlider = {
	idx: 0,
	max: 0,
	init: function()
	{
		this.max = $("#hotnews_titles ul li").size();
		$("#hotnews_stripe").css('width', this.max*533 + 'px');
		$("#hotnews_titles a").click(function(){
			window.clearInterval(hst);
			hotSlider.slide($(this).attr('rel'));
			$(this).blur();
			return false;
		});
		return this.max;
	},
	slide: function(n)
	{
		this.idx = n;
		var pos = -this.idx*533;
		$("#hotnews_stripe").stop().animate({left: pos + 'px'}, 1000);
	},
	stop: function()
	{
		window.clearInterval(hst);
	},
	autoSlide: function()
	{
		if (++this.idx >= this.max) this.idx = 0;
		this.slide(this.idx);
	}
}

//starter menu
$(document).ready(function(){
	hotSlider.init();

	$(".starter_module").hide();
	$("#hotnews").show();
	$("#events_list_last>.events_prev").addClass("active");

	$("#starter_menu>ul>li>a").click(function(){
		$("#starter_menu>ul>li>a").removeClass("active");
		$(this).addClass("active");
    });

	$("#s_hotnews").click(function(){
		$(".starter_module").hide();
		$("#hotnews").show();
		return false;
    });

    $("#s_calendar").click(function(){
		$(".starter_module").hide();
		$("#calendar").show();
		return false;
    });

   	$("#s_tv_schedule").click(function(){
		$(".starter_module").hide();
		$("#tv_schedule").show();
		return false;
    });

    //shop module
/*
    $("#sw_shop").addClass("active");
    $("#shop_bestsellers").show();
    $("#announcements").hide();
*/
    $("#sw_shop").click(function(){
    	//$("#sw_shop").addClass("active");
    	//$("#sw_announcements").removeClass("active");
		//$("#announcements").hide();
		//$("#shop_bestsellers").show();
		return false;
    });

	$("#sw_announcements").click(function(){
		$("#sw_announcements").addClass("active");
		$("#sw_shop").removeClass("active");
		$("#shop_bestsellers").hide();
		$("#announcements").show();
		return false;
	});
/*
	if (Math.floor(Math.random()*10+1) < 6) {
		$("#sw_announcements").trigger('click');
	}
*/
	if (hotSlider.init()) {
		hst = window.setInterval("hotSlider.autoSlide()", 5000);
	}
});
