
//odznacza radio button jezeli zostanie klikniety a wczesniej byl zaznaczony
function CheckRadio(obj)
{
	 	if (obj.checked) obj.checked = false;
}
//funkcja sprawdz poprawnosc wypelnienia formularza szukaj
function CheckFormSzukaj()
{
 	frm=document.szukaj;
 	SetCookie('szRegion',frm.regionID.value,0);
 	SetCookie('szMiasto',frm.miasto.value,0);
 	SetCookie('szDzielnica',frm.dzielnica.value,0);
 	SetCookie('szUlica',frm.ulica.value,0);
 	SetCookie('szPowOd',frm.powierzchnia_od.value,0);
 	SetCookie('szPowDo',frm.powierzchnia_do.value,0);
 	SetCookie('szCenaOd',frm.cena_od.value,0);
 	SetCookie('szCenaDo',frm.cena_do.value,0);
 	SetCookie('szRodzaj',frm.rodzaj.value,0);
	return true;
}

function DeleteOgloszenie()
{
	if (confirm('Czy napewno chcesz usun±ć ogłoszenie?')==true)
	{
		 return true;
	}
	else return false;
}


function DeleteCookie(cookieName,cookieValue,nDays)
{
	if (confirm('Czy napewno chcesz usun±ć ogłoszenie z listy obserwowanych?')==true)
	{
		 SetCookie(cookieName,cookieValue,nDays)
		 return true;
	}
	else 
		return false;
	
}

function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) 
 { 
 	nDays=200;
 	expire.setTime(today.getTime() + 3600000*24*nDays);
 }
 else
 {
	expire.setTime(today.getTime() - 3600000*24);
 }

 document.cookie = cookieName+"="+cookieValue + ";expires="+expire.toGMTString();
}


//funkcja sprawdza poprawnosc wypelnienia pola mail w formularzu send2friend
function CheckSend2Friend()
{
	frm = document.send2friend;
	re_email=/^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$/;

	if ((re_email.test(frm.email.value)==false) || (frm.email.value.length < 6)) {	alert('Niepoprawny adres email');	frm.email.focus();	return false;	}
	if (frm.safetycode.value.length < 5) { alert('Niepoprawny kod autoryzuj±cy'); frm.safetycode.focus(); return false; }
	document.getElementById('send2friend').style.display='none';
	window.open('','send2friend','menubar=no, toolbar=no, location=no,scrollbars=no, resizable=no, status=no, width=300, height=200');
	return true;	
}

//funkcja sprawdz poprawnosc wypelnienia formularza szukaj
function CheckFormRejestracja()
{
	var test;
	frm = document.rejestracja;
	if (frm.login.value.length < 3) {alert('Nazwa użytkownika musi zawierać conajmniej 4 znaki'); frm.login.focus(); return false;}
	if (frm.pwd1.value.length < 5) {alert('Hasło powinno zawierać conajmniej 6 znaków'); frm.pwd1.focus(); return false;}
	if (frm.pwd2.value != frm.pwd1.value) {alert('Hasła nie s± identyczne'); frm.pwd1.select(); frm.pwd1.focus(); return false;}
	if (frm.company.value.length == 0)
	{
		if (frm.name.value.length < 1) test=1
		if (frm.sourname.value.length <1) test=1
		if (test == 1)	{ alert('Pola Imię, Nazwisko lub Nazwa firmy musz± być uzupełnione'); frm.name.focus(); return false;	}
	}
	
	if (frm.street.value.length < 1) {alert('Podaj nazwę ulicy'); frm.street.focus(); return false;}
	if (frm.zipcode.value.length < 6) {alert('¬le wypełnione pole Kod pocztowy'); frm.zipcode.focus(); return false;}
	if (frm.city.value.length < 2) {alert('¬le wypełnione pole Miasto'); frm.city.focus(); return false;}
	if (frm.regionid.value == 'null') {alert('Wybierz województwo'); frm.regionid.focus(); return false;}
	if (frm.email.value.length < 3) {alert('Podałe¶ nieprawidłowy adres email'); frm.email.focus(); return false; }
	return true;
}


//funkcja sprawdz poprawnosc wypelnienia formularza szukaj
function CheckFormSendMsg()
{
	frm = document.send_msg;
	if (frm.nazwa.value.length < 1) {alert('Żlę wypełnione pole Nadawca'); frm.nazwa.focus(); return false;}
	if (frm.email.value.length < 5) {alert('Podałe¶ nieprawidłowy adres email'); frm.email.select(); frm.email.focus(); return false; }
	if (frm.body.value.length < 5) {alert('Nie prawidłowy format wiadomo¶ci'); frm.body.focus(); return false; }
	return true;
}


