// animowane promocje na stronie glownej - cz.srodkowa.

function scrollObject(main, width, height, direct, pause, speed) {
	var self = this;
	this.main = main;
	this.width = width;
	this.height = height;
	this.direct = direct;
	this.pause = pause;
	this.speed = Math.max(1.001, Math.min((direct == "up" || direct == "down") ? height : width, speed));
	this.block = new Array();
	this.blockprev = this.offset = 0;
	this.blockcurr = 1;
	this.mouse = false;
	this.scroll = function() {
		if (!document.getElementById('sProm')) return false;
		this.main = document.getElementById(this.main);
		while (this.main.firstChild) this.main.removeChild(this.main.firstChild);
		this.main.style.overflow = "hidden";
		this.main.style.position = "relative";
		this.main.style.width = this.width + "px";
		this.main.style.height = this.height + "px";
		for (var x = 0; x < this.block.length; x++) {
			var table = document.createElement('table');
					table.cellPadding = table.cellSpacing = table.border = "0";
					table.style.position = "absolute";
					table.style.left = table.style.top = "0px";
					table.style.width = this.width + "px";
					table.style.height = this.height + "px";
					table.style.overflow = table.style.visibility = "hidden";
				var tbody = document.createElement('tbody');
					var tr = document.createElement('tr');
						var td = document.createElement('td');
								td.align="center";
								td.innerHTML = unescape(this.block[x]);
							tr.appendChild(td);
						tbody.appendChild(tr);
					table.appendChild(tbody);
			this.main.appendChild(this.block[x] = table);
		}
		if (this.block.length > 1) {
			this.main.onmouseover = function() { self.mouse = true; }
			this.main.onmouseout = function() { self.mouse = false; }
			setInterval(function() {
				if (!self.offset && self.scrollLoop()) self.block[self.blockcurr].style.visibility = "visible";
			}, this.pause);
		} this.block[this.blockprev].style.visibility = "visible";
	}
	this.scrollLoop = function() {
		if (!this.offset) {
      if (this.mouse) return false;
			this.offset = (this.direct == "up" || this.direct == "down") ? this.height : this.width;
    } else this.offset = Math.floor(this.offset / this.speed);
		if (this.direct == "up" || this.direct == "down") {
			this.block[this.blockcurr].style.top = ((this.direct == "up") ? this.offset : -this.offset) + "px";
			this.block[this.blockprev].style.top = ((this.direct == "up") ? this.offset - this.height : this.height - this.offset) + "px";
		} else {
			this.block[this.blockcurr].style.left = ((this.direct == "left") ? this.offset : -this.offset) + "px";
			this.block[this.blockprev].style.left = ((this.direct == "left") ? this.offset - this.width : this.width - this.offset) + "px";
		}
		if (!this.offset) {
			this.block[this.blockprev].style.visibility = "hidden";
			this.blockprev = this.blockcurr;
			if (++this.blockcurr >= this.block.length) this.blockcurr = 0;
		} else setTimeout(function() { self.scrollLoop(); }, 30);
    return true;
	}
}

// animowane promocje nw boxie - efekt przewijany

function pausescroller(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
document.write(unescape('<div id="'+divId+'" class="'+divClass+'" style="position: relative; display:block; overflow: hidden;"><div class="innerDiv" style="position: absolute; width: 100%;" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: relative; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>'))
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

pausescroller.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}

pausescroller.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+2)){
this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-2+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-2+"px"
setTimeout(function(){scrollerinstance.animateup()}, 50)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

pausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

pausescroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=unescape(this.content[this.hiddendivpointer])
this.animateup()
}
}

pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}

// animowane nowosci nw boxie - efekt przewijany

function pausescrollern(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
document.write(unescape('<div id="'+divId+'" class="'+divClass+'" style="position: relative; display:block; overflow: hidden;"><div class="innerDiv" style="position: absolute; width: 100%;" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: relative; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>'))
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

pausescrollern.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescrollern.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}

pausescrollern.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+2)){
this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-2+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-2+"px"
setTimeout(function(){scrollerinstance.animateup()}, 50)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

pausescrollern.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

pausescrollern.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

pausescrollern.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=unescape(this.content[this.hiddendivpointer])
this.animateup()
}
}

pausescrollern.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}
  
// animowane bestsellery nw boxie - efekt przewijany

function pausescrollerbest(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=0 //index of message array for hidden div
document.write(unescape('<div id="'+divId+'" class="'+divClass+'" style="position: relative; display:block; overflow: hidden;"><div class="innerDiv" style="position: absolute; width: 100%;" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: relative; width: 100%; visibility: hidden" id="'+divId+'2">'+content[0]+'</div></div>'))
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

pausescrollerbest.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescrollerbest.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}

pausescrollerbest.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+2)){
this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-2+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-2+"px"
setTimeout(function(){scrollerinstance.animateup()}, 50)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

pausescrollerbest.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

pausescrollerbest.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

pausescrollerbest.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=0;
this.hiddendiv.innerHTML=unescape(this.content[this.hiddendivpointer])
this.animateup()
}
}

