

function clearField(obj, str){
  if(obj.value == str) obj.value='';
}

function getCharsCount(sourceId, outputId, limit){
  var source = objGet(sourceId);
  var output = objGet(outputId);
  output.innerHTML = source.value.length;
  if(source.value.length > limit)
    output.style.color = '#F00';
  else 
    output.style.color = '#666';
}


function show(id){
  objGet(id).style.visibility = "visible"
}
function hide(){
  objGet("sub1").style.visibility = "hidden"
  objGet("sub2").style.visibility = "hidden"
  objGet("sub3").style.visibility = "hidden"
  objGet("sub4").style.visibility = "hidden"
  objGet("sub5").style.visibility = "hidden"
  objGet("sub6").style.visibility = "hidden"
}

function smajliky(cislo){
    objGet('zprava').value += " " + cislo + " ";
  }

function objGet(id) 
{
   if (Boolean(document.getElementById))
      return document.getElementById(id);
   else if (Boolean(document.all))
      return eval('document.all.'+id);
   else
      return eval('document.'+id);
}

function OpenWindowID(query, jmeno, w, h) 
{
    Fokus = window.open(query, jmeno,'resizable=1,top=20,left=20,menubar=0,scrollbars=1,width=' + w + ',height=' + h);
    Fokus.focus()
}

function OpenWindowPoptavka(id, jmeno, w, h) 
{
	  url = 'popt.php?id=' + id;
    Fokus = window.open(url, jmeno,'resizable=1,top=100,left=150,menubar=0,scrollbars=1,width=' + w + ',height=' + h);
    Fokus.focus()
}
function openPhoto(file){
    url = '/photo.php?file=' + file;
    Fokus = window.open(url, 'photo','resizable=0, status=1, menubar=0, scrollbars=0, width=300, height=300, top=40, left=150');
    Fokus.focus()
}
//----------------------
function Load(){          
          Druh();
          validate_add();
}

//----------------------
function Load_Edit(){
          Druh();
          Vyber();
          Udaje();
          check_zeme();
          validate();
          display_brno();          
}
//----------------------
function Druh(){
     if(objGet('btn_prodej').checked){    
          objGet('prodej').style.display='block';
          objGet('pronajem').style.display='none';
          Vyber(); 
     }
     else{ 
            objGet('prodej').style.display='none';
            objGet('pronajem').style.display='block';
     } 
}


//----------------------
function Vyber(){   
   if (objGet('typ').value=='1' ){ 
          objGet('subtyp1').style.display='inline';
          objGet('subtyp2').style.display='none';
          objGet('subtyp3').style.display='none';
          objGet('subtyp4').style.display='none';
          objGet('subtyp5').style.display='none';
        }
   if (objGet('typ').value=='2'){  
           objGet('subtyp1').style.display='none';
           objGet('subtyp2').style.display='inline';
           objGet('subtyp3').style.display='none';
           objGet('subtyp4').style.display='none';
           objGet('subtyp5').style.display='none';

        }       
   if (objGet('typ').value=='3'){  
           objGet('subtyp1').style.display='none';
           objGet('subtyp2').style.display='none';
           objGet('subtyp3').style.display='inline';
           objGet('subtyp4').style.display='none';
           objGet('subtyp5').style.display='none';
   }     
   if (objGet('typ').value=='4'){ 
           objGet('subtyp1').style.display='none';
           objGet('subtyp2').style.display='none';
           objGet('subtyp3').style.display='none';
           objGet('subtyp4').style.display='inline';
           objGet('subtyp5').style.display='none';
   }       
   if (objGet('typ').value=='5'){  
           objGet('subtyp1').style.display='none';
           objGet('subtyp2').style.display='none';
           objGet('subtyp3').style.display='none';
           objGet('subtyp4').style.display='none';
           objGet('subtyp5').style.display='inline';
   }     
}

function display_brno(){
  if(objGet('okres_sel').value=='1')
    objGet('brno').style.display='inline';
  else
    objGet('brno').style.display='none';
}

function novinky_brno(){
  if(objGet('okres').value=='1')
    objGet('brno_div').style.display='block';
  else
    objGet('brno_div').style.display='none';
}

