/// <reference path="../jQuery-vsdoc.js" />
var B=BigNews={
	current:0,
	next:0,
	scrollInterval:0,
	autoScroller:0,
	smallpic:"#SwitchSmaPic"
};
BigNews.turn=function(index,obj){
	obj=eval(obj);
	clearInterval(BigNews.autoScroller);
	BigNews.scroll(index,obj);
}
BigNews.scroll=function(index,obj){
	if(obj.smallpic==null || obj.smallpic==""){
		clearInterval(BigNews.autoScroller);
		return;
	}
	var count=0;
	var step=obj.step;
	var duration=16;
	var b=BigNews;
	b.next=index;
	
	if(index==b.current){
		return;
	}

	clearInterval(b.scrollInterval);
	for(var i=0;i<obj.totalcount;i++){
		jQuery(obj.smallpic+"_"+i).get(0).className="normal";
		if(obj.pictxt!=null && obj.pictxt!="")
		{	
			jQuery(obj.pictxt+"_"+i).hide();
	    }
	}
	jQuery(obj.smallpic+"_"+index).get(0).className=obj.selectstyle;
	if(obj.pictxt!=null && obj.pictxt!="")
	{
		jQuery(obj.pictxt+"_"+index).show();
	}	
	var span=index-b.current;
	var chang_in_value=span*step+b.current*step;
	jQuery(obj.bigpic).animate({top: -1*chang_in_value}, 300);
	BigNews.current=index;
}
BigNews.auto=function(obj){
	obj=eval(obj);
	clearInterval(BigNews.autoScroller);
	BigNews.autoScroller=setInterval(function(){
		BigNews.scroll(BigNews.current==(obj.totalcount-1)?0:BigNews.current+1,obj);
	},obj.autotimeintval);
}
BigNews.pauseSwitch = function() {	
	clearInterval(BigNews.autoScroller);
}
BigNews.init=function(obj){
    jQuery(obj.bigpic).bind({
            mouseover:function(){
                BigNews.pauseSwitch();	
            },
            mouseout:function()
            {
                BigNews.auto(obj.objname);
    }});
	jQuery("li[id^="+obj.smallpic.replace("#","")+"]").each(function(i){
	    jQuery(this).bind({
            mouseover:function(){
                BigNews.turn(i,obj.objname);
                BigNews.pauseSwitch();	
            },
            mouseout:function()
            {
                BigNews.auto(obj.objname);
            }
        });
	});
	BigNews.smallpic = obj.smallpic;
}