pausescrollerbest.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}

// animowane nowosci w module - przewijane

function scroll_fwd(s) {
    if(s) scroll = true;
    if (parseInt(document.getElementById('img_scroll').style.left) < 0) { document.getElementById('img_scroll').style.left = (parseInt(document.getElementById('img_scroll').style.left) + 8) +"px";
        } else { document.getElementById('img_scroll').style.left = "0px"; }
    wspolczynnik = (document.getElementById('scroller').offsetWidth/((document.getElementById('img_scroll').offsetWidth - document.getElementById('scroller').offsetWidth)));
    wspolczynnik_szerokosci = 1-(szerokosc_suwaka/document.getElementById('scroller').offsetWidth);
    document.getElementById('kwadrat').style.left = (((parseInt(document.getElementById('img_scroll').style.left)*-1)*wspolczynnik)*wspolczynnik_szerokosci) +"px";
    if(scroll) setTimeout("scroll_fwd()",10) }

function scroll_rew(s) {
    if(s) scroll = true;
    if ((parseInt(document.getElementById('img_scroll').style.left)*-1) < (document.getElementById('img_scroll').offsetWidth - document.getElementById('scroller').offsetWidth)) { document.getElementById('img_scroll').style.left = (parseInt(document.getElementById('img_scroll').style.left) - 8) +"px";
        } else { document.getElementById('img_scroll').style.left = ((document.getElementById('img_scroll').offsetWidth - document.getElementById('scroller').offsetWidth)*-1) +"px"; }
    wspolczynnik = (document.getElementById('scroller').offsetWidth/((document.getElementById('img_scroll').offsetWidth - document.getElementById('scroller').offsetWidth)));
    wspolczynnik_szerokosci = 1-(szerokosc_suwaka/document.getElementById('scroller').offsetWidth);
    document.getElementById('kwadrat').style.left = (((parseInt(document.getElementById('img_scroll').style.left)*-1)*wspolczynnik)*wspolczynnik_szerokosci) +"px";
    if(scroll) setTimeout("scroll_rew()",10)
}

function movemouse(e) {
  if (isdrag) {
    if (nn6) {
            if (tx + e.clientX - x >= 0 && tx + e.clientX - x <= parseInt(document.getElementById('scroller').offsetWidth-szerokosc_suwaka)) {
                dobj.style.left = tx + e.clientX - x +"px";
                if (parseInt(dobj.style.left) == parseInt(document.getElementById('scroller').offsetWidth-szerokosc_suwaka)) {
                    document.getElementById('img_scroll').style.left = (document.getElementById('img_scroll').offsetWidth-document.getElementById('scroller').offsetWidth)*-1 +"px";
                  } else if (parseInt(dobj.style.left) == 0) {
                        document.getElementById('img_scroll').style.left = 0+"px";
                     } else {
                    wspolczynnik_odchylenia = 1+(szerokosc_suwaka/document.getElementById('scroller').offsetWidth);
                    ile = ((document.getElementById('img_scroll').offsetWidth-document.getElementById('scroller').offsetWidth)/document.getElementById('scroller').offsetWidth)*(parseInt(dobj.style.left)*wspolczynnik_odchylenia);
                    document.getElementById('img_scroll').style.left = (ile*-1) +"px";	} }
        } else {
            if (tx + event.clientX - x >= 0 && tx + event.clientX - x <= parseInt(document.getElementById('scroller').offsetWidth-szerokosc_suwaka)) {
                dobj.style.left = tx + event.clientX - x +"px";
                if (parseInt(dobj.style.left) == parseInt(document.getElementById('scroller').offsetWidth-szerokosc_suwaka)) {
                    document.getElementById('img_scroll').style.left = (document.getElementById('img_scroll').offsetWidth-document.getElementById('scroller').offsetWidth)*-1+"px";
                  } else if (parseInt(dobj.style.left) == 0) {
                        document.getElementById('img_scroll').style.left = 0+"px";
                     } else {
                    wspolczynnik_odchylenia = 1+(szerokosc_suwaka/document.getElementById('scroller').offsetWidth);
                    ile = ((document.getElementById('img_scroll').offsetWidth-document.getElementById('scroller').offsetWidth)/document.getElementById('scroller').offsetWidth)*(parseInt(dobj.style.left)*wspolczynnik_odchylenia);
                    document.getElementById('img_scroll').style.left = (ile*-1) +"px";	} }
    } return false; } }

function selectmouse(e)  {
  var fobj       = nn6 ? e.target : event.srcElement;
  var topelement = nn6 ? "HTML" : "BODY";
  while (fobj.tagName != topelement && fobj.className != "dragme") { fobj = nn6 ? fobj.parentNode : fobj.parentElement; }
  if (fobj.className=="dragme") { isdrag = true;dobj = fobj;tx = parseInt(dobj.style.left+0);x = nn6 ? e.clientX : event.clientX;document.onmousemove=movemouse;return false; } }
