// ----------------------------------------------------	

    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 = parseInt(document.getElementById(el.id+"_price").innerHTML);
            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 -= parseInt(document.getElementById("sleva").innerHTML);

                var Cena = new String(suma+this.price);
                Cena = Cena.reverse().replace(/(\d{3})/gi, "$1 ").reverse().replace(/\./gi, ",");
                nr = Cena.split(",");
                if (nr.length>1 && nr[1].length<2)
                    Cena += "0";

                for (var i=0;i<elem.length; i++)
                    document.getElementById(elem[i]).innerHTML = Cena;
            }
        }
    }

// ----------------------------------------------------

    var ShowImage={
        w:null,
        showBigImage:function (file,w,h) {
            if (ShowImage.w!=null) ShowImage.w.close();
            url = document.URL.replace(/([a-z]+):.+/, "$1")+"://"+document.location.host;
            ShowImage.w = window.open(url+"/show-image.php?f="+encodeURI(file), "FOTO", "scrollbars=no,resizable=no,status=no,width="+w+",height="+h+",left=440, top=300");
            ShowImage.w.focus();
        },
        showDetailImage:function (kod,key,w,h) {
            if (ShowImage.w!=null) ShowImage.w.close();
            url = document.URL.replace(/([a-z]+):.+/, "$1")+"://"+document.location.host;
            ShowImage.w = window.open(url+"/show-detail-image.php?k="+encodeURI(kod)+"&key="+key, "FOTO", "scrollbars=no,resizable=no,status=no,width="+w+",height="+h+",left=440, top=300");
            ShowImage.w.focus();
        },

        makeBigImgLink: function (w,h) {
            var img=document.getElementById("main");
            var anchor=img.parentNode;
            anchor.file=img.getAttribute("src").replace(/\/foto\//, "/foto/big/");
            anchor.w=w;
            anchor.h=h;
            anchor.href="javascript: //nop/";
            anchor.onclick = function() {
                ShowImage.showBigImage(this.file, this.w, this.h);
                return false;
            }

        },
        makeDetailLink: function (kod,key,w,h) {
            var img = document.getElementById("photos").getElementsByTagName("img");
            var r=0;
            for (i=0;i<img.length;i++) {
                if (img[i].getAttribute("id")=="main")  {
                    r++;
                    continue;
                }
                var anchor = img[i].parentNode;
                anchor.w=w[i-r]+10;
                anchor.h=h[i-r]+30;
                anchor.kod=kod;
                anchor.key=key[i-r];
                anchor.href="javascript: //nop/"
                anchor.onclick = function() {
                    ShowImage.showDetailImage(this.kod, this.key, this.w, this.h);
                    return false;
                }
            }
        }
    }

// ----------------------------------------------------

    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;
        url = document.URL.replace(/([a-z]+):.+/, "$1")+"://"+document.location.host;
        window.open(url+"/"+file, "PICTO", "scrollbars=yes,resizable=no,status=no,width="+winWidth+",height="+winHeight+",left="+posW+",top="+posH);
    }
// ----------------------------------------------------
    function opennhlsets(file) {
        var winWidth = 770;
        var winHeight = 510;
        var posW = (screen.availWidth/2) - (winWidth/2);
        var posH = 100;
        url = document.URL.replace(/([a-z]+):.+/, "$1")+"://"+document.location.host;
        window.open(url+"/"+file, "NHLsets", "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"; }
    }

// ----------------------------------------------------
