
function doSelectActors(value, actors, mask) {
    alert('zm\u011bna!');
}




function winH() {
    if (window.innerHeight) return window.innerHeight;
    else if (document.documentElement && document.documentElement.clientHeight)
        return document.documentElement.clientHeight;
    else if (document.body && document.body.clientHeight)
        return document.body.clientHeight;
    else return null;
}
function winW() {
    if (window.innerWidth) return window.innerWidth;
    else if (document.documentElement && document.documentElement.clientWidth)
        return document.documentElement.clientWidth;
    else if (document.body && document.body.clientWidth)
        return document.body.clientWidth;
    else return null;
}
function OpenDiv(id) {
    document.getElementById(id).style.display = 'inline';
}
function CloseDiv(id) {
    document.getElementById(id).style.display = 'none';
}

var maxHeight = 1;
var anime = 1;

function animeDebug() {
    if (anime == 0) return;

    if (maxHeight == 1)
        animeDebugIn();
}

function animeDebugIn() {
    DivId = document.getElementById("conDebug");

    if (maxHeight < 20) {
        anime = 0;
        maxHeight++;
        DivId.style.top = -20 + maxHeight + "px";
        setTimeout("animeDebugIn()", 40);
    } else {
        anime = 1;
        setTimeout("animeDebugOut()", 5000);
    }
}

function animeDebugOut() {
    DivId = document.getElementById("conDebug");

    if (maxHeight > 1) {
        maxHeight--;
        DivId.style.top = -20 + maxHeight + "px";
        setTimeout("animeDebugOut()", 50);
    }
}

function show() {
    DivId = document.getElementById("debug");
    DivId.style.left = (winW() - 600) / 2 + "px";
    //DivId.style.top = winH();
    if (DivId.style.display == 'none')
        DivId.style.display = "inline";
    else
        DivId.style.display = "none";
}

function showForm() {
    DivId = document.getElementById("debug01");
    DivId.style.left = (winW() - 600) / 2 + "px";
    //DivId.style.top = winH();
    if (DivId.style.display == 'none')
        DivId.style.display = "inline";
    else
        DivId.style.display = "none";
}


function ShowDivCond(element, input, testval) {
    if (document.getElementById(element).value == testval) {
        document.getElementById(input).style.display = "block";
    }
    else {
        document.getElementById(input).style.display = "none";
    }
}





function ShowP1FieldCond(elemTest, elemInpur) {
    if (document.getElementById(elemTest).value == "jine") {
        document.getElementById(elemInpur).style.visibility = "visible";
    }
    else {
        document.getElementById(elemInpur).style.visibility = "hidden";
    }
}

function ShowPermissionToIS(element, visibility) {
    document.getElementById(element).style.visibility = "visible";
}




function ShowFieldCond(elemTest, elemLabel, elemInpur, elemBr) {
    if (document.getElementById(elemTest).value == "jine") {
        document.getElementById(elemLabel).style.display = "inline";
        document.getElementById(elemInpur).style.display = "inline";
        document.getElementById(elemBr).style.display = "inline";
    }
    else {
        document.getElementById(elemLabel).style.display = "none";
        document.getElementById(elemInpur).style.display = "none";
        document.getElementById(elemBr).style.display = "none";
    }


}

function SetElemValue(elem, val, comp) {
    if ((document.getElementById(comp).value != "jine") && (document.getElementById(comp).value != "none")) {
        document.getElementById(elem).value = val;
    }

}

var clen = new Array();
function manuSet() {
    show = 10;
    clenove = document.getElementById("ul_clenove");
    count = clenove.childNodes.length; //bylo tu -1 CHYBA!!!! Uz jsem tu Zackovou dostal pryc :-D
    j = 0;
    for (i = 0; i < count; i++) {
        if (clenove.childNodes[i].tagName != "LI") continue;
        clen[j++] = clenove.childNodes[i];
        clenove.childNodes[i].style.display = 'none';
    }
    count = j;
    for (i = actual; i < show + actual; i++) {
        clen[i].style.display = '';
    }
}
function nextmenu() {
    numnext = 1;
    count = clen.length;
    /*help = document.getElementById("div_debug");
    help.innerHTML = actual+"/"+count;*/
    if (actual + 10 < count) actual += numnext;
    for (i = 0; i < count; i++) {
        /*help.innerHTML += clen[i].innerHTML+" "+clen[i].tagName +"<br>";*/
        clen[i].style.display = 'none';
    }
    for (i = actual; i < show + actual; i++) {
        clen[i].style.display = '';
    }
}

