//************************************************************************
// --- scrollin'
// based on script by Urs Dudli and Peter Gehrig 
//************************************************************************


ns4 = (document.layers)? true:false
ns6 = (navigator.product=="Gecko")? true:false
ie4 = (document.all)? true:false

var scrollerWidth, scrollerHeight, scrollerLeft, scrollerTop, scrollerPause, scrollerStep;
var scrollerCLeft, scrollerCRight, scrollerCTop, scrollerCBtm;
var scrollTimer,   scrollerTWidth, scrollerText;
var intWinHeight, intWinWidth;
var intWinMaxWidth = 780; 
var intSearchLeft = 100; 
var intSearchTop = 325; 
var intSearchWidth =0; 


function WindowSizeCheck() 
{ 
    if (ie4) 
    { 
	intWinWidth = document.body.offsetWidth; 
	intWinHeight = document.body.offsetHeight; 
    } 
    else if (ns4 || ns6) 
    { 
	intWinWidth = window.innerWidth; 
	intWinHeight = window.innerHeight; 
    } 
} 

function initScroll() 
{ 
    if (scrollTimer) clearTimeout(scrollTimer); 
    WindowSizeCheck(); 
    if (intWinWidth <= intWinMaxWidth) 
    { 
	intWinWidth = intWinMaxWidth; 
    } 
    scrollerLeft = Math.round((intWinWidth - intWinMaxWidth) / 2) + 20; 
    scrollerWidth = 740;
    scrollerHeight = 15; 
    scrollerTop = 165; 
    scrollerPause = 20; 
    scrollerStep = 2; 
    if (ie4) 
    { 
	text.innerHTML=scrollerText; 
	scrollerTWidth=text.offsetWidth; 
        document.all.text.style.posTop=scrollerTop; 
        document.all.text.style.posLeft=scrollerLeft+scrollerWidth;
	scrollerCLeft=0;
	scrollerCRight=0; 
	scrollerCTop=0; 
	scrollerCBtm=scrollerHeight; 
	document.all.text.style.clip ="rect("+scrollerCTop+" "+scrollerCRight+" "+scrollerCBtm+" "+scrollerCLeft+")"; 
	scrollText(); 
    }
    if (ns6)
    { 
	document.getElementById('text').innerHTML = scrollerText; 
       scrollerTWidth=parseInt(document.getElementById("text").offsetWidth); 
       document.getElementById('text').style.top=scrollerTop; document.getElementById('text').style.left=scrollerLeft+scrollerWidth; 
       scrollerCLeft=0; scrollerCRight=0; scrollerCTop=0; scrollerCBtm=scrollerHeight; 
       document.getElementById('text').style.clip ="rect("+scrollerCTop+" "+scrollerCRight+" "+scrollerCBtm+" "+scrollerCLeft+")"; 
       scrollText(); } if (ns4) { document.text.document.write(scrollerText); document.text.document.close(); 
       scrollerTWidth=document.text.document.width; document.text.top = scrollerTop; 
       document.text.left = scrollerLeft+scrollerWidth; document.text.clip.left=0; 
       document.text.clip.right=0; document.text.clip.top=0; 
       document.text.clip.bottom = scrollerHeight; scrollText(); 
    } 
} 
function scrollText() 
{
    if (ie4) 
    { 
	if (document.all.text.style.posLeft >= scrollerLeft - scrollerTWidth)
	{ 
	    document.all.text.style.posLeft -= scrollerStep; 
	    scrollerCRight += scrollerStep; 
	    if (scrollerCRight > scrollerWidth) 
		scrollerCLeft += scrollerStep; 
	    document.all.text.style.clip ="rect("+scrollerCTop+" "+scrollerCRight+" "+scrollerCBtm+" "+scrollerCLeft+")"; 
	    scrollTimer=setTimeout("scrollText()",scrollerPause); 
	} 
	else scrollReset(); 
    } 
    if (ns6) 
    { 
	ns6_left = parseInt(document.getElementById("text").style.left); 
	if ( ns6_left >= scrollerLeft - scrollerTWidth) 
	{ 
	    document.getElementById('text').style.left = parseInt(document.getElementById('text').style.left) - scrollerStep; 
	    scrollerCRight += scrollerStep; if (scrollerCRight > scrollerWidth) scrollerCLeft += scrollerStep; 
	    document.getElementById('text').style.clip ="rect("+scrollerCTop+" "+scrollerCRight+" "+scrollerCBtm+" "+scrollerCLeft+")"; 
	    scrollTimer=setTimeout("scrollText()",scrollerPause); 
	} 
	else scrollReset(); 
    } 
    if (ns4) 
    { 
	if (document.text.left >= scrollerLeft - scrollerTWidth) 
	{ 
	    document.text.left -= scrollerStep; document.text.clip.right += scrollerStep; 
	    if (document.text.clip.right > scrollerWidth) 
		document.text.clip.left += scrollerStep; 
	    scrollTimer=setTimeout("scrollText()",scrollerPause); 
	} 
	else scrollReset(); 
    } 
} 

