<!--

function get(id) {
    if (document.getElementById(id)) {
        return document.getElementById(id);
    }
    return false;
}

function loopSelected(from, to) {
    var selectedArray = new Array();
    var selectFrom = get(from);
    var i;
    var count = 0;
    for (i=0; i<selectFrom.options.length; i++) {
        if (selectFrom.options[i].selected) {
            selectedArray[count] = selectFrom.options[i].value;
            count++;
        }
    }
    var wartosc;
    if (count == 0) {
        wartosc = 0;
    }
    else {
        wartosc = selectedArray.join("");
    }
    get(to).value = wartosc;
}

function checkMail(id) {
    email = get(id).value;
        var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (filter.test(email)) {
        return true;
    }
    return false;
}

function checkInput(id, min) {
    input = get(id).value;
    if (input.length >= min) {
        return true;
    }
    return false;
}
function checkCheckbox(id) {
    checkbox = get(id);
    if (checkbox.checked == false) {
        return false;
    }
    return true;
}
function checkCompare(id1, id2) {
    pole1 = get(id1).value;
    pole2 = get(id2).value;
    if (pole1 == pole2) {
        return true;
    }
    return false;
}
function checkForm(form, submit, pokaz) {
    wynik = true;
    var info = new Array();
    var j = 0;
    
    var pola_wymagane = get('wymagane').value.split(";");
    for (var i=0; i < pola_wymagane.length; i++) {
        if (pola_wymagane[i] != '') {
            if (!checkInput(pola_wymagane[i], 1)) { wynik = false; if (pokaz == true) { info[j++] = '- '+pola_wymagane[i]; } }
        }
    }
    if (wynik == false && info.length > 0 && pokaz == true) {
        var napis = "Proszę poprawnie uzupełnić następujące pola: \n"+info.join("\n");
        alert(napis);
    }
    return wynik;
}

function zapalTr(id) {
    i = 1;
    while(get('tr'+i)) {
        if (i == id) {
            get('tr'+i).bgColor="#CCCCCC";
        }
        else {
            get('tr'+i).bgColor="#FFFFFF";
        }
        i++;
    }
}

function pokazDiv(id) {
    i = 1;
    
    while(get('w'+i)) {
        get('w'+i).style.display='none';
        i++;
    }
    i = 1;
    while(get('w'+i)) {
        if (i == id) {
            get('w'+i).style.display='block';
        }
        i++;
    }
}
function pokazDivPorownanie(id, numer) {
    i = 1;
    
    while(get('w'+numer+'_'+i)) {
        get('w'+numer+'_'+i).style.display='none';
        i++;
    }
    i = 1;
    while(get('w'+numer+'_'+i)) {
        if (i == id) {
            get('w'+numer+'_'+i).style.display='block';
        }
        i++;
    }
}

function zapal(id, kolor) {
    i = 1;
    while(get('tr'+i)) {
        if (i == id) {
            get('tr'+i).bgColor="#"+kolor;
        }
        else {
            get('tr'+i).bgColor="#FFFFFF";
        }
        i++;
    }
}

function l(strona) {
    window.location.href = strona;
}

function l2(strona) {
    parent.kalkulacja.location.href = strona;
}

function l3(strona) {
    parent.content2.location.href = strona;
}
function l4(strona) {
    parent.sesja.location.href = strona;
}

function get(id) {
        if (document.getElementById(id)) {
            return document.getElementById(id);
        }
    return false;
}

function checkMail(id) {
    email = get(id).value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (filter.test(email)) {
        return true;
    }
    return false;
}

function checkInput(id, min) {
    input = get(id).value;
    if (input.length >= min) {
        return true;
    }
    return false;
}

