/*************************************************/
/* scroll-list.js                                 */
/*                                               */
/* V1.0 04.06.2007 Ausgabe einer Liste von Icons */
/*  für Scroll-Navigation                        */
/*                                               */
/*************************************************/

window.onload = init;

var scrollRate = 1;  // Scrollrate für langsam
var scrollRate2 = 5; // Scrollrate für schnell
var xInterval = null;
var x2Interval = null;
var direction = 1;
var scrollIconsIconContainer;
var scrollIconsCaption;
var currentLeft = 0;
var startScroll = 0;
var stopScroll = 480;

function init()
{
 if ( !document.getElementById ) return;

 scrollIconsLeftArrow  = document.getElementById( "scrollIconsLeftArrowID" );
 scrollIconsRightArrow = document.getElementById( "scrollIconsRightArrowID" );

 scrollIconsLeftArrow.onmousedown  = function() { scrollObjectsDown( 1 ); }
 scrollIconsRightArrow.onmousedown = function() { scrollObjectsDown( 0 ); }
 scrollIconsLeftArrow.onmouseup  = function() { scrollObjectsUp( 1 ); }
 scrollIconsRightArrow.onmouseup = function() { scrollObjectsUp( 0 ); }
 scrollIconsLeftArrow.onmouseout  = function() { scrollObjectsUp( 1 ); }
 scrollIconsRightArrow.onmouseout = function() { scrollObjectsUp( 0 ); }

 scrollIconsIconContainer = document.getElementById( "scrollIconsIconContainerID" );
 scrollIconsIconContainer.style.left = startScroll + "px";
 scrollIconsIconContainer.onmouseout  = function() { startScrolling(); }
 scrollIconsIconContainer.onmouseover = function() { stopScrolling(); }

 scrollIconsCaption = document.getElementById( "scrollIconsCaptionID" );

 if ( ( widthIcons * countIcons ) > stopScroll )
 {
  startScroll = stopScroll - ( widthIcons * countIcons );
 }

 currentLeft = startScroll;
 xInterval = setInterval( "scroll()", 50 );
}

function startScrolling()
{
 if ( !xInterval )
 {
  xInterval = setInterval( "scroll()", 50 );
 }
}

function stopScrolling()
{
 if ( xInterval )
 {
  clearInterval( xInterval );
  xInterval=null;
 }
}

function scrollObjectsDown( dir )
{
 if ( !x2Interval )
 {
  x2Interval = setInterval( "scrollfaster( " + dir  + ")", 50 );
 }
 stopScrolling();
}

function scrollObjectsUp()
{
 if ( x2Interval )
 {
  clearInterval( x2Interval );
  x2Interval = null;
 }
 startScrolling();
}

function scrollfaster( dir )
{
 direction = dir;

 if ( !direction )
 {
  currentLeft -= scrollRate2;
 }
 else
 {
  currentLeft += scrollRate2;
 }

 if ( currentLeft < startScroll )
 {
  currentLeft = startScroll;
 }

 if ( currentLeft >= 0 )
 {
  currentLeft = 0;
 }

 if ( currentLeft <= 0 )
 {
  scrollIconsIconContainer.style.left = currentLeft + "px";
 }
}

function scroll()
{
 if ( !direction )
 {
  currentLeft -= scrollRate;
 }
 else
 {
  currentLeft += scrollRate;
 }

 if ( currentLeft <= 0 )
 {
  scrollIconsIconContainer.style.left = currentLeft + "px";
 }

 if ( currentLeft >= 0 )
 {
  direction = 0;
 }

 if ( currentLeft <= startScroll )
 {
  direction = 1;
 }
}

function setCaption( text )
{
 scrollIconsCaption.innerHTML = text;
}

function clearCaption()
{
 scrollIconsCaption.innerHTML = "&nbsp;";
}


