//==================================================================================================
// Desciription:
////////////////
// Scrolls the contents of an object horizontal or vertical without spaces (as on <marquee>).
//
// Usage:
/////////
// View index.html for example.
// initTicker('objID', 'to', ms)          // objID    : ID of an object which contents should
//                                                      be scrollable
//                                        // to       : orientation to scroll ( 'v' = vertical
//                                                                              'h' = horizontal )
//                                        // ms       : milliseconds to move 1 pixel (min. 10ms)
//==================================================================================================
var tickerc=0;
var mTimer = new Array(); var tickerTo = new Array(); var tickerSpeed = new Array();
function startTickerDiv(subID)
{ 
  tableObj        = document.getElementById('scrollTable' + subID); 
  obj             = tableObj.parentNode;   
  objWidth        = (tickerTo[subID] == 'h') ? tableObj.offsetWidth : tableObj.offsetHeight;
  newWidth        = (Math.floor(objWidth/2)*2)+2;
  obj.style.width = newWidth;
  
  moveDiv(obj, newWidth, subID);
}

function moveDiv(obj, width, subID)
{
  var thisObj = (typeof(obj) == 'string') ? document.getElementById(obj) : obj;
  if(tickerTo[subID] == 'h') thisObj.style.left = (parseInt(thisObj.style.left) <= (0-(width/2)+2)) ? 0 : parseInt(thisObj.style.left)-1 + 'px';
  else {
    if(thisObj.style.top == '')                     thisObj.style.top = 0;
    if(parseInt(thisObj.style.top)<(0-(width/2)+6)) thisObj.style.top = 0;
    else                                            thisObj.style.top = parseInt(thisObj.style.top)-1 + 'px';
  }
  mTimer[subID] = setTimeout("moveDiv('"+thisObj.id+"', " + width + ", " + subID + ");", tickerSpeed[subID]); 
}

function initTicker(objID, to ,ms)
{
 // set settings
  tickerTo[tickerc] = (to == 'h' || to == 'v') ? to : 'v';
  tickerSpeed[tickerc] = (parseInt(ms) <= 10) ? 10 : parseInt(ms);

 // prepare  object
  var orgData = document.getElementById(objID).innerHTML;
  var newData  = '  <div id="scrollDiv' + tickerc +'" class="scrollDiv" style="position:relative;left:0;z-index:1">';
      newData += '    <table id="scrollTable' + tickerc +'" class="scrolltable"  cellpadding="0" cellspacing="0">';
      newData += '      <tr>';
      newData += '        <td onmouseover="clearTimeout(mTimer[' + tickerc +'])" onmouseout="startTickerDiv(' + tickerc +')">';
      
    if(tickerTo[tickerc] == 'h')
      newData += '          <table style="width:100%" cellspacing="0" cellpadding="0"><tr>';
       
        for(var i=0;i<8;i++)
        {
          newData += tickerTo[tickerc] == 'h' ? '<td>' + orgData + '</td>' : orgData;
        }
        
    if(tickerTo[tickerc] == 'h')
      newData += '          </tr></table>';
      
      newData += '        </td>';
      newData += '      </tr>';
      newData += '    </table>';
      newData += '  </div>';
  
  document.getElementById(objID).innerHTML = newData;
 // start ticker
  window.setTimeout("startTickerDiv("+tickerc+");",1000);
  tickerc++;
}