function Udaje(){
  var typ, sub;
  typ = objGet('typ').value;
  switch(typ){
    case '1': sub = objGet('subtyp1').value; break;
    case '2': sub = objGet('subtyp2').value; break;
    case '3': sub = objGet('subtyp3').value; break;
    case '4': sub = objGet('subtyp4').value; break;
    case '5': sub = objGet('subtyp5').value; break;
    default: sub = objGet('subtyp6').value; break;
  }
 
  objGet('rd').style.display='none';
  objGet('byt').style.display='none';
  objGet('zahrada').style.display='none';
  objGet('rek').style.display='none';
  objGet('pozem').style.display='none';
  objGet('sell_obchod').style.display='none';
  objGet('sell_dilna').style.display='none';
  objGet('sell_restaurace').style.display='none';
  objGet('sell_hotel').style.display='none';
  objGet('sell_garaz').style.display='none';
  objGet('sell_jine').style.display='none';
  objGet('pron_byt').style.display='none';
  objGet('pron_rd').style.display='none';
  objGet('pron_pokoj').style.display='none';
  objGet('pron_kom').style.display='none';
  objGet('pron_pozem').style.display='none';
  objGet('pron_garaz').style.display='none';
  objGet('pron_rek').style.display='none';
  objGet('pron_jine').style.display='none';
  
  if(typ == '1' && sub != 4 && !(objGet('btn_pronajem').checked)) objGet('rd').style.display = 'block';
  if(typ == '1' && sub == 4 && !(objGet('btn_pronajem').checked)) objGet('sell_najem').style.display = 'block';
  if(typ == '2' && !(objGet('btn_pronajem').checked)) objGet('byt').style.display = 'block';
  if(typ == '3' && !(objGet('btn_pronajem').checked)){
    if(sub == '3') objGet('zahrada').style.display = 'block';
    else objGet('rek').style.display = 'block';
  }
  if(typ == '4' && !(objGet('btn_pronajem').checked)) objGet('pozem').style.display = 'block';
  if(typ == '5' && !(objGet('btn_pronajem').checked)){
     if(sub == '1') objGet('sell_obchod').style.display = 'block';
     if(sub == '2') objGet('sell_dilna').style.display = 'block';
     if(sub == '3') objGet('sell_restaurace').style.display = 'block';
     if(sub == '4') objGet('sell_hotel').style.display = 'block';
     if(sub == '5') objGet('sell_garaz').style.display = 'block';
     if(sub == '6') objGet('sell_jine').style.display = 'block';  
  }   
  if(objGet('btn_pronajem').checked){
    sub = objGet('subtyp6').value;
     if(sub == '1') objGet('pron_byt').style.display = 'block';
     if(sub == '2') objGet('pron_rd').style.display = 'block';
     if(sub == '3') objGet('pron_pokoj').style.display = 'block';
     if(sub == '4') objGet('pron_kom').style.display = 'block';
     if(sub == '5') objGet('pron_pozem').style.display = 'block';
     if(sub == '6') objGet('pron_garaz').style.display = 'block';
     if(sub == '7') objGet('pron_rek').style.display = 'block';
     if(sub == '8') objGet('pron_jine').style.display = 'block';  
  }
}


function validate()  {
if(objGet('komentar').value == '' || objGet('lokalita').value=='' || objGet('cena').value.length == 0  || objGet('new_id').value.length == 0)
  {
	  objGet('dalsi').disabled=true;
  }
else
  {
	  objGet('dalsi').disabled=false;
  }
}	

function validate_add()  
{	  
if(objGet('lokalita').value=='' || objGet('cena').value.length == 0 || objGet('new_id').value.length == 0)
  {
	  objGet('dalsi').disabled=true;
  }
else
  {
	  objGet('dalsi').disabled=false;
  }
}

function taskValidate(){
  if(objGet('name').value.length && objGet('text').value.length && objGet('mail').value.length){
    objGet('submit').disabled = false;
  }
  else{
    objGet('submit').disabled = true;
  }
}

function switch_foto(path){
  objGet('foto').src = path;
}

function show_foto(){
  if(objGet('fotky').style.display == 'none'){
    objGet('fotky').style.display = 'block'; 
    objGet('multi-upload').style.display = 'none';
    objGet('fotky_btn').caption = 'zobrazit fotografie';
  }
  else{
    objGet('fotky').style.display = 'none';
    objGet('fotky_btn').caption = 'skrýt fotografie';
  }
}
function show_multi(){
  if(objGet('multi-upload').style.display == 'none'){
    objGet('multi-upload').style.display = 'block'; 
    objGet('fotky').style.display = 'none';
    objGet('multi-upload_btn').caption = 'nahrát více fotek';
  }
  else{
    objGet('multi-upload').style.display = 'none';
    objGet('multi-upload_btn').caption = 'skrýt';
  }
}

