//NEWS TICKER//
//Settings
//NEWS TICKER//
//Settings
var pxShown = 1;
var pauseTime = 3000;

var currentItem, maskObj, animate, tickcontent, tickermask, startlink, stoplink;

var stopped = new Boolean();
stopped = 0;


function moveRight(){
   maskObj.style.left = parseInt(maskObj.style.left) + pxShown + 'px';

   if (parseInt(maskObj.style.left) < tickcontent.offsetWidth)
   {
     animate = setTimeout(moveRight,25);
   }
   else
   {
      maskObj.style.display = 'none';
      animate = setTimeout(change,pauseTime);   
   }
}

function change(){
     stopped = 0;
     clearTimeout(animate);
     if (x < newsArray.length - 1)
     {
        x++;
     }
     else
     {
        x = 0
     }
     tickcontent.innerHTML = newsArray[x]; 
     stoplink.style.display = 'block';
     startlink.style.display = 'none';
     maskObj.style.left = 0;
     maskObj.style.display = 'inline';
     moveRight();
}

function next(){
     if (x < newsArray.length - 1)
     {
        x++;
     }
     else
     {
        x = 0
    }
     stopped = 1;
     stop();
     tickcontent.innerHTML = newsArray[x];
}


function previous(){
     if (x == 0)
     {
        x = newsArray.length - 1;
     }
     else
     {
        x = x - 1;
    }
     stopped = 1;
     stop();
     tickcontent.innerHTML = newsArray[x];
}

function stop(){
   maskObj.style.display = 'none';
   maskObj.style.left = 0;
   stoplink.style.display = 'none';
   startlink.style.display = 'block';
   clearTimeout(animate);

}

function stopButton() {
      stopped = 1;
	  stop();
}

function pause(){
   clearTimeout(animate);
}

function mouseOver()
{
     stop();
}

function mouseOut(){
    if (stopped == 0)
  {
     setTimeout(change, 1000);
  }
}

function displayTicker(){
   maskObj = document.getElementById('tickermask');
   tickcontent = document.getElementById('output');
   startlink = document.getElementById('newstickerstart');
   stoplink = document.getElementById('newstickerstop');
   newstickerdiv = document.getElementById('newsticker');
   newsfeedslink = document.getElementById('NewsFeeds');
   previouslink = document.getElementById('newstickerpre');
   nextlink = document.getElementById('newstickernext');

   title = document.getElementById('newstickerTitle');

   newstickerdiv.style.height = '20px';
   maskObj.style.display = 'inline';
   startlink.style.display = 'none';
   stoplink.style.display = 'block';
   title.style.display = 'inline';
   newsfeedslink.style.display = 'inline';
   previouslink.style.display = 'block';
   nextlink.style.display = 'inline';
}