function sprawdz_pola(formularz)
{
	var Wzor = /^[^\ \@\"\|\`\[\]\\\?\>\<\;\:\,\(\)\$\#]+@([A-Za-z0-9]+\.)+[A-Za-z]{1,4}$/;
		
	with(formularz)
	{

		if(miasto.selectedIndex==0)
		{
			alert("Proszę podać miasto. ");
			miasto.focus();
			return false;
		}
		if(obiekt.selectedIndex==0)
		{
			alert("Proszę podać obiekt wynajmu. ");
			obiekt.focus();
			return false;
		}
		if(dzielnica.value=="")
		{
			alert("Proszę określić dzielnicę/ulicę. ");
			dzielnica.focus();
			return false;
		}
		if(header.value=="")
		{
			alert("Proszę podać tytuł ogłoszenia. ");
			header.focus();
			return false;
		}
		if(opis.value=="")
		{
			alert("Proszę podać treść ogłoszenia. ");
			opis.focus();
			return false;
		}
		if(koszt.value=="")
		{
			alert("Proszę określić koszt wynajmu. ");
			koszt.focus();
			return false;
		}
		
		if(mail.value==""){
			alert("Aby dodać ogłoszenie proszę podać adres e-mail. ");
			mail.focus();
			return false;
		}
		if(mail2.value==""){
			alert("Powtórz adres e-mail. ");
			mail2.focus();
			return false;
		}
		if(mail.value!=mail2.value) {
			alert("Podane adresy e-mail są różne");
			mail.focus();
			return false;
		}
		if(Wzor.test(mail.value)==false) {
			alert("Niepoprawny format adresu e-mail");
			mail.focus();
			return false;
		}
		
		if(mail.value.length>50)
		{
			alert("Zbyt długi wpis w polu adresu e-mail. Max 50 znaków");
			mail.focus();
			return false;
		}
		
		if(gg.value && /^[0-9]+$/.test(gg.value)==false) {
			alert("Niepoprawny format numeru gg. Dopuszczalne są same cyfry. ");
			gg.focus();
			return false;
		}

	}
	document.getElementById("dodajBtn").style.display = "none";

}


function sprawdz_pola2(formularz)
{
	var Wzor = /^[^\ \@\"\|\`\[\]\\\?\>\<\;\:\,\(\)\$\#]+@([A-Za-z0-9]+\.)+[A-Za-z]{1,4}$/;
   
	with(formularz)
	{
		if(miasto2.selectedIndex==0)
		{
			alert("Proszę podać miasto. ");
			miasto2.focus();
			return false;
		}
		if(dzielnica2.value=="")
		{
			alert("Proszę określić rejon/dzielnicę miasta. ");
			dzielnica2.focus();
			return false;
		}
		if(opis2.value=="")
		{
			alert("Proszę podać treść ogłoszenia. ");
			opis2.focus();
			return false;
		}
		if(koszt2.value=="")
		{
			alert("Proszę podać oczekiwany koszt wynajmu. ");
			koszt2.focus();
			return false;
		}
		if(mail2.value==""){
			alert("Aby dodać ogłoszenie musisz podać swój adres e-mail. ");
			mail2.focus();
			return false;
		}
		if(mail3.value==""){
			alert("Powtórz swój adres e-mail. ");
			mail3.focus();
			return false;
		}
		if(mail2.value!=mail3.value) {
			alert("Podane adresy e-mail są różne");
			mail2.focus();
			return false;
		}
		
		if(Wzor.test(mail2.value)==false) {
			alert("Niepoprawny format adresu e-mail");
			mail2.focus();
			return false;
		}
			
		if(gg2.value && /^[0-9]+$/.test(gg2.value)==false) {
			alert("Niepoprawny format numeru gg. Dopuszczalne są same cyfry. ");
			gg2.focus();
			return false;
		}
	}
	document.getElementById("dodajBtn").style.display = "none";
}

function sprawdz_formularz(formularz)
{
	var Wzor = /^[^\ \@\"\|\`\[\]\\\?\>\<\;\:\,\(\)\$\#]+@([A-Za-z0-9]+\.)+[A-Za-z]{1,4}$/;
	var Wzor2 = /^\"[^\|\`\?\"]+\"@([A-Za-z0-9]+\.)+[A-Za-z]{1,4}$/;
	
	with(formularz)
	{
		if(mail.value=="")
		{
			alert("Musisz podać swój adres e-mail");
			mail.focus();
			return false;
		}
		if(temat.value=="")
		{
			alert("Musisz podać temat wiadomości");
			temat.focus();
			return false;
		}
		if(wiadomosc.value=="")
		{
			alert("Musisz podać treść wiadomości");
			wiadomosc.focus();
			return false;
		}
		else if(Wzor.test(mail.value)==false && Wzor2.test(mail.value)==false)
		{
			alert("Niepoprawny format adresu e-mail");
			mail.focus();
			return false;
                }
		if(wiadomosc.value.length>1000)
		{
			alert("Zbyt długa treść wiadomości. Max 1000 znaków");
			wiadomosc.focus();
			return false;
		}
		if(temat.value.length>250)
		{
			alert("Zbyt długi temat. Max 250 znaków");
			temat.focus();
			return false;
		}
	}
}

function createMail(m1, m2) {
	document.getElementById('m').innerHTML='<a style="color: #330000; font-size: 11px; font-family: Arial; text-decoration: underline;" href="mailto:'+m2+'@'+m1+'">'+m2+'@'+m1+'</a>';
}

function manage_search_obiekt() {
	
	if ( document.getElementById('s_kategoria').value=='mam' ) {
		document.getElementById('ss_obiekt').style.display = 'block';
		document.getElementById('s_obiekt').style.display = 'block';
	}
	else {
		document.getElementById('ss_obiekt').style.display = 'none';
		document.getElementById('s_obiekt').style.display = 'none';
	}
}


