var tt_max_karty_cnt = 0;
var tt_max_rows_cnt = 0;
var was_reload_change=false;
var reload_to = false;

function indexLoaded(auto_refr)
{
 putTheWatchesIn();
 
// if(typeof(console) != "undefined")
//  console.clear();

 if(document.getElementById("mala_mapa"))
 {
  document.getElementById("mala_mapa").onmousedown=selectmousesmallmapa;
  document.getElementById("mala_mapa").onmousemove=movemouse;
  document.getElementById("mala_mapa").onmouseup=mouseup;
 }

 if(document.zoom_slider)
 {
  document.zoom_slider.onmousedown=selectmousezoom;
  document.zoom_slider.onmouseup=mouseup;
 }
 
 if(document.fl_slider_top)
 {
  document.fl_slider_top.onmousedown=selectmousefltop;
  document.fl_slider_top.onmouseup=mouseup;
 }

 if(document.fl_slider_bottom)
 {
  document.fl_slider_bottom.onmousedown=selectmouseflbottom;
  document.fl_slider_bottom.onmouseup=mouseup;
 }

 if(document.tm_slider_from)
 {
  document.tm_slider_from.onmousedown=selectmousetmfrom;
  document.tm_slider_from.onmouseup=mouseup;
 }

 if(document.tm_slider_to)
 {
  document.tm_slider_to.onmousedown=selectmousetmto;
  document.tm_slider_to.onmouseup=mouseup;
 }
 
 if(document.tm_bar)
 {
  document.tm_bar.onmousedown=selectmousetm;
  document.tm_bar.onmouseup=mouseup;
 }

 if(document.tm_shift_left)
 {
  document.tm_shift_left.onmousedown=selectmousetmaxepast;
  document.tm_shift_left.onmouseup=mouseup;
 }

 if(document.tm_shift_right)
 {
  document.tm_shift_right.onmousedown=selectmousetmaxefuture;
  document.tm_shift_right.onmouseup=mouseup;
 }

 window.onmouseup=document.onmouseup=mouseup;
 window.onmousemove=document.onmousemove=movemouse;

 if(nn6)
  document.getElementById("tt_data").style.height = 149;
 
 if(typeof(auto_refr) != "undefined" && auto_refr>0)
  setTmAxeBound(calculateTmAxeFromDt()); 

 setTmSlidersPos();
 setFL(document.getElementById("fl_lvl_from").selectedIndex,document.getElementById("fl_lvl_to").selectedIndex,true);  
 
 createUpresnitFrm();
 
 if(auto_refr)
  setInterval("autoRefresh();",auto_refr*1000);
}

function autoRefresh()
{
 var ctrl_from = document.getElementById("fl_tm_from");
 var ctrl_to = document.getElementById("fl_tm_to");
 
 if(ctrl_from && ctrl_to)
 {
  var dt = UTCDate();  
  dt.setUTCMinutes(dt.getUTCMinutes()-parseInt(document.getElementById("refr_od").value));
  
  ctrl_from.value = sprintf("%02d.%02d. %02d:%02d",dt.getDate(),dt.getMonth()+1,dt.getHours(),dt.getMinutes());
  
  dt = UTCDate();  
  dt.setUTCMinutes(dt.getUTCMinutes()+parseInt(document.getElementById("refr_do").value));
  
  ctrl_to.value = sprintf("%02d.%02d. %02d:%02d",dt.getDate(),dt.getMonth()+1,dt.getHours(),dt.getMinutes());
 }
 
 setTmAxeBound(calculateTmAxeFromDt()); 
// setTmSlidersPos();
 
 reloadMap();  
}

function putTheWatchesIn() 
{
 var cas = "";
 
 var justnow = new Date();
 var hodiny = justnow.getUTCHours().toString();
 var minuty = justnow.getUTCMinutes().toString();
 var vteriny = justnow.getUTCSeconds().toString();
 if (hodiny.length == 1) cas += " ";
  cas += hodiny + ":";
 if (minuty.length == 1) cas += "0";
  cas += minuty + ":";
 if (vteriny.length == 1) cas += "0";
  cas += vteriny;
 
 var inn = document.getElementById("utc_cas").innerHTML;
  
 if(inn.toUpperCase() != "<B>UTC:</B>&NBSP;" + cas)
 {
  document.getElementById("utc_cas").innerHTML = "<b>UTC:</b>&nbsp;" + cas;

//  if(vteriny == 59 && top.reg_qnh.location != null)
//   top.document.getElementById("reg_qnh").src = "reg_qnh.php";
 }
 
 setTimeout ("putTheWatchesIn()",500);
}
    
function changeZoom()
{
 var lz_ctrl = document.getElementById("last_zoom");
 
 if((document.getElementById("zoom_slider").offsetTop-222)/12 != lz_ctrl.value)
 {
  lz_ctrl.value = (document.getElementById("zoom_slider").offsetTop-222)/12; 
  document.getElementById("zoom_val").style.top = 219 + 12*lz_ctrl.value;
  document.getElementById("zoom_val").value = lz_ctrl.value;
  mapDataChange();
//  document.getElementById("mapa_tiles").src = "mapa_tiles.php";
 }
}

function changeFLTop()
{
 var fl_ctrl = document.getElementById("fl_lvl_to");
 
 if(fl_val_desc[(507-(document.getElementById("fl_slider_top").offsetTop+10))/3][0] != fl_ctrl.value)
 {
  fl_ctrl.value = fl_val_desc[(507-(document.getElementById("fl_slider_top").offsetTop+10))/3][0]; 
  mapDataChange();
//  document.getElementById("mapa_tiles").src = "mapa_tiles.php";
 }
}

function changeFLBottom()
{
 var fl_ctrl = document.getElementById("fl_lvl_from");
 
 if(fl_val_desc[(507-document.getElementById("fl_slider_bottom").offsetTop)/3][0] != fl_ctrl.value)
 {
  fl_ctrl.value = fl_val_desc[(507-document.getElementById("fl_slider_bottom").offsetTop)/3][0]; 
  mapDataChange();
//  document.getElementById("mapa_tiles").src = "mapa_tiles.php";
 }
}

function changeTm()
{
 var tm_ctrl = document.getElementById("fl_tm_from");
 
 if(start_fl_from != tm_ctrl.value)
 {
  mapDataChange();
//  document.getElementById("mapa_tiles").src = "mapa_tiles.php";
 }
}

function zoomOpacity(val)
{
 document.getElementById("zoom_bar").style.filter="alpha(opacity=" + val + ")"; 
 document.getElementById("zoom_bar").style.opacity=val/100;
 document.getElementById("zoom_slider").style.filter="alpha(opacity=" + val + ")"; 
 document.getElementById("zoom_slider").style.opacity=val/100;

 if(val == 100)
  document.getElementById("zoom_val").className="input";
 else
  document.getElementById("zoom_val").className="hidden";
}

function moveOpacity(val)
{
 document.getElementById("move_butt").style.filter="alpha(opacity=" + val + ")"; 
 document.getElementById("move_butt").style.opacity=val/100;
}

