function ukaPoz(p_id) {
 var objStyl = document.getElementById(p_id).style;
 if(objStyl.display=='block')
   objStyl.display = 'none';
 else objStyl.display = 'block';
}

function ukaPozOkno(typ, contens, title) {
 var poznOkno = dhtmlwindow.open('pozn', typ, contens, title, 'width=690px,height=350px,resize=1,scrolling=1,center=1', 'recal');
}

var gRa = null;
var gOd = -1;
var gDo = -1;
var gSl = -1;

function setCurOut () {
    document.body.style.cursor='auto';
}

function setCurOver () {
    document.body.style.cursor='url(html.s?j=graf.ico), url(html.s?j=graf.ico), auto';
}

function eventMouseOut (radek) {
    radek.parentNode.style.backgroundColor='';
    setCurOut();
}

function eventMouseOver (radek) {    
    radek.parentNode.style.backgroundColor='#B3D9FF';
    setCurOver();
}

function eventMouseOutS (bunka) {
    setCurOut();
    if (gOd != -1){        
     for (i=gOd; i<gDo; i++) {
      if(gRa[i].cells[0].innerHTML == "&nbsp;") break;                    
      gRa[i].cells[gSl-1].style.backgroundColor = '';
      gRa[i].cells[gSl].style.backgroundColor = '';       
     }
     gRa = null;
     gOd = -1;
     gDo = -1;
     gSl = -1;
    }     
}

function eventMouseOverS (bunka) {    
    setCurOver();
    gOd = bunka.parentNode.rowIndex + 1;
    gDo = bunka.parentNode.parentNode.rows.length;
    gRa = bunka.parentNode.parentNode.rows;
    gSl = bunka.cellIndex * 2;
         
    for (i=gOd; i<gDo; i++) {
      if (gRa[i].cells[0].innerHTML == "&nbsp;") break;        
       gRa[i].cells[gSl-1].style.backgroundColor = '#B3D9FF';
      gRa[i].cells[gSl].style.backgroundColor = '#B3D9FF';              
    }
}

/* ----------- pro graf ----------- */
var g = null;
var j = ""; 
var grafXml = "";
var radekColor;

function winH() {
   if (window.innerHeight)
      /* NN4 a kompatibilní prohlížeče */
      return window.innerHeight;
   else if
   (document.documentElement && document.documentElement.clientHeight)   
      /* MSIE6 v std. režimu - Opera a Mozilla
      již uspěly s window.innerHeight */
      return document.documentElement.clientHeight;
   else if
   (document.body && document.body.clientHeight)
      /* starší MSIE + MSIE6 v quirk režimu */
      return document.body.clientHeight;
   else
      return null;
}

function winW() {
   if (window.innerWidth)
      /* NN4 a kompatibilní prohlížeče */
      return window.innerWidth;
   else if
   (document.documentElement && document.documentElement.clientWidth)
      /* MSIE6 v std. režimu - Opera a Mozilla
      již uspěly s window.innerHeight */
      return document.documentElement.clientWidth;
   else if
   (document.body && document.body.clientWidth)
      /* starší MSIE + MSIE6 v quirk režimu */
      return document.body.clientWidth;
   else
      return null;
}


function setGrafVisible() {
  document.body.parentNode.style.overflow = 'hidden';
  ifr = document.createElement("iframe");              
  ifr.setAttribute("id", "mujGraf");
  ifr.setAttribute("name", "mujGraf");  
  ifr.setAttribute("scrolling", "auto");
  ifr.setAttribute("frameborder", "NO");
  ifr.setAttribute("hspace", "0px");
  ifr.setAttribute("vspace", "0px");
  ifr.style.backgroundColor = "#ffffff";
  ifr.style.position = "absolute";
  ifr.style.width = winW()+"px";
  ifr.style.height = winH()+"px";
  ifr.style.top = "0px";
  ifr.style.left = "0px";
  ifr.style.borderWidth = "0px";
  ifr.style.zIndex = 2;
  document.getElementsByTagName("body")[0].appendChild(ifr);
  
  ifr = document.getElementById("mujGraf");
  ifr = (ifr.contentWindow) ? ifr.contentWindow : (ifr.contentDocument.document) ? ifr.contentDocument.document : ifr.contentDocument; 
  ifr.document.open();
  ifr.document.write(
'<html><body>'+  
'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' +
                'id="gObj" name="gObj" ' +
                'width="100%" height="100%" ' +
                'codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">' +
                  '<param name="movie" value="html.s?j=Graf.swf" /> ' +
                  '<param name="quality" value="high" /> ' +
                  '<param name="bgcolor" value="#FFFFFF" /> ' +
                  '<param name="allowScriptAccess" value="sameDomain" /> ' +
                  '<embed id="gEmb" name="gEmb" src="html.s?j=Graf.swf" ' +
                    'quality="high" bgcolor="#FFFFFF" ' +
                    'width="100%" height="100%" ' +
                    'align="middle" ' +
                    'play="true" ' +
                    'loop="false" ' +
                    'quality="high" ' +
                    'allowScriptAccess="sameDomain" ' +
                    'type="application/x-shockwave-flash" ' +                   
                    'pluginspage="http://www.adobe.com/go/getflashplayer"> ' +
                  '</embed> ' +
              '</object>' +
              '</body></html>');
  ifr.document.close();            
}

