
<!--
function Otevri_popup(sirka, vyska) {
msg = window.open(wwwroot+'/templates/popup.php', 'nove_okno', 'toolbar=no,menubar=no,location=no,directories=no, scrollbars=no,resizable=yes,status=no,width='+sirka+',height='+vyska+',top=50,left=50')
//Pozor, definice prom?nné msg musí být napsána na jednom ?ádku!
}

function window_open(width, height, previewfile) {
    if(DEBUG)
    {
      msg = window.open(wwwroot+'/'+previewfile, 'email', 'toolbar=yes,menubar=yes,location=yes,directories=no, scrollbars=yes,resizable=yes,status=no,width='+width+',height='+height+',top=50,left=50')
    }
    else
    {
      msg = window.open(wwwroot+'/'+previewfile, 'email', 'toolbar=no,menubar=no,location=no,directories=no, scrollbars=yes,resizable=yes,status=no,width='+width+',height='+height+',top=50,left=50')
    }
}

function image_preview(imageurl, width, height, previewfile) {
msg = window.open(wwwroot+'/'+previewfile+'?image_path='+imageurl, 'image', 'toolbar=no,menubar=no,location=no,directories=no, scrollbars=yes,resizable=yes,status=no,width='+width+',height='+height+',top=50,left=50'); msg.focus();
//Pozor, definice proměnné msg musí být napsána na jednom řádku!
}

function image_preview_page(imageurl, width, height, previewfile, title) {
msg = window.open(wwwroot+'/'+previewfile+'?title=' + title + '&image_path='+imageurl, 'image', 'toolbar=no,menubar=no,location=no,directories=no, scrollbars=yes,resizable=yes,status=no,width='+width+',height='+height+',top=50,left=50'); msg.focus();
//Pozor, definice proměnné msg musí být napsána na jednom řádku!
}


function nastav_homepage(link) {
    document.body.style.behavior='url(#default#homepage)';
    document.body.setHomePage(link);
}

function runList(limit,from) {
        document.getElementById('from').value = from;
        document.getElementById('limit').value = limit;
        var oForm = document.getElementById('formular');
        oForm.submit();
} 

function AddFavorite(uri, title, this_a)  {
  if (document.all && !window.opera)  {
    window.external.AddFavorite(uri,title);
    return false;
  }
  else if (window.opera) {
    this_a.title = title;
    return true;
  }
  else if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function')) {
    if (window.confirm('Přidat oblíbenou stránku jako nový panel?'))  {
      window.sidebar.addPanel(title, uri, '');
      return false;
    }
  }
  window.alert('Po potvrzení stiskněte CTRL-D,\nstránka bude přidána k vašim oblíbeným odkazům.');
  return false;
}


function rozbal_menu(nov_str,img)
{
    z = nov_str;
    x = document.getElementById(z).style.display;
    y = 'none';
        document.getElementById(img).src = wwwroot+"/images/tree/plus.gif";

    if (x == 'none') {
      document.getElementById(img).src = wwwroot+"/images/tree/minus.gif";
      y = 'inline';
    }
    document.getElementById(z).style.display = y;

}

function kontrola_email(id)
{
  if (!document.getElementById(id).value.search(/^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,3}$/) == 0) 
  {
    alert(chybny_email);
    return false;
  }
  return true;
}

function odeslat_email(email,domain)
{
  window.navigate("mailto:" + email + '@' + domain);
//  window.location.href = "mailto:" + email + '@' + domain; 
}

var menu_last_selected_el_id; // predchozi vybrany element
var menu_selected_el_id; // soucasny

// zmeni, u vybraneho elementu podle jeho id, hodnotu atributu stylu display, na opacnou, nez jaka je.
// tzn. budto ho zobrazni, nebo schova
function changeDisplay(el_id)
{
  if (document.getElementById(el_id) != null){
    my_el = document.getElementById(el_id);
    if (menu_selected_el_id == undefined){
      menu_last_selected_el_id = el_id;
    } else {
      menu_last_selected_el_id = menu_selected_el_id;
    } // end if

    menu_selected_el_id = el_id;

    el_sipka_id = el_id + "_sipka";
    el_sipka = document.getElementById(el_sipka_id);

    display_style = my_el.style.display;
    if (display_style == "none") {
      my_el.style.display = "inline";
      el_sipka.src = wwwroot+"/images/arr_down2.gif";
      ret_val = 1;
    } else {
      el_sipka.src = wwwroot+"/images/arr_right.gif";
      my_el.style.display = "none";
      ret_val = 0;
    } // end if else
  } // end if
  else
  {
    ret_val = 0;
  } // end else 

  return ret_val;
} // end function



