/**
	*       Javascript Library
	* -------------------------------
	* www.avatec.pl / biuro@avatec.pl
**/

	function wopen(url, name, w, h)
	{
		// Fudge factors for window decoration space.
		// In my tests these work well on all platforms & browsers.
		w += 32;
		h += 96;
		wleft = (screen.width - w) / 2;
		wtop = (screen.height - h) / 2;
		// IE5 and other old browsers might allow a window that is
		// partially offscreen or wider than the screen. Fix that.
		// (Newer browsers fix this for us, but let's be thorough.)
		if (wleft < 0) {
			w = screen.width;
			wleft = 0;
		}
		if (wtop < 0) {
			h = screen.height;
			wtop = 0;
		}
		var win = window.open(url, 'okno', 'width=' + w + ', height=' + h + ', left=' + wleft + ', top=' + wtop + ', location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=no');
		// Just in case width and height are ignored
		win.resizeTo(w, h);
		// Just in case left and top are ignored
		win.moveTo(wleft, wtop);
		win.focus();
	}
	
	function checkEmail(email)
	{
		var x = email;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(x)) { return true; }
		else { return false; }
	}

	function checkContactForm(form)
	{
		var msg='';
		if(form.imie.value=='') { msg+='* Wpisz swoje imię\n'; }
		if(form.email.value=='') { msg+='* Podaj swój adres e-mail\n'; }
		if(checkEmail(form.email.value)==false) { msg+='* Składnia adresu e-mail jest nieprawidłowa\n'; }
		if(form.temat.value=='') { msg+='* Podaj temat wiadomości\n'; }
		if(form.wiadomosc.value=='') { msg+='* Pole wiadomość musi zawierać treść\n'; }
		if(msg)
		{
			alert('Wystąpiły błędy\n\n'+msg);
			return false;
		} else { return true; }
	}
	
	function showPodgladKomentarza() 
	{

		if (document.all) { eval( "document.all.podglad.style.display = 'block'");	}
		if (document.layers) { 	document.layers['podglad'].display = 'block'; }
		if (document.getElementById &&!document.all) { hza = document.getElementById('podglad'); hza.style.display = 'block'; }

		if (document.all) { eval( "document.all.komentarz_p.style.display = 'none'");	}
		if (document.layers) { 	document.layers['komentarz_p'].display = 'none'; }
		if (document.getElementById &&!document.all) { hza = document.getElementById('komentarz_p'); hza.style.display = 'none'; }
		
		document.getElementById('tekst_komentarza').innerHTML=document.getElementById('komentarz_input').value;
	
	}
	
	function hidePodgladKomentarza() 
	{
		if (document.all) { eval( "document.all.podglad.style.display = 'none'");	}
		if (document.layers) { 	document.layers['podglad'].display = 'none'; }
		if (document.getElementById &&!document.all) { hza = document.getElementById('podglad'); hza.style.display = 'none'; }

		if (document.all) { eval( "document.all.komentarz_p.style.display = 'block'");	}
		if (document.layers) { 	document.layers['komentarz_p'].display = 'block'; }
		if (document.getElementById &&!document.all) { hza = document.getElementById('komentarz_p'); hza.style.display = 'block'; }
	}
	
	function noenter() {
		return !(window.event && window.event.keyCode == 13); 
	}
	
	function enter(nextfield) 
	{
		if(window.event && window.event.keyCode == 13) 
		{
			nextfield.focus();
			return false; 
		} else return true; 
	}
	
	function entsub(event,ourform) 
	{
		if (event && event.which == 13) ourform.submit(); else  return true;
	}