//funkcja sprawdz poprawnosc wypelnienia formularza zmiana danych
function CheckFormZmianaDanych()
{
	frm = document.zmianadanych;
	if (frm.name.value.length < 1) {alert('Żlę wypełnione pole Imię'); frm.name.focus(); return false;}
	if (frm.sourname.value.length < 1) {alert('¬le wypełnione pole Nazwisko'); frm.sourname.focus(); return false;}
	if (frm.street.value.length < 1) {alert('Podaj nazwę ulicy'); frm.street.focus(); return false;}
	if (frm.zipcode.value.length < 6) {alert('¬le wypełnione pole Kod pocztowy'); frm.zipcode.focus(); return false;}
	if (frm.city.value.length < 2) {alert('¬le wypełnione pole Miasto'); frm.city.focus(); return false;}
	if (frm.company.value.length > 0) {if (frm.nip.value.length < 10) {alert('Nieprawidłowy NIP'); frm.nip.focus(); return false; }}
	if (frm.email.value.length < 3) {alert('Podałe¶ nieprawidłowy adres email'); frm.email.focus(); return false; }
	
	if (frm.region.value == "Dolno¶l±skie") {frm.regionID.value="1";}
	else if (frm.region.value == "Kujawsko-Pomorskie") {frm.regionID.value="2";}
	else if (frm.region.value == "Lubelskie") {frm.regionID.value="3";}
	else if (frm.region.value == "Lubuskie") {frm.regionID.value="4";}
	else if (frm.region.value == "Łódzkie") {frm.regionID.value="5";}
	else if (frm.region.value == "Małopolskie") {frm.regionID.value="6";}
	else if (frm.region.value == "Mazowieckie") {frm.regionID.value="7";}
	else if (frm.region.value == "Opolskie") {frm.regionID.value="8";}
	else if (frm.region.value == "Podkarpackie") {frm.regionID.value="9";}
	else if (frm.region.value == "Podlaskie") {frm.regionID.value="10";}
	else if (frm.region.value == "Pomorskie") {frm.regionID.value="11";}
	else if (frm.region.value == "¦l±skie") {frm.regionID.value="12";}
	else if (frm.region.value == "¦więtokrzyskie") {frm.regionID.value="13";}
	else if (frm.region.value == "Warmińsko-Mazurskie") {frm.regionID.value="14";}
	else if (frm.region.value == "Wielkopolskie") {frm.regionID.value="15";}
	else if (frm.region.value == "Zachodniopomorskie") {frm.regionID.value="16";}
	else 	
	{
		alert('Wpisz poprawnie województwo!\nMożliwe warto¶ci to:\n\n1 - Dolno¶l±skie \n2 - Kujawsko-Pomorskie \n3 - Lubelskie  \n4 - Lubuskie \n5 - Łódzkie \n6 - Małopolskie \n7 - Mazowieckie \n8 - Opolskie \n9 - Podkarpackie \n10 - Podlaskie \n11 - Pomorskie \n12 - ¦l±skie \n13 - ¦więtokrzyskie \n14 - Warmińsko-Mazurskie \n15 - Wielkopolskie \n16 - Zachodniopomorskie '); 	
		return false;
	}
	if (confirm('Czy napewno chcesz zmienić swoje dane?')==true) { return true; }	else {return false;}
}

//funkcja sprawdz poprawnosc wypelnienia formularza szukaj
function CheckFormZmianaHasla()
{
	frm = document.zmianahasla;
	if (frm.pwd.value.length < 5) {alert('Hasło powinno zawierać conajmniej 6 znaków'); frm.pwd.select(); frm.pwd.focus(); return false;}
	if (frm.pwd1.value.length < 5) {alert('Hasło powinno zawierać conajmniej 6 znaków'); frm.pwd1.select(); frm.pwd1.focus(); return false;}
	if (frm.pwd2.value != frm.pwd1.value) {alert('Hasła nie s± identyczne'); frm.pwd1.select(); frm.pwd1.focus(); return false;}
	if (confirm('Czy napewno chcesz zmienić swoje hasło?')==true) { return true; }	else {return false;}
}



