function tip (znacka) {
        switch (znacka) {
                case 'a':
                        document.getElementById('tip').innerHTML='Vlo�en� odkazu:<br> <code>&lt;a href="<i>odkaz na str�nku</i>" title="<i>text v bubline</i>"&gt;<i>text odkazu</i>&lt;/a&gt;<br>parametr <b>href</b> je povinn�</code>';
                        break;
                case 'p':
                        document.getElementById('tip').innerHTML='Zna�ka odstavce: <code>&lt;p&gt;<i>text odstavce</i>&lt;/p&gt;</code>';
                        break;
                case 'img':
                        document.getElementById('tip').innerHTML='Vlo�en� obr�zku:<br> <code>&lt;img src="<i>odkaz na obr�zek</i>" title="<i>text v bubline</i>" width="<i>sirka v pixelech</i>" height="<i>v��ka v pixelech</i>"&gt;<br>parametr <b>src</b> je povinn�</code>';
                        break;
                case 'b':
                        document.getElementById('tip').innerHTML='Tu�n� text: <code>&lt;b&gt;<i>text</i>&lt;/b&gt;</code>';
                        break;
                case 'i':
                        document.getElementById('tip').innerHTML='Sklon�n� text: <code>&lt;i&gt;<i>text</i>&lt;/i&gt;</code>';
                        break;
                default:
                        document.getElementById('tip').innerHTML='&nbsp;';
        }
}


function insertAtCursor(myField, prefix, postfix) {
        var re = new RegExp("^(.*\\S)(\\s*)$");
  myField.focus();
  //IE support
  if (document.selection) {
    sel = document.selection.createRange();
                var selection = sel.text;
                var wasEmpty = (selection == "");
                var space = "";
                if (!wasEmpty) {
                        var matches = selection.match(re);
                        if (matches) {
                                selection = RegExp.$1;
                                space = RegExp.$2;
                        }
                }
    sel.text = prefix+selection+postfix+space;
                sel.collapse(false);
                if (wasEmpty) {
                        sel.moveEnd('character',-(prefix.length+1))
                }
                sel.select();
  }
  //MOZILLA/NETSCAPE support
  else {
                if (myField.selectionStart || myField.selectionStart == '0') {
                        var startPos = myField.selectionStart;
                        var endPos = myField.selectionEnd;
                        var selection = myField.value.substring(startPos, endPos);
                        var wasEmpty = (startPos == endPos);
                        var space = "";
                        if (!wasEmpty) {
                                var matches = selection.match(re);
                                if (matches) {
                                        selection = RegExp.$1;
                                        space = RegExp.$2;
                                }
                        }
                        myField.value = myField.value.substring(0, startPos)
                                                                                + prefix+selection+postfix+space
                                                                                + myField.value.substring(endPos, myField.value.length);

                        var newPosition;
                        if (wasEmpty) {
                                newPosition = startPos+prefix.length;
                        } else {
                                newPosition = startPos+prefix.length+selection.length+postfix.length+space.length;
                        }
                        myField.setSelectionRange(newPosition, newPosition);
                } else {
                        myField.value += prefix+postfix;
                        myField.setSelectionRange(startPos+prefix.length, startPos+prefix.length);
                }
        }
}

function skryj_vlakno(id) {
        if (document.getElementById('prispevek'+id+'00').style.display == 'none') {
                document.getElementById('prispevek'+id+'00').style.display = 'block';
                document.getElementById('toggle_'+id).innerHTML = 'Sbalit';
                if (window.innerHeight) winHeight = window.innerHeight; else if (document.documentElement) winHeight = document.documentElement.clientHeight; else if (document.body && document.body.clientHeight) winHeight = document.body.clientHeight; else return;
                if (document.getElementById("page").offsetHeight < winHeight) {
                        document.getElementById('stranka').style.height = stranka_height + winHeight - document.getElementById("page").offsetHeight - 10 + 'px';
                }    
        } else {
                stranka_height=document.getElementById('stranka').offsetHeight;
                document.getElementById('prispevek'+id+'00').style.display = 'none';
                document.getElementById('toggle_'+id).innerHTML = 'Rozbalit';
                setPageHeight("page");
        }
}




function mail_control() {
        frm=document.forms['mail'];
        if (frm.email.value.search("^.+@.+\\..+$") == -1) {
                alert("Nazadali jste platnou e-mailovou adresu!");
                exit;
        }
        pole = frm.text.value.split(' ');
        if (pole.length < 4) {
                alert("Buďte, prosím, trochu sdílnější.");
                exit;
        }
        frm.ready.value="ok";
        frm.submit();
}