function valid_novinky(admin){
  if((objGet('email').value != '' || (objGet('email').value == '' && admin)) && objGet('telefon').value != '' && objGet('prijmeni').value != ''){
    objGet('submit').disabled = false;
  }
  else{
    objGet('submit').disabled = true;
  }
}

function vyber_novinky(){
  objGet('subtyp0').style.display='none';
  objGet('subtyp1').style.display='none';
  objGet('subtyp2').style.display='none';
  objGet('subtyp3').style.display='none';
  objGet('subtyp4').style.display='none';
  objGet('subtyp5').style.display='none';
  objGet('subtyp6').style.display='none';
  objGet('pozemek').style.display='none';
  objGet('plocha').style.display='none';
  objGet('vlastnictvi').style.display='none';
  objGet('zdivo').style.display='none';
  objGet('velikost').style.display='none';
  switch(objGet('typ').value){
    case '0': objGet('subtyp0').style.display='inline'; break;
    case '1': objGet('subtyp1').style.display='inline'; objGet('pozemek').style.display='block'; objGet('velikost').style.display='block'; objGet('zdivo').style.display='block'; break;
    case '2': objGet('subtyp0').style.display='inline'; objGet('vlastnictvi').style.display='block'; objGet('plocha').style.display='block'; objGet('velikost').style.display='block'; objGet('zdivo').style.display='block'; break;
    case '3': objGet('subtyp3').style.display='inline'; objGet('pozemek').style.display='block'; objGet('velikost').style.display='block'; objGet('zdivo').style.display='block';break;
    case '4': objGet('subtyp4').style.display='inline'; objGet('pozemek').style.display='block'; break;
    case '5': objGet('subtyp5').style.display='inline'; break;
    case '6': objGet('subtyp6').style.display='inline'; break;
  }
}

function check_zeme(){
  if(objGet('zeme_cr').checked == true){
    objGet('okres').style.display = 'block';
    objGet('jmeno_zeme').style.display = 'none';
  }
  else{
    objGet('okres').style.display = 'none';
    objGet('jmeno_zeme').style.display = 'block';
  }
}

function confirm_del_sending(id){
  if(confirm('Opravdu zrušit zasílání novinek?')){
      location.href='kontakty.php?delete_sending='+id;
  }
}

function confirm_del_kontakt(id){
  if(confirm('Opravdu smazat tento kontakt?')){
      location.href='kontakty.php?del_kontakt='+id;
  }
}

function show_details(id){
  if(objGet('d'+id).style.display == 'block'){
    objGet('d'+id).style.display = 'none';
    objGet('s'+id).style.display = 'inline';
    objGet('b'+id).value = 'V';
  }
  else{
    objGet('s'+id).style.display = 'none';
    objGet('d'+id).style.display = 'block';
    objGet('b'+id).value = 'Λ';
  }
}

function vypocet_cs () {
var splatnost
var uver
var urok
var pocet_splatek
var mocnina
var anuita

uver = objGet('uver').value;

splatnost = objGet('delka_uveru').value;

urok = 0.0339;

pocet_splatek = splatnost * 12;
mocnina = Math.pow(1+(urok/12),pocet_splatek);
anuita = (uver*(urok/12)*mocnina)/(mocnina-1)
anuita_round = Math.round(anuita);
objGet('mesicni_splatka').value = anuita_round;
}

function fit_window(){
  pictureWidth = objGet('pic').width;
  pictureHeight = objGet('pic').height;
  window.resizeTo(pictureWidth+60, pictureHeight+96);  
}

function show_kontakt(id){
  url = 'show_kontakt.php?kontakt=' + id;
    Fokus = window.open(url, 'kontakt','resizable=0, status=1, menubar=0, scrollbars=0, width=700, height=390, top=200, left=400');
    Fokus.focus();
  return 0;
}


function show_sent(id){
  url = 'show_sent_offers.php?kontakt=' + id;
    Fokus = window.open(url, 'kontakt','resizable=1, status=1, menubar=0, scrollbars=1, width=440, height=380, top=200, left=600');
    Fokus.focus();
  return 0;
}

<!-- konec skriptu -->
