/*
 * Image preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Aaron.xue (http://icpark.com)
 * 
 *
 */
 
var a=0;
var b=1;
var t;

$(document).ready(function(){
	pageinit();
	grouptodayhover();
	startgroup();
	t= setInterval("roll(a,b);", 5000); //时间间隔??
});

this.pageinit = function(){
	$("#ulgrouptoday li dl").hide();
	$("#ulgrouptoday li:first").addClass("bgyellowthin");
    $("#ulgrouptoday li:first span.arrowright4").hide();
	$("#ulgrouptoday li:first dl").show();
	//$("#ulgrouptoday :not(li:first) dl").hide();
};

this.grouptodayhover = function(){
	//$("#ulgrouptoday :not(li:first)").hover(function(){
$("#ulgrouptoday li").hover(function(){
			//$(this).find("dl").addClass("bgredthin");
			$("#ulgrouptoday li span.arrowright4").show();
			$("#ulgrouptoday li dl").hide();
			$("#ulgrouptoday li").removeClass("bgyellowthin");
			$(this).find("span.arrowright4").hide();
			$(this).addClass("bgyellowthin");
			$(this).find("dl").show();	
		},
       	function(){
				//$(this).find("dl").removeClass("bgredthin");
		});
};
     this.startgroup=function() {
            var hl=$("#hot_movies_menu li"),content=$(".movie_headerline .content");
            hl.mouseover(function() {
                $(".menu li .newclearfix").removeClass("on");
                $("#"+this.id+" .newclearfix").addClass("on");
                content.hide();
                $("#content_"+this.id).show();
                return false;
            });
        };

function roll (off,on){
	clearInterval(t);
	var $firstNode = $('#motto>p'); //#motto 是DIV的ID,'p'是该区间的段?         
	$firstNode.eq(off).fadeOut('slow',function(){  
		$firstNode.eq(on).fadeIn('slow');
	});

	if(on==($('#motto>p').length-1)){
		a=on; //on 指DIV里最后一个P
		b=0;
	}
	else if(off==($('#motto>p').length-1)){
                //当最后一个准备关闭，a, b 重新赋?
		a=0;   
		b=1;
	}
	else{
		a++;
		b++;
	}
	t = setInterval ("roll(a, b);", 5000);
}

