var timeout = 10000;
var t = [];
var i = randomik(2);
var Interval;

function randomik(max)
{
	iter = new Date();
	tmp = Math.round(iter.getTime() * Math.random()) % max;
	return tmp;
}

/*
  *	Funkcja odpowiedzialna za odpieranie ciastek o danej nazwie
  */

function getCookie(check_name) {
	var a_all_cookies 	= document.cookie.split(';');
	var b_cookie_found 	= false; 
	var a_temp_cookie 	= '';
	var cookie_name 	= '';
	var cookie_value 	= '';
	
	for (i=0; i<a_all_cookies.length; i++){
		a_temp_cookie = a_all_cookies[i].split('=');

		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		if (cookie_name == check_name){
			b_cookie_found = true;
			
			if (a_temp_cookie.length > 1)
				cookie_value = unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g, ''));
			
			return cookie_value;
			break;
		}

		a_temp_cookie = null;
		cookie_name   = '';
	}
	
	if(!b_cookie_found)
		return null;
}		

/*
  *	Dodajemy zdarzenie
  */
  
function addEvent(o, e, f){
	return (o.a=o.addEventListener)?o.a(e,f,1):(o.a=o.attachEvent)?o.a('on'+e,f):!1;
}


/*
  *	Jeśli jest na liście banner flashowy to ...
  */
  
function isFlash(x, y){
	if((x=navigator.plugins)&&x.length)
		y=x["Shockwave Flash"];
	else if(x=window.ActiveXObject)
		eval('try{y=new x("ShockwaveFlash.ShockwaveFlash"),1}catch(e){}');
  
	return y;
}


/*
  *	Funkcja dodająca banner do tablicy rotowań
  */

function addBanner(SRC, HREF, ALT){
	if(/.swf/.test(SRC)||isFlash())
		t[t.length]={s:SRC,h:HREF,a:ALT,display:createBanner}
}


/*
  *	Funkcja tworzaca obiekt
  */

function createBanner(e){	
	if(!document.createElement)
		return;
	
	with(e = document.createElement("div")){
		id = "advert";
		innerHTML=/.swf/.test(this.s)?flashCode(this):imgCode(this);
	}
	
	document.getElementById('banner').appendChild(e);
}


/*
  *	Czyścimy co zostało z poprzedniej rotacji
  */

function clearBanner(){
	var adv = document.getElementById("banner");
	nowaZaw = "";
	adv.innerHTML = nowaZaw;
}


/*
  *	Kod flashowy
  */

function flashCode(X){
	return ''+
	'<embed style="width:486px; height:100px;" type="application/x-shockwave-flash" src="'+X.s+'"" id="movie" quality="best" wmode="transparent">'+
	'</embed>'+
	'';
}


/*
  *	Kod dla gif / png
  */
  
function imgCode(X){
	return '<a href="'+X.h+'" target="blank"><img width="486" height="100" src="'+X.s+'" alt="'+X.a+'" /><\/a>';
}


/*
  *	Inicjujemy wszystko
  */

function init(){
	if(document.getElementById('banner')){
		clearBanner();

		if(i>=t.length)
			i=0;

			t[i].display();
		}
		i++;
		//setTimeout("init("+i+")", timeout);
	}

function funky()
{
	Interavl = self.setInterval('init()', timeout);
}

/*
  *	Wywołanie 
  */
funky();
//addEvent(window,'load',function(){initialit()}) 

