document.write('<style type="text/css">');
document.write('.js-hidden{display: none;}');
document.write('</style>');

function swapDisplay(x) {
	x.style.display = (x.style.display=="block") ? "none" : "block";
}

function getNextElementNode(nextElement){
    do nextElement = nextElement.nextSibling;
	while (nextElement.nodeType != 1/* Node.ELEMENT_NODE */);
	return nextElement;
}

function getNextSiblingByClassName(element, elClassName) {
	do element = element.nextSibling;
	while (element && (!element.className || (element.className.indexOf(elClassName) == -1)));
	return element;
}

function getPreviousSiblingByClassName(element, elClassName) {
	do element = element.previousSibling;
	while (element && (!element.className || (element.className.indexOf(elClassName) == -1)));
	return element;
}

function getNextSiblingByNodeName(element, nodeName) {
	do element = element.nextSibling;
	while (element && (element.nodeName.toLowerCase() != nodeName.toLowerCase()));
	return element;
} 

function show(x) {
	swapDisplay(document.getElementById(x));
}

function RevealMenu(menuId) {
	document.getElementById(menuId).style.display="block";
}

function zoomImage(imageLink) {
    var imgSrc = imageLink.href;
    var imgTitle = imageLink.title ? (imageLink.title != 'zvětšit' ? imageLink.title : '') : '';
    window.open('../zoom_image.php?img='+imgSrc+'&title='+encodeURIComponent(imgTitle),'', 'toolbar=no,menubar=no,location=no,directories=no,scrollbars=yes,resizable=yes,status=no,width=800,height=600');
    return false;
}

function printPage(){
    if(typeof(window.print) != 'undefined')window.print();
    return false;
}

function changeColors(node,bg_Color,text_Color,border_Color){
    if (bg_Color) node.style.backgroundColor = bg_Color;
    if (text_Color) node.style.color = text_Color;
    if (border_Color) node.style.borderColor = border_Color;
}

function tableRowPointer(tableElement){
    var rows = tableElement.getElementsByTagName("tr");
    for(var i = 0; i < rows.length; i++){
        rows[i].onmouseover = function(){
            if(this.style.backgroundColor != "red")changeColors(this,"#808080","White");
        }
        rows[i].onmouseout = function(){
            if(this.style.backgroundColor != "red")changeColors(this,"#F2F2F2","Black");
        }
        rows[i].onclick = function(){
            if(this.style.backgroundColor != "red")changeColors(this,"red","White");else changeColors(this,"#808080","White");
        }
    }
}

isMB = Boolean (document.getElementById && document.styleSheets); //is Modern Bowser

function setEventHandlers(){
    /*--- event handlers for tables with class 'cenik' ---*/

    if(isMB){   //styles & JS for modern browsers
        var tables = document.getElementsByTagName("table");
        for(var i = 0; i < tables.length; i++){
            if(tables[i].className.indexOf("cenik") != -1)tableRowPointer(tables[i]);
        }
    }
}