function changeDisplay_last(el_id, hide){
  changeDisplay(el_id);
} // end function


function display_produkt_tree(ids){
   for(var i=0;i<ids.length;i++)
   {
     changeDisplay('left_'+ids[i]);
   }
} // end function

function selectGoto()
{
 page = ge_s('gotopage');
 window.document.location.href = page;
}

// funkce vraci hodnotu elementu na zaklade jeho id pomoci funkce getElementById
function ge_s(el_id){
  if (document.getElementById(el_id) != null)
  {
    form_el = document.getElementById(el_id);
    return form_el.options[form_el.selectedIndex].value;
  } // if(else)
  else
  {
    return null;
  } // end (if)else
} // end function

// funkce pro zvyrazneni radku tabulky nebo pozadi nejakeho elementu
function row_highlight(id1, id2, class_name, point)
{
  obj = document.getElementById(id1);
  
  obj.className = class_name;
  
  if (point) obj.style.cursor = 'pointer';
  else       obj.style.cursor = '';
  
  if (document.getElementById(id2)) document.getElementById(id2).className = class_name;
} // end function


  //https://lists.latech.edu/pipermail/javascript/2004-January/006877.html
  function isEmail (p_sEmail)
  {
   var regEmail = /^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$/;
   return regEmail.test (p_sEmail);
  }

                
  // nastaveni focusu 
  // timeout je tam kvuli nutnemu zpozdeni, protoze ve vyjimecnych pripadech dochazi k chybe js z duvodu nemoznosti zpracovat danou operaci dostatecn rychle
  function refocus(form_name, el_name){
  
     wait_time = 250; // hodnota je nastavena odhadem [ms]
     
     el = document.forms[form_name].elements[el_name];
     setTimeout("el.focus();",wait_time);
  
  } // end function  

  // 
  function fitWindowSize(width_plus, height_plus) {
    
    width = document.images[0].width - document.body.clientWidth + width_plus;
    height =  document.images[0].height - document.body.clientHeight + height_plus;
    window.resizeBy(width, height);
    
  } // end function 
  // ---
  
  function foto_preview(width, height, id_reality, id_foto) {                                    //ZDE NESMI BYT &AMP;!!!!! - pak to nefunguje v mozille
    foto = window.open(wwwroot+'/templates/reality/preview.php?reality_id='+id_reality+'&foto_id=' + id_foto, 'image', 'toolbar=no,menubar=no,location=no,directories=no, scrollbars=yes,resizable=yes,status=no,width='+width+',height='+height+',top=50,left=50'); foto.focus();
  }


  function stop_prop(e){

    if (window.event)
    {
      window.event.cancelBubble = true; 
    } // end if 
    else    
    {
      e.stopPropagation();
    } // end else 
      
  } // end function 
  // ---
  
  document.onkeydown  = handlekeypress;
  var myKeycode       = 0;
 
  function handlekeypress(evt){
                  myKeycode;
                  if (window.Event) myKeycode = evt.which;
                  else myKeycode = event.keyCode;
                  return true;
  } // end function   
  
  
  // 0707271043pf-1 PATCH "doplneni 3 funkci: reformat_num, number_format a ReplaceAll " 
  
  // funkce prevede danou hodnotu (podle id) na reformatovane cislo a prenastavi jeho (pro stejne id) hodnotu.
  function reformat_num(el_id, decs, sep_dec, sep_tho)  
  {        
    formated_val = number_format(ge_v(el_id), decs, sep_dec, sep_tho); 
    ge(el_id).value = formated_val;     
  } // end function 
 


    // http://neo.mlodzi.pl/archiwum/number_format_javascript.html
  function number_format(number, decimals, dec_point, thousand_sep, p){    
  
      number = ReplaceAll(number,',','.');
      number = ReplaceAll(number,' ','');
   
      var n=(''+(Math.round(number*(p=Math.pow(10,decimals||0)))/p)).split('.');
      for(var i=(n[0]=n[0].split('')).length-3; i>0; i-=3){
          n[0].splice(i,0,thousand_sep);
      } 
      
      val = n[0].join('')+(n[1]?(dec_point||',')+n[1]:'');
      
      if (val != 'NaN')
      {      
        return val;
      } // end if 
      else
      {
        return number;
      } // end else 
            
  }
    
  // http://blog.blueshop.com.tw/ajun/archive/2005/03/22/2305.aspx
  function ReplaceAll(strOrg,strFind,strReplace){
    var index = 0;
    while(strOrg.indexOf(strFind,index) != -1)
    {
      strOrg = strOrg.replace(strFind,strReplace);
      index = strOrg.indexOf(strFind,index);
    }
    return strOrg
  } 
  // ---
  
-->

