 var interval = 0;
 var Reklama = Class.create();
 Reklama.prototype = {

    initialize: function() {
       var popup = document.getElementsByTagName("body").item(0);

		var objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','zoverlay');
		objOverlay.style.display = 'none';
        objOverlay.className ="reklama";
        popup.appendChild(objOverlay);

        var top = document.createElement("div");
        top.setAttribute('id','top');
        top.className ="rTop";
        top.innerHTML='X';
        top.style.cursor = 'pointer';
        top.onclick = function() {myReklama.end(); return false; }
        objOverlay.appendChild(top);

        var naglowek = document.createElement("div");
        naglowek.setAttribute('id','naglowek');
        naglowek.className ="rIns";
        naglowek.innerHTML='INSTYTUT BEZPIECZEŃSTWA BIZNESU Sp. z o.o.';
        objOverlay.appendChild(naglowek);

        var blok = document.createElement("div");
        blok.setAttribute('id','blok');
        blok.className ="rBlok";
        blok.innerHTML='OFERTA SPECJALNA !!!';
        objOverlay.appendChild(blok);

        var content0 = document.createElement("div");
        content0.setAttribute('id','t1');
        content0.className ="rT";

         LinkP = document.createElement("a");
 	      LinkP.href = "index.php?p=badania_poligraficzne";
 	      LinkP.appendChild(document.createTextNode('Badania poligraficzne'));
          LinkP.className = 'rLoc';
          content0.appendChild(LinkP);
        objOverlay.appendChild(content0);

        var content01 = document.createElement("div");
        content01.setAttribute('id','blok1');
        content01.className ="rT1";
        var elNew = document.createElement('li');
        elNew.innerHTML='cena od 400 zł   <span style="font-size:15px;" class="red" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>PROMOCJA !!!</b></span>';
        elNew.className ="rTa";
        content01.appendChild(elNew);
        objOverlay.appendChild(content01);

        var content1 = document.createElement("div");
        content1.setAttribute('id','t2');
        content1.className ="rT";

         LinkA = document.createElement("a");
 	      LinkA.href = "index.php?p=badania_antypodsluchowe";
 	      LinkA.appendChild(document.createTextNode('Badania antypodsłuchowe'));
          LinkA.className = 'rLoc';
          content1.appendChild(LinkA);
        objOverlay.appendChild(content1);

        var content11 = document.createElement("div");
        content11.setAttribute('id','blok2');
        content11.className ="rT1";
        var elNew1 = document.createElement('li');
        elNew1.innerHTML='cena od 20 zł za 1m<span style="font-size:10;font-weight:bold;"><sup>2</sup></span>  <span style="font-size:15px;" class="red">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>PROMOCJA !!!</b></span>';
        elNew1.className ="rTa";
        content11.appendChild(elNew1);
        objOverlay.appendChild(content11);
    },

    start: function() {
        this.initialize();
        var pSize = this.getPageSize();
         $('zoverlay').style.top =  50;
         $('zoverlay').style.left =  0;

         clearInterval(interval) ;
              interval = setInterval('rPlay()',3000);

//this.eventResize = this.moveWin.bindAsEventListener(this);
//Event.observe(window, "scroll", this.eventResize);

    },

    moveWin: function(e){
      // Position.prepare();
       el=$('zoverlay');
      // var offsets = Position.cumulativeOffset(event);

    },
    setHref: function(element,href) {
    	element = $(element);
    	element.href = href;
	},
	setInnerHTML: function(element,content) {
		element = $(element);
		element.innerHTML = content;
	},
  	end: function() {
		//Element.hide('overlay');
		new Effect.Fade('zoverlay', { duration: 0.2});

	},
    getPageSize:function(){

	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}

};
    function rPlay(){
       clearInterval(interval) ;
       Effect.Appear('zoverlay');

    };

function zblink() {
 if (!document.all) return;
 else {
   for(i=0;i<document.all.tags('blink').length;i++){
      s=document.all.tags('blink')[i];
      s.style.visibility=(s.style.visibility=='visible')?'hidden':'visible';
   }
 }
}
function initblink(){setInterval('zblink()',500)}
Event.observe(window, 'load', initblink, false);