function flOpacity(val)
{
 document.getElementById("fl_bar").style.filter="alpha(opacity=" + val + ")"; 
 document.getElementById("fl_bar").style.opacity=val/100;
 document.getElementById("fl_slider_top").style.filter="alpha(opacity=" + val + ")"; 
 document.getElementById("fl_slider_top").style.opacity=val/100;
 document.getElementById("fl_slider_bottom").style.filter="alpha(opacity=" + val + ")"; 
 document.getElementById("fl_slider_bottom").style.opacity=val/100;
 
 if(val == 100)
 {
  document.getElementById("fl_val_top").className="input";
  document.getElementById("fl_val_bottom").className="input";
 }
 else
 {
  document.getElementById("fl_val_top").className="hidden";
  document.getElementById("fl_val_bottom").className="hidden";
 }
}

function tmOpacity(val)
{
 document.getElementById("tm_bar").style.filter="alpha(opacity=" + val + ")"; 
 document.getElementById("tm_bar").style.opacity=val/100;
 document.getElementById("tm_shift_left").style.filter="alpha(opacity=" + val + ")"; 
 document.getElementById("tm_shift_left").style.opacity=val/100;
 document.getElementById("tm_shift_right").style.filter="alpha(opacity=" + val + ")"; 
 document.getElementById("tm_shift_right").style.opacity=val/100;
 document.getElementById("tm_axe_from").style.filter="alpha(opacity=" + val + ")"; 
 document.getElementById("tm_axe_from").style.opacity=val/100;
 document.getElementById("tm_axe_to").style.filter="alpha(opacity=" + val + ")"; 
 document.getElementById("tm_axe_to").style.opacity=val/100;
 if(document.getElementById("tm_slider_from"))
 {
  document.getElementById("tm_slider_from").style.filter="alpha(opacity=" + val + ")"; 
  document.getElementById("tm_slider_from").style.opacity=val/100;
  document.getElementById("tm_slider_to").style.filter="alpha(opacity=" + val + ")"; 
  document.getElementById("tm_slider_to").style.opacity=val/100;
  
  if(val == 100)
  {
   document.getElementById("tm_val_from").className="input";
   document.getElementById("tm_val_to").className="input";
  }
  else
  {
   document.getElementById("tm_val_from").className="hidden";
   document.getElementById("tm_val_to").className="hidden";
  }
 }
 
 if(document.getElementById("SR_symbol").className != "hidden")
 {
  document.getElementById("SR_symbol").style.filter="alpha(opacity=" + val + ")"; 
  document.getElementById("SR_symbol").style.opacity=val/100;
 }
 
 if(document.getElementById("SS_symbol").className != "hidden")
 {
  document.getElementById("SS_symbol").style.filter="alpha(opacity=" + val + ")"; 
  document.getElementById("SS_symbol").style.opacity=val/100;
 }
 
 if(document.getElementById("CTSR_symbol").className != "hidden")
 {
  document.getElementById("CTSR_symbol").style.filter="alpha(opacity=" + val + ")"; 
  document.getElementById("CTSR_symbol").style.opacity=val/100;
 }
 
 if(document.getElementById("CTSS_symbol").className != "hidden")
 {
  document.getElementById("CTSS_symbol").style.filter="alpha(opacity=" + val + ")"; 
  document.getElementById("CTSS_symbol").style.opacity=val/100;
 }
}

function setFL(fl_od,fl_do,noreload)
{
 document.getElementById("fl_lvl_from").selectedIndex=fl_od;
 document.getElementById("fl_lvl_to").selectedIndex=fl_do;
 document.getElementById("fl_slider_bottom").style.top = 507 - 3*fl_od; 
 document.getElementById("fl_val_bottom").style.top = 507 - 3*fl_od - 3; 
 document.getElementById("fl_val_bottom").value = fl_val_desc[fl_od][1];
 document.getElementById("fl_slider_top").style.top = (507 - 3*(fl_do+1))-10; 
 document.getElementById("fl_val_top").style.top = (507 - 3*(fl_do+1))-13; 
 document.getElementById("fl_val_top").value = fl_val_desc[fl_do+1][1];
 
 if(!noreload)
 {
  mapDataChange();
//  document.getElementById("mapa_tiles").src = "mapa_tiles.php";
 }
}

function changeTmFrom()
{
 var fl_ctrl = document.getElementById("fl_tm_from");
 
 if(document.getElementById("tm_val_from").value != fl_ctrl.value)
 {
  fl_ctrl.value = document.getElementById("tm_val_from").value; 
  mapDataChange();
//  document.getElementById("mapa_tiles").src = "mapa_tiles.php";
 }
}

function changeTmTo()
{
 var fl_ctrl = document.getElementById("fl_tm_to");
 
 if(document.getElementById("tm_val_to").value != fl_ctrl.value)
 {
  fl_ctrl.value = document.getElementById("tm_val_to").value; 
  mapDataChange();
//  document.getElementById("mapa_tiles").src = "mapa_tiles.php";
 }
}

function shiftAxe(step,set_dt)
{    
// document.getElementById("fl_tm_from").value=step;
// document.getElementById("fl_tm_to").value = start_axe_from;
// document.getElementById("fl_tm_to").value = Math.round(step*2.4);
 if(set_dt == undefined || set_dt == null)
 {
  var dt = getDtFromString(document.getElementById("tm_axe_from").value);
  dt.setUTCMinutes(dt.getUTCMinutes()-(step*60/25));
  
  var fl_tm = getDtFromString(document.getElementById("fl_tm_from").value);
  fl_tm.setUTCMinutes(fl_tm.getUTCMinutes()-(step*60/25));
  document.getElementById("fl_tm_from").value = sprintf("%02d.%02d. %02d:%02d",fl_tm.getUTCDate(),fl_tm.getUTCMonth()+1,fl_tm.getUTCHours(),fl_tm.getUTCMinutes());

  fl_tm = getDtFromString(document.getElementById("fl_tm_to").value);
  fl_tm.setUTCMinutes(fl_tm.getUTCMinutes()-(step*60/25));
  document.getElementById("fl_tm_to").value = sprintf("%02d.%02d. %02d:%02d",fl_tm.getUTCDate(),fl_tm.getUTCMonth()+1,fl_tm.getUTCHours(),fl_tm.getUTCMinutes());
 }
 else
 {
  var dt = getDtFromString(set_dt);
  dt.setUTCMinutes(dt.getUTCMinutes()+Math.round(step*5));
  
  var fl_tm = getDtFromString(start_fl_from);
  fl_tm.setUTCMinutes(fl_tm.getUTCMinutes()+Math.round(step*5));
  document.getElementById("fl_tm_from").value = sprintf("%02d.%02d. %02d:%02d",fl_tm.getUTCDate(),fl_tm.getUTCMonth()+1,fl_tm.getUTCHours(),fl_tm.getUTCMinutes());

  fl_tm = getDtFromString(start_fl_to);
  fl_tm.setUTCMinutes(fl_tm.getUTCMinutes()+Math.round(step*5));
  document.getElementById("fl_tm_to").value = sprintf("%02d.%02d. %02d:%02d",fl_tm.getUTCDate(),fl_tm.getUTCMonth()+1,fl_tm.getUTCHours(),fl_tm.getUTCMinutes());
 }
 
 document.getElementById("tm_val_to").value = document.getElementById("fl_tm_to").value;
 document.getElementById("tm_val_from").value = document.getElementById("fl_tm_from").value;
 
 setTmAxeBound(dt);
 setTmSlidersPos();                                                                                                                                                                                                                                                                                               // 
 setSRSSSymbols();                                                                                                                                                                                                                                                                                             // 
}                                                                                                                                                                                                                                                                                                                      

