// JavaScript Document

// image rotater script

$(document).ready(function () {
	var current_content = $(".image-rot-container>ul#content>li:first-child");
	var next_content = current_content.next("li");
	var current_thumb = $(".image-rot-container>ul#thumb>li:first-child");
	var next_thumb = current_thumb.next("li");
	
	
	$(current_content).css("display","block");
	$(current_thumb).addClass("current-thumb").attr('id', 'current');


	
	
	setInterval(function next () {
		
		if ($(".image-rot-container>ul#thumb>li:last-child").attr('id')=='current') {
			
			 $(".image-rot-container>ul#thumb").children().removeAttr("style");
		 $(".image-rot-container>ul#thumb>li:last-child").css('visibility', 'visible');
		 $(".image-rot-container>ul#thumb>li:first-child").css('visibility', 'visible');
		
		}
			
			
	
	 current_content.removeAttr("style");
	 current_thumb.removeClass("current-thumb").removeAttr("id");

	 
	 current_content=next_content;
	 current_thumb=next_thumb;
	 
	 next_content=current_content.next("li");
	 next_thumb=current_thumb.next("li");
	 
	
		 
	 
	 if (next_content.length==0) {
		 next_content=$(".image-rot-container>ul#content>li:first-child");
		 next_thumb = $(".image-rot-container>ul#thumb>li:first-child");
		 
		 $(".image-rot-container>ul#thumb").children().animate({bottom:'0px'});
		 $(".image-rot-container>ul#thumb>li:last-child").css('visibility', 'visible');
		 $(".image-rot-container>ul#thumb>li:first-child").css('visibility', 'visible');
	 }
	 $(current_content).fadeIn("slow");
	 $(current_thumb).addClass("current-thumb").attr('id', 'current');
	 
	},6000);
	
	$(".image-rot-container>ul#thumb>li").click(function(){
		
		var element_id = $(this).index()+1;
		var n = parseInt(element_id);
		current_content.removeAttr("style");
		current_thumb.removeClass("current-thumb").removeAttr("id");
		
		current_content = $(".image-rot-container>ul#content>li:nth-child("+element_id+")");
		current_thumb=$(".image-rot-container>ul#thumb>li:nth-child("+element_id+")");

		next_content=current_content.next("li");
	    next_thumb=current_thumb.next("li");
		if (next_content.length==0) {
		 next_content=$(".image-rot-container>ul#content>li:first-child");
		 next_thumb = $(".image-rot-container>ul#thumb>li:first-child");
	 }
		
		$(current_content).fadeIn("slow");
	    $(current_thumb).addClass("current-thumb").attr('id', 'current');
		

		});
	
});		

// hotnews script

$(document).ready(function () {
 var ani = 30;
        var hotNum = 1;
        setInterval(function(){
            $("#sweep").removeClass('hidd');
            $("#sweep").removeAttr('style');
            if (hotNum>=10) {
            $("#hot-news-content").removeAttr('style');
            ani = 0;
            hotNum = 0;
            }
            $("#hot-news-content").animate({bottom:ani});
            $("#sweep").animate({marginRight:"50%"},4000);
            ani = ani+30;
            hotNum = hotNum+1;
        },5000)
});