function checkZamow(form, submit, pokaz) {
    wynik = true;
    var info = new Array();
    var i = 0;
    if (!checkInput('imie', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- imię'; } }
    if (!checkInput('nazwisko', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- nazwisko'; } }
    if (!checkMail('email')) { wynik = false; if (pokaz == true) { info[i++] = '- e-mail'; } }
    if (!checkInput('opis', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- poszukiwana nieruchomość'; } }
    
    if (wynik == false && info.length > 0 && pokaz == true) {
        var napis = "Proszę poprawnie uzupełnić następujące pola: \n"+info.join("\n");
        alert(napis);
    }
    return wynik;
}

function checkZamowKoszyk(form, submit, pokaz) {
    wynik = true;
    var info = new Array();
    var i = 0;
    
    if (!checkInput('imie', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- imię'; } }
    if (!checkInput('nazwisko', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- nazwisko'; } }
    if (!checkMail('email')) { wynik = false; if (pokaz == true) { info[i++] = '- e-mail'; } }
  
    if (wynik == false && info.length > 0 && pokaz == true) {
        var napis = "Proszę poprawnie uzupełnić następujące pola: \n"+info.join("\n");
        alert(napis);
    }
    return wynik;
}

function checkZglos(form, submit, pokaz) {
    wynik = true;
    var info = new Array();
    var i = 0;
    
    if (!checkInput('imie', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- imię'; } }
    if (!checkInput('nazwisko', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- nazwisko'; } }
    if (!checkMail('email')) { wynik = false; if (pokaz == true) { info[i++] = '- e-mail'; } }
    if (!checkInput('opis', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- opis nieruchomości'; } }
    
    if (wynik == false && info.length > 0 && pokaz == true) {
        var napis = "Proszę poprawnie uzupełnić następujące pola: \n"+info.join("\n");
        alert(napis);
    }
    return wynik;
}

function num(x) { 
	x.value=x.value.replace(/[a-zA-Z]/g, '') 
}

function checkKalkulator(form, submit, pokaz) {
    wynik = true;
    var info = new Array();
    var i = 0;
    
    if ((!checkInput('cena', 5)) || (parseInt(get('cena').value) == 0)) { wynik = false; if (pokaz == true) { info[i++] = 'cena.'; } }
    
    if (wynik == false && info.length > 0 && pokaz == true) {
        var napis = "Proszę poprawnie wypełnić pole "+info.join("\n");
        alert(napis);
    }
    return wynik;
}

function dodajMail(form, submit, pokaz) {
    wynik = true;
    var info = new Array();
    var i = 0;
    
    if (!checkMail('email')) { wynik = false; if (pokaz == true) { info[i++] = 'e-mail'; } }
    
    if (wynik == false && info.length > 0 && pokaz == true) {
        var napis = "Proszę poprawnie uzupełnić pole "+info.join("\n");
        alert(napis);
    }
    return wynik;
}

function maks200(obj) {
    var maksD=200;
    if (obj.getAttribute && obj.value.length>maksD)
    obj.value=obj.value.substring(0,maksD)
}

function pokazPorownanie() {
    get('tr_porownanie').style.display='block';
    get('tr_koszyk').style.display='none';
}

function pokazKoszyk() {
    get('tr_koszyk').style.display='block';
    get('tr_porownanie').style.display='none';
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function skasuj_1(obj) {
    if(obj.value == "GG")
    obj.value = "";
}
function wstaw_1(obj) {
    if(obj.value == "")
    obj.value = "GG";
}
function skasuj_2(obj) {
    if(obj.value == "MM")
    obj.value = "";
}
function wstaw_2(obj) {
    if(obj.value == "")
    obj.value = "MM";
}


function zaznacz1() {
	MM_swapImage('k1','','img/k1b.gif','k2','','img/k1.gif','k3','','img/k1.gif','w1','','img/w1b.gif','w2','','img/w2.gif','w3','','img/w3.gif','k4','','img/k1.gif','k5','','img/k1.gif',0);
	get('t1').className='wybrany';
	get('t2').className='odznacz';
	get('t3').className='odznacz';
	get('t4').className='odznacz';
	get('t5').className='odznacz';
}

function zaznacz2() {
	MM_swapImage('k1','','img/k1.gif','k2','','img/k1b.gif','k3','','img/k1.gif','w1','','img/w1.gif','w2','','img/w2b.gif','w3','','img/w3.gif','k4','','img/k1.gif','k5','','img/k1.gif',0);
	get('t1').className='odznacz';
	get('t2').className='wybrany';
	get('t3').className='odznacz';
	get('t4').className='odznacz';
	get('t5').className='odznacz';

}

function zaznacz3() {
	MM_swapImage('k1','','img/k1.gif','k2','','img/k1.gif','k3','','img/k1b.gif','w1','','img/w1.gif','w2','','img/w2.gif','w3','','img/w3b.gif','k4','','img/k1.gif','k5','','img/k1.gif',0);
	get('t1').className='odznacz';
	get('t2').className='odznacz';
	get('t3').className='wybrany';
	get('t4').className='odznacz';
	get('t5').className='odznacz';
}

function zaznacz4() {
	MM_swapImage('k1','','img/k1.gif','k2','','img/k1.gif','k3','','img/k1.gif','w1','','img/w1c.gif','w2','','img/w2b.gif','w3','','img/w3.gif','k4','','img/w1b.gif','k5','','img/k1.gif',0);
	get('t1').className='odznacz';
	get('t2').className='odznacz';
	get('t3').className='odznacz';
	get('t4').className='wybrany';
	get('t5').className='odznacz';
}

function zaznacz5() {
	MM_swapImage('k1','','img/k1.gif','k2','','img/k1.gif','k3','','img/k1.gif','w1','','img/w1.gif','w2','','img/w2b.gif','w3','','img/w3c.gif','k4','','img/k1.gif','k5','','img/k1b.gif',0);
	get('t1').className='odznacz';
	get('t2').className='odznacz';
	get('t3').className='odznacz';
	get('t4').className='odznacz';
	get('t5').className='wybrany';
}

function setSize(width,height) {
	if (window.outerWidth) {
		window.outerWidth = width;
		window.outerHeight = height;
	}
	else if (window.resizeTo) {
		window.resizeTo(width,height);
	}
	else {
		alert("Not supported.");
	}
}

function fitSize(width,height) {
    if (window.innerWidth){
        iWidth = window.innerWidth;
        iHeight = window.innerHeight;
    }else{
        iWidth = document.body.clientWidth;
        iHeight =document.body.clientHeight;
    }
    iWidth = width - iWidth;
    iHeight = height - iHeight;
    window.resizeBy(iWidth, iHeight);
};

popup_zoom = null;
function pokazZoom(link, width, height) {
    var width_left = 526;
    var width_top = 273;
    parent.popup_zoom = window.open(link,'zoom','width='+width+',height='+height+',left='+width_left+',top='+width_top+'');
}
function pokazLinkOferta() {
    if (get('oferta1').style.display == 'block') {
        get('oferta1').style.display = 'none';
        get('oferta2').style.display = 'block';
        get('oferta_link').innerHTML = '&lsaquo;&lsaquo; skrócony opis';
    }
    else {
        get('oferta1').style.display = 'block';
        get('oferta2').style.display = 'none';
        get('oferta_link').innerHTML = 'pełny opis &rsaquo;&rsaquo;';
    }
}

function zmien(typ) {
    document.search_form.target = "";
    document.search_form.action = "search.php";
    document.search_form.submit();
}
function zmienTyp(typ) {
    if (get('cena_przedzial')) { get('cena_przedzial').value = ''; }
    if (get('koszt_przedzial')) { get('koszt_przedzial').value = ''; }
    if (get('powierzchnia_przedzial')) { get('powierzchnia_przedzial').value = ''; }
    get('typ').value = typ;
    document.search_form.target = "";
    document.search_form.action = "search.php";
    document.search_form.submit();
}
function zmienWyszukiwarka(wyszukiwarka) {
    get('wyszukiwarka').value = wyszukiwarka;
    document.search_form.target = "";
    document.search_form.action = "search.php";
    document.search_form.submit();
}
function zmienOperacja(operacja) {
    get('operacja').value = operacja;
    document.search_form.target = "";
    document.search_form.action = "search.php";
    document.search_form.submit();
}
function pokazProsta() {
    if (get('ilosc').value == 0) {
        alert('Nie znaleziono zadnych ofert.');
    }
    else {
        document.search_form.target = "_parent";
        document.search_form.action = "/wyniki";
        document.search_form.submit();
    }
}
function pokazZaawansowana() {
    document.search_form.target = "";
    get('pokaz').value = 1;
    document.search_form.action = "search.php";
    document.search_form.submit();
}
 function pokazWydruk() {
    var cena = get('cena').value;
    var typ = get('typ').options[get('typ').selectedIndex].value;
    var prowizja = get('prowizja').value;
    var waluta = get('waluta').options[get('waluta').selectedIndex].value;
    var url = '/kalkulator_wydruk.php?typ='+typ+'&cena='+cena+'&prowizja='+prowizja+'&waluta='+waluta;
    MM_openBrWindow(url,'k','width=412,height=540,top=50,left=50');
 }

function zapalOferte(id) {
    if (get('tr'+id).bgColor != '#f4f4f4') {
        get('tr'+id).className='pointer';
    }
}
function zgasOferte(id) {
    if (get('tr'+id).bgColor != '#f4f4f4') {
        get('tr'+id).className='hand';
    }
}

//-->