// JavaScript Document

czywyslanie = true;

var wr = /^[a-zA-Z0-9_\-\.!]+@[a-zA-Z0-9_\-\.!]+\.[a-zA-Z0-9_\-\.!]{2,}/g;



function pozaladowaniu() {

//	wyswietl('ladowanie0','none');

//	wyswietl('ladowanie1','block');

//ustawBaner();

czyLad = true;

}

function zmienObr(ob, skad) {

	nwsrc = pobierzsrc(skad);

	wymien(ob, nwsrc);

}

function sprawdz_formularz_mieszkanie(f) {

	il=0;

	if (document.getElementById('imieinazwisko').value == '') {

		wyswietl ('f_imieinazwisko','inline');

		il++;

	} else {

		wyswietl ('f_imieinazwisko','none'); 

	}

	if (document.getElementById('tel_mail').value == '') {

		wyswietl ('f_tel_mail','inline');

		il++;

	} else {

		wyswietl ('f_tel_mail','none'); 

	}

	if (document.getElementById('tel_mail').value.indexOf('@')>0){

		if (!document.getElementById('tel_mail').value.match(wr)){

			wyswietl ('f_tel_mail','inline');

			il++;

		} else {

			wyswietl ('f_tel_mail','none'); 

		}

	} else {

		if (document.getElementById('tel_mail').value=='' ) {

			wyswietl ('f_tel_mail','inline');

			il++;

		} else {

			ile = document.getElementById('tel_mail').value.length;

			txt = document.getElementById('tel_mail').value;

			spr = 0;

			for (i=0;i<ile;i++){

				if((txt.charAt(i)>=0 && txt.charAt(i)<=9) || txt.charAt(i)=='(' || txt.charAt(i)==')' || txt.charAt(i)=='-' || txt.charAt(i)==' '){spr++;}

			}

			if (spr<ile){

				wyswietl ('f_tel_mail','inline');

				document.getElementById('tel_mail').value = '';

				il++;

			} else {

				wyswietl ('f_tel_mail','none');

			}

		}

	}

	if (document.getElementById('data_kont').value == '') {

		wyswietl ('f_data_kont','inline');

		il++;

	} else {

		wyswietl ('f_data_kont','none'); 

	}

if (il>0) {return false;}

return true; 

}

function sprawdz_mail(f) {

	il=0;

	if (document.getElementById('mail').value=='' || !f.mail.value.match(wr)){

		wyswietl ('komunikat','inline');

		il++;

	} else {

		wyswietl ('komunikat','none'); 

	}

if (il>0) {return false;}

return true; 

}

function pokazRealizacje(wyswietlanie) {

	switch (wyswietlanie) {

	case 'block':	wyswietl('topRealizacje','block'); break;

	case 'none': wyswietl('topRealizacje','none'); break;

	}

	

}



function sprawdz_formularz_logowanie_klub(f) {

	il=0;

	if (document.getElementById('login').value == '') {

		wyswietl ('f_login','inline');

		il++;

	} else {

		wyswietl ('f_login','none'); 

	}

	if (document.getElementById('haslo').value == '') {

		wyswietl ('f_haslo','inline');

		il++;

	} else {

		wyswietl ('f_haslo','none'); 

	}

if (il>0) {return false;}

return true; 

}





function ustawSuwakiForm(co,wart,start,koniec,pmin,pmax,coC, wartC,startcen,konieccen,cmin,cmax) {

	document.getElementById('ftmieszkan').tPOW.value = wart;

	document.getElementById('ftmieszkan').tPOW_start.value = start;

	document.getElementById('ftmieszkan').tPOW_koniec.value = koniec;

	document.getElementById('ftmieszkan').tPOW_min.value = pmin;

	document.getElementById('ftmieszkan').tPOW_max.value = pmax;

	document.getElementById('ftmieszkan').tCEN.value = wartC;

	document.getElementById('ftmieszkan').tCEN_start.value = startcen;

	document.getElementById('ftmieszkan').tCEN_koniec.value = konieccen;

	document.getElementById('ftmieszkan').tCEN_min.value = cmin;

	document.getElementById('ftmieszkan').tCEN_max.value = cmax;

}

function ustaw_wyszukiwarke(lokal,nzurl) {

	document.getElementById('lokalzlisty').value = lokal;

	document.getElementById('ftmieszkan').action = nzurl + ','+lokal+'.html';

	document.getElementById('ftmieszkan').submit();

	

	

}



function ustaw_wyszukiwarke_lista(co,jak) {

	document.getElementById('wgSORT').value = co;

	document.getElementById('jakSORT').value = jak

	document.getElementById('ftmieszkan').submit();

}





function asortuj(k,co) {

  posortowane=false;

  alert (k);

  tr = document.getElementById(co).childNodes[0].childNodes;

  while (!posortowane) {

    posortowane=true;

    for (i=1;i<tr.length-1;i++) {

      if (tr[i].childNodes[k].childNodes[0].nodeValue>

        tr[i+1].childNodes[k].childNodes[0].nodeValue) {

        posortowane=false;

        for (j=0;j<tr[i].childNodes.length;j++) {

          tmp = tr[i].childNodes[j].firstChild.nodeValue;

          tr[i].childNodes[j].firstChild.nodeValue

            = tr[i+1].childNodes[j].firstChild.nodeValue;

          tr[i+1].childNodes[j].firstChild.nodeValue = tmp;

        }

      }

    }

  }

}



