var d = document;
var last_id_active = '';






function peok(url, width, height)
{ 
 var czas  = new Date();
 rok   = czas.getYear();
 mies  = ( ( czas.getMonth() < 10 ) ? "0": "" ) + ( czas.getMonth() + 1 );
 dzien = ( ( czas.getDate()  < 10 ) ? "0": "" ) + ( czas.getDate() );
 godz  = ( ( czas.getHours() < 10 ) ? "0": "" ) + ( czas.getHours() );
 min   = ( ( czas.getMinutes() < 10 ) ? "0": "" ) + ( czas.getMinutes() );
 sek   = ( ( czas.getSeconds() < 10 ) ? "0": "" ) + ( czas.getSeconds() );
 aktdata=dzien+"_"+mies+"_"+rok+"_"+godz+"_"+min+"_"+sek;
 maxszer=window.screen.width;
 maxwys=window.screen.height;
 polx=Math.round( (maxszer-width)/2);
 poly=Math.round( (maxwys-height)/2)-20;
 
 mojas=window.open(url,aktdata,"toolbar=no,scrollbars=auto,directories=no,top="+poly+",left="+polx+",menubar=no,width="+ width +",height="+ height +",resizable=no");
}



function peoksc(url, width, height)
{ 
 var czas  = new Date();
 rok   = czas.getYear();
 mies  = ( ( czas.getMonth() < 10 ) ? "0": "" ) + ( czas.getMonth() + 1 );
 dzien = ( ( czas.getDate()  < 10 ) ? "0": "" ) + ( czas.getDate() );
 godz  = ( ( czas.getHours() < 10 ) ? "0": "" ) + ( czas.getHours() );
 min   = ( ( czas.getMinutes() < 10 ) ? "0": "" ) + ( czas.getMinutes() );
 sek   = ( ( czas.getSeconds() < 10 ) ? "0": "" ) + ( czas.getSeconds() );
 aktdata=dzien+"_"+mies+"_"+rok+"_"+godz+"_"+min+"_"+sek;
 maxszer=window.screen.width;
 maxwys=window.screen.height;
 polx=Math.round( (maxszer-width)/2);
 poly=Math.round( (maxwys-height)/2)-20;
 
 mojas=window.open(url,aktdata,"toolbar=no,scrollbars=yes,directories=no,top="+poly+",left="+polx+",menubar=no,width="+ width +",height="+ height +",resizable=no");
}



function szukaj_sprawdz(form)
{
 if (form.trans.value!='')
   with(document.forms['fszukaj'])
    {
     submit()
    }
 else 
  {
   alert('Wybierz pole rodzaju transakcji');
   return false;
  }

}




function zglos_sprawdz(form, tt)
{
 var t; t='';

 if (form.f_typ.value=='')   t="Pole 'Typ nieruchomości' musi być wybrane\n";
 if (form.f_trans.value=='') t=t+"Pole 'Transakcja' musi być wybrane\n";
 if (form.f_wojew.value=='') t=t+"Pole 'Województwo' musi być wybrane\n";
 if (form.f_miasto.value=='') t=t+"Pole 'Miejscowość' musi być wypełnione\n";
 
 if (tt=='sw')
   if (form.f_pow.value=='') t=t+"Pole 'Powierzchnia' musi być wypełnione\n";
 if (tt=='kn')
   {
    if (form.f_pow_od.value=='') t=t+"Pole 'Powierzchnia od' musi być wypełnione\n";
    if (form.f_pow_do.value=='') t=t+"Pole 'Powierzchnia do' musi być wypełnione\n";
   }
   
 if (form.f_opis.value=='') t=t+"Pole 'Opis' musi być wypełnione\n";
 
 if (tt=='sw')
   if (form.f_cena.value=='') t=t+"Pole 'Cena' musi być wypełnione\n";
   
 if (tt=='kn')
  {
   if (form.f_cena_od.value=='') t=t+"Pole 'Cena od' musi być wypełnione\n";
   if (form.f_cena_do.value=='') t=t+"Pole 'Cena do' musi być wypełnione\n";
  }
 if (form.f_imie_nazw.value=='' || form.f_imie_nazw.value=='Imię nazwisko') t=t+"Pole 'Imię nazwisko' musi być wypełnione\n";
 if (form.f_email.value=='' || form.f_email.value=='Adres e-mail') t=t+"Pole 'Adres e-mail' musi być wypełnione\n";
 if (form.f_telefon.value=='' || form.f_telefon.value=='Nr telefonu') t=t+"Pole 'Nr telefonu' musi być wypełnione\n";
 
 if (t!='') window.alert(t);
 else with(document.forms['fzglos'])
        {
         submit()
        }
}




function zglos_formsprawdz(form, zm)
{
 form.act.value=zm;
 
 with(document.forms['fzglos'])
   {
    submit()
   }
}




function sprawdz_email(email)
{
 if (!/^[a-zA-Z0-9\-_\.]+?@[a-zA-Z0-9\-_\.]+?\.[a-zA-Z]{2,5}$/.test(email)) return false;
 else return true;

}




function newsletter_akcja(form, zm)
{
 var t;
 t='';
 
 if (!sprawdz_email(form.email.value) && form.email.value!='twoj@email.pl') t='Podaj poprawny adres e-mail.';
 
 if (t!='')
   {
    window.alert(t);
    return false;
   }
 else
   {
    peok('newsletter.php?g='+zm+'&mail='+form.email.value, '287', '243');
   }
}




function nlp_sprawdz(form, zm)
{
 var t;
 t='';
 
 if (!sprawdz_email(form.email.value)) t="Podaj poprawny adres e-mail.\n";
 if (form.pd.checked==false) t=t+"Musisz wyrazić zgodę na użycie adresu e-mail.";
 
 if (t!='')
   {
    window.alert(t);
    return false;
   }
 else
   {
    form.g.value=zm;
    return true;
   }
}




function nlp_usun_sprawdz(form, zm)
{
 var t;
 t='';
 
 if (!sprawdz_email(form.email.value)) t="Podaj poprawny adres e-mail.\n";
 if (form.pd.checked==false) t=t+"Musisz wyrazić zgodę na wykreślenie adresu e-mail.";
 
 if (t!='')
   {
    window.alert(t);
    return false;
   }
 else
   {
    form.g.value=zm;
    return true;
   }
}



function pof_wyslij(form)
{
 var t;
 t='';
 
 if (!sprawdz_email(form.f_email_nadawcy.value)) t="Twój adres e-mail jest nieprawidłowy.\n\n";
 if (!sprawdz_email(form.f_email_adresata.value)) t=t+"E-mail adresata jest nieprawidłowy.\n\n";
 
 if (t!="") t="Proszę uzupełnić informacje\ni ponownie nacisnąć przycisk \"Wyślij\"\n\n"+t;

 
 if (t!='')
   {
    window.alert(t);
    return false;
   }
 else
   {
    return true;
   }
}





function getElement(i)
{ 
 var ob = d.all?d.all[i]:d.layers?d.layers[i]:d.getElementById(i); 
 return ob; 
} 






function checkTypeCombo(el)
{
 e = el.value;
 
 if (last_id_active==3) getElement('typ3').style.display = 'none';
 if (last_id_active==5) getElement('typ5').style.display = 'none';
 
 if (e==3) getElement('typ3').style.display = 'block';
 if (e==5) getElement('typ5').style.display = 'block';
 
 
 last_id_active = e;
 //alert(el.value);
}