function setSRSSSymbols()                                                                                                                                                                                                                           
{    
 if(!document.getElementById("tm_bar") || !document.getElementById("SR_symbol") || !document.getElementById("SS_symbol")|| !document.getElementById("CTSR_symbol") || !document.getElementById("CTSS_symbol"))
  return false;
                                                                                                                                                                                                                                                 
 var coords = window.frames.mapa_tiles.getDispCoords();
 
// if(console)
//  console.debug(coords);
  
 var ln = coords[0];
 var le = coords[1];
 var lz = coords[2];
 var rn = coords[3];
 var re = coords[4];
 var rz = coords[5];
 var conv_r = convertUTMZone(rn,re,rz,lz);                                                                                                                                                                                                          
 var cent = convertUTM2LL(ln-((ln-conv_r[0])/2),le+((conv_r[1]-le)/2),lz,"N",0);                                                                                                                                                                    
 var fl_from = getDtFromString(document.getElementById("tm_axe_from").value);                                                                                                                                                                
 var fl_to = getDtFromString(document.getElementById("tm_axe_to").value,fl_from);                                                                                                                                                            
 var SRSS = vychodZapad(cent[0],cent[1],fl_from);                                                                                                                                                                                                   
                                                                                                                                                                                                                                                    
 if(fl_from>SRSS[3][0])
  SRSS[3][0].setUTCDate(SRSS[3][0].getUTCDate()+1);
 else if(fl_to<SRSS[3][0])
  SRSS[3][0].setUTCDate(SRSS[3][0].getUTCDate()-1);

 if(fl_from>SRSS[3][1])
  SRSS[3][1].setUTCDate(SRSS[3][1].getUTCDate()+1);
 else if(fl_to<SRSS[3][1])
  SRSS[3][1].setUTCDate(SRSS[3][1].getUTCDate()-1);

 if(fl_from>SRSS[2][0])
  SRSS[2][0].setUTCDate(SRSS[2][0].getUTCDate()+1);
 else if(fl_to<SRSS[2][0])
  SRSS[2][0].setUTCDate(SRSS[2][0].getUTCDate()-1);

 if(fl_from>SRSS[2][1])
  SRSS[2][1].setUTCDate(SRSS[2][1].getUTCDate()+1);
 else if(fl_to<SRSS[2][1])
  SRSS[2][1].setUTCDate(SRSS[2][1].getUTCDate()-1);
  
 var tm_bar_start = document.getElementById("tm_bar").offsetLeft + 4;
 var symbol_width = document.getElementById("SR_symbol").width/2;

 document.getElementById("SR_symbol").style.left = (tm_bar_start-symbol_width)+Math.round((SRSS[3][0]-fl_from)*25/3600e3);
 document.getElementById("SR_symbol").title = sprintf("%02d:%02d",SRSS[3][0].getUTCHours(),SRSS[3][0].getUTCMinutes());                                                                                                                                  
                                                                                                                                                                                                                                                    
 if(fl_from<=SRSS[3][0] && fl_to>=SRSS[3][0])                                                                                                                                                                                                             
  document.getElementById("SR_symbol").className = "";                                                                                                                                                                                       
 else                                                                                                                                                                                                                                               
  document.getElementById("SR_symbol").className = "hidden";                                                                                                                                                                                 

 document.getElementById("CTSR_symbol").style.left = (tm_bar_start-symbol_width)+Math.round((SRSS[2][0]-fl_from)*25/3600e3);
 document.getElementById("CTSR_symbol").title = sprintf("%02d:%02d",SRSS[2][0].getUTCHours(),SRSS[2][0].getUTCMinutes());                                                                                                                                  
                                                                                                                                                                                                                                                    
 if(fl_from<=SRSS[2][0] && fl_to>=SRSS[2][0])                                                                                                                                                                                                             
  document.getElementById("CTSR_symbol").className = "";                                                                                                                                                                                       
 else                                                                                                                                                                                                                                               
  document.getElementById("CTSR_symbol").className = "hidden";                                                                                                                                                                                 

                                                                                                                                                                                                                                                    
 document.getElementById("SS_symbol").style.left = (tm_bar_start-symbol_width)+Math.round((SRSS[3][1]-fl_from)*25/3600e3);
 document.getElementById("SS_symbol").title = sprintf("%02d:%02d",SRSS[3][1].getUTCHours(),SRSS[3][1].getUTCMinutes());
                                                                                                                                                                                                                                                    
 if(fl_from<=SRSS[3][1] && fl_to>=SRSS[3][1])                                                                                                                                                                                                             
  document.getElementById("SS_symbol").className = "";                                                                                                                                                                                       
 else                                                                                                                                                                                                                                               
  document.getElementById("SS_symbol").className = "hidden";                                                                                                                                                                                 

 document.getElementById("CTSS_symbol").style.left = (tm_bar_start-symbol_width)+Math.round((SRSS[2][1]-fl_from)*25/3600e3);
 document.getElementById("CTSS_symbol").title = sprintf("%02d:%02d",SRSS[2][1].getUTCHours(),SRSS[2][1].getUTCMinutes());
                                                                                                                                                                                                                                                    
 if(fl_from<=SRSS[2][1] && fl_to>=SRSS[2][1])                                                                                                                                                                                                             
  document.getElementById("CTSS_symbol").className = "";                                                                                                                                                                                       
 else                                                                                                                                                                                                                                               
  document.getElementById("CTSS_symbol").className = "hidden";                                                                                                                                                                                 
}   

