var divId	= 'div_running_line';
var bWidth	= 500;
var bHeight	= 40;
var shift	= 1;
var leftPos	= 0;

function WindowSize(){
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	return [myWidth, myHeight];
}

function getScrollXY() {
	var scrOfX = 0, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	return [scrOfX, scrOfY];
}

function start(){
	document.getElementById(divId).style.visibility = 'visible';
	vAlignment();
	if(navigator.appVersion.indexOf("MSIE")!=-1){
		try {document.execCommand('BackgroundImageCache', false, true);} catch(err) {};
	}
	setInterval("roll()", 30);
}

function vAlignment(){
	document.getElementById(divId).style.left = 0 + 'px';
	winSize		= WindowSize();
	ScrollPos	= getScrollXY();
	document.getElementById(divId).style.top = (ScrollPos[1] + winSize[1] - bHeight) + 'px';
	document.getElementById(divId).style.width = document.body.clientWidth + 'px';
}

function roll(){
	if (document.all || document.getElementById){
		document.getElementById(divId).style.backgroundPosition = leftPos + 'px 0px';
		leftPos = leftPos - shift;
		if(leftPos<=(-bWidth)){leftPos=bWidth+leftPos;}
	}
}

function showBanner(bLink, bgSrc, bgW, bgH){
	var position;
	bWidth	= bgW;
	bHeight	= bgH;
	if (window.attachEvent){
		window.attachEvent("onscroll", vAlignment);
		window.attachEvent("onresize", vAlignment);
		position = "absolute";
	}else{
		window.addEventListener("resize", vAlignment, 1);
		position = "fixed";
	}
	document.write('<div id="' + divId + '" onMouseout="shift=1" onMouseover="shift=0" style="background-image: url('+bgSrc+');position:' + position + ';height:' + bHeight + 'px;"><a href="'+bLink+'" id="running_line_link">&nbsp;</a></div>');
	//setTimeout("", 0);
	start();
}