function backmenu() {
    numnext = 1;
    count = clen.length;
    if (actual >= numnext) actual -= numnext;
    for (i = 0; i < count; i++) {
        clen[i].style.display = 'none';
    }
    for (i = actual; i < show + actual; i++) {
        clen[i].style.display = '';
    }
}


function regme_test() {
    var ret = false;
    //	var name = document.forms['regfrm']['reg_fs_name'].value;
    var mail = document.forms['regfrm']['reg_fs_mail'].value;

    var pos = mail.indexOf('@');
    if (pos < 0) {
        ret = false;
    }
    var pred_zav = mail.substring(0, pos);
    var za_za = mail.substring(pos + 1, mail.length);
    if (za_za.indexOf('@') >= 0 || pred_zav.length <= 0 || za_za.length <= 0 || mail.length == 0) {
        ret = false;
        alert("Chybny email.");
    }
    else {
        ret = true;
    }

    return ret;
}



function odbarvi(prvek) {
    document.getElementById(prvek).style.background = "none";
}

function odbarvia(prvek, barva) {
    document.getElementById(prvek).style.background = barva;
}

function podbarvi(prvek) {
    document.getElementById(prvek).style.background = "#ffdc87";
}

function rozbal(prvek) {
    document.getElementById(prvek).style.display = "block";
}

function zabal(prvek) {
    document.getElementById(prvek).style.display = "none";
}

function EnDisPrvek(prvek) {
    if (document.getElementById(prvek).disabled) {
        document.getElementById(prvek).disabled = false;
    //alert("pica");
    }
    else {
        document.getElementById(prvek).disabled = true;
    }
}

function EnDisDiv(prvek) {

    if (document.getElementById(prvek).style.display == 'none') {
        document.getElementById(prvek).style.display = 'block';

    }
    else {
        document.getElementById(prvek).style.display = 'none';

    }
}

function EnPristup(volajici, filedset) {
    document.getElementById(volajici).style.display = 'none';
    // Get a fieldset
    
    var forms = document.forms;
    var f = document.getElementById(filedset);
    f.style.display = 'block';
    // Get all inputs in fieldset
    var c = f.getElementsByTagName('input');
    var l = c.length;
    // Disable all inputs
    for (var i = 0; i < l; i++)
        c[i].disabled = false;

    var x = f.getElementsByTagName('textarea');
    var m = x.length;
    // Disable all inputs
    for (var j = 0; j < m; j++)
        x[j].disabled = false;
}

function DisPristup(volajici, filedset) {
    document.getElementById(volajici).style.display = 'block';
        
    // Get a fieldset
    var f = document.getElementById(filedset);
    //f.disabled=true;
    //f.style.display = 'none';
    
    // Get all inputs in fieldset
    var c = f.getElementsByTagName('input');
    var l = c.length;
    // Disable all inputs
    for (var i = 0; i < l; i++)
        c[i].disabled = true;

    var x = f.getElementsByTagName('textarea');
    var m = x.length;
    // Disable all inputs
    for (var j = 0; j < m; j++)
        x[j].disabled = true;
    
    f.style.display = 'none';
}

function EnPristup2(filedset) {
    //document.getElementById(volajici).style.display = 'block';
    // Get a fieldset
    var f = document.getElementById(filedset);
    f.style.display = 'block';
    // Get all inputs in fieldset
    var c = f.getElementsByTagName('input');
    var l = c.length;
    // Disable all inputs
    for (var i = 0; i < l; i++){
        c[i].disabled = false;
        c[i].removeAttribute('readonly');
    }

    var x = f.getElementsByTagName('textarea');
    var m = x.length;
    // Disable all inputs
    for (var j = 0; j < m; j++){
        x[j].disabled = false;
        x[j].removeAttribute('readonly');
    }

    x = f.getElementsByTagName('select');
    m = x.length;
    // Disable all inputs
    for (var j = 0; j < m; j++){
        x[j].disabled = false;
        x[j].removeAttribute('readonly');
    }
}



function SetMyValue(formular, prvek, hodnota) {

    document.forms[formular][prvek].value = hodnota;
}

function Smile(what, prvek) {
    //alert(what);
    document.getElementById(prvek).value += what;
//document.forms.insert.text.value=document.forms.comment.zprava.value+what;
}