function setTmSlidersPos()
{
// console.log(mouse_action);
//alert(mouse_action);
 if(document.getElementById("unp_frm") && (mouse_action==0 || mouse_action==16384))
 {
  was_tm_change = true;
//  document.getElementById("unp_frm").src = "unp_notam.php?od="+document.getElementById("fl_tm_from").value+"&do="+document.getElementById("fl_tm_to").value;
 }
 
 if(document.getElementById("tm_slider_from"))
 {
  var let_od = getDtFromString(document.getElementById("fl_tm_from").value);
  var axe_from = getDtFromString(document.getElementById("tm_axe_from").value);
  var ctrl = document.getElementById("tm_slider_from");
  var ctrl_val = document.getElementById("tm_val_from");
 
  var tm_bar_start = document.getElementById("tm_bar").offsetLeft + 4;
  var tm_bar_width = document.getElementById("tm_bar").width - 8;
  var symbol_width = document.getElementById("tm_slider_from").width;
 
  var pos = (tm_bar_start-symbol_width)+Math.round((let_od-axe_from)*25/3600e3);
 
  if(pos < (tm_bar_start-symbol_width) || pos>(tm_bar_start+tm_bar_width-symbol_width))
  {
   ctrl.className="hidden";
   ctrl_val.className="hidden";
  }
  else
  {
   ctrl.className="";
   ctrl.style.left = pos;
   ctrl_val.style.left = pos-59;
   ctrl_val.value=document.getElementById("fl_tm_from").value;
  }

  var let_do = getDtFromString(document.getElementById("fl_tm_to").value);
  ctrl = document.getElementById("tm_slider_to");
  ctrl_val = document.getElementById("tm_val_to");
  pos = tm_bar_start+Math.round((let_do-axe_from)*25/3600e3);
 
  if(pos < tm_bar_start || pos>(tm_bar_start+tm_bar_width))
  {
   ctrl.className="hidden";
   ctrl_val.className="hidden";
  }
  else
  {
   ctrl.className="";
   ctrl.style.left = pos;
   ctrl_val.style.left = pos;
   ctrl_val.value=document.getElementById("fl_tm_to").value;
  }
 }
 
 return false;
}

function setLnLe(ln,le,lz)
{
 if(typeof(ln) == "undefined")
  var coords = window.frames.mapa_tiles.getDispCoords();
 else
  var coords = Array(ln,le,lz);
 
 document.getElementById("ln").value=coords[0];
 document.getElementById("le").value=coords[1];
 document.getElementById("lz").value=coords[2];
}

function disp_reg()
{
 var ctrl = document.getElementById("reg_frm");
 ctrl.style.zIndex = 100000;
}

function disp_upres()
{
 check_upres();  
 
 var ctrl = document.getElementById("upres_frm");
 ctrl.style.zIndex = 100000;
}

function disp_meteo_menu()
{
 var ctrl = document.getElementById("meteo_menu_frm");
 ctrl.style.zIndex = 100000;
}

function check_upres()
{
 var ctrl = document.getElementById("upres_frm");

 if(ctrl)
 {
  var zobr = document.getElementById("druhy").value;
  var zobr2 = document.getElementById("druhy2").value;
  var ctrl2;
  
  for(var i=0; i<=max_spc_id; i++)
  {
   ctrl2 = window.frames.upres_frm.document.getElementById("spc_"+i);
   
//   if(typeof(console) != "undefined")
//    console.log(i,ctrl2);
   
   if(ctrl2)
   {
    if(i<32)
     ctrl2.checked = zobr & Math.pow(2,i);
    else
     ctrl2.checked = zobr2 & Math.pow(2,i-32);
   }
  }
 } 
}

function hide_upres(meteo_typ)
{
 var ctrl = document.getElementById("upres_frm");
 var is_nongarant = false;

 if(ctrl)
 {
  var act_zobr = document.getElementById("druhy").value;
  var act_zobr2 = document.getElementById("druhy2").value;
  var zobr = 0;
  var zobr2 = 0;
  var ctrl2;
  
  for(var i=0; i<=max_spc_id; i++)
  {
   ctrl2 = window.frames.upres_frm.document.getElementById("spc_"+i);
   
//   if(typeof(console) != "undefined")
//    console.log(i,ctrl2);
   
   if(ctrl2 && ctrl2.checked)
   {
    if(i<32)
     zobr += Math.pow(2,i);
    else
     zobr2 += Math.pow(2,i-32);
    
    ctrl2 = window.frames.upres_frm.document.getElementById("spc_"+i+"_n");
    
    if(ctrl2 && ctrl2.className != "garant_druhy")
    {
//     if(typeof(console) != "undefined")
//      console.log(ctrl2.className);
    
     is_nongarant = true;
    }
   }
  }
  
  if(meteo_typ != undefined)
  {
   switch(meteo_typ)
   {
    case 2:
      zobr += Math.pow(2,15);
      zobr += Math.pow(2,16);
      zobr2 += Math.pow(2,4);
      zobr2 += Math.pow(2,9);
      is_nongarant = true;
     break;
    case 1:
      zobr += Math.pow(2,16);
      zobr2 += Math.pow(2,4);
     break;
   }
  }
  else 
   ctrl.style.zIndex = -1;
  
  if(zobr == 0 && zobr2==0)
  {
   zobr=document.getElementById("druhy").value;   
   zobr2=document.getElementById("druhy2").value;   
  }
  
  if(zobr != act_zobr || zobr2 != act_zobr2)
  {
   if(is_nongarant)
   {
//    console.log("ne");
    document.getElementById("garant_warn_no").className="garant_warn_no";
    document.getElementById("garant_warn_yes").className="hidden";
   }
   else
   {
//    console.log("ano");
    document.getElementById("garant_warn_no").className="hidden";
    document.getElementById("garant_warn_yes").className="garant_warn_yes";
   }
    
   document.getElementById("druhy").value = zobr;
   document.getElementById("druhy2").value = zobr2;
   
   mapDataChange();
   //document.getElementById("mapa_tiles").src = "mapa_tiles.php";
  }
 } 
}

function hide_meteo_menu()
{
 var ctrl = document.getElementById("meteo_menu_frm");
 ctrl.style.zIndex = -1;
}


function hide_reg()
{
 var ctrl = document.getElementById("reg_frm");
 ctrl.style.zIndex = -1;
}

function setTmAxeBound(dt)
{
 document.getElementById("tm_axe_from").value = sprintf("%02d.%02d. %02d:%02d",dt.getUTCDate(),dt.getUTCMonth()+1,dt.getUTCHours(),dt.getUTCMinutes());
 dt.setUTCMinutes(dt.getUTCMinutes()+1440);                                                                                                                                                                                                                                                                                  
 document.getElementById("tm_axe_to").value = sprintf("%02d.%02d. %02d:%02d",dt.getUTCDate(),dt.getUTCMonth()+1,dt.getUTCHours(),dt.getUTCMinutes());                                                                                                                                                                              
}

function calculateTmAxeFromDt()
{
 var let_od = getDtFromString(document.getElementById("fl_tm_from").value);

/* 
 if(document.getElementById("auto_refr").value > 0)
 {
  return let_od;
 }
 else
 {
*/ 
  var let_do = getDtFromString(document.getElementById("fl_tm_to").value);
 
  var let_len = (let_do-let_od)/1000;
 
  if(let_len > 86400)
  {
   return let_od;
  }
  else
  {
   var tmp = Math.floor((86400 - let_len)/2); 
   return new Date(let_od-(tmp*1000));
  }
// }
}

