//-------------------------------------------------------------------------
// Vertical Scrolling News Ticker
// XHTML Compat
// Version 2.0
// Copyright 2006 DevDude.com
// Modified by Muzaffer DOGAN
//-------------------------------------------------------------------------

//scroller's speed
var sspeed=1;

//scroller height
var sheight=360;

//height of the div elements in the ticker
var tickerHeight = 40;

//wait time
var waitTime = 1000;

//internal variables:
var resumesspeed=sspeed;
var browser;
var fromWait = false;
var fromMouse = false;

function start()
{
    // Check the browser:
	if (document.all)
	{
	    iemarquee(ticker);
	}
	else if (document.getElementById)
	{
		ns6marquee(document.getElementById('ticker'));
    }
}

function iemarquee(whichdiv)
{
    browser = 'ie';
	iediv = eval(whichdiv);
	iediv.style.pixelTop = sheight;
	sizeup = iediv.offsetHeight;
	ieslide();
}

function ns6marquee(whichdiv)
{
    browser = 'ns6';
	ns6div = eval(whichdiv);
	ns6div.style.top = sheight + "px";
	sizeup = ns6div.offsetHeight;
	ns6slide();
}

function ieslide()
{
    if (!fromWait)
    {
        if (iediv.style.pixelTop <= 0 && iediv.style.pixelTop % tickerHeight == 0)
        {
            sspeed = 0;
            setTimeout("awake()", waitTime);
            return;
        }
    }
    else
    {
        fromWait = false;
    }

	if (iediv.style.pixelTop >= sizeup*(-1))
	{
		iediv.style.pixelTop -= sspeed;
		setTimeout("ieslide()",30);
	}
	else
	{
		iediv.style.pixelTop = sheight;
		ieslide();
	}
}

function ns6slide()
{
    if (!fromWait)
    {
        if (parseInt(ns6div.style.top) <= 0 && parseInt(ns6div.style.top) % tickerHeight == 0)
        {
            sspeed = 0;
            setTimeout("awake()", waitTime);
            return;
        }
    }
    else
    {
        fromWait = false;
    }

	if (parseInt(ns6div.style.top) >= sizeup * (-1))
	{
		theTop = parseInt(ns6div.style.top) - sspeed;
		ns6div.style.top = theTop + "px";
		setTimeout("ns6slide()",30);
	}
	else
	{
		ns6div.style.top = sheight + "px";
		ns6slide();
	}
}

function awake()
{
    if (fromMouse)
    {
        setTimeout('awake()', 30);
        return;
    }

    sspeed = resumesspeed;

    fromWait = true;

    if (browser == 'ie')
    {
    	ieslide();
    }
    else
    {
        ns6slide();
    }
}