function getSelectedText(formular, prvek) {
    var txtarea = document.forms[formular][prvek];
    var browser = navigator.appName;



    // code for IE
    if (browser == "Microsoft Internet Explorer") { //tohle je pro toho billova zplozence pekel!!!
        if (document.selection) {
            txtarea.focus();
            var sel = document.selection.createRange();
            // alert the selected text in textarea
            if (sel.text == '') {
                alert("Nic nevybráno.\nNejprve je potřeba vybrat část textu coby název odkazu...");
                return false;
            }
            var url = prompt('Zadejte URL (http://www.../...html) pro "' + sel.text + '":', "http://");
            if (url) {
                sel.text = "[url=" + url + "]" + sel.text + "[/url]";
            }

            return true;
        // Finally replace the value of the selected text with this new replacement one
        }
        else {
            alert("Nic nevybráno.\nNejprve je potřeba vybrat část textu coby název odkazu...");
            return false;
        }
    }
    else {
        var x = (txtarea.value).substring(0, txtarea.selectionStart);
        var y = (txtarea.value).substring(txtarea.selectionEnd, txtarea.value.length);
        var sela = (txtarea.value).substring(txtarea.selectionStart, txtarea.selectionEnd);



        //if (x == ''){
        if (txtarea.selectionStart == txtarea.selectionEnd) {
            alert("Nic nevybráno.\nNejprve je potřeba vybrat část textu coby název odkazu...");
            return false;
        }
        else {
            var url2 = prompt('Zadejte URL (http://www.../...html) pro "' + sela + '":', "http://");
            if (url2) {
                txtarea.value = x + "[url=" + url2 + "]" + sela + "[/url]" + y;
            }

            return x;
        }
    }
}

function makeLink(formular, prvek) {
    var link = getSelectedText(formular, prvek);
    return;


}


function getSelectedText4Bold(formular, prvek) {
    var txtarea = document.forms[formular][prvek];
    var browser = navigator.appName;



    // code for IE
    if (browser == "Microsoft Internet Explorer") { //tohle je pro toho billova zplozence pekel!!!
        if (document.selection) {
            txtarea.focus();
            var sel = document.selection.createRange();
            // alert the selected text in textarea
            if (sel.text == '') {
                alert("Nic nevybráno.\nNejprve je potřeba vybrat část textu...");
                return false;
            }

            sel.text = "[b]" + sel.text + "[/b]";


            return true;
        // Finally replace the value of the selected text with this new replacement one
        }
        else {
            alert("Nic nevybráno.\nNejprve je potřeba vybrat část textu coby název odkazu...");
            return false;
        }
    }
    else {
        var x = (txtarea.value).substring(0, txtarea.selectionStart);
        var y = (txtarea.value).substring(txtarea.selectionEnd, txtarea.value.length);
        var sela = (txtarea.value).substring(txtarea.selectionStart, txtarea.selectionEnd);



        if (txtarea.selectionStart == txtarea.selectionEnd) {
            alert("Nic nevybráno.\nNejprve je potřeba vybrat část textu...");
            return false;
        }
        else {
            txtarea.value = x + "[b]" + sela + "[/b]" + y;
            return x;
        }
    }
}




function makeLink4Bold(formular, prvek) {
    var link = getSelectedText4Bold(formular, prvek);
    return;


}




function getSelectedText4Cursive(formular, prvek) {
    var txtarea = document.forms[formular][prvek];
    var browser = navigator.appName;



    // code for IE
    if (browser == "Microsoft Internet Explorer") { //tohle je pro toho billova zplozence pekel!!!
        if (document.selection) {
            txtarea.focus();
            var sel = document.selection.createRange();
            // alert the selected text in textarea
            if (sel.text == '') {
                alert("Nic nevybráno.\nNejprve je potřeba vybrat část textu...");
                return false;
            }

            sel.text = "[i]" + sel.text + "[/i]";


            return true;
        // Finally replace the value of the selected text with this new replacement one
        }
        else {
            alert("Nic nevybráno.\nNejprve je potřeba vybrat část textu coby název odkazu...");
            return false;
        }
    }
    else {
        var x = (txtarea.value).substring(0, txtarea.selectionStart);
        var y = (txtarea.value).substring(txtarea.selectionEnd, txtarea.value.length);
        var sela = (txtarea.value).substring(txtarea.selectionStart, txtarea.selectionEnd);



        if (txtarea.selectionStart == txtarea.selectionEnd) {
            alert("Nic nevybráno.\nNejprve je potřeba vybrat část textu...");
            return false;
        }
        else {
            txtarea.value = x + "[i]" + sela + "[/i]" + y;
            return x;
        }
    }
}




