/***********************************************
* IFRAME Scroller script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

//Specify speed of scroll. Larger=faster (ie: 5)
var scrollspeed=cache=1;

// Specifiy the time interval of the timer
var timeInterval=60;

// Specify intial delay before scroller starts scrolling (in miliseconds):
var initialdelay=1000;

// Specifiy the height of the container (iframe)
// Must be set by the page to be framed...
var container_height;

function initializeScroller()
{
	// container_height must be set in the page before coming here...
	if (container_height == null) return;
	
    clippingContainer = document.getElementById("main_clipping");
    
    if (clippingContainer == null) return;

    clippingContainer.style.top = 0;
    clippingContainer.style.position = "absolute";

    var scrollContainer = document.getElementById("scroller_container");

    if (scrollContainer != null && scrollContainer.tagName == "DIV"
      && container_height
      && scrollContainer.offsetHeight > container_height)
    {
      var data2 = document.createElement("div");

      data2.innerHTML = scrollContainer.innerHTML;

      clippingContainer.appendChild(data2);
    }
    else 
      return;

    if (window.addEventListener)
        clippingContainer.addEventListener("mouseover", divOnMouseOver, false)
    else if (window.attachEvent)
        clippingContainer.attachEvent("onmouseover", divOnMouseOver)

    if (window.addEventListener)
        clippingContainer.addEventListener("mouseout", divOnMouseOut, false)
    else if (window.attachEvent)
        clippingContainer.attachEvent("onmouseout", divOnMouseOut)

    setTimeout("getdataheight()", initialdelay);
}

function divOnMouseOver()
{
    scrollspeed=0;
}

function divOnMouseOut()
{
    scrollspeed=cache;
}

function getdataheight()
{
    thelength= (clippingContainer.offsetHeight - getIntFromString(clippingContainer.style.paddingTop)) / 2;
    
    if (thelength==0)
        setTimeout("getdataheight()", timeInterval);
    else
        scrollDiv();
}

function scrollDiv()
{
    clippingContainer.style.top=getIntFromString(clippingContainer.style.top)-scrollspeed+"px";
    
    if (getIntFromString(clippingContainer.style.top)<thelength*(-1))
    {
	    clippingContainer.style.top = 0-scrollspeed+"px";
    }
    
    setTimeout("scrollDiv()",timeInterval);
}


if (window.addEventListener)
    window.addEventListener("load", initializeScroller, false);
else if (window.attachEvent)
    window.attachEvent("onload", initializeScroller);
else
    window.onload=initializeScroller;

function getIntFromString(strValue)
{
	if (strValue == null || strValue == "")
		return 0;
		
	return parseInt(strValue);
}
