function findObj(n, d) {  
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { 
  d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} 
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; 
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document); 
  if(!x && document.getElementById) x=document.getElementById(n); return x; 
} 


function replaceText(node, text)
{
    while (node.hasChildNodes()) {
        node.removeChild(node.firstChild);
    }
    node.appendChild(document.createTextNode(text));
}


function innerXHTML(node, html)
{
    while (node.hasChildNodes()) {
        node.removeChild(node.firstChild);
    }
    
    _doInnerXHTML(node, html)
}


function _doInnerXHTML(node, html)
{
    /* Pokud je v textu značka */
    if ((index = html.indexOf('<')) != -1) {
        /* Pokud je před značkou ještě nějaký text */
        if (index != 0) {
            text = html.substring(0, index);
            node.appendChild(document.createTextNode(text));
            html = html.substr(index);
//            alert('text:"'+text+'" html:"'+html+'"');
        }

        /* Teď by měl text začínat "<" */
        if ((index = html.indexOf('>')) != -1) {            
            /* Do prom. tag si uložim celou značku bez špič. závorek */
            tag = html.substring(1, index);
            /* V textu nechám zbytek po tagu */
            html = html.substr(index + 1);
            
//            alert('tag:"'+tag+'" html:"'+html+'"');
            /* Pokud jde o ukončovací tag */
            if (tag.charAt(0) == '/') {
                endTag = true;
                if (html.length > 0) {
                    _doInnerXHTML(node.parentNode, html);
                }
            } else {
                endTag = false;
                /* Pokud jde o prázdný element */
                if (tag.charAt(tag.length - 1) == '/') {
                    empty = true;
                    tag = tag.substr(0, tag.length - 1);
                /* Pokud jde o počáteční tag */
                } else {
                    empty = false;
                }

                /* Rozdělim na části oddělené mezerou */
                /* Tohle je chyba - mezery můžou být i v hodnotách atributů.
                Ale zatim se mi nedaří to udělat líp.
                */
                tagParts = tag.split(/\s+/);
                
                if (tagParts[tagParts.length - 1] == "") {
                    tagParts.pop();
                }
            
                /* Vytvořím požadovaný element (na atributy zatím dlabu) */
                newElement = node.appendChild(document.createElement(tagParts[0]));
                
                /* Naplním element atributy */
                for (i=1; i<tagParts.length; i++) { // Projdeme všechny prvky kromě názvu
                    attrib = tagParts[i]
                    attrName = attrib.replace(/^([^=]+)(=.+)?$/, "$1");
                    if (attrib.indexOf("=") != -1) {
                        attrValue = attrib.replace(/^[^=]+="?([^"]*)"?$/, "$1");
                    } else {
                        attrValue = "";
                    }
                    newElement.setAttribute(attrName, attrValue);
//                    alert('name:"'+attrName+'" value:"'+attrValue+'"');
                }

                /* Pokud ještě zbývá nějaký text */
                if (html.length > 0) {
                    if (empty) {
                        _doInnerXHTML(node, html);
                    } else {
                        _doInnerXHTML(newElement, html);
                    }
                }
            }
        }
    } else {
        /* Pokud ještě v textu zbyl nějaký text */
        if (html.length > 0) {
            node.appendChild(document.createTextNode(html));
        }
    }

}

function popisChange(den,popis) { 
  innerXHTML(document.getElementById('itinerar-popis'), "<strong>Den "+den+"</strong><br/><br/><br/>"+popis.replace(/&quot;/g,'"'));
}

function lightup(imgName)
 {
   if (document.images)
    {
      imgOn=eval(imgName + "on.src");
      findObj(imgName).src= imgOn;
    }
 }

function turnoff(imgName)
 {
   if (document.images)
    {
      imgOff=eval(imgName + "off.src");
        findObj(imgName).src= imgOff;
    }
 }


  if (document.images)
   {
     menu1on= new Image(107,51);
     menu1on.src="/img/menu/menu-on_01.jpg";  
     menu1off= new Image(107,51);
     menu1off.src="/img/menu/menu-off_01.jpg";

     menu2on= new Image(112,51);
     menu2on.src="/img/menu/menu-on_02.jpg";  
     menu2off= new Image(112,51);
     menu2off.src="/img/menu/menu-off_02.jpg";

     menu3on= new Image(112,51);
     menu3on.src="/img/menu/menu-on_03.jpg";  
     menu3off= new Image(112,51);
     menu3off.src="/img/menu/menu-off_03.jpg";

     menu4on= new Image(111,51);
     menu4on.src="/img/menu/menu-on_04.jpg";  
     menu4off= new Image(111,51);
     menu4off.src="/img/menu/menu-off_04.jpg";

     menu5on= new Image(239,51);
     menu5on.src="/img/menu/menu-on_05.jpg";  
     menu5off= new Image(239,51);
     menu5off.src="/img/menu/menu-off_05.jpg";
     
     menu6on= new Image(111,51);
     menu6on.src="/img/menu/menu-on_06.jpg";  
     menu6off= new Image(111,51);
     menu6off.src="/img/menu/menu-off_06.jpg";


     menu7on= new Image(108,51);
     menu7on.src="/img/menu/menu-on_07.jpg";  
     menu7off= new Image(108,51);
     menu7off.src="/img/menu/menu-off_07.jpg";
     
     menu8on= new Image(108,51);
     menu8on.src="/img/menu/menu-on_08.jpg";  
     menu8off= new Image(108,51);
     menu8off.src="/img/menu/menu-off_08.jpg";

     rezervaceprejitoff= new Image(108,51);
     rezervaceprejitoff.src="/img/tlacitko_prejit_vypnuto_ruz.jpg";  
     rezervaceprejiton= new Image(108,51);
     rezervaceprejiton.src="/img/tlacitko_prejit_zapnuto_cerv.jpg";

     rezervaceodeslatoff= new Image(283,69);
     rezervaceodeslatoff.src="/img/tlacitko_odeslat_vypnuto_ruz.jpg";  
     rezervaceodeslaton= new Image(283,69);
     rezervaceodeslaton.src="/img/tlacitko_odeslat_zapnuto_cerv.jpg";


   }
   
function rezervace(produkt) {
 window.open("/rezervace.php?produkt="+produkt,"rezervacniformular","height=450, width=720,resizable=0,status=0,scrollbars=1");
}