//funkcja wylacza mozliwosc wpisywania parametrow do formularza w momencie gdy uzytkownik uzupelni pole nr oferty
function DisableSearchForm()
{
	frm = document.szukaj;
	if (frm.nroferty.value.length!=0)	
	{	
		for (i=0; i < frm.length; i++) frm[i].disabled=true;
	}
	else 	
	{ 
		for (i=0; i < frm.length; i++)	frm[i].disabled=false;
	}
	frm.nroferty.disabled=false;
	frm.submit.disabled=false;
}

//funkcja sprawdz poprawnosc wypelnienia pierwszego formularz ze strony dodaj ogloszenie
function CheckFormDodaj1()
{
	var RadioButton = document.dodaj.rodzaj;
	var state = 0;
	
	for (i=0; i < RadioButton.length;i++)	{	if (RadioButton[i].checked == true) {state++ ; break;} }
	if (RadioButton[5].checked != true)
	{
		RadioButton = document.dodaj.oferta;
		for (i=0; i < RadioButton.length;i++)	{	if (RadioButton[i].checked == true) {state++ ; break;} }
	}
	else 
	{
		state++;
		document.dodaj.oferta[2].checked = true;		
	}
	if (state != 2) {alert('Zaznacz wszystkie wymagane pola'); return false;}
	return true;
}

