function MeteorApi2(){

	var error=false;
	var IE_OP = document.all?true:false;
	var IE_nOP = document.all&&!window.opera?true:false;
	var IE = window.XMLHttpRequest?false:true;
	var quirksMode=((document.compatMode+'a')=='BackCompata')?true:false;
	var rok=0;
	var flash=0,mapaPolozenia=0,dyplomNowy=0,dyplom06=0,bwmGlobal=0;
	var czyRamka;
	var ileRazySprawdzanyDyplom=0;
	try{
		czyRamka=window.parent.location.href!=window.location.href;
		if(czyRamka){
			var framesets = window.parent.document.getElementsByTagName('FRAMESET');
			if(framesets.length>0){
				czyRamka=false;
			}
		}
	}catch(err){
		//Handle errors here
		czyRamka=false;
	}

	/////////////////////////
	// baza wolnych miejsc //
	/////////////////////////

	function sprawdzCzyBWMDobrzeWklejona(map){
		return true;
	}

	this.bazaWolnychMiejsc=function(){

		if(bwmGlobal){
			return;
		}
		var bwm=document.getElementById("kontenerBazaWolnychMiejsc");
		if(!bwm){
			return;
		}

		if(!sprawdzCzyBWMDobrzeWklejona(bwm)){
			return;
		}
		var p=bwm.getElementsByTagName("P");
		p=p[0];


		var id=(p.id).replace("n","");
		var tmp=id.split("_");
		id=parseInt(tmp[0]);
		
		var ileDni=parseInt(tmp[1]);
		var kolor=p.style.backgroundColor;
		kolor=kolor.replace("#","");
		if(kolor.match("rgb")){
			kolor=RGBtoHex(kolor);
		}

		var h=parseInt(bwm.style.height)-20;
		var get='';
		//http://localhost/bwm/index.php?p=0&f=i&id=2&iframe=1&iledni=14&y=2009&m=9&d=26&j=pl&bgcolor=ccF
		if(h>0){
			//	map.append("<iframe src='http://www.noclegiw.pl/mapawpsolrzedne.php?sub="+id+"&amp;loc="+window.location+"' style='height:"+map.height()+"px;width:"+(map.width()-2)+"px;'></iframe>");
			//get="id="+id+"&amp;r=1&amp;prtner=1&amp;s="+kolor;
			get="id="+id+"&r=1&iframe=1&bgcolor="+kolor+"&iledni="+ileDni;
		}else{
			//get="id="+id+"&amp;r=1&amp;prtner=1&amp;s="+kolor;
			get="id="+id+"&r=1&iframe=1&bgcolor="+kolor+"&iledni="+ileDni;
		}
		//alert (get);
		//alert("<iframe class='bwm' src='http://bwm.emeteor.pl/index.php?funkcja=uzytkownik&amp;"+get+"' scrolling='auto' border=0 marginheight=0 marginwidth=0 frameborder=0 ></iframe>");
		bwm.style.height='auto';
		//bwm.prepend("<iframe class='bwm' src='http://bwm.emeteor.pl/index.php?funkcja=uzytkownik&amp;"+get+"' scrolling='auto' border=0 marginheight=0 marginwidth=0 frameborder=0 style='display:block;width:100%;height:"+h+"px;' ></iframe>");

		var iframe = document.createElement('iframe');
		iframe.src='http://bwm.emeteor.pl/index.php?f=i&'+get;
		iframe.scrolling='auto';
		iframe.border=0;
		iframe.marginheight=0;
		iframe.marginwidth=0;
		iframe.frameborder=0;
		iframe.style.display='block';
		iframe.style.width='99%';
		iframe.style.height=h+'px';
		iframe.style.margin='0 auto';
		iframe.style.borderStyle='none';
		iframe.className='bwm';

		bwm.insertBefore(iframe,p);
		bwm.style.textAlign='center';
		bwmGlobal=1;
	};

	function RGBtoHex(kolor) {
		var tmp=kolor.replace("rgba","");
		tmp=kolor.replace("rgb","");
		tmp=tmp.replace("(","");
		tmp=tmp.replace(")","");
		tmp=tmp.split(",");
		//alert(tmp[0]);
		var R=parseInt(tmp[0]);
		var G=parseInt(tmp[1]);
		var B=parseInt(tmp[2]);
		return toHex(R)+toHex(G)+toHex(B);
	}

	function toHex(N) {
		if (N==null){
			return "00";
		}
		N=parseInt(N);
		if (N==0 || isNaN(N)) {
			return "00";
		}
		N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
		return "0123456789ABCDEF".charAt((N-N%16)/16) + "0123456789ABCDEF".charAt(N%16);
	}
}

var meteor2=0;
meteor2=new MeteorApi2();
window.setTimeout("meteor2.bazaWolnychMiejsc()",400);