$(document).ready( function () {
	function Banner(img, title, href)
	{
		this.img=img;
		this.url='url('+img+')';
		this.title=title;
		this.href=href;
	}
	function BannersRotator(banners, id)
	{
		this.banners=banners;
		this.id=id;
	}
	function setBanner(index,id){
		$(id).css('background',this.banners[index].url);
		$(id).attr("href",this.banners[index].href);
		$(id).attr("title",this.banners[index].title);
	}			
	function rotate(index,timeout,id){
		if(id==null){
			id=this.id; 
		}
		setBanner(index,id);
		setTimeout(function(){			
			rotate((index+1)%this.banners.length,timeout,id);
		},timeout);
	}		
	BannersRotator.prototype.setBanner=setBanner;				
	BannersRotator.prototype.rotate=rotate;

	banner1=new Banner('/images/layout/e-kantorwalutowy.pl.png','Kantor wymiany walut','http://www.e-kantorwalutowy.pl');
	banner2=new Banner('/images/layout/e-numizmatyka.pl.png', 'Monety, numizmatyka, złoto','http://www.e-numizmatyka.pl');
	banner3=new Banner('/images/layout/fabrykazlota.pl.png','Złoto, sztabki złota, kursy złota','http://www.fabrykazlota.pl');
	banners=[banner1, banner2, banner3];

	var oBanRot=new BannersRotator(banners,'#rotator');
	oBanRot.rotate(1,2000);
});