//funkcja sprawdz poprawnosc wypelnienia pierwszego formularz ze strony dodaj ogloszenie
function CheckFormDodaj()
{
	var frm = document.dodaj;
	if (frm.rodzaj.value=='MIESZKANIE')
	{
			if (frm.regionid.value=='null') { alert('Pole WOJEWÓDZTWO nie może być puste'); frm.regionid.focus(); return false; }
			if (frm.miasto.value.length==0) { alert('Pole MIASTO nie może być puste'); frm.miasto.focus(); return false; }
			if (frm.powierzchnia.value.length==0) { alert('Pole POWIERZCHNIA nie może być puste'); frm.powierzchnia.focus(); return false; }
			if (frm.oferta.value=='SPRZEDAZ') {if (frm.cena.value.length<=3) { alert('Pole CENA ma za nisk± warto¶ć'); frm.cena.focus(); return false; }}
			if (frm.oferta.value=='NAJEM') {if (frm.czynsz.value.length<=1) { alert('Pole CZYNSZ ma za nisk± warto¶ć'); frm.czynsz.focus(); return false; }}
			if (frm.liczbapokoi.value.length==0) { alert('Pole LICZBA POKOI nie może być puste'); frm.liczbapokoi.focus(); return false; }
			if (frm.pietro.value.length==0) { alert('Pole PIĘTRO nie może być puste, 0 - Parter'); frm.pietro.focus(); return false; }
			if (frm.liczbapieter.value.length==0) { alert('Pole LICZBA PIĘTER nie może być puste'); frm.liczbapieter.focus(); return false; }
			if (frm.liczbapieter.value=='0') { alert('Jeżeli budynek nie ma pięter wstaw 1'); frm.liczbapieter.focus(); return false; }

			if (frm.oferta.value=='ZAMIANA')
			{
				if (frm.czynsz.value.length==0) { alert('Pole CZYNSZ nie może być puste'); frm.czynsz.focus(); return false; }
				if (frm.regionid2.value=='null') { alert('Pole WOJEWÓDZTWO nie może być puste'); frm.regionid2.focus(); return false; }
				if (frm.powierzchnia2.value.length==0) { alert('Pole POWIERZCHNIA nie może być puste'); frm.powierzchnia2.focus(); return false; }
			}
	}
	else if (frm.rodzaj.value=='DOM')
	{
			if (frm.regionid.value=='null') { alert('Pole WOJEWÓDZTWO nie może być puste'); frm.regionid.focus(); return false; }
			if (frm.miasto.value.length==0) { alert('Pole MIASTO nie może być puste'); frm.miasto.focus(); return false; }
			if (frm.powierzchnia.value.length==0 || frm.powierzchnia.value==0) { alert('Pole POWIERZCHNIA nie może być puste ani równe 0'); frm.powierzchnia.focus(); return false; }
			if (frm.oferta.value=='SPRZEDAZ') {if (frm.cena.value.length<=3) { alert('Pole CENA ma za nisk± warto¶ć'); frm.cena.focus(); return false; }}
			if (frm.oferta.value=='NAJEM') {if (frm.czynsz.value.length<=1) { alert('Pole CZYNSZ ma za nisk± warto¶ć'); frm.czynsz.focus(); return false; }}
			if (frm.oferta.value=='ZAMIANA') {if (frm.zamieniena.value.length==0) { alert('Pole ZAMIENIĘ NA nie może być puste'); frm.zamieniena.focus(); return false; }}
	}
	else if (frm.rodzaj.value=='DZIALKA')
	{
			if (frm.regionid.value=='null') { alert('Pole WOJEWÓDZTWO nie może być puste'); frm.regionid.focus(); return false; }
			if (frm.miasto.value.length==0) { alert('Pole MIASTO nie może być puste'); frm.miasto.focus(); return false; }
			if (frm.powdzialki.value.length==0) { alert('Pole POWIERZCHNIA nie może być puste'); frm.powdzialki.focus(); return false; }
			if (frm.oferta.value=='SPRZEDAZ') {if (frm.cena.value.length<=3) { alert('Pole CENA ma za nisk± warto¶ć'); frm.cena.focus(); return false; }}
			if (frm.oferta.value=='NAJEM') {if (frm.czynsz.value.length<=1) { alert('Pole CZYNSZ ma za nisk± warto¶ć'); frm.czynsz.focus(); return false; }}
			if (frm.oferta.value=='ZAMIANA') {if (frm.zamieniena.value.length==0) { alert('Pole ZAMIENIĘ NA nie może być puste'); frm.zamieniena.focus(); return false; }}
	}
	else if (frm.rodzaj.value=='LOKAL')
	{
			if (frm.regionid.value=='null') { alert('Pole WOJEWÓDZTWO nie może być puste'); frm.regionid.focus(); return false; }
			if (frm.miasto.value.length==0) { alert('Pole MIASTO nie może być puste'); frm.miasto.focus(); return false; }
			if (frm.powcalkowita.value.length==0) { alert('Pole POWIERZCHNIA CAŁKOWITA nie może być puste'); frm.powcalkowita.focus(); return false; }
			if (frm.oferta.value=='SPRZEDAZ') {if (frm.cena.value.length<=3) { alert('Pole CENA ma za nisk± warto¶ć'); frm.cena.focus(); return false; }}
			if (frm.oferta.value=='NAJEM') {if (frm.czynsz.value.length<=1) { alert('Pole CZYNSZ ma za nisk± warto¶ć'); frm.czynsz.focus(); return false; }}
			if (frm.oferta.value=='ZAMIANA') {if (frm.zamieniena.value.length==0) { alert('Pole ZAMIENIĘ NA nie może być puste'); frm.zamieniena.focus(); return false; }}
	}
	else if (frm.rodzaj.value=='GARAZ')
	{
			if (frm.regionid.value=='null') { alert('Pole WOJEWÓDZTWO nie może być puste'); frm.regionid.focus(); return false; }
			if (frm.miasto.value.length==0) { alert('Pole MIASTO nie może być puste'); frm.miasto.focus(); return false; }
			if (frm.oferta.value=='SPRZEDAZ') {if (frm.cena.value.length<=2) { alert('Pole CENA ma za nisk± warto¶ć'); frm.cena.focus(); return false; }}
			if (frm.oferta.value=='NAJEM') {if (frm.czynsz.value.length<=1) { alert('Pole CZYNSZ ma za nisk± warto¶ć'); frm.czynsz.focus(); return false; }}
			if (frm.oferta.value=='ZAMIANA') {if (frm.zamieniena.value.length==0) { alert('Pole ZAMIENIĘ NA nie może być puste'); frm.zamieniena.focus(); return false; }}
	}
	else if (frm.rodzaj.value=='NOCLEG')
	{
			if (frm.regionid.value=='null') { alert('Pole WOJEWÓDZTWO nie może być puste'); frm.regionid.focus(); return false; }
			if (frm.miasto.value.length==0) { alert('Pole MIASTO nie może być puste'); frm.miasto.focus(); return false; }
			if (frm.cena.value.length==0) { alert('Pole CENA nie może być puste'); frm.cena.focus(); return false; }		
	}

	if (frm.pietro.value==0) { frm.pietro.value='P'; }
	if (frm.kontakt.value.length==0) { alert('Pole OSOBA DO KONTAKTU nie może być puste'); frm.kontakt.focus(); return false; }
	if (frm.telkom.value.length==0 && frm.telstacj.value.length==0 && frm.email.value.length==0) { alert('Jedno z pól TELEFON KOMÓRKOWY, TELEFON STACJONARNY, EMAIL musi być uzupełnione'); frm.telkom.focus(); return false; }
	if (frm.safetycode.value.length<5) {alert('Aby dodać ogłoszenie musisz podać kod z obrazka'); frm.safetycode.focus(); return false;}
	document.getElementById('progress').style.display='block';
	document.getElementById('hideonsubmit').style.display='none';
	return true;
}


