var elem;
var lastElemID;
var par;
var topMargin = 0;
var height = 0;
var interval;

var newsId;
var newsElem;
var newsTimeout;

function Scroll(elemID, px, time)
{
    if (lastElemID != elemID) {
	lastElemID = elemID
	    elem = document.getElementById(elemID);
	par = elem.parentNode;
	height = elem.offsetHeight - par.offsetHeight + 10;
	topMargin = 0;
    }

    topMargin -= px;

    if (topMargin > 0 || topMargin < -height)
	topMargin += px;
    else
	elem.style.marginTop = topMargin + 'px';

    if (time) {
       interval = setTimeout('Scroll("'+elemID+'",'+px+','+time+')', time);
     }
}


function ScrollNews(id)
{
    var px = 1;
    if (!newsElem) {
        newsElem      = document.getElementById(id);
        newsID        = id;
        newsTopMargin = 105;
    }

    newsTopMargin -= px;

    if (newsTopMargin < -newsElem.offsetHeight)
        newsTopMargin = 105;
    else {
        newsElem.style.marginTop = newsTopMargin + 'px';
    }

    newsTimeout = setTimeout('ScrollNews("'+newsID+'")', 35);

}

function StopNews()
{
    if (newsTimeout) clearTimeout(newsTimeout);
}

function StartNews()
{
    newsTimeout = setTimeout('ScrollNews("'+newsID+'")', 35);
}

function StopScroll()
{
    if (interval) {
       clearTimeout(interval);
       interval = null;
    }
}


function wheel(event){
   var delta = 0;
   if (!event) event = window.event;
   if (event.wheelDelta) {
      delta = event.wheelDelta/120; 
      if (window.opera) delta = -delta;
   } else if (event.detail) {
      delta = -event.detail/3;
   }
   if (delta)
      Scroll('contentdivin', -delta*20, 0);
}

/* Initialization code. */
if (window.addEventListener)
   	window.addEventListener('DOMMouseScroll', wheel, false);
window.onmousewheel = document.onmousewheel = wheel;