function showToolTip()
{
 clearTimeout(ttTmOut);
 ttTmOut = 0;
 
 ttx = lastScroll.x;
 tty = lastScroll.y;
 
 if(top.document.getElementById("wait_pic").style.visibility!="visible")
 {
  var disp_ind = window.frames.mapa_tiles.getDispInd(tty,ttx,false);
 
// if(typeof(console) != "undefined")
//  console.log(disp_ind);

  var coords = window.frames.mapa_tiles.getPointCoords(disp_ind[0],disp_ind[1],disp_ind[2],disp_ind[3],false);
 
// if(typeof(console) != "undefined")
//  console.log(coords);

  var toler = 3000;
  var param = "ln=" + (coords[0] + toler) + "&le=" + (coords[1] - toler) + "&lz=" + coords[2]
   + "&rn=" + (coords[0] - toler) + "&re=" + (coords[1] + toler) + "&rz=" + coords[2]
   + "&b=" + window.frames.mapa_tiles.mapa.fl_od + "&c=" + window.frames.mapa_tiles.mapa.fl_do 
   + "&t=" + (window.frames.mapa_tiles.mapa.tm_real==false?"0":"1")
   + "&od=" + window.frames.mapa_tiles.mapa.tm_od + "&do=" + window.frames.mapa_tiles.mapa.tm_do 
   + "&d=" + window.frames.mapa_tiles.mapa.init_druhy + "&d2=" + window.frames.mapa_tiles.mapa.init_druhy2
   + "&ct=" + window.frames.mapa_tiles.mapa.ctries 
   + "&z=" + window.frames.mapa_tiles.mapa.init_zoom + "&dm=" + new Date().getTime();    

/*  
  alert(window.frames.mapa_tiles.mapa.tm_real);
  window.frames.mapa_tiles.mapa.tm_real=false;
  alert(window.frames.mapa_tiles.mapa.tm_real==false);
  alert(param);
*/
  
  window.frames.mapa_tiles.document.body.style.cursor = 'help';
  
  loadXMLDoc("get_tt.php",param);
 }
}

function ttReceived(result)
{
 if(result == null || result == undefined || result.childNodes[0] == null 
  || result.childNodes[0] == undefined || result.childNodes[0].nodeValue == "" 
  || result.childNodes[0].nodeValue == "nodata" 
  || ttx != lastScroll.x || tty != lastScroll.y
  || top.document.getElementById("wait_pic").style.visibility == "visible")
 {
  window.frames.mapa_tiles.document.body.style.cursor = 'default';
  document.getElementById("tt_frm").className="hidden";
 }
 else
 {
  ttClear(true);
  
  var data = result.getElementsByTagName("obj");  
  
  if(data)
   tt_cnt = data.length;
  else
   tt_cnt = 0;
   
  if(tt_cnt>0)
  {
   ttTmOut = -1;
   tt_data = Array();
   
   document.getElementById("tt_nazev_sel").options.length = 0;

   document.getElementById("tt_nazev").className="tt_head";
   document.getElementById("tt_nazev_sel").className="hidden";
   
   var nazev;
   var druh_id;
   var is_garant;
   var nazev_disp;
   var karty;
   var karta_data;
   var clr;
   var title;
   var side_index = 45;
   var bck;
   var set_hgh;
   var frm = document.getElementById("tt_frm");
   var metar_karta = -1;
   var metar_karta_druh = -1;

   tt_max_karty_cnt = 0;
   tt_max_rows_cnt = 0;
   
   for(var i = 0; i<tt_cnt; i++)
   {
    nazev = data[i].getElementsByTagName("nazev");
    
    if(nazev && nazev.length>0)
     nazev = nazev[0].childNodes[0].nodeValue;
    else
     nazev="";

    is_garant = data[i].getElementsByTagName("is_garant");

    if(is_garant && is_garant.length>0)
     is_garant = is_garant[0].childNodes[0].nodeValue;
    else
     is_garant="";
     
    druh_id = data[i].getElementsByTagName("druh");

    if(druh_id && druh_id.length>0)
     druh_id = druh_id[0].childNodes[0].nodeValue;
    else
     druh_id="";
     
    if((druh_id==16 || druh_id==36 || druh_id==15 || druh_id==41) && (metar_karta<0 || druh_id==16 || (druh_id==36 && (metar_karta_druh==15 || metar_karta_druh==41))))
    {
     metar_karta = i;
     metar_karta_druh = druh_id;
	}
     
    nazev_disp = data[i].getElementsByTagName("nazev_disp");
    
    if(nazev_disp && nazev_disp.length>0)
     nazev_disp = nazev_disp[0].childNodes[0].nodeValue;
    else
     nazev_disp="";
     
    if(tt_cnt>1)
    {
     var new_div = document.createElement('div');
     
     bck = data[i].getElementsByTagName("bck");
    
     if(bck && bck.length>0 && bck[0].childNodes.length>0)
      bck = bck[0].childNodes[0].nodeValue;
     else
      bck="CCCCCC";
      
     if(new_div)
     {
      new_div.setAttribute('id','tt_side_'+i);
      new_div.setAttribute('name','tt_side_'+i);
      new_div.className = 'tt_side';
      new_div.style.top = side_index;
      
      if(i==0)
       new_div.style.left = 9;
      
      new_div.title = nazev_disp;
      new_div.innerHTML = (nazev_disp.length>27?nazev_disp.substr(0,24)+"...":nazev_disp);
   
      new_div.style.backgroundColor= "#" + bck;
      new_div.style.color = "#" + (isColorDifferenceOK("000000",bck)?"000000":"FFFFFF");
      new_div.onclick = new Function("changeTTObjekt(\"" + i + "\",\"" + nazev + "\",\"" + is_garant + "\")");
       
      if(nn6)
      {
       new_div.style.width = 143;
       new_div.style.height = 15;
      }
       
      if(nn6)
       side_index += 17;
      else
       side_index += 15;

      frm.appendChild(new_div);      
     }
    }
     
    tt_data[i]= new Array();
    tt_data[i][0] = new Array(nazev,is_garant);

    karty = data[i].getElementsByTagName("karty");
    
    if(karty && karty.length>0)
    {
     var karta_id=1;
      
     for(var j = 0; j<karty[0].childNodes.length; j++)
     {
      clr = karty[0].childNodes[j].childNodes[0].childNodes[0].nodeValue;
      nazev = karty[0].childNodes[j].childNodes[1].childNodes[0].nodeValue;
      title = karty[0].childNodes[j].childNodes[2].childNodes[0].nodeValue;
      set_hgh = karty[0].childNodes[j].childNodes[3].childNodes[0].nodeValue;
      
      if(karty[0].childNodes[j].childNodes[4].childNodes.length > 0)
      {
       karta_data = karty[0].childNodes[j].childNodes[4].childNodes[0].nodeValue.decodePost();
       
       var row_cnt = (karta_data.split("<tr").length-1)+(karta_data.split("<br>").length-1);
       
       if(set_hgh==1 && row_cnt>tt_max_rows_cnt)
        tt_max_rows_cnt = row_cnt;
        
       tt_data[i][karta_id++]=new Array(clr,nazev,title,karta_data);
      }
      
      if((karta_id-1)>tt_max_karty_cnt)
       tt_max_karty_cnt=(karta_id-1);
     }
    }
   }

   if(tt_cnt>1)
   {
    document.getElementById("tt_nazev").style.left = 155;
    document.getElementById("tt_data").style.left = 155;
   }
   else
   {
    document.getElementById("tt_nazev").style.left = 5;
    document.getElementById("tt_data").style.left = 5;
   }
    
   var disp_objekt_ind = (metar_karta>=0 && isMeteoDisplay()?metar_karta:0); 
   changeTTObjekt(disp_objekt_ind,tt_data[disp_objekt_ind][0][0],tt_data[disp_objekt_ind][0][1]);
  
   window.frames.mapa_tiles.document.body.style.cursor = 'default';
   document.getElementById("tt_frm").className="";
  }
  else
  {
   window.frames.mapa_tiles.document.body.style.cursor = 'default';
   document.getElementById("tt_frm").className="hidden";
  }
 }
}