//funckcja formatuje lancuch znakow wpisany w pole formularza pierwsza litera w wyrazach z duzej litery
function FormatInput(obj)
{
   var CapLet   = "ABCDEFGHIJKLMNOPQRSTUVWXYZˇĆĘŁŃÓ¦¬Ż";
   var SmallLet = "abcdefghijklmnopqrstuvwxyz±ćęłńó¶Ľż";

   var Key = obj.value.charAt(0);
    if (obj.value.length>0) {
     for (var c=0;c<SmallLet.length;c++) {
      if (Key==SmallLet.charAt(c)) obj.value = CapLet.charAt(c) + obj.value.substring(1).toLowerCase;
     } 
    }
    var HyphIdx=obj.value.indexOf("-");
    if (HyphIdx==-1) HyphIdx=obj.value.indexOf(" ");
    if (obj.value.length>=2 && HyphIdx!=-1 && obj.value.length>HyphIdx+1) {
     Key = obj.value.charAt(HyphIdx+1);
     for (var c=0;c<SmallLet.length;c++) {
      if (Key==SmallLet.charAt(c)) obj.value = obj.value = obj.value.substring(0,HyphIdx+1) + CapLet.charAt(c) + ((obj.value.length>HyphIdx+2) ? obj.value.substring(HyphIdx+2) : "");
     } 
    }
}

function PolePowierzchni(obj)
{
	var width = document.dodaj.szdzialki.value;
	var height = document.dodaj.dldzialki.value;
	if (width!=0 && height!=0)	obj.value= width * height;
}

function PietroControl(obj)
{
	if (obj.value==0) obj.value='P';
	return true;
}

function BigLetters(obj)
{
	obj.value = obj.value.toUpperCase();
	return true;
}

//funkcja zmienia pierwsza litere kazdego wyrazu na duza
function UcFirst(e,obj)
{
  var SmallLet 		= "abcdefghijklmnopqrstuvwxyz";
  var BigLet 			= "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  var SmallLetPL 	= "±ćęłńó¶Ľż"; //261,263,281,322,324,243,347,378,380
  var BigLetPL 		= "ˇĆĘŁŃÓ¦¬Ż"; //260,262,280,321,323,211,346,377,379
  var beforeBig 	= " ,-";
	var keynum;
	var keychar;
	if(window.event) // IE
	{
		keynum = e.keyCode;
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which;
	}	
	
	keychar = String.fromCharCode(keynum);
	lastChar = obj.value.substring(obj.value.length-1);
	//jezeli wczesniej wpisany znak pasowal do wzorca beforeBig
	if (beforeBig.indexOf(lastChar) >= 0 || obj.value.length==0)
	{
		//jezeli wpisany znak pasuje do wzorca malych liter zmien wartoc keyCode na jego odpowiednik duzej litery
		if ((idx = SmallLet.indexOf(keychar)) >= 0) e.keyCode -= 32;
		else if ((idx = SmallLetPL.indexOf(keychar)) >= 0) 
		{
		 switch(idx)
		 {
		 	case 0: {e.keyCode = 260; break;}
		 	case 1: {e.keyCode = 262;	break;}
		 	case 2: {e.keyCode = 280;	break;}
		 	case 3: {e.keyCode = 321;	break;}
		 	case 4: {e.keyCode = 323;	break;}
		 	case 5: {e.keyCode = 211; break;}
		 	case 6: {e.keyCode = 346;	break;}
		 	case 7: {e.keyCode = 377;	break;}
		 	case 8: {e.keyCode = 379;	break;}
		 }
		}
	}
	else if ((idx = BigLet.indexOf(keychar)) >= 0) e.keyCode += 32;
	else if ((idx = BigLetPL.indexOf(keychar)) >= 0)
	{
		 switch(idx)
		 {
		 	case 0: {e.keyCode = 261; break;}
		 	case 1: {e.keyCode = 263;	break;}
		 	case 2: {e.keyCode = 281;	break;}
		 	case 3: {e.keyCode = 322;	break;}
		 	case 4: {e.keyCode = 324;	break;}
		 	case 5: {e.keyCode = 243; break;}
		 	case 6: {e.keyCode = 347;	break;}
		 	case 7: {e.keyCode = 378;	break;}
		 	case 8: {e.keyCode = 380;	break;}
		 }
	}
	lastChar = keychar;	
}