function scrollReset() {
	if (ie4) {
		document.all.text.style.posLeft = scrollerLeft + scrollerWidth;
		scrollerCLeft=0; scrollerCRight=0;
		document.all.text.style.clip ="rect("+scrollerCTop+" "+scrollerCRight+" "+scrollerCBtm+" "+scrollerCLeft+")";
		scrollText();
	}
	
	if (ns6) {
		document.getElementById('text').style.left = scrollerLeft + scrollerWidth;
		scrollerCLeft=0; scrollerCRight=0;
		document.getElementById('text').style.clip ="rect("+scrollerCTop+" "+scrollerCRight+" "+scrollerCBtm+" "+scrollerCLeft+")";
		scrollText();
	}
	
	if (ns4) {
		document.text.document.write(scrollerText);
		document.text.document.close();
		document.text.left=scrollerLeft+scrollerWidth;
		document.text.clip.left=0; document.text.clip.right=0;
		scrollText();
	}
}

function scrollReset() 
{ 
    if (ie4) 
    { 
	document.all.text.style.posLeft = scrollerLeft + scrollerWidth; 
        scrollerCLeft=0; scrollerCRight=0; 
        document.all.text.style.clip ="rect("+scrollerCTop+" "+scrollerCRight+" "+scrollerCBtm+" "+scrollerCLeft+")"; 
        scrollText(); 
    } 
    if (ns6) 
    { 
	document.getElementById('text').style.left = scrollerLeft + scrollerWidth; scrollerCLeft=0; 
        scrollerCRight=0; 
        document.getElementById('text').style.clip ="rect("+scrollerCTop+" "+scrollerCRight+" "+scrollerCBtm+" "+scrollerCLeft+")"; 
        scrollText(); 
    } 
    if (ns4) 
    { 
	document.text.document.write(scrollerText); 
	document.text.document.close(); 
        document.text.left=scrollerLeft+scrollerWidth; 
	document.text.clip.left=0; 
	document.text.clip.right=0; 
	scrollText(); 
    } 
} 
function scrollSpeed(inc) 
{ 
    if (inc == 0) scrollerStep = 0; 
    else scrollerStep += inc; 
    if (scrollerStep >= 20) scrollerStep = 20; 
    if (scrollerStep<0) scrollerStep = 0; 
} 

// netscape, change the winindow size 
if (ns4) 
{ 
    widthCheck = window.innerWidth; 
    heightCheck = window.innerHeight; 
} 	
function resizeFix() 
{ 
    if (!document.layers) return; 
    if (widthCheck != window.innerWidth || heightCheck != window.innerHeight) 
	document.location.href = document.location.href; 
} 

function onWinResize() 
{ 
    resizeFix(); 
    initScroll(); 
} 

function initSearch() 
{ 
    WindowSizeCheck(); 
    if (intWinWidth <= intWinMaxWidth) 
    { 
	intWinWidth = intWinMaxWidth; 
    } 
    intSearchLeft = Math.round((intWinWidth - intWinMaxWidth) / 2)+intSearchLeft; 
    if (ie4) 
    { 
	document.all.ofsearch.style.posTop=intSearchTop; 
	document.all.ofsearch.style.posLeft=intSearchLeft; 
	document.all.acmsearch.style.posTop=intSearchTop; 
	document.all.acmsearch.style.posLeft=intSearchLeft; 
    } 
    if (ns6) 
    { 
	intSearchLeft += 2; 
	intSearchTop += 4; 
	document.getElementById('ofsearch').style.top=intSearchTop; 
        document.getElementById('ofsearch').style.left=intSearchLeft;
	document.getElementById('acmsearch').style.top=intSearchTop; 
        document.getElementById('acmsearch').style.left=intSearchLeft; 
    } 
    if (ns4) 
    { 
	document.ofsearch.top = intSearchTop; 
	document.ofsearch.left = intSearchLeft; 
	document.ofsearch.top = intSearchTop; 
	document.ofsearch.left = intSearchLeft; 
    } 
} 

function initMain() 
{ 
    scrollSpeed(2); 
    initScroll(); 
    window.onresize = onWinResize; 
}