function zprava_control() {
        frm=document.forms['zprava'];
        if (frm.jmeno.value.length < 4) {
                alert("Příliš krátké jméno!");
                exit;
        }
        if (frm.email.value.length > 0)
                if (frm.email.value.search("^.+@.+\\..+$") == -1) {
                        alert("Nazadali jste platnou e-mailovou adresu!");
                        exit;
                }
        pole = frm.text.value.split(' ');
        if (pole.length < 4) {
                alert("Buďte, prosím, trochu sdílnější.");
                exit;
        }
        if (frm.cislo.value.length == 0) {
                alert("Je potřeba správně sečíst uvedená čísla. Bez toho nelze zprávu odeslat!");
                exit;
        }
        frm.ready.value="ok";
        frm.submit();
}

function rezervace_control() {
        frm=document.forms['rezervace'];
        if (frm.jmeno.value.length < 4) {
                alert("Příliš krátké jméno!");
                exit;
        }
        if (frm.email.value.length > 0) {
                if (frm.email.value.search("^.+@.+\\..+$") == -1) {
                        alert("Nazadali jste platnou e-mailovou adresu!");
                        exit;
                }
        } else {
                alert("Zadejte prosím svou emailovou adresu, abychom Vás mohli kontaktovat.");
                exit;
        }
        if (frm.pocet.value.length > 0) {
                if (frm.pocet.value > 6) {
                        alert("Rezervovat lze maximálně 6 vstupenek!");
                        exit;
                }
        } else {
                alert("Nebyl zadán počet vstupenek!");
                exit;
        }
        frm.jmeno.disabled=false;
        frm.email.disabled=false;
        frm.telefon.disabled=false;
        frm.pocet.disabled=false;
        frm.poznamka.disabled=false;
        frm.submit();
}

function rezervace_upravit() {
        frm=document.forms['rezervace'];
        frm.jmeno.disabled=false;
        frm.email.disabled=false;
        frm.telefon.disabled=false;
        frm.pocet.disabled=false;
        frm.poznamka.disabled=false;
        frm.odeslat.value="Odeslat";
        frm.upravit.style.visibility="hidden";
        frm.faze.value="potvrdit";
        frm.jmeno.focus();
        document.getElementById("rezervace").getElementsByTagName("img")[0].src = "text.php?txt=Rezervace vstupenek&w=155&h=25&s=14&bg=1";
        document.getElementById("poznamka").style.visibility="visible";
}

function smile(smajlik) {
        obj=document.getElementById('text');
        obj.value=obj.value + "\##" + smajlik;
}

function setPageHeight(page_styl) {
        if (window.innerHeight) winHeight = window.innerHeight; else if (document.documentElement) winHeight = document.documentElement.clientHeight; else if (document.body && document.body.clientHeight) winHeight = document.body.clientHeight; else return;
        //alert(document.getElementById('stranka').offsetHeight);
        //alert(winHeight); alert(document.getElementById(page_styl).offsetHeight);
        if (document.getElementById(page_styl).offsetHeight < winHeight) {
                document.getElementById('stranka').style.height = document.getElementById('stranka').offsetHeight + winHeight - document.getElementById(page_styl).offsetHeight - 10 + 'px';
                try {
                        document.getElementById('logo1').style.height = document.getElementById('stranka').style.height;
                } catch(err) {}
        }                        
}

function openWindow(theURL,WinName,features) {
        scrHeight = screen.availHeight;
        scrWidth = screen.availWidth;
        winWidth = 1024;//scrWidth * 2/3;
        winHeight = 768;//scrHeight * 2/3;
        //alert(winWidth);
        //alert(winHeight);
        if (features) window.open(theURL, WinName, features + ',resizable=yes'); //else window.open(theURL, WinName, 'resizable=yes');
        else window.open(theURL, WinName, 'width=' + winWidth + ',height=' + winHeight + ',resizable=yes,scrollbars=yes');
}