//funkcja blokuje wpisywanie liter w niektore pola
function OnlyNumbers(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
  if (charCode < 48 || charCode > 57) return false;
  return true;	
}

//funkcja blokuje wpisywanie innych znakow niz P i 0-9
function OnlyNumbersP(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
  if ((charCode < 49 || charCode > 57) && charCode!=80) return false;
  return true;	
}

//funkcja blokuje wpisywanie liter w niektore pola
function PhoneNumbers(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
  if ((charCode < 48 || charCode > 57) && (charCode!=43 && charCode!=45 && charCode!=32 && charCode!=40 && charCode!=41)) return false;
  return true;	
}



//funkcja umozliwia wpisywanie tylko cyfr oraz -
function ZipCodeFormat(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
  if ((charCode > 47 && charCode < 58) || charCode==45) return true;
  return false;	
}

//funkcja pozwala tylko na wpisywanie liter w pola tekstowe
function OnlyLetters(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
  if ((charCode < 65 || charCode > 90) && (charCode < 97 || charCode > 122) && charCode != 32 && charCode!=45 && charCode!=261 && charCode!=346 && charCode!=352 && charCode!=322 && charCode!=361 && charCode!=347 && charCode!=380 && charCode!=378 && charCode!=363 && charCode!=241 && charCode!=306 && charCode!=312 && charCode!=243 && charCode!=321 && charCode!=346 && charCode!=379 && charCode!=377 && charCode!=323  ) return false;
  return true;	
}

//funkcja pozwala tylko na wpisywanie liter w pola tekstowe
function PasswordFormat(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
  if ((charCode > 47 && charCode < 58) || (charCode > 64 && charCode < 91) || (charCode > 96 && charCode < 123) || charCode == 45 || charCode == 46 || charCode == 95) return true;
  return false;	
}

//funckja wyswietla obrazki na stronie item.php w momencie wyswietlania podlgadu ogloszenia
function ShowBigPic(oferta,picid)
{
 document.getElementById('bigpic').style.display = 'block';
 document.getElementById('bigpic').src = '/thumbnail.php?fileName='+oferta+'_'+picid+'.jpg';
 return 0;
}


// funckcja tworzy miniaturki obrazkow i wyswietla je w polu o id = "pic"[id]
function ShowImage(id,width) 
{
if (navigator.appName=="Microsoft Internet Explorer")
{
	if (document.getElementById('pic'+id).value == '')
	{
		document.getElementById('imageThumbnail').style.display = 'none';
		document.getElementById('picinfo').style.display = 'block';
	}
	else {
		var thumbnailSize = width;
		t = document.getElementById('imageThumbnail');
    imgObj = new Image();
    
    imgObj.onload = function() 
    {
      w = this.width; h = this.height;
      if (w > thumbnailSize || h > thumbnailSize)
      if (w > h) {
          h = Math.round(h * thumbnailSize / w);
          w = thumbnailSize;
      } else {
          w = Math.round(w * thumbnailSize / h);
          h = thumbnailSize;
      }
      with (t.style) {
          width = w+'px';
          height = h+'px';
          display = 'block';
      }
      t.src = "file://" + document.getElementById('pic' + id).value;
      t.title = "Oryginalny rozmiar: " + this.width + ' x ' + this.height;
    }
    
    imgObj.onerror = function() 
    {
      document.getElementById('imageThumbnail').style.display = 'none';
    }
    imgObj.src = "file://" + document.getElementById('pic' + id).value;
    document.getElementById('picinfo').style.display = 'none';
  }
}
}

