var intervalID = [];
var duration=40;
var allDIVs=[];
 
$(document).ready(function(n){
			
			var css_text = "position:absolute; overflow:hidden;  top:0px; left:0px;";
			$('.newsscroller').each(function(n){
				
			   $(this).attr('serial',n);
			   $(this).css({
						   'position':'relative',
						   'overflow': 'hidden'
						   });
			   css_text = css_text+" width:"+$(this).css('width')+"; height:"+$(this).css('height')+";";
			   var contents = "<div class='n_content'>"+$(this).html()+"</div>";
			   contents = "<div class='plate' style='position:absolute; top:0px; left:0px;'>"+contents+contents+"</div>";
			   var htmlc = "<div class='newscomp' style='"+css_text+"'>"+contents+"</div>";
			   $(this).html(htmlc)
			   
			   $(this).find('.plate').eq(0).attr('maxheight',$(this).find('.n_content').eq(0).height());
			   
			   $(this).bind('mouseover',function(){
												 		clearInterval(intervalID[n]);
												  })
			   
			   $(this).bind('mouseleave',function(){
												 		clearInterval(intervalID[n]);
														intervalID[n] = setInterval(moveupwords,duration,$(this));
												  })
			   allDIVs.push($(this));
			   intervalID[n] = setInterval(moveupwords,duration);
			   
			   												 
			});
						   


});

function moveupwords()
{
  	var i=0;
	while(i<allDIVs.length)
	{
	div = allDIVs[i];
	
	topamount = parseInt(div.find('.plate').eq(0).css('top'));
	
	if(topamount<=0)
	{
	 topamount++;
	}
	else
	{
	 topamount = (-1)*div.find('.plate').eq(0).attr('maxheight');	
	}
	 div.find('.plate').eq(0).css('top',topamount);
	 
	 i++;
	}
}