function makeLink4Cursive(formular, prvek) {
    var link = getSelectedText4Cursive(formular, prvek);
    return;


}


function getSelectedText4Underline(formular, prvek) {
    var txtarea = document.forms[formular][prvek];
    var browser = navigator.appName;



    // code for IE
    if (browser == "Microsoft Internet Explorer") { //tohle je pro toho billova zplozence pekel!!!
        if (document.selection) {
            txtarea.focus();
            var sel = document.selection.createRange();
            // alert the selected text in textarea
            if (sel.text == '') {
                alert("Nic nevybráno.\nNejprve je potřeba vybrat část textu...");
                return false;
            }

            sel.text = "[u]" + sel.text + "[/u]";


            return true;
        // Finally replace the value of the selected text with this new replacement one
        }
        else {
            alert("Nic nevybráno.\nNejprve je potřeba vybrat část textu coby název odkazu...");
            return false;
        }
    }
    else {
        var x = (txtarea.value).substring(0, txtarea.selectionStart);
        var y = (txtarea.value).substring(txtarea.selectionEnd, txtarea.value.length);
        var sela = (txtarea.value).substring(txtarea.selectionStart, txtarea.selectionEnd);



        if (txtarea.selectionStart == txtarea.selectionEnd) {
            alert("Nic nevybráno.\nNejprve je potřeba vybrat část textu...");
            return false;
        }
        else {
            txtarea.value = x + "[u]" + sela + "[/u]" + y;
            return x;
        }
    }
}




function makeLink4Underline(formular, prvek) {
    var link = getSelectedText4Underline(formular, prvek);
    return;


}

function checkProdukceForm(_divOrganizace, _divNovaOrganizace, _form) {
    var selOrg = document.getElementById(_divOrganizace);
    var novaOrg = document.getElementById(_divNovaOrganizace);
    var text = "";
    var ret = true;
    if (novaOrg.style.display == "none") {
        if (document.forms[_form]['produkce_select'].value == "") {
            text += "Nen� vybr�n produk\u010dn�!\n";
            ret = false;
        }

        if (document.forms[_form]['so_org'].value == "") {
            text += "Nen� vybr�na organizace!\n";
            ret = false;
        }
        if (document.forms[_form]['ivloz_kontakt'].value == "") {
            text += "Nen� zad�no datum dal\u0161�ho kontaktov�n�!\n";
            ret = false;
        }
        if (document.forms[_form]['ivloz_text'].value == "") {
            text += "Nen� zad�na dodate\u010dn� informace!\n";
            ret = false;
        }
    }
    if (selOrg.style.display == 'none') {
        if (document.forms[_form]['produkce_select'].value == "") {
            text += "Nen� vybr�n produk\u010dn�!\n";
            ret = false;
        }

        if (document.forms[_form]['o_org'].value == "") {
            text += "Nebyl zad�n n�zev organizace!\n";
            ret = false;
        }
        if (document.forms[_form]['o_adr'].value == "") {
            text += "Nebyla zad�na adresa organizace!\n";
            ret = false;
        }
        if (document.forms[_form]['o_ko1'].value == "") {
            text += "Nebyla vypln\u011bna kontaktn� osoba!\n";
            ret = false;
        }
        if (document.forms[_form]['o_tel1'].value == "") {
            text += "Nebyl vypln\u011bn kontaktn� telefon!\n";
            ret = false;
        }
        if (document.forms[_form]['o_email'].value == "") {
            text += "Nebyla vypln\u011bn kontaktn� email!\n";
            ret = false;
        }

        if ((document.forms[_form]['o_mesto'].value == "null") || (document.forms[_form]['o_mesto'].value == "jine" && document.forms[_form]['o_mesto_jine'].value == "")) {
            text += "Nebylo vypln\u011bno m\u011bsto!\n";
            ret = false;
        }






        if (document.forms[_form]['ivloz_kontakt'].value == "") {
            text += "Nen� zad�no datum dal\u0161�ho kontaktov�n�!\n";
            ret = false;
        }
        if (document.forms[_form]['ivloz_text'].value == "") {
            text += "Nen� zad�na dodate\u010dn� informace!\n";
            ret = false;
        }
    }
    if (text != "") {
        alert("Do\u0161lo k chyb�:\n" + text);
    }



    return ret;
}
