function hide_show_div(div) {
    obj=document.getElementById(div);
    visible=(obj.style.display=="block");
    if (visible) {
        obj.style.display="none";
    } else {
        obj.style.display="block";
    }
}

function hide_show_div_jq(div) {
    obj=document.getElementById(div);
    visible=(obj.style.display=="block");
    if (visible) {
        $('#' + div).css('display', 'none');
    } else {
        $('#' + div).css('display', 'block');
    }
}

function hide_show_div_jqv(div) {
    obj=document.getElementById(div);
    visible=(obj.style.visibility=="visible");
    if (visible) {
        $('#' + div).css('visibility', 'hidden');
    } else {
        $('#' + div).css('visibility', 'visible');
    }
}

function show_hide_div(div) {
    obj=document.getElementById(div);
    visible=(obj.style.display=="none");
    if (visible) {
        obj.style.display="block";
    } else {
        obj.style.display="none";
    }
}

//POZOR - musi byt naprosto stejna funkce jako v PHP fce.php!!!!
function remove_diacritics (str) {
    sdiak = "áäčďéěëíïĺľňóô öŕšťúů üýÿřžÁÄČĎÉĚËÍÏĹĽŇÓÔ ÖŔŠŤÚŮ ÜÝŘŽ";
    bdiak = "aacdeeeiillnoo orstuu uyyrzAACDEEEIILLNOO ORSTUU UYRZ";
    pom = "";
    for(i = 0; i < str.length; i++) {
        if (sdiak.indexOf(str.charAt(i)) != -1) {
            pom = pom + bdiak.charAt(sdiak.indexOf(str.charAt(i)));
        }
        else pom = pom + str.charAt(i);
    }
    return pom;
}

function strToLower (str) {
    big = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    small = "abcdefghijklmnopqrstuvwxyz";
    pom = "";
    for(i = 0; i < str.length; i++) {
        if (big.indexOf(str.charAt(i)) != -1) {
            pom = pom + small.charAt(big.indexOf(str.charAt(i)));
        }
        else pom = pom + str.charAt(i);
    }
    return pom;
}

//POZOR - musi byt naprosto stejna funkce jako v PHP fce.php!!!!
function create_cool_url(str) {
    var enable_char = /^([a-zA-Z0-9_ \\/\-])$/;
    str = remove_diacritics(str);
    str = strToLower(str);
    pom = "";
    for (i = 0; i < str.length; i++) {
        if (enable_char.test(str.charAt(i))) {
            if (str.charAt(i) == " " || str.charAt(i) == "-" || str.charAt(i) == "_" || str.charAt(i) == "/" || str.charAt(i) == "\\") {
                if (pom.charAt(pom.length - 1) != "-" && i+1 != str.length) pom = pom + "-";
            }
            else pom = pom + str.charAt(i);
        }
    }
    return pom;
}

function create_keywords (a,b,c,d,e) {
    pom = "";
    if (a != "" && a != "-----") pom = a;
    if (b != "" && b != "-----") {
        if (pom == "") pom = b;
        else pom = pom + ', ' + b;
    }
    if (c != "" && c != "-----") {
        if (pom == "") pom = c;
        else pom = pom + ', ' + c;
    }
    if (d != "") {
        if (pom == "") pom = d;
        else pom = pom + ', ' + d;
    }
    if (e != "") {
        if (pom == "") pom = e;
        else pom = pom + ', ' + e;
    }
    return pom;
}

function create_description (str) {
    pom = "";
    if (str.length <= 150) return str;
    else {
        for (i = 0; i < 151; i++) pom = pom + str.charAt(i);
    }
    return pom;
}

function dom_remove_element (parrent,child) {
    var p = document.getElementById(parrent);
    var ch = document.getElementById(child);
    p.removeChild(ch);
}

//nacte elementy podle name
//hodnoty elemntu bude davat za sebe oddeleny znakem ~  napr. a~b~c~d kde a,b,c,d jsou hodnoty elemntu
//vystupem je pak retezec napr.: a~b~c~d
function create_par_by_elemet_name (tag_name) {
    var str = '';
    var a = document.getElementsByName(tag_name);
    if (a.length == 0) str = '';
    else {
        for (i=0; i<a.length; i++) {
            if (i == 0) str = a[i].value;
            else str = str + '~' + a[i].value;
        }
    }
    return str;
}