function change() {
        iheight = window.innerHeight ? window.innerHeight : document.documentElement ? document.documentElement.clientHeight : document.body.clientHeight;
        iwidth =  window.innerWidth ? window.innerWidth : document.documentElement ? document.documentElement.clientWidth : document.body.clientWidth;
        imwidth = document.images[1].width;
        imheight = document.images[1].height;
        iheight -= 13;
        iwidth -= 13;
        portrait = imwidth < imheight ? true : false;
        newwidth = 0; newheight = 0;
        /*if(portrait)
        {
        if(imwidth * (iheight / imheight) > iwidth)
        {
                newheight = document.images[0].height = imheight * (iwidth / imwidth);
                newwidth = document.images[0].width = iwidth;
        }
        else
        {
                newheight = document.images[0].height = iheight;
                newwidth = document.images[0].width = imwidth * (iheight / imheight);
        }
        }
        else
        {
        if(imheight * (iwidth / imwidth) > iheight)
        {
                newheight = document.images[0].height = iheight;
                newwidth = document.images[0].width = imwidth * (iheight / imheight);
        }
        else
        {
                newheight = document.images[0].height = imheight * (iwidth / imwidth);
                newwidth = document.images[0].width = iwidth;
        }
        }*/
        document.getElementById('obrazek').style.marginLeft = '5px';
        
        document.getElementById('loading').style.visibility = 'hidden';
        document.getElementById('obrazek').style.visibility = 'visible';
        
        //document.getElementById('obrazek').style.marginTop = '5px';
        //document.getElementById('obrazek').style.marginLeft = '5px';//iwidth / 2 - (newwidth / 2);
        //document.getElementById('obrazek').style.marginRight = '5px';
        //document.getElementById('obrazek').style.marginBottom = '5px';
        //window.resizeBy(newwidth-iwidth,newheight-iheight); zmena=false;
        
        window.resizeBy(imwidth-iwidth,imheight-iheight); zmena=false;
}
    
        
/*function imagePreload(str) {
        obrazky = str.split(' ');
        if (obrazky.length > 0) {
                imgs = new Array();
                for (i = 0;i < obrazky.length;i++) {
                        imgs[i] = new Image();
                        imgs[i].src = obrazky[i];
                }
        } 
                
}*/

function getMouseXY(e) {
        var browserIE = document.all?true:false;
        if (!browserIE) document.captureEvents(Event.MOUSEMOVE);
        //zjisteni souradnic
        positionX = browserIE?event.clientX + document.body.scrollLeft:e.pageX;
        positionY = browserIE?event.clientY + document.body.scrollTop:e.pageY;
        //posun elementu 
        setPosition();
        return true;
}

function setPosition() {
    divElement=document.getElementById('popis');
    var windowWidth = 0;
    //zjisteni sirky okna
    if( typeof( window.innerWidth ) == 'number' ) {
        windowWidth = window.innerWidth;
        windowHeight = window.innerHeight;
    } else if( document.documentElement && document.documentElement.clientWidth ) {
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if( document.body && document.body.clientWidth  ) {
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }
    //pokud je pozice za okrajem okna, nastavi se pred kurzor
    if( ( positionX +  parseInt(divElement.style.width ) + movingX + 50 ) > windowWidth ){
        positionX -= ( movingX + parseInt(divElement.style.width ) );
    }

    if( ( positionY +  parseInt(divElement.style.height ) + movingY + 50 ) > windowHeight ){
        positionY -= ( movingY + parseInt(divElement.style.height ) );
    }
    
    divElement.style.left =  ( movingX + positionX ) + 'px';
    divElement.style.top = ( movingY + positionY ) + 'px';
    
}

function hidetip(){
        divElement=document.getElementById('popis');
        divElement.style.visibility = 'hidden';
}

function setOpacity( element, alpha ){
    var el = document.getElementById(element);
    
    if( el.style.opacity != undefined ){
        el.style.opacity = alpha;
    }
    else if( el.style.MozOpacity != undefined ){ 
        el.style.MozOpacity = alpha;
    }
    else if( el.style.filter != undefined ){
        el.style.filter = "alpha(opacity=0)";
        el.filters.alpha.opacity = ( alpha * 100 );
    }
    
    return true;
}

function pulseOn(){
    for( i = 0; i <= 9; i++ ){
        setTimeout("setOpacity('" + "popis" + "'," + i/10 + ");", 25*i);
    }   
}


function viewPopis(el,popis) {
        if (popis != '') {
                prvek=document.getElementById('popis');
                prvek.innerHTML=popis;
                if (popis.length > 20) sirka=(popis.length%30)*6; else sirka=100;
                prvek.style.width=sirka + 'px';
                //setOpacity('popis', 0 );
                prvek.style.visibility='visible';
                //pulseOn();
                el.onmousemove=getMouseXY;
                el.onmouseout = hidetip;
        }
}

var iheight;
var iwidth;
var zmena=true;

var positionX=0;
var positionY=0;

var movingX = -60; //px
var movingY = 35; //px
