// JavaScript Document
$(function()
		   {
			   var newsInitLi = $("#list_immsg li").size();
			   if(newsInitLi%2 == 1)
			   {
				   $("#list_immsg").append("<li style='background:none'></li>");
			   }
			   var newsInitLi = $("#list_immsg li").size();
			   var weatherInitLi = $("#list_weather li").size();
			   var applyInitTr = $("#tb_listchecknum tr").size();
			   moveNews(newsInitLi);
			   moveNewsStop(newsInitLi);
			   moveWeather(weatherInitLi);
			   moveWeatherStop(weatherInitLi);
			   moveApply(applyInitTr);
			   moveApplyStop(applyInitTr);
		   })
var MTNow = 0;
var MTWNow = 0;
var MTANow = 0;
var lestNews = null;
var lestWeather = null;
var lestApply= null;

function moveNews(liN,MT)
{
	if(liN == 3)
	{
		moveNTUp(liN)
	}
	if(liN >3)
	{
		moveNUp(liN);
	}
	
	lestNews = window.setTimeout("moveNews("+liN+")",3000);
}
function moveNTUp(liNums)
{
	MTNow = MTNow-28;
	var liNowNum = $("#list_immsg li").size();
	//alert(liNowNum);
	$("#list_immsg li").clone().appendTo("#list_immsg");
	$("#list_immsg").animate({marginTop:MTNow},1000,function()
															 {
																		  $("#list_immsg li:lt("+(2)+")").remove();
																		  $("#list_immsg li:last").remove();
																		  $("#list_immsg").css({"margin-top":0});
																		  MTNow = 0;
															 });
}
function moveNUp(liNums)
{
	
	MTNow = MTNow-28;
	var liNowNum = $("#list_immsg li").size();
	//alert(liNowNum);
	$("#list_immsg").animate({marginTop:MTNow},1000,function(){
																	  if(MTNow == -(liNums/2-1)*28)
																	  {
																		  $("#list_immsg li").clone().appendTo("#list_immsg");
																	  }
																	  if(MTNow ==-(liNums/2)*28)
																	  {
																		  $("#list_immsg li:lt("+(liNums)+")").remove();
																		  $("#list_immsg").css({"margin-top":0});
																		  MTNow = 0;
																	  }     
															   });
}
function moveNewsStop(liN)
{
	$("#list_immsg").hover(function()
									{
										if(lestNews)
										   {
											   clearTimeout(lestNews);
										   }
									},
									function()
									{
										lestNews = window.setTimeout("moveNews("+liN+")",3000);
                                        this.blur();            
                                        return false;
									});
}
//天气滚动
function moveWeather(liN)
{
	if(liN >1)
	{
		moveWUp(liN);
	}
	
	lestWeather = window.setTimeout("moveWeather("+liN+")",3000);
}
function moveWUp(liNums)
{
	MTWNow = MTWNow-25;
	var liNowNum = $("#list_weather li").size();
	//alert(liNowNum);
	$("#list_weather").animate({marginTop:MTWNow},1000,function()
															 {
																 if(MTWNow == -(liNums-1)*25 )
																 {
																	 $("#list_weather li").clone().appendTo("#list_weather");
																 }
																 if(MTWNow == -liNums*25)
																 {
																	 $("#list_weather li:lt("+(liNums)+")").remove();
																	 $("#list_weather").css({"margin-top":0});
																	 MTWNow = 0;
																 }
															 });
}
function moveWeatherStop(liN)
{
	$("#list_weather").hover(function()
									{
										if(lestWeather)
										   {
											   clearTimeout(lestWeather);
										   }
									},
									function()
									{
										lestWeather = window.setTimeout("moveWeather("+liN+")",3000);
                                        this.blur();            
                                        return false;
									});
}
//申报滚动
function moveApply(trNum)
{
	if(trNum > 4)
	{
		moveAUp(trNum);
	}
	
	lestApply = window.setTimeout("moveApply("+trNum+")",3000);
}
function moveAUp(trN)
{
	MTANow = MTANow-24;
	//alert(MTANow);
	var trNowNum = $("#tb_listchecknum tr").size();
	//alert(trNowNum);
	$("#tb_listchecknum").animate({marginTop:MTANow},1000,function()
															 {
																 if(MTANow == -(trN-4)*24)
																 {
																	 $("#tb_listchecknum tr").clone().appendTo("#tb_listchecknum");
																 }
																 if(MTANow == -trN*24)
																 {
																	 $("#tb_listchecknum tr:lt("+(trN)+")").remove();
																	 $("#tb_listchecknum").css({"margin-top":0});
																	 MTANow = 0;
																 }
																 
															 });
}
function moveApplyStop(trNum)
{
	$("#tb_listchecknum").hover(function()
									{
										if(lestApply)
										   {
											   clearTimeout(lestApply);
										   }
									},
									function()
									{
										lestApply = window.setTimeout("moveApply("+trNum+")",3000);
                                        this.blur();            
                                        return false;
									});
}

