 
	//var domena = "http://polskiemiasta3d.pl/ver_2/";
	var domena = "http://polskiemiasta3d.pl/";
	

	var widoczne_okno = false;
	
	function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isOP    = false;  // Opera
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;


  if (navigator.userAgent.indexOf("Opera")!=-1) {
    this.isOP = true;
    return;
  }
  else if (document.getElementById&&document.all){
    this.isIE = true;
    s="MSIE";
    if ((i = ua.indexOf(s)) >= 0) {
     this.version = parseFloat(ua.substr(i + s.length));
    }
    return;
  }
  else if (typeof(document.all)!="undefined"){
    alert("ie4");
  }
  else if (document.getElementById){
    this.isNS = true;
    this.version = 6.1;
    return;
  }
  else {
     alert("Unknown or Unsupported Browser");
  }


  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isOP = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as Netscape 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }

  s = "MSIE";
  if ((i = ua.indexOf(s))) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
}

var browser = new Browser();


	
	function otworz(adres)
	{
		noweOkno = window.open(adres, '');
	} 
	

	function usun_element(adres)
	{
		if (confirm('Czy napewno usun±ć ten element?')) { przejdz(adres); } else { return false; }
	}
	
	function getPageHeight()
	{
		var windowHeight;
		if (self.innerHeight)
		{    // all except Explorer
			windowHeight = self.innerHeight;
		} else 
		if (document.documentElement && document.documentElement.clientHeight) 
		{ // Explorer 6 Strict Mode
			windowHeight = document.documentElement.clientHeight;
		}	else if (document.body)
		{ // other Explorers
			windowHeight = document.body.clientHeight;
		}   
		return windowHeight;
	}
	
	function getPageWidth()
	{
		var windowWidth;
		if (self.innerHeight) 
		{    // all except Explorer
			windowWidth = self.innerWidth;
		} else if (document.documentElement && document.documentElement.clientHeight) 
		{ // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
		} else if (document.body)
		{ // other Explorers
			windowWidth = document.body.clientWidth;
		}   
		return windowWidth;
	}
	
	
	function createRequester()
	{
		if(window.XMLHttpRequest) // Is the browser DOM compliant?
		{
			requestObject = new XMLHttpRequest();
			//requestObject.overrideMimeType("text/xml");
		}
		else if(window.ActiveXObject) // Or was it made by Microsoft?
		{
			try 
			{	
				requestObject = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				try 
				{
					requestObject = new ActiveXObject("Msxml2.XMLHTTP");
				
				}
				catch (e)
				{
					alert("Twoja przeglądarka nie obsługuje tej metody");
					return false; 
				}
			}
		}
		else
		{
			return false; // If you make it here you need a new browser
		}
		return requestObject;
	}



	function przeslij(url) 
	{
		var oRequest;
		
		//alert(nazwa);

		oRequest = createRequester();	

		oRequest.open('GET', url, true);
		oRequest.send(null);
	}
	
	function pobierz(url)
	{	
		var oRequest;
		var wynik;

		oRequest = createRequester();

		oRequest.open('POST', url, false);

		oRequest.send(null);
		if (oRequest.status==200)
			{ wynik = oRequest.responseText } else
			{ wynik = 'Błąd'; }
		return wynik;	
	}
	
	function pobierz_async(url,func)
	{	
		var oRequest;
		oRequest = createRequester();

		oRequest.open('GET', url, true);
		
		oRequest.onreadystatechange = function (aEvt) 
		{
			if (oRequest.readyState == 4)
			{
				if(oRequest.status == 200) func(oRequest.responseText);
			}
		};
		oRequest.send(null);
	}	
	
	function zaznacz_pole(obj)
	{
		obj.focus();
	}
	
	function sprawdz_pole(obj,tab)
	{
		wyn = true;
		v = obj.value;
		func = tab["func"];
		if ("len" in tab)
		{
			if ("min" in tab)
			{
				if (v.length<tab["min"]) wyn = false;
			}
			if ("max" in tab)
			{
				if (v.length>tab["max"]) wyn = false;
			}
			if ( (tab["min"]==undefined) && (tab["max"]==undefined) && (v=='') ) wyn = false;				
		}
		
		if ("mail" in tab)
		{
			var reg = new RegExp(".*@{1}.[^@]*[.][^@].","i");
			var m = v.match(reg);
			//alert(m);
			if (m==null) wyn = false;
		}
		
		if ("equal" in tab)
		{
			obj_2 = document.getElementById(tab["obj"]);
			if (obj_2!=undefined)
			{
				v_2 = obj_2.value;
				if (v != v_2) wyn = false;
			}
		}
		return wyn;
	}
	
	function walidacja(forma,elementy)
	{
		var wyn = true;
		if (forma==undefined) forma = this;
		if ( (elementy==undefined) || (elementy=='') )
		{
			w = forma.elements['walidate'].value;
			if (w!=undefined) regula = w; 
		} else { regula = elementy; }		
		for(i=0;i<forma.elements.length;i++)
		{
			tab = new Object();
			tab["var"] = '';
			obj = forma.elements[i];
			var id = forma.elements[i].id;
			next = false;
			if ( ( ("id" in obj) && (id!='') && (regula.indexOf(id+':')>-1) ) || ( "reg" in obj ) )
			{
				
				if ("reg" in obj) alert( obj.reg );
				pos = regula.indexOf(id);
				d = false;
				func = '';
				for (j=pos;j<regula.length;j++)
				{			
					if ( (d==true) && (regula.charAt(j)!='%') && (next==false) && (regula.charAt(j)!=';') ) func = func + regula.charAt(j);
					if ( (d==true) && ( (regula.charAt(j)=='%') || (regula.charAt(j)==';') || (j==regula.length-1) ) && (next==false) ) 
					{
						if (func.indexOf('=')>0)
						{
							tab[func.substr(0,func.indexOf('='))]=func.substr(func.indexOf('=')+1);
						} else tab[func] = '1';
						func = '';
					}
					if (regula.charAt(j) == ';') { next = true; d = false; }
					if (regula.charAt(j)==':') d = true;
				}
				wyn = sprawdz_pole(obj,tab);
				if (wyn!=true)
				{
					zaznacz_pole(obj);
					if ("info" in tab) alert(tab["info"]);
					if ("eval" in tab) eval(tab["eval"]);
					return false;
				}	
			}
			delete tab;
		}
		return wyn;
		
	}
	
	function wyslij_formularz(forma)
	{
		if (forma.walidate==null)
		{ 
			forma.submit();
		} else
		{ 
			if (walidacja(forma,forma.walidate.value)==true) forma.submit();
		}
	}
	
	
	function pokaz_okno(e,zawartosc,dx,dy)
	{
		obj = document.getElementById('div_okno');
		if (obj==undefined)
		{
			obj = document.createElement("div");
		}
		if (widoczne_okno==false)
		{
			var tresc;
			if (zawartosc.charAt(0)=='@')
				{ tresc = pobierz(zawartosc.substr(1)); } else { tresc = zawartosc; }

			obj.innerHTML = tresc;
			var x = 0;
			var y = 0;
			if (document.all) 
			{
				var b = document.body;
				x = b.scrollTop + e.x; 
				y = b.scrollTop + e.y;
				//alert( x + '  ' + y);
			} else
			{
				x = e.pageX;
				y = e.pageY;
			}
			x = x + dx;
			y = y + dy;
			obj.style.left = x + "px";
			obj.style.top  = y + "px";
			obj.style.display = 'block';
			widoczne_okno = true;
		}
		
	}
		
	
	function ukryj_okno(e)
	{
		//alert('ukrywam');
		/*if (document.all) 
		{
			var b = document.body;
			x = b.scrollTop + e.x; 
			y = b.scrollTop + e.y;
			//alert( x + '  ' + y);
		} else
		{
			x = e.pageX;
			y = e.pageY;
			//alert( x + '  ' + y);
		}*/
		obj = document.getElementById('div_okno');
		//alert(obj.style.top+obj.style.height);
		//if ( (x<obj.style.left) || (x>obj.style.left+obj.style.width) || (y<obj.style.top) || (y>obj.style.top+obj.style.height) )
		{
			if (obj!=undefined)	obj.style.display = 'none';
			widoczne_okno = false;
		}	
	}

