var scroll = function() {
	var	div = null,
		dir = null,
		speed = null,
		interval = null,
		inc = 0;
	
	return {
		//funkcja inicjujaca pasek oraz przypisjaca podstawowe parametry
		init: function(imageP,urlP,heightP,directionP,speedP,bottomPaddingP,zIndexP,crossP,closeP,targetP) {
			directionP != 1 ? dir = -1 : dir = 1;
			speed = speedP;
			
			document.write('<style type="text/css">div#advScrollerId {z-index:'+ zIndexP +';height:'+ heightP +'px;background:url(\''+ imageP +'\') repeat-x;position:fixed;width:100%;} div#advScrollerId a {display:block;width:100%;}');
			if(crossP == 1)	document.write('div#advScrollerCross {display:block;z-index:'+ (zIndexP+1) +';height:16px;width:16px;background:url(\'image/cross.gif\') center center no-repeat;position:absolute;top:0px;right:0px;} div#advScrollerCross a {display:block;width:16px;height:16px;}');
			else document.write('div#advScrollerCross {display:none;}');
			document.write('</style>');

			if(navigator.appName == 'Microsoft Internet Explorer') {
				document.write('<!--[if gte IE 5.5]><![if lt IE 7]><style type="text/css">div#advScrollerId {position:absolute;right:auto;bottom:auto;left: expression( ( -advScrollerId.offsetWidth + ( document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth ) + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + \'px\');top: expression( ( '+ -bottomPaddingP +'-advScrollerId.offsetHeight + ( document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + \'px\');}</style><![endif]><![endif]-->');
				if(speed == 0) speed = 1;
			}
			
			document.write('<div id="advScrollerId"><a href="'+ urlP +'" style="height:'+ heightP +'px;text-decoration:none;border:none;" '+ (closeP == 1 ? 'onClick="scroll.close()"' : '') +' onMouseOver="scroll.stop()" onMouseOut="scroll.start()" target="'+ (targetP == 1 ? '_blank' : '_self') +'"></a><div id="advScrollerCross"><a href="#" onClick="scroll.close()" style="text-decoration:none;border:none;"></a></div></div>');
			div = document.getElementById('advScrollerId');
		
			div.style.bottom = bottomPaddingP + 'px';
			
			return this.start();
		},
		
		//funkcja wyzwalajaca animacje
		start: function() {
			interval = setInterval("scroll.animate()",speed);
		},
		
		//funkcja zatrzymujaca animacje
		stop: function() {
			clearInterval(interval);
			return;
		},
		
		//funkcja animujaca zamiast dir * 2 mozna zmienic minimalny krok przesuniecia paska. Dir wyznacza kierunek.
		animate: function() {
			div.style.backgroundPosition = inc + 'px 0px';
			inc += dir * 3;
			return;
		},
		
		//funckja zatrzymuje animacje i zamyka scroll
		close: function() {
			clearInterval(interval);
			div.style.display = 'none';
		}
	}
}();