function ttClear(side_butts)
{
 var frm = document.getElementById("tt_frm");
 var nodes = Array();
 var id=0;

 for(var i = 0; i<frm.childNodes.length; i++)
 {
  if(frm.childNodes[i].id && frm.childNodes[i].id.indexOf("tt_")==0 && frm.childNodes[i].id != "tt_data" 
   && frm.childNodes[i].id != "tt_right" && frm.childNodes[i].id != "tt_left" && frm.childNodes[i].id != "tt_legenda"
   && frm.childNodes[i].id != "tt_nazev" && frm.childNodes[i].id != "tt_nazev_sel" 
   && (side_butts || frm.childNodes[i].id.indexOf("tt_side")<0))
  {
   nodes[id++] = frm.childNodes[i].id;
  }
 }

 for(var i = 0; i<nodes.length; i++)
  frm.removeChild(document.getElementById(nodes[i]));
}

function isMeteoDisplay()
{
 var zobr = document.getElementById("druhy").value;
 var zobr2 = document.getElementById("druhy2").value;
 
 if((zobr & Math.pow(2,15)) || (zobr & Math.pow(2,16)) || (zobr2 & Math.pow(2,4)) || (zobr2 & Math.pow(2,9)))
  return true;
 else
  return false;
}

function changeTTObjekt(id,nazev,is_garant)
{
 ttClear();

 var i=1;
 var data;
 var new_div;
 var karta_index = 5 +(tt_cnt>1?150:0);
 var frm = document.getElementById("tt_frm");

 while(true)
 {
  if(!tt_data[id][i])
   break;
  
  new_div = document.createElement('div');
      
  if(new_div)
  {
   new_div.setAttribute('id','tt_karta_'+i);
   new_div.setAttribute('name','tt_karta_'+i);
   new_div.className = 'tt_button';
   new_div.style.left = karta_index;
   new_div.title = tt_data[id][i][2];
   new_div.innerHTML = tt_data[id][i][1];
   
   if(tt_data[id][i][3] != "")
   {
    new_div.style.backgroundColor= tt_data[id][i][0];
    new_div.onclick = new Function("showKarta(\"" + id + "\",\"" + i + "\")");
   }
   else
   {
    new_div.style.backgroundColor= "#ACACAC";
    new_div.style.color = "#E0E0E0";
   }

       
   if(nn6)
    new_div.style.height = 12;
       
   if(nn6)
    karta_index += 51;
   else
    karta_index += 49;

   frm.appendChild(new_div);      
  }
  
  i++;
 }
 
 var wdth = Math.max(300,(tt_max_karty_cnt*(nn6?51:49)) + 20)+(tt_cnt>1?150:0);

 if(nazev)
  document.getElementById("tt_nazev").innerHTML = nazev;
  
 if(is_garant != undefined)
  document.getElementById("tt_nazev").className = "tt_head" + (is_garant == 1?"_garant":"");
 
 var row_height = 153/8;
 var v_tab_height = 18;
 var hght = Math.max(200,(tt_max_rows_cnt*row_height)+40+10);
 
 hght = Math.max(hght,(tt_cnt*v_tab_height)+40+10);
 
 frm.style.width = wdth;
 frm.style.height = hght;
 
 document.getElementById("tt_data").style.width = wdth-(nn6?13:11)-(tt_cnt>1?150:0);
 document.getElementById("tt_data").style.height = hght - 40 - (nn6?13:7);

 var tt_right = document.getElementById("tt_right");
 var tt_left = document.getElementById("tt_left");
 
 var top_offset = 85;
 var top_pos = Math.max(-5,tty-(hght/2));
 top_pos = Math.min(top_pos,window.frames.mapa_tiles.mapa.frm_height-(hght-10));
 var top_pos_arr = tty-top_pos-15;

 frm.style.top = top_offset + top_pos;
 
 var nav_ctrl = document.getElementById("navig_frm");

 if(ttx > wdth + 30 + (nav_ctrl && nav_ctrl.style.zIndex>0?300:0))
 {
  frm.style.left = ttx-wdth-20;
  tt_right.style.left = wdth-(nn6?0:2);
  tt_right.style.top = top_pos_arr;
  tt_right.className = "";
  tt_left.className = "hidden";
 }
 else
 {
  frm.style.left = ttx+20;
  tt_left.style.top = top_pos_arr;
  tt_right.className = "hidden";
  tt_left.className = "";
 }
 
 i=0;
 
 while(true)
 {
  if(!tt_data[i])
   break;
  
  if(i==id)
  {
   if(document.getElementById("tt_side_"+i))
    document.getElementById("tt_side_"+i).style.left = 9;
  }
  else
  {
   if(document.getElementById("tt_side_"+i))
    document.getElementById("tt_side_"+i).style.left = 5;
  }
   
  i++;
 }

 showKarta(id,1);
}

function showKarta(obj,id)
{
 var data_frm = document.getElementById("tt_data");
 
 var i=1;

 while(true)
 {
  if(!tt_data[obj][i])
   break;
   
  if(id == i)
  {
//   document.getElementById("tt_karta_"+i).style.borderBottomStyle = "none";

   if(nn6)
    document.getElementById("tt_karta_"+i).style.height = 12;

   document.getElementById("tt_karta_"+i).style.top = 26;
   
   if(data_frm)
   {
    data_frm.innerHTML = tt_data[obj][id][3];
    data_frm.style.backgroundColor= tt_data[obj][id][0];
   }
  }
  else
  {
   if(nn6)
    document.getElementById("tt_karta_"+i).style.height = 12;
    
   document.getElementById("tt_karta_"+i).style.top = 25;
//   document.getElementById("tt_karta_"+i).style.borderBottomStyle = "solid";
  }
  
  i++;
 }
 
 if(document.getElementById("tt_listbox"))
 {
  document.getElementById("tt_listbox").style.height = document.getElementById("tt_data").clientHeight-10;
  document.getElementById("tt_listbox").style.width = document.getElementById("tt_data").clientWidth-10;
 }
 
 if(document.getElementById("tt_photobox"))
 {
  document.getElementById("tt_photobox").style.height = document.getElementById("tt_data").clientHeight-10;
  document.getElementById("tt_photobox").style.width = document.getElementById("tt_data").clientWidth-10;
 }
}

