// ----------------------------------------------------	

    String.prototype.reverse = function() {
        var newCena = new String();
        for (var j=this.length-1;j>-1;j--)
            newCena+=this.substr(j,1);

        return newCena.valueOf();
    }

    function changeSum(id, elem, sourceId) {
        for(i=0;i<id.length;i++) {
            var el = document.getElementById(id[i]);
            el.price = parseFloat(document.getElementById(el.id+"_price").innerHTML.replace(/ /gi,"").replace(/,/gi,"."));
            el.elem = elem;
            el.sourceId = sourceId;
            el.onclick = function() {
                var suma = parseFloat( document.getElementById(this.sourceId).innerHTML.replace(/ /gi,"").replace(/,/gi,"."));

                if (document.getElementById("sleva"))
                    suma -= parseFloat(document.getElementById("sleva").innerHTML);

                var Cena = new String(suma+this.price);
                Cena = Cena.reverse().replace(/(\d{3})/gi, "$1 ").reverse();
                for (var i=0;i<elem.length; i++)
                    document.getElementById(elem[i]).innerHTML = Cena.replace(/\./,",");
            }
        }
    }


// ----------------------------------------------------

    function openCenterWindow(file) {
        var winWidth = 350;
        var winHeight = 350;
        var posW = (screen.availWidth/2) - (winWidth/2);
        var posH = (screen.availHeight/2) - (winHeight/2);
        window.open(file, "INFO", "scrollbars=no,resizable=no,status=no,width="+winWidth+",height="+winHeight+",left="+posW+",top="+posH);
    }

// ----------------------------------------------------
    function openPictograms(file) {
        var winWidth = 600;
        var winHeight = 300;
        var posW = (screen.availWidth/2) - (winWidth/2);
        var posH = 100;
        window.open(file, "PICTO", "scrollbars=yes,resizable=no,status=no,width="+winWidth+",height="+winHeight+",left="+posW+",top="+posH);
    }
// ----------------------------------------------------

    function openCenterWindow2(file) {
        var winWidth = 350;
        var winHeight = 350;
        var posW = (screen.availWidth/2) - (winWidth/2);
        var posH = (screen.availHeight/2) - (winHeight/2);
        window.open(file, "INFO", "scrollbars=yes,resizable=no,status=no,width="+winWidth+",height="+winHeight+",left="+posW+",top="+posH);
    }

// ----------------------------------------------------

    function inputback() {
        document.write('\074input type="button" value="&nbsp;&laquo;&nbsp;zpět&nbsp;&laquo;&nbsp;" onclick="history.back()" class="likebutton" /\076&nbsp;');
    }
    function buttonback() {
        document.write('\074button type="button" class="likebutton" onclick="history.back()" title="O stránku zpět"\076&laquo;&nbsp;zpět&nbsp;&laquo;\074/button\076');
    }

// ----------------------------------------------------

    window.onload = function() {
        var anch = document.getElementById("allinfoli");
        document.getElementById("allinfo").href="javascript: void(0);";
        anch.menu = document.getElementById("js");
        anch.onmouseover = function() { this.menu.style.display="block"; }
        anch.onmouseout = function() { this.menu.style.display="none"; }

        if (document.getElementById("discussopen")!=null)
            document.getElementById("discussopen").onclick=function() { document.getElementById("disscussform").style.display="block"; }
    }

// ------------------------------------------------------------------
    function prn() {
        document.write('\074a href=\"javascript:goprn();\"\076tisknout stránku\074/a\076, ');
    }
    function goprn() {
        if(window.print) {
            window.print();
        }
        else {
            alert("Stránky jsou připraveny pro tisk.\nZvolte Tisk/Print ve svém prohlížeči.");
        }
    }
// ------------------------------------------------------------------
var EventTools = {
    setEvent: function(el, action, fce) {
        if (window.attachEvent)
            el.attachEvent("on"+action, fce);
        else
            el.addEventListener(action, fce, true);
    },
    removeEvent: function(el, action, fce) {
        if (window.detachEvent)
            el.detachEvent("on"+action, fce);
        else
            el.removeEventListener(action, fce, true);
    },
    stopEvent: function(event) {
        if (window.event)
            event = window.event;
        if (event.stopPropagation) {
            event.stopPropagation();
            event.preventDefault();
        }
        else
            event.cancelBubble = true;

        return false;
    },
    getKeyCode: function(event) {
        var code;
        if(event.keyCode)
            code = event.keyCode;
        else if(event.which)
            code = event.which;

        return code;
    },
    getElement: function(event, prop) {
        var el=null;
        if (window.event) {
            var elem = window.event.srcElement;
            do {
                if (elem[prop]!=null)
                    el=elem;
                else
                    elem = elem.parentNode;
            } while (!(elem.nodeName=="BODY" || el!=null));
        }
        else if (event!=null)
            el = event.currentTarget;

        return el;
    }
}
function CheckDisabler(checkId,disElems) {
    this.c = document.getElementById(checkId);
    if (this.c==null) return;
    this.elems=new Array();
    for(var i=0;i<disElems.length;i++)
        this.elems[this.elems.length]=document.getElementById(disElems[i]);
    this.c.cd=this;
    EventTools.setEvent(this.c, "click", this.make);
    this.makeDis();
}
CheckDisabler.prototype.make=function(e){
    var d=EventTools.getElement(e,"cd");
    if (d==null) return;
    d.cd.makeDis();
}
CheckDisabler.prototype.makeDis=function() {
    for (var i=0;i<this.elems.length;i++) {
        this.elems[i].disabled=!this.c.checked;
        if (this.elems[i].type=="text" && this.elems[i].disabled)
            this.elems[i].value="";
    }
}


