//use http://jsbeautifier.org/ to read this
resDur = 0.6;
var ohover = false;
function pause(A) {
    var C = new Date();
    var B = C.getTime() + A;
    while (true) {
        C = new Date();
        if (C.getTime() > B) {
            return
        }
    }
}
function showimg3(id) {
    eval(id).iload.showimg3()
}
function setimg(id) {
    eval(id).iload.setimg()
}
function getphpath(D, B) {
    var C = false;
    var E = B.lastIndexOf("index.html");
    if (E >= 0) {
        if (B.indexOf("/i") == 0 && D.cfg.i == "o") {
            C = true;
            B = B.substring(3)
        } else {
            B = B.substring(E + 1)
        }
    }
    phtcid = D.id;
    var A = "";
    if (D.cfg.i != "o") {
        A = phiroot + "/pdir/" + phtcid + "/i/" + D.imgsize + "-" + B
    } else {
        if (C) {
            A = phiroot + "/" + B
        } else {
            A = phiroot + "/pdir/" + phtcid + "/" + B
        }
    }
    return A
}
function showhovnav(B, A) {
    if (A == true) {
        new Effect.Appear(B, {
            duration: 0.5,
            from: 0,
            to: 1,
            queue: "end"
        })
    } else {
        new Effect.Appear(B, {
            duration: 0.5,
            from: 1,
            to: 0,
            queue: "end"
        })
    }
}
function updatenextprev(F, D, A, E, B) {
    var C = "";
    if (A >= E) {
        C = C + '<a id="nxpib" href="javascript:' + D + ".jump(" + (A - E) + ')">Prev</a>'
    }
    startcn = 0;
    endcn = B;
    if ((B / E) > 20) {
        nstart = A - (10 * E);
        nend = 1 * A + (10 * E);
        if (nstart < 0) {
            nend = E * 20;
            nstart = 0
        }
        if (nend > endcn) {
            nend = Math.round(endcn / E) * E;
            nstart = 1 * nend - (20 * E)
        }
        startcn = nstart;
        endcn = nend
    }
    if (B > E) {
        for (i = startcn; i < endcn; i = i + E) {
            ct = Math.round(i / E);
            if (i == A) {
                C = C + '<span id="nxpisel">';
                C = C + (ct + 1);
                C = C + "</span>"
            } else {
                C = C + '<a id="nxpi" href="javascript:' + D + ".jump(" + (i) + ')">';
                C = C + (ct + 1) + "</a>"
            }
        }
    }
    if (B > A + E) {
        C = C + '<a id="nxpib" href="javascript:' + D + ".jump(" + (A + E) + ')">Next</a>'
    }
    ndiv = document.getElementById("nextprev" + F);
    if (ndiv && C.length > 0) {
        ndiv.style.display = "block";
        ndiv.innerHTML = C
    }
}
function pilink(G, B, C, E, F, A) {
    var D = C.ilink;
    if (!D || D == null) {
        D = 0
    }
    if (D == "0") {
        cellstr = '<img border=0 src="' + F + '" ' + A + ">"
    }
    if (D == "2") {
        cellstr = "<a " + E.pl + ');"><img  border=0 src="' + F + '" ' + A + "></a>"
    }
    if (D == "1") {
        func = "javascript:th" + G + ".viewdetail(" + B + ")";
        cellstr = '<a href="' + func + '"><img border=0 src="' + F + '" ' + A + "></a>"
    }
    return cellstr
}
function pgScroll() {
    var A;
    if (self.pageYOffset) {
        A = self.pageYOffset
    } else {
        if (document.documentElement && document.documentElement.scrollTop) {
            A = document.documentElement.scrollTop
        } else {
            if (document.body) {
                A = document.body.scrollTop
            }
        }
    }
    aPS = new Array("", A);
    return aPS
}
function photohelperobj(C, B, D, A) {
    this.images = B;
    this.cfg = D;
    this.id = C;
    this.col = 0;
    this.row = 0;
    this.html = "";
    this.imgsize = A;
    this.scrollx = 0;
    this.trot = null;
    this.doscroll = true;
    this.scrolling = false;
    this.popup = true;
    this.reset = function() {
        this.col = 0;
        this.html = ""
    };
    this.start = function() {
        this.html = this.html + '<table class="phgrid" border=0 cellpadding=0 cellspacing=0>'
    };
    this.over = function() {
        if (this.cfg.pause == true) {
            this.doscroll = false
        }
    };
    this.out = function() {
        this.doscroll = true
    };
    this.slt = function(E) {
        if (E) {
            this.scrollx = -2
        } else {
            this.scrollx = 0
        }
        this.scroll(false)
    };
    this.srt = function(E) {
        if (E) {
            this.scrollx = 2
        } else {
            this.scrollx = 0
        }
        this.scroll(false)
    };
    this.cscroll = function() {
        this.scrollx = 1;
        this.scroll(true)
    };
    this.scroll = function(E) {
        if (this.scrollx != 0 && this.doscroll) {
            ds = $("ppdiv" + this.id);
            if (ds && ds != null) {
                sl = ds.scrollLeft;
                ds.scrollLeft = ds.scrollLeft + this.scrollx;
                if (sl == ds.scrollLeft) {
                    ds.scrollLeft = (ds.scrollLeft / 2) - (ds.clientWidth / 2) + this.scrollx
                }
            }
        }
        if (E || this.scrolling == false) {
            window.setTimeout("th" + this.id + ".scroll(true)", 10 * this.cfg.speed);
            this.scrolling = true
        }
    };
    this.add = function(E) {
        if (this.col == 0) {
            this.html = this.html + "<tr>";
            this.row = this.row + 1
        }
        if (this.row > this.cfg.rows) {
            return false
        }
        this.html = this.html + '<td valign="top" class="gtd">' + E + "</td>";
        if (this.col == (this.cfg.cols - 1)) {
            this.html = this.html + "</tr>";
            this.col = 0
        } else {
            this.col++
        }
        return true
    };
    this.jump = function(E) {
        var F = 0;
        for (x = E; x < E + (this.cfg.cols * this.cfg.rows); x++) {
            var G = $("pd-" + this.id + "-" + F);
            if (x < this.images.length) {
                G.style.visibility = "visible";
                this.showpic(x, F++)
            } else {
                G.style.visibility = "hidden";
                F++;
                de = $("desc-" + this.id + "-" + F);
                if (de && de != null) {
                    de.innerHTML = ""
                }
            }
        }
        updatenextprev(this.id, "th" + this.id, E, this.cfg.rows * this.cfg.cols, this.images.length)
    };
    this.endtable = function() {
        this.html = this.html + "</tr></table>";
        updatenextprev(this.id, "th" + this.id, 0, this.cfg.rows * this.cfg.cols, this.images.length)
    };
    this.updatenextprevs = function() {
        updatenextprev(this.id, "th" + this.id, 0, this.cfg.rows * this.cfg.cols, this.images.length)
    };
    this.gethtml = function() {
        return this.html
    };
    this.closedetail = function() {
        var E = $("photodetailw");
        if (E) {
            E.style.display = "none"
        }
        var E = $("photodetail" + this.id);
        E.style.visibility = "hidden"
    };
    this.viewdetail = function(E) {
        var G = document.body;
        if (this.popup) {
            var F = $("photodetailw");
            F.style.width = G.offsetWidth + "px";
            F.style.height = G.offsetHeight + "0px";
            F.style.visibility = "visible";
            F.style.display = "block"
        }
        if (this.popup) {
            var F = $("photodetail" + this.id);
            F.style.visibility = "visible";
            F.style.width = G.offsetWidth + "px";
            ps = pgScroll();
            F.style.top = (ps[1] + 50) + "px"
        }
        if (this.trot) {
            this.trot.showimg(E, false)
        }
    };
    this.showpic = function(G, E) {
        var F = this.images[G];
        if (F.p.indexOf(".") < 0) {
            return
        }
        var H = $("pd2-" + this.id + "-" + E);
        cellstr = pilink(this.id, G, this.cfg, F, getphpath(this, F.p) + "?bd=" + this.phbid, ' id="img-' + this.id + "-" + E + '" ');
        H.innerHTML = cellstr;
        de = $("desc-" + this.id + "-" + E);
        if (de && de != null) {
            if (this.cfg.desc == true && F.pd) {
                de.innerHTML = F.pd
            } else {
                de.innerHTML = ""
            }
        }
    };
    this.swapphotorand = function() {
        var E = (Math.floor(Math.random() * this.cfg.cols));
        var F = Math.floor(Math.random() * this.images.length);
        this.showpic(F, E);
        window.setTimeout("th" + this.id + ".swapphotorand()", this.cfg.speed * 1000)
    };
    this.dispp = function(F, E) {
        if (F.p.indexOf(".") < 0) {
            return
        }
        var H = "";
        H = H + '<div class="pd" id="pd-' + this.id + "-" + E + '"><table cellpadding=0 cellspacing=0 border=0><tr><td><div class="pd1"><div class="pd2" id="pd2-' + this.id + "-" + E + '">';
        H = H + pilink(this.id, E, this.cfg, F, getphpath(this, F.p) + "?bd=" + this.phbid, ' id="img-' + this.id + "-" + E + '" ');
        H = H + "</div></div></td></tr></table>";
        if (this.cfg.desc == true) {
            H = H + '<div class="phinfo">';
            var G = "";
            if (F.pd) {
                G = F.pd
            }
            H = H + '<div id="desc-' + this.id + "-" + E + '" class="phdesc">' + G + "</div>";
            H = H + "</div></div>"
        }
        this.add(H)
    }
}
function rotatorhelperobj(A, D, C, E, B) {
    this.popup = false;
    this.varname = A;
    this.cfg = E;
    this.id = D;
    this.images = C;
    this.curidx = 0;
    this.dorotate = true;
    this.imgsize = B;
    this.iload = null;
    this.phbid = 1;
    this.viewdetail = function(F) {
        var H = document.body;
        if (this.popup) {
            var G = $("photodetailw");
            G.style.width = H.offsetWidth + "px";
            G.style.height = H.offsetHeight + "0px";
            G.style.visibility = "visible";
            G.style.display = "block"
        }
        if (this.popup) {
            var G = $("photodetail" + this.id);
            G.style.visibility = "visible";
            G.style.width = H.offsetWidth + "px";
            ps = pgScroll();
            G.style.top = (ps[1] + 50) + "px"
        }
        if (this.trot) {
            this.trot.showimg(F, false)
        }
    };
    this.findPos = function(F) {
        var G = curtop = 0;
        if (F.offsetParent) {
            G = F.offsetLeft;
            curtop = F.offsetTop;
            while (F = F.offsetParent) {
                G += F.offsetLeft;
                curtop += F.offsetTop
            }
        }
        return [G, curtop]
    };
    this.alignnextprev = function() {
        if (this.cfg.nextprev != 0) {
            document.getElementById("thumbarr-" + this.id + "-left").style.display = "block";
            document.getElementById("thumbarr-" + this.id + "-right").style.display = "block";
            document.getElementById("pd2i-" + this.id + "-r").style.display = "block"
        }
        return;
        if (this.popup) {
            prot = this.findPos($("img-" + this.id + "-r"));
            var G = $("pdprev" + this.id);
            var F = 0;
            var H = 0;
            G.style.position = "absolute";
            G.style.top = ( - H) + "px";
            G.style.left = ( - F) + "px";
            var G = $("pdnext" + this.id);
            G.style.position = "absolute";
            G.style.top = ( - H) + "px";
            G.style.left = (F + $("img-" + this.id + "-r").clientWidth - G.clientWidth - 4) + "px"
        } else {
            prot = this.findPos($("img-" + this.id + "-r"));
            var G = $("pdprev" + this.id);
            var F = 20;
            var H = 10;
            G.style.position = "absolute";
            G.style.top = (prot[1] - H) + "px";
            G.style.left = (prot[0] - F) + "px";
            var G = $("pdnext" + this.id);
            G.style.position = "absolute";
            G.style.top = (prot[1] - H) + "px";
            G.style.left = (F + prot[0] + $("img-" + this.id + "-r").clientWidth - G.clientWidth - 4) + "px"
        }
    };
    this.start = function() {
        this.showimg(this.curidx, true);
        //if (this.cfg.speed && this.cfg.speed != 0) {
        //    window.setTimeout(this.varname + ".anext()", this.cfg.speed * 1000)
        //}
    };
    this.anext = function() {
        if (this.cfg.speed && this.cfg.speed != 0) {
            if (this.curidx >= this.images.length - 1) {
                this.curidx = -1
            }
            this.rnext();
            window.setTimeout(this.varname + ".anext()", this.cfg.speed * 1000)
        }
    };
    this.next = function() {
        this.cfg.speed = 0;
        this.rnext()
    };
    this.rnext = function() {
        this.curidx++;
        if (this.curidx >= this.images.length) {
            this.curidx = 0
        }
        this.showimg(this.curidx, false)
    };
    this.prev = function() {
        this.cfg.speed = 0;
        this.curidx--;
        if (this.curidx < 0) {
            this.curidx = this.images.length - 1
        }
        this.showimg(this.curidx, false)
    };
    this.showimg = function(F, J) {
        this.curidx = F;
        var H = this.images[F];
        if (H == null || H.p.indexOf(".") < 0) {
            return
        }
        if (this.cfg.ct == true) {
            ctd = document.getElementById("ct-" + this.id + "-r");
            if (ctd && ctd != null) {
                ctd.style.display = "block";
                var G = (F * 1 + 1) + "/" + this.images.length;
                ctd.innerHTML = " " + G + " "
            }
        }
        var I = H.p;
        var K = I.lastIndexOf("index.html");
        if (K > 0) {
            I = I.substring(K + 1)
        }
        iload = new picloader(this, this.imgsize, F, "r", this.cfg);
        this.iload = iload;
        iload.showimg(F, J)
    }
}
function picloader(D, C, B, A, E) {
    this.helper = D;
    this.dividx = A;
    this.imgsize = C;
    this.iload = null;
    this.id = this.helper.id;
    this.idx = 0;
    this.pidx = B;
    this.wc = 0;
    this.hc = 0;
    this.cfg = E;
    this.cfg = E;
    this.iload = null;
    this.bks = null;
    this.showimg3 = function() {
        if (this.iload.complete == false) {
            window.setTimeout(this.helper.varname + ".iload.showimg3()", 30);
            return
        }
        var G = $("tspc-" + this.helper.id + "-" + this.dividx);
        var F = $("img-" + this.helper.id + "-" + this.dividx);
        this.bks = F.src;
        if (F && F != null) {
            G.style.backgroundImage = "url(" + this.bks + ")"
        }
        var H = $("tdiv-" + this.id + "-" + this.dividx);
        if (H != null) {
            H.style.visibility = "hidden"
        }
        this.wc = H.offsetWidth;
        this.hc = H.offsetHeight;
        this.pcon = G;
        window.setTimeout(this.helper.varname + ".iload.showimg4()", 500)
    };
    this.showimg4 = function() {
        this.sizepic()
    };
    this.showimg = function(F, H) {
        pi = $("pd2i-" + this.helper.id + "-r");
        if (pi && pi != null) {
            pi.style.visibility = "visible"
        }
        var G = this.helper.images[F];
        if (G.p.indexOf(".") < 0) {
            return
        }
        var I = this.helper.varname;
        this.iload = new Image();
        this.iload.onload = function() {
            showimg3(I)
        };
        this.iload.src = getphpath(this, G.p) + "?ab=" + this.helper.phbid
    };
    this.setimg = function() {
        var G = this.helper.images[this.pidx];
        if (G.p.indexOf(".") < 0) {
            return
        }
        tx = "tdiv-" + this.id + "-" + this.dividx;
        var F = '<div id="' + tx + '" style="opacity:.0;filter:alpha(opacity=0)">' + pilink(this.helper.id, this.pidx, this.helper.cfg, G, getphpath(this, G.p) + "?ab=" + this.helper.phbid, 'id="img-' + this.id + "-" + this.dividx + '"') + "</div>";
        $("tspc-" + this.id + "-" + this.dividx).innerHTML = F;
        new Effect.Appear(tx, {
            duration: 1,
            from: 0,
            to: 1,
            queue: "end"
        });
        pi = $("pd2i-" + this.helper.id + "-r");
        if (pi && pi != null) {
            pi.style.visibility = "hidden"
        }
    };
    this.sizepic = function() {
        pc = this.pcon;
        this.wc = pc.offsetWidth;
        if (this.wc == 0) {
            return
        }
        this.hc = pc.offsetHeight;
        this.xs = ((this.iload.width) / this.wc) * 100;
        this.ys = ((this.iload.height) / this.hc) * 100;
        wd = (this.wc) - this.iload.width;
        hd = (this.hc) - this.iload.height;
        var I = this.helper.varname;
        var H = "tspc-" + this.id + "-" + this.dividx;
        if (hd == 0 && wd == 0) {
            this.setimg();
            pause(250)
        } else {
            var F = "";
            var G = "";
            if (wd != 0) {
                F = ""
            }
            if (! (hd == 0)) {
                if (wd == 0) {
                    new Effect.Scale(H, this.ys, {
                        scaleX: false,
                        duration: resDur,
                        queue: "front",
                        afterFinish: function() {
                            setimg(I)
                        }
                    })
                } else {
                    new Effect.Scale(H, this.ys, {
                        scaleX: false,
                        duration: resDur,
                        queue: "front"
                    })
                }
            }
            if (! (wd == 0)) {
                new Effect.Scale(H, this.xs, {
                    scaleY: false,
                    delay: resDur,
                    duration: resDur,
                    afterFinish: function() {
                        setimg(I)
                    }
                })
            }
        }
    }
};