function hideTT()
{
// console.log(lastScroll.x, lastScroll.y);
// console.log(ttx, tty);

 if(ttTmOut!=(-1)) 
 {
  clearTimeout(ttTmOut*(-1));
  ttTmOut = (-1);
 }
 
 var frm = document.getElementById("tt_frm");
// console.log(frm.offsetLeft,frm.offsetTop);
 
 if(lastScroll.x < frm.offsetLeft || lastScroll.x > frm.offsetLeft+200
  || lastScroll.y < frm.offsetTop || lastScroll.y > frm.offsetTop+200 || frm.className=="hidden")
 {
  frm.className="hidden";
  ttTmOut = 0;
 }
}

function resetMap()
{
 document.getElementById("ln").value = document.getElementById("init_ln").value;
 document.getElementById("le").value = document.getElementById("init_le").value;
 document.getElementById("lz").value = document.getElementById("init_lz").value;
 
 parent.document.getElementById("zoom_slider").style.top = document.getElementById("init_zoom").value*12+222;
 document.getElementById("last_zoom").value = -1;
 
 changeZoom();
 
 return false;
}

function disp_unp()
{
 var ctrl = document.getElementById("unp_frm");

 if(ctrl)
  ctrl.style.zIndex = 100002;
 
 return false;
}

function hide_unp()
{
 var ctrl = document.getElementById("unp_frm");

 if(ctrl)
  ctrl.style.zIndex = -1;
  
 return false;
}

function disp_sig()
{
 var ctrl = document.getElementById("sig_frm");

 if(ctrl)
  ctrl.style.zIndex = 100002;
 
 return false;
}

function hide_sig()
{
 var ctrl = document.getElementById("sig_frm");

 if(ctrl)
  ctrl.style.zIndex = -1;
  
 return false;
}

function setSmallMap()
{
 var ctrl = document.getElementById("mala_mapa_area");
 
 if(ctrl)
 {
  var ctrl_map = document.getElementById("mala_mapa");
  
  if(ctrl_map)
  {
   var sm_height = ctrl_map.offsetHeight;
   var sm_width = ctrl_map.offsetWidth;
   
//   if(typeof(console) != undefined)
//    console.log(sm_height,sm_width);
   
   var sm_ln = parseInt(document.getElementById("small_map_ln").value);
   var sm_le = parseInt(document.getElementById("small_map_le").value);
   var sm_lz = parseInt(document.getElementById("small_map_lz").value);
   var sm_rn = parseInt(document.getElementById("small_map_rn").value);
   
   var sm_rate = sm_height/(sm_ln-sm_rn);
  
   var coords = window.frames.mapa_tiles.getDispCoords();
 
   var disp_ln = coords[0];
   var disp_le = coords[1];
   var disp_lz = coords[2];
   var disp_rn = coords[3];
   var disp_re = coords[4];
   var disp_rz = coords[5];
   
//   if(typeof(console) != undefined)
//    console.log(sm_height,sm_rate,disp_ln,disp_rn);
  
   ctrl.style.top = (sm_ln-disp_ln)*sm_rate;
   ctrl.style.left = (disp_le-sm_le)*sm_rate;
//   ctrl.style.height = (disp_ln-disp_rn)*sm_rate;
   ctrl.style.width = (disp_re-disp_le)*sm_rate;
  }
 }
}

function dispNOTAM(tbl,id,druh_id,pl_od,pl_do,disp_druh)
{
 var ctrl = document.getElementById("notam_frm");
 var ctrl2 = document.getElementById("notam_close");
 
 if(ctrl && ctrl2 && ctrl.style.zIndex<0);
 {
  var frm_width = document.body.clientWidth;
  var frm_height = document.body.clientHeight;

  ctrl.style.height = frm_height - ctrl.offsetTop-20;
  ctrl.style.width = frm_width - ctrl.offsetLeft-20;

  ctrl2.style.top = ctrl.offsetTop+5;
  ctrl2.style.left = frm_width - ctrl.offsetLeft - 52;
  
  document.getElementById("wait_icon").style.zIndex = 10000;
  ctrl.src = "notam.php?tbl=" + tbl + "&id="  + id + "&druh_id=" + druh_id + "&pl_od=" + pl_od + "&pl_do=" + pl_do + "&disp_druh=" + (disp_druh?disp_druh:0);
 }
}

function dispMETAR(id,druh_id,pl_od,pl_do)
{
 var ctrl = document.getElementById("notam_frm");
 var ctrl2 = document.getElementById("notam_close");
 
 if(ctrl && ctrl2 && ctrl.style.zIndex<0);
 {
  var frm_width = document.body.clientWidth;
  var frm_height = document.body.clientHeight;

  ctrl.style.height = frm_height - ctrl.offsetTop-20;
  ctrl.style.width = frm_width - ctrl.offsetLeft-20;

  ctrl2.style.top = ctrl.offsetTop+5;
  ctrl2.style.left = frm_width - ctrl.offsetLeft - 52;
  
  document.getElementById("wait_icon").style.zIndex = 10000;
  ctrl.src = "metar.php?id="  + id + "&druh_id=" + druh_id + "&pl_od=" + pl_od + "&pl_do=" + pl_do;
 }
}

function dispMETEO(icao,pl_od,pl_do)
{
 var ctrl = document.getElementById("notam_frm");
 var ctrl2 = document.getElementById("notam_close");
 
 if(ctrl && ctrl2 && ctrl.style.zIndex<0);
 {
  var frm_width = document.body.clientWidth;
  var frm_height = document.body.clientHeight;

  ctrl.style.height = frm_height - ctrl.offsetTop-20;
  ctrl.style.width = frm_width - ctrl.offsetLeft-20;

  ctrl2.style.top = ctrl.offsetTop+5;
  ctrl2.style.left = frm_width - ctrl.offsetLeft - 52;
  
  document.getElementById("wait_icon").style.zIndex = 10000;
  ctrl.src = "meteo.php?icao="  + icao + "&pl_od=" + pl_od + "&pl_do=" + pl_do;
 }
}

function selectFoundPt()
{
 ctrl = document.getElementById("found_pts_list");
 
 if(ctrl.selectedIndex >= 0)
 {
  if(clicked_pts[ctrl.selectedIndex][2]>0 || clicked_pts[ctrl.selectedIndex][3]>0)
  {
   window.frames.navig_frm.addRtPoint(clicked_pts[ctrl.selectedIndex][0],clicked_pts[ctrl.selectedIndex][5]==0?"":clicked_pts[ctrl.selectedIndex][1],clicked_pts[ctrl.selectedIndex][2],clicked_pts[ctrl.selectedIndex][3],clicked_pts[ctrl.selectedIndex][4],clicked_pts[ctrl.selectedIndex][5],"",-2,-2,-2);
   window.frames.navig_frm.updateWind(0);
  }
  else
  {
   var nav_frm = top.frames["navig_frm"];

   if(nav_frm.sel_rt_bod != nav_frm.rt_body[clicked_pts[ctrl.selectedIndex][5]][0])
    nav_frm.changeRowSelection(nav_frm.document.getElementById("cell_"+nav_frm.rt_body[clicked_pts[ctrl.selectedIndex][5]][0]));  
  } 
   
  document.getElementById("found_pts").className="hidden";   
 }
}