function setGrafClose() { 
 document.getElementsByTagName("body")[0].removeChild(document.getElementById("mujGraf"));
 closeMap();
 document.getElementsByTagName("body")[0].parentNode.style.overflow = 'auto';
}

function closeMap() {
if(document.getElementById("mujMapa")) document.getElementsByTagName("body")[0].removeChild(document.getElementById("mujMapa"));
}

function getXmlData() {
  return '<?xml version="1.0" encoding="UTF-8"?>\n' + 
         '<graf>' +    
         grafXml +
         '</graf>';          
}

function getNadpisTab(pRow){
   if(document.getElementsByTagName("table")[0].rows[pRow].cells[0].innerHTML == "&nbsp;")
    return "";
   else
    return document.getElementsByTagName("table")[0].rows[pRow].cells[0].innerHTML;
}

function getFootnotes() {
    grafXml += "<popis>";
    var f = document.getElementsByTagName("table");
    var fr = null;
    for (i=0; i<f.length; i++){
     if(f[i].className=="foot") {
      fr = f[i];
      for (ii=0; ii<fr.rows.length; ii++){         
        if(fr.rows[ii].cells[0].innerHTML=="&nbsp;") break;
        grafXml += '<hodnota jmenp="'+fr.rows[ii].cells[0].firstChild.innerHTML+'">'+fr.rows[ii].cells[1].firstChild.innerHTML+'</hodnota>';
      }    
      break;  
     }
    }
    grafXml += "</popis>";
}

