
//MOOTOOLS 1.21

var scroll = Array();
var counter = Array();
var count = Array();
var items = Array();
var hrefs = Array();

function setScroll(id, it, len)
{
    if ( $('scroll_'+id) == null ) return;
    if ( $('scroll_content_'+id) == null ) return;
    
    counter[id] = 0;
    items[id] = it;
    count[id] = $$("#scroll_"+id+" .item").length;
    hrefs[id] = $$("#scroll_"+id+" .item_"+id+"_href");

    if (len != 0)
        $('scroll_content_'+id).setStyle('height', (len*count[id])+'px')

  scroll[id] = new Fx.Scroll('scroll_'+id);
  scroll[id].toElement('item_'+id+'_0');
  
  if( $('item_'+id+'_href_dest') != undefined ) $('item_'+id+'_href_dest').href = hrefs[id][0].href;
}

function scrollSelect(id, it)
{
	scroll[id].toElement('item_'+id+'_'+it);
    counter[id] = it;
}

function scrollNext(id, mode)
{
    counter[id]++;
        
    if ( counter[id] > count[id]-1  )
    {
        if (!mode)
            counter[id]--;
        else
            counter[id] = 0;
    }

    if (counter[id] == 0)
    {
	if( $('scroll_left_'+id) != undefined) $('scroll_left_'+id).setStyle( 'display', 'none' );
    }
    else
    {
        if( $('scroll_left_'+id) != undefined) $('scroll_left_'+id).setStyle( 'display', '' );
    }

    if ( counter[id] >= count[id]-1)
    {
    	if( $('scroll_right_'+id) != undefined ) $('scroll_right_'+id).setStyle( 'display', 'none' );
    }
    else
    {
        if( $('scroll_right_'+id) != undefined ) $('scroll_right_'+id).setStyle( 'display', '' );
    }

    scroll[id].cancel();
    scroll[id].toElement('item_'+id+'_'+counter[id]);

    if( $('item_'+id+'_href_dest') != undefined ) $('item_'+id+'_href_dest').href = hrefs[id][counter[id]].href;
}

function scrollPrev(id)
{
    counter[id]--;

    if ( counter[id] == 0 )
    	if( $('scroll_left_'+id) != undefined ) $('scroll_left_'+id).setStyle( 'display', 'none' );
    
    
	if ( counter[id] < 0 )
        {
	    counter[id]++;
            
	    if( $('scroll_left_'+id) != undefined )
                $('scroll_left_'+id).setStyle( 'display', 'none' );

	} 
        else
        {
		if( $('scroll_right_'+id) != undefined ) $('scroll_right_'+id).setStyle( 'display', '' );
	}

	scroll[id].cancel();
	scroll[id].toElement('item_'+id+'_'+counter[id]);
	if( $('item_'+id+'_href_dest') != undefined ) $('item_'+id+'_href_dest').href = hrefs[id][counter[id]].href;
}