function displayUserObjects()
{
 var nav_frm = top.frames["navig_frm"];
 var bod_frm = nav_frm.document.getElementById("bod_frm");
 var rt_frm = nav_frm.document.getElementById("rt_frm");

//alert(rt_frm);
 
 
 if(rt_frm && rt_frm.offsetLeft >= 0 && nav_frm.rt_body.length>0)
 {
  for(var i=0; i<nav_frm.rt_body.length; i++)
  {
   var wpt_id = parseInt(nav_frm.rt_body[i][0].substr(7));
   var bod_id = parseInt(((nav_frm.edited_object<1?1:nav_frm.edited_object+1)*10000+wpt_id));
   
   var coord = window.frames.mapa_tiles.getPtPos(reformatCoord(nav_frm.rt_body[i][3]),reformatCoord(nav_frm.rt_body[i][4]));
   
   nav_frm.rt_body[i][8] = coord[1];
   nav_frm.rt_body[i][9] = coord[0];
   
   if(i>0)
    nav_frm.drawLine(bod_id,nav_frm.rt_body[i][8],nav_frm.rt_body[i][9],nav_frm.rt_body[i-1][8],nav_frm.rt_body[i-1][9]);   
    
   nav_frm.showIconOnMap("usr_obj_"+bod_id,nav_frm.rt_body[i][8],nav_frm.rt_body[i][9],"images/ikona_rt_bod.gif",null,selectmousertbod);
  }
  
  nav_frm.recalcStat();
 }
  
 if(disp_objects)
 {
  for(var i=0; i<disp_objects.length; i++)
  {
   if(i!=navig_frm.edited_object && disp_objects[i] && window.frames.navig_frm.objects[i] && window.frames.navig_frm.objects[i].length>2)
   {
    var druh_id = window.frames.navig_frm.objects[i][2];
    
    switch(druh_id)
    {
     case "37":
      window.frames.navig_frm.toggleBodOnMap(i,disp_objects[i][0],disp_objects[i][1],window.frames.navig_frm.objects[i][5]);
      break;
     case "38":
      window.frames.navig_frm.toggleRtOnMap(i,true);
      break;
    } 
   }   
  }   
 }
 
 if(bod_frm && bod_frm.offsetLeft >= 0 && nav_frm.document.getElementById("bod_lat").value!="" && nav_frm.document.getElementById("bod_lon").value!="" && !disp_objects[nav_frm.edited_object])
 {
  var coord = window.frames.mapa_tiles.getPtPos(nav_frm.document.getElementById("bod_lat").value,nav_frm.document.getElementById("bod_lon").value);
  nav_frm.showIconOnMap("usr_obj_"+(nav_frm.edited_object>=0?nav_frm.edited_object:0),coord[1],coord[0],nav_frm.document.getElementById("bod_ikona").value);    
 }
}

function setNow()
{
 var akt_tm = new Date();
 
 document.getElementById("fl_tm_from").value = document.getElementById("fl_tm_to").value = sprintf("%02d.%02d. %02d:%02d",akt_tm.getUTCDate(),akt_tm.getUTCMonth()+1,akt_tm.getUTCHours(),akt_tm.getUTCMinutes());
 reloadMap();
}

function showNast()
{
 var ctrl = top.document.getElementById("rep_frm");
    
 if(ctrl)
 {
  showWait(true);
  ctrl.src = "user_settings.php";
  ctrl.style.zIndex = 10000;
 }
}

function showNews()
{
 var ctrl = document.getElementById("notam_frm");
 var ctrl2 = document.getElementById("notam_close");
 
 if(ctrl && ctrl2 && ctrl.style.zIndex<0);
 {
  var frm_width = document.body.clientWidth;
  var frm_height = document.body.clientHeight;

  ctrl.style.height = frm_height - ctrl.offsetTop-20;
  ctrl.style.width = frm_width - ctrl.offsetLeft-20;

  ctrl2.style.top = ctrl.offsetTop+5;
  ctrl2.style.left = frm_width - ctrl.offsetLeft - 52;
  
  showWait(true);
  
  ctrl.src = "news.php?dummy="+new Date().getTime();
 }
}

function printMap()
{
 var keys = new Array("w","h","ln","le","lz","z","b","c","od","do","d","d2","ui","si","gr");
 var vals = new Array(window.frames.mapa_tiles.mapa.frm_width
     ,window.frames.mapa_tiles.mapa.frm_height
     ,document.getElementById("ln").value,document.getElementById("le").value
     ,document.getElementById("lz").value,window.frames.mapa_tiles.mapa.init_zoom
     ,window.frames.mapa_tiles.mapa.fl_od,window.frames.mapa_tiles.mapa.fl_do
     ,window.frames.mapa_tiles.mapa.tm_od,window.frames.mapa_tiles.mapa.tm_do
     ,window.frames.mapa_tiles.mapa.init_druhy,window.frames.mapa_tiles.mapa.init_druhy2
     ,document.getElementById("upoz_icon").className=="hidden"?"0":"1"
     ,document.getElementById("sig_icon").className=="hidden"?"0":"1"
     ,document.getElementById("garant_warn_yes").className=="hidden"?"0":"1");
     
 openWindowWithPost("print_map.php","print_window",keys,vals);
}

function mapDataChange()
{
 stopReload();
 
 if(document.getElementById("auto_chk").checked)
  reloadMap();
 else 
 {
  if(!was_reload_change)   
  {
   was_reload_change = true;   
   document.getElementById("reload_butt").src="images/ikona_reload.gif";
  }
  
  if(reload_period>0)
   reload_to=setTimeout("reloadMap()",reload_period*1000);  
 }
}

function setZobrParamTxt()
{
 var txt = "("+document.getElementById("fl_tm_from").value+"&nbsp;-&nbsp;"+document.getElementById("fl_tm_to").value+"; "
  +document.getElementById("fl_lvl_from").options[document.getElementById("fl_lvl_from").selectedIndex].text+"&nbsp;-&nbsp;"
  +document.getElementById("fl_lvl_to").options[document.getElementById("fl_lvl_to").selectedIndex].text+")";
 
 document.getElementById("zobr_param_txt").innerHTML = txt;
}

function reloadMap()
{
 was_reload_change=false;
 stopReload();
 document.getElementById("reload_butt").src="images/ikona_reload_noactive.gif";
 
 setTmAxeBound(calculateTmAxeFromDt()); 
 setTmSlidersPos(); 
 document.getElementById("mapa_tiles").src = "mapa_tiles.php";
}

function stopReload()
{
 if(reload_to)
  clearTimeout(reload_to);
  
 reload_to = false;
}