function getGraf(radek) {            
grafXml = "";
var lRadek;
var lHeadValue;
var lBunka = 0;
var lCellValue;
var oX ="";
var elmX="";
var oY ="";
for(i=radek.rowIndex-1; i>-1; i--){
 lRadek = radek.parentNode.rows[i];  
 if(lRadek.innerHTML.indexOf("suiteHeaderBreakText") > -1) {
   // nadpis   
   grafXml += "<nadpis sekce=\"" + lRadek.cells[1].innerHTML + "\">" + getNadpisTab(1) + "</nadpis>";   
   elmX += "<osax popis=\"" + radek.cells[0].firstChild.innerHTML + "\">"; 
   break;   
 } else if(lRadek.innerHTML.indexOf("suiteHeaderRow") > -1){
   // sloupcova legenda + hodnota + footnote   
   for(ii=0; ii<lRadek.cells.length; ii++) {    
    if(lRadek.cells[ii].className == 'suiteHeaderRow') {
      lBunka += 2;
      lHeadValue = lRadek.cells[ii].firstChild.innerHTML;
      lCellValue = (radek.cells[lBunka-1].firstChild.innerHTML !=":" ? radek.cells[lBunka-1].firstChild.innerHTML : "");           
      lCellFootn = (radek.cells[lBunka-1].firstChild.innerHTML !=":" ? radek.cells[lBunka].firstChild.firstChild.innerHTML.replace("&nbsp;","") : ""+radek.cells[lBunka-1].firstChild.innerHTML+"");
      oY += "<hodnota popis='"+lCellFootn+"'>" + lCellValue + "</hodnota>";
      oX += "<hodnota>" + lHeadValue + "</hodnota>";      
    }    
   }
 }
}
oY = "<osay popis=\"" + getNadpisTab(2) + "\">" + oY + "</osay>";
oX = elmX + oX +"</osax>";
grafXml += oY + oX;  
getFootnotes(); 
setGrafVisible();
}
var gB;
function getGrafS(bunka) {
gB = bunka;
    grafXml = "";    
    var slIndex = (bunka.cellIndex * 2) - 1;
    var rowstab = bunka.parentNode.parentNode.rows;
    var oX ="";
    var oY ="";
    var lCellValue ="";
    var lCellFootn ="";
    
    // nadpis
    grafXml += "<nadpis sekce=\"\">" + getNadpisTab(1) + "</nadpis>";    
    for(i=bunka.parentNode.rowIndex-1; i > -1; i--) {
       if (rowstab[i].cells.length > 1) {
        grafXml = grafXml.replace('sekce=""', 'sekce="' +rowstab[i].cells[1].innerHTML +'"');
        break;
       } 
    }
    
    // osy
    for(i=(bunka.parentNode.rowIndex+1); i<rowstab.length; i++) {
      if (rowstab[i].cells.length > slIndex) {                      
            // osaY              
          lCellValue = (rowstab[i].cells[slIndex].firstChild.innerHTML !=":" ? rowstab[i].cells[slIndex].firstChild.innerHTML : "");                              
          lCellFootn = (rowstab[i].cells[slIndex].firstChild.innerHTML !=":" ? rowstab[i].cells[slIndex+1].firstChild.firstChild.innerHTML.replace("&nbsp;","") : ""+rowstab[i].cells[slIndex].firstChild.innerHTML+"");
          oY += "<hodnota popis='" + lCellFootn+"'>" + lCellValue + "</hodnota>";
          // osaX
          oX += "<hodnota>" + rowstab[i].cells[0].firstChild.innerHTML + "</hodnota>";
      } else {
            if(rowstab[i].cells[0].innerHTML == "&nbsp;") break;       
      } 
    }
    grafXml += "<osay popis=\"" + getNadpisTab(2) + "\">" + oY + "</osay>" +
               "<osax popis=\"" + bunka.firstChild.innerHTML + "\">" + oX + "</osax>";               
    // footnotes           
    getFootnotes();                    
    setGrafVisible();     
}

function getMap(pMapa,pData) {
  lMa = document.createElement("iframe");              
  lMa.setAttribute("id", "mujMapa");
  lMa.setAttribute("name", "mujMapa");
  lMa.setAttribute("scrolling", "auto");
  lMa.style.backgroundColor = "#ffffff";
  lMa.style.position = "absolute";
  lMa.style.width = winW()+"px";
  lMa.style.height = (winH()-110)+"px";
  lMa.style.top = "50px";
  lMa.style.left = "0px";
  lMa.style.border = "0px none #ffffff";
  lMa.style.borderStyle = "none";
  lMa.style.zIndex = 255;
  document.getElementsByTagName("body")[0].appendChild(lMa);
  
  lMa = document.getElementById("mujMapa");
  lMa = (lMa.contentWindow) ? lMa.contentWindow : (lMa.contentDocument.document) ? lMa.contentDocument.document : lMa.contentDocument;   
  var lScr =   
         "function mapa(pData) { " +
         "var map = new self.parent.FusionMaps('html.s?j=FCMap_" + pMapa + ".swf','mapId','850', '450','0','1'); " +
         "var dat = pData; " +                          
         "map.setDataXML(dat); " +
         "map.render(document.getElementById('mapDiv')); " +         
         "} " +
         
         "function prn() { " +      
         "var mapPr = document.getElementById('mapId'); " +
         "mapPr.print(); " +         
         "} ";
         
  lHtm = "<html><head><script>" + lScr + "</script></head><body><div id='mapDiv'>MAPA</div></body></html>";
  lMa.document.open();
  lMa.document.write(lHtm);
  lMa.document.close();
  
  lMa = document.getElementById("mujMapa");
  lMa = (lMa.contentWindow) ? lMa.contentWindow : (lMa.contentDocument.document) ? lMa.contentDocument.document : lMa.contentDocument;
  lMa.mapa(pData); 
}
   
function printMap() {
  lMa = document.getElementById("mujMapa");
  lMa = (lMa.contentWindow) ? lMa.contentWindow : (lMa.contentDocument.document) ? lMa.contentDocument.document : lMa.contentDocument;
  lMa.prn();    
}