

$(document).ready
(
  function()
  {
    roll_news_f( '#roll_news_box_', 2000 );
  }
);/* $(document).ready */

/*  
    版本: 2009-6-15 13:03:36
    作用: 滚动新闻
必填参数: contaier_j
*/
function roll_news_f( contaier_j, interval_ms )
{
  contaier_j = $(contaier_j);
  interval_ms = interval_ms || 1000;
  var sub_container_j = contaier_j.find("> div");
  
  sub_container_j.css( {position:'absolute'} );
  
  var items_j = sub_container_j.find('div');
  var step_len = sub_container_j.height() / items_j.length;

  var step_i = 2;
  var index_count = 0;
  
  var temp_interval_ = undefined;
  var another_interval_ = undefined;
  
  begin_interval_f();
  
  function begin_interval_f()
  {
  
    temp_interval_ = 
    setInterval
    (
      function()
      {
        var temp_cur = index_count;
        index_count += 2;
        
        //document.title = index_count+', '+items_j.length
        
        if( index_count>= items_j.length )
        {
          
          clearInterval( temp_interval_ );
          
          reverse_interval_f();
          return;
        }
        
        var move_how = 0;
        
        var temp_ = '';
        
        if( items_j.eq(temp_cur).length )
        {
          move_how+=items_j.eq(temp_cur).height();
          temp_+= ', '+items_j.eq(temp_cur).height()
          
        }        
        
        if( items_j.eq(temp_cur+1).length )
        {
          move_how+=items_j.eq(temp_cur+1).height();
          temp_+= ', '+items_j.eq(temp_cur+1).height()
        }
        
        //document.title = temp_
        
        move_how += 14;
        
        var top_ = parseInt( sub_container_j.css('top') ) || 0;

        defaultStatus = move_how +', '+top_+', '+items_j.eq(temp_cur).height()+', '+items_j.eq(temp_cur+1).height();
        
        var next_top_ = top_ - move_how;
          
        sub_container_j.animate( { top: next_top_+'px'} );
      }
      , interval_ms
    );  
  }/* function begin_interval_f() */
  
  function reverse_interval_f()
  {
    another_interval_ = 
    setInterval
    (
      function()
      {
        var temp_cur = index_count;
        index_count -= 2;
        
        defaultStatus = index_count
        
        if( index_count<=0 )
        {
          
          clearInterval( another_interval_ );
          begin_interval_f();
          
          return;
        }
        
        var move_how = 0;
        
        var temp_ = '';
        
        if( items_j.eq(temp_cur-1).length )
        {
          move_how+=items_j.eq(temp_cur-1).height();
          temp_+= ', '+items_j.eq(temp_cur-1).height()
          
        }        
        
        if( items_j.eq(temp_cur-2).length )
        {
          move_how+=items_j.eq(temp_cur-2).height();
          temp_+= ', '+items_j.eq(temp_cur-2).height()
        }
        
        //document.title = temp_
        
        move_how += 14;
        
        var top_ = parseInt( sub_container_j.css('top') ) || 0;

        defaultStatus = move_how +', '+top_+', '+items_j.eq(temp_cur).height()+', '+items_j.eq(temp_cur+1).height();
        
        var next_top_ = top_ + move_how;
          
        sub_container_j.animate( { top: next_top_+'px'} );
      }
      , interval_ms
    );  
  }
  
}/* function roll_news_f( contaier_j, interval_ms ) */
