var scroll_state = 0;
var scroll_item_count = 4;
var move_pxs = 135;
var busy = false;

var n_scroll_state = 0;
var n_scroll_item_count = 2;
var n_move_pxs = 165;


function showNextThumb( max )
{
  if( busy == false )
  {
    busy = true;
    if( scroll_state < ( max - scroll_item_count ) )
    {
      $('#flexterscroll').animate({left: '-='+move_pxs}, 290);
      scroll_state = scroll_state+1;
    }
    else
    {
      var t = max - scroll_item_count;
      $('#flexterscroll').animate({left: '+='+(t*move_pxs)}, 400);
      scroll_state = 0;
    }
    busy = false;
  }
}

function showPreviousThumb( max )
{
  if( busy == false )
  {
    busy = true;
    if( scroll_state > 0 )
    {
      $('#flexterscroll').animate({left: '+='+move_pxs}, 290);
      scroll_state = scroll_state-1;
    }
    else
    {
      var t = max - scroll_item_count;
      $('#flexterscroll').animate({left: '-='+(t*move_pxs)}, 400);
      scroll_state = ( max - scroll_item_count );
    }
    busy = false;
  }
}

function showNextNews( max )
{
  if( n_scroll_state < ( max - n_scroll_item_count ) )
  {
    $('#newsscrolldiv').animate({top: '-='+n_move_pxs}, 290);
    n_scroll_state = n_scroll_state+1;
  }
  else
  {
    var t = max - n_scroll_item_count;
    $('#newsscrolldiv').animate({top: '+='+(t*n_move_pxs)}, 700);
    n_scroll_state = 0;
  }
}

function showPreviousNews( max )
{
  if( n_scroll_state > 0 )
  {
    $('#newsscrolldiv').animate({top: '+='+n_move_pxs}, 290);
    n_scroll_state = n_scroll_state-1;
  }
  else
  {
    var t = max - n_scroll_item_count;
    $('#newsscrolldiv').animate({top: '-='+(t*n_move_pxs)}, 700);
    n_scroll_state = ( max - n_scroll_item_count );
  }
}