function asortujl(k,co) {

  posortowane=false;

  tr = document.getElementById(co).childNodes[0].childNodes;

  while (!posortowane) {

    posortowane=true;

    for (i=1;i<tr.length-1;i++) {

      if (parseFloat(tr[i].childNodes[k].childNodes[0].nodeValue)>

        parseFloat(tr[i+1].childNodes[k].childNodes[0].nodeValue)) {

        posortowane=false;

        for (j=0;j<tr[i].childNodes.length;j++) {

          tmp = tr[i].childNodes[j].firstChild.nodeValue;

          tr[i].childNodes[j].firstChild.nodeValue

            = tr[i+1].childNodes[j].firstChild.nodeValue;

          tr[i+1].childNodes[j].firstChild.nodeValue = tmp;

        }

      }

    }

  }

}





function sprawdzFormularzKontaktowy(f,wer) {

il = 0;

if (document.getElementById('KomunikatFormularzKontaktowyStat').value=='ok') {

	czywyslac = confirm ('Twoja wiadomość została już poprawnie wysłana. Czy chcesz ją wysłać jeszcze raz?');

} else {

	czywyslac = true;

}



if (czywyslac) {

	if (document.getElementById('imie')){

		if (document.getElementById('imie').value=='') {

			document.getElementById('komImie').innerHTML = ' &nbsp; '+document.getElementById('kom4').value;

			wyswietl ('komImie','inline');

				il++;

		} else {

			wyswietl ('komImie','none');

		}

	}

	if (document.getElementById('nazwisko')){

		if (document.getElementById('nazwisko').value=='') {

			document.getElementById('komNazwisko').innerHTML = ' &nbsp; '+document.getElementById('kom4').value;

			wyswietl ('komNazwisko','inline');

				il++;

		} else {

			wyswietl ('komNazwisko','none');

		}

	}

	

	

	if (document.getElementById('telefon') && document.getElementById('email')){

		if (document.getElementById('telefon').value=='' && document.getElementById('email').value=='') {

			document.getElementById('komTelefon').innerHTML = ' &nbsp; '+document.getElementById('kom1').value;

			wyswietl ('komTelefon','inline');

			document.getElementById('komEmail').innerHTML = ' &nbsp; '+document.getElementById('kom1').value;

			wyswietl ('komEmail','inline');

				il++;

		} else {

			if (!document.getElementById('email').value.match(wr) && document.getElementById('email').value!='') {

					document.getElementById('komEmail').innerHTML = ' &nbsp; '+document.getElementById('kom2').value;

					wyswietl ('komEmail','inline');

					il++;

			} else {

				wyswietl ('komEmail','none');

				wyswietl ('komTelefon','none');

			}

			

		}

	}



	if (document.getElementById('data_kont')){

		if (document.getElementById('data_kont').value=='') {

			document.getElementById('komData').innerHTML = ' &nbsp; '+document.getElementById('kom4').value;

			wyswietl ('komData','inline');

				il++;

		} else {

			wyswietl ('komData','none');

		}

	}

	if (document.getElementById('zgoda')){

		if (!f.zgoda.checked) {

			document.getElementById('komZgoda').innerHTML = ' &nbsp; '+document.getElementById('kom4').value;

			wyswietl ('komZgoda','inline');

				il++;

		} else {

			wyswietl ('komZgoda','none');

		}

	}



 



if (il>0) {return false;}

else {

	wyswietl('KomunikatFormularzKontaktowy','block');

	document.getElementById('KomunikatFormularzKontaktowyStat').value = 0;

	document.getElementById('KomunikatFormularzKontaktowy').innerHTML = 'wysyłanie wiadomości, proszę czekać...';

	}

return true; } else { return false; }

}





function sprawdzFormularzPowiadomZnajomego(f,wer) {

il = 0;

if (document.getElementById('KomunikatFormularzPowiadomZnajomegoStat').value=='ok') {

	czywyslac = confirm ('Twoja wiadomość została już poprawnie wysłana. Czy chcesz ją wysłać jeszcze raz?');

} else {

	czywyslac = true;

}



if (czywyslac) {

	if (document.getElementById('mailPZ')){

		if (document.getElementById('mailPZ').value=='') {

			document.getElementById('komMailPZ').innerHTML = ' &nbsp; '+document.getElementById('kom4').value;

			wyswietl ('komMailPZ','inline');

				il++;

		} else if (!document.getElementById('mailPZ').value.match(wr)) {

			document.getElementById('komMailPZ').innerHTML = ' &nbsp; '+document.getElementById('kom2').value;

			wyswietl ('komMailPZ','inline');

			il++;

		} else {

			wyswietl ('komMailPZ','none');

		}

	}

	





if (il>0) {return false;}

else {

	wyswietl('KomunikatFormularzPowiadomZnajomego','block');

	document.getElementById('KomunikatFormularzPowiadomZnajomegoStat').value = 0;

	document.getElementById('KomunikatFormularzPowiadomZnajomego').innerHTML = 'wysyłanie wiadomości, proszę czekać...';

	}

return true; } else { return false; }

}