function SelectRodzaj(obj)
{
 form = document.szukaj;
 document.getElementById("mieszkanie").style.display = 'none';
 document.getElementById("dom").style.display = 'none';
 document.getElementById("dzialka").style.display = 'none';
 document.getElementById("lokal").style.display = 'none';
 document.getElementById("garaz").style.display = 'none';
 document.getElementById("nocleg").style.display = 'none';
 if (obj.selectedIndex == 0) {document.getElementById("mieszkanie").style.display = 'block'; document.getElementById("search").style.height = "430px";}
 else if (obj.selectedIndex == 1) {document.getElementById("dom").style.display = 'block'; document.getElementById("search").style.height = "380px";}
 else if (obj.selectedIndex == 2) {document.getElementById("dzialka").style.display = 'block'; document.getElementById("search").style.height = "380px";}
 else if (obj.selectedIndex == 3) {document.getElementById("lokal").style.display = 'block'; document.getElementById("search").style.height = "420px";}
 else if (obj.selectedIndex == 4) {document.getElementById("garaz").style.display = 'block'; document.getElementById("search").style.height = "330px";}
 else if (obj.selectedIndex == 5) {document.getElementById("nocleg").style.display = 'block'; document.getElementById("search").style.height = "350px";}
 else {document.getElementById("search").style.height = "250px";}
 	
}


function SelectRegion(id)
{
	if (id != 'null') document.szukaj.regionid.selectedIndex = id;
	if (typeof(icon) != "undefined") { icon.display = 'none';}
	if (typeof(icon1) != "undefined") { icon1.display = 'none';}
	if (id == 1) {icon = document.getElementById("w_dolnoslaskie").style; icon.display = 'block'; icon.left = '341px'; icon.top = '87px';}
	else if (id == 2) {icon = document.getElementById("w_kujawskopomorskie").style; icon.display = 'block'; icon.left = '400px'; icon.top = '8px';}
	else if (id == 3) {icon = document.getElementById("w_lubelskie").style; icon.display = 'block'; icon.left = '506px'; icon.top = '66px';}
	else if (id == 4) {icon = document.getElementById("w_lubuskie").style; 	icon.display = 'block'; icon.left = '334px'; icon.top = '34px';}
	else if (id == 5) {icon = document.getElementById("w_lodzkie").style; icon.display = 'block'; icon.left = '423px'; icon.top = '63px';}
	else if (id == 6) {icon = document.getElementById("w_malopolskie").style; icon.display = 'block'; icon.left = '448px'; icon.top = '134px';}
	else if (id == 7) {icon = document.getElementById("w_mazowieckie").style; icon.display = 'block'; icon.left = '452px'; icon.top = '21px';}
	else if (id == 8) {icon = document.getElementById("w_opolskie").style; icon.display = 'block'; icon.left = '394px'; icon.top = '110px';}
	else if (id == 9) {icon = document.getElementById("w_podkarpackie").style; icon.display = 'block'; icon.left = '496px'; icon.top = '122px';}
	else if (id == 10) {icon = document.getElementById("w_podlaskie").style; 	icon.display = 'block'; icon.left = '505px'; icon.top = '-16px';}
	else if (id == 11) {icon = document.getElementById("w_pomorskie").style; 	icon.display = 'block'; icon.left = '386px'; icon.top = '-37px';}
	else if (id == 12) {icon = document.getElementById("w_slaskie").style; icon.display = 'block'; icon.left = '421px'; icon.top = '113px';}
	else if (id == 13) {icon = document.getElementById("w_swietokrzyskie").style; icon.display = 'block'; icon.left = '463px'; icon.top = '103px';}
	else if (id == 14) {icon = document.getElementById("w_warminskomazurskie").style; icon.display = 'block'; icon.left = '449px'; icon.top = '-18px';}
	else if (id == 15) {icon = document.getElementById("w_wielkopolskie1").style; icon.display = 'block'; icon.left = '366px'; icon.top = '12px'; icon1 = document.getElementById("w_wielkopolskie2").style; icon1.display = 'block'; icon1.left = '363px'; icon1.top = '50px';}
	else if (id == 16) {icon = document.getElementById("w_zachodniopomorskie").style; icon.display = 'block'; icon.left = '324px'; icon.top = '-25px';}
}

// funkcja podswietla tlo pola input text w formularzu
function select_i (id)
{
	id.style.background= "#efd";
}

// funkcja ustawia tlo pola input text w formularzu na standardowy kolor
function unselect_i (id)
{
	id.style.background= "#f9f9f9";
}

// funkcja podswietla tlo pola TR w tabeli
function SelectTR (id)
{
	id.style.background= "#eee";
}

// funkcja ustawia tlo pola TR w tabeli
function UnSelectTR (id)
{
	id.style.background= "#f9f9f9";
}

