﻿var oygInit = false;
var oygError = "Failed to load or execute required JavaScript files.";
function JSONscriptRequest(_1) {
    this.fullUrl = _1;
    this.headLoc = document.getElementsByTagName("head").item(0);
    this.scriptId = "JscriptId" + JSONscriptRequest.scriptCounter++;
}
JSONscriptRequest.scriptCounter = 1;
JSONscriptRequest.prototype.init = function() {
    this.scriptObj = document.createElement("script");
    this.scriptObj.setAttribute("type", "text/javascript");
    this.scriptObj.setAttribute("charset", "utf-8");
    this.scriptObj.setAttribute("src", this.fullUrl);
    this.scriptObj.setAttribute("id", this.scriptId);
};
JSONscriptRequest.prototype.finit = function() {
    this.headLoc.removeChild(this.scriptObj);
};
JSONscriptRequest.prototype.submit = function(_2) {
    this.headLoc.appendChild(this.scriptObj);
};
function oyCrosswordClue(_1, _2, _3, _4, _5, _6, _7) {
    this.len = _1;
    this.clue = _2;
    this.answer = _3;
    this.sign = _4;
    this.dir = _5;
    this.xpos = _6;
    this.ypos = _7;
    this.revealed = false;
    this.matched = false;
}
oyCrosswordClue.prototype.completed = function() {
    return this.matched || this.revealed;
};
function oyClueList(_8, _9, _a, ns) {
    this.puzz = _8;
    this.name = _9;
    this.clues = _a;
    this.ns = ns;
    this.selIdx = -1;
}
oyClueList.prototype.render = function() {
    var _c = this.name;
    _c += "<table class='oyList' border='0' cellspacing='0' cellpadding='0'>";
    for (var i = 0; i < this.clues.length; i++) {
        if (i != 0) {
            _c += "<tr class='oyListSpacer'><td></td></tr>";
        }
        _c += "<tr><td class='oyListNormal' id='" + this.ns + i + "'><b>" + (i + 1) + ".</b> " + this.clues[i].clue + "</td></tr>";
    }
    _c += "</table>";
    return _c;
};
oyClueList.prototype.bind = function() {
    for (var i = 0; i < this.clues.length; i++) {
        var _f = document.getElementById(this.ns + i);
        this.bindItem(_f, i);
    }
};
oyClueList.prototype.unbind = function() {
    for (var i = 0; i < this.clues.length; i++) {
        var _11 = document.getElementById(this.ns + i);
        _11.onclick = null;
    }
};
oyClueList.prototype.bindItem = function(_12, idx) {
    var _14 = this;
    _12.onclick = function() {
        _14.clickItem(idx);
    };
};
oyClueList.prototype.clickItem = function(idx) {
    this.selectItem(idx);
    this.puzz.unfocusOldCell();
    this.puzz.focusNewCell(this.clues[idx].xpos, this.clues[idx].ypos, true, this.clues[idx]);
};
oyClueList.prototype.selectItem = function(idx) {
    if (this.selIdx != -1) {
        document.getElementById(this.ns + this.selIdx).className = "oyListNormal";
    }
    if (idx != -1) {
        document.getElementById(this.ns + idx).className = "oyListSel";
    }
    this.selIdx = idx;
};
oyClueList.prototype.getClueIndexForPoint = function(x, y) {
    for (var i = 0; i < this.clues.length; i++) {
        if (this.clues[i].dir == 0) {
            if (y == this.clues[i].ypos) {
                if (x >= this.clues[i].xpos && x < this.clues[i].xpos + this.clues[i].len) {
                    return i;
                }
            }
        } else {
            if (x == this.clues[i].xpos) {
                if (y >= this.clues[i].ypos && y < this.clues[i].ypos + this.clues[i].len) {
                    return i;
                }
            }
        }
    }
    return - 1;
};
function oyCrosswordMenu(_1) {
    this.puzz = _1;
    this.hlist = _1.hlist;
    this.vlist = _1.vlist;
    this.footer = _1.footer;
    this.canReveal = _1.canReveal;
    this.canCheck = _1.canCheck;
    this.clues = _1.clues;
    this.currentMenu = null;
    this.over = null;
    this.cache = new Array();
    for (var i = 0; i < this.puzz.h; i++) {
        for (var j = 0; j < this.puzz.w; j++) {
            var _4 = j + "_" + i;
            this.cache[_4] = -1;
        }
    }
    this.checks = 0;
    this.reveals = 0;
    this.deducts = 0;
    this.matches = 0;
    this.score = 0;
    this.rank = -1;
    this.xpos = _1.xpos;
    this.ypos = _1.ypos;
    this.name = oyGetCookie("OYG_NICK_NAME");
    if (this.name == null || this.name == "") {
        this.name = "Anonymous";
    }
    this.server = new oyServer(this.puzz.appHome, this.puzz.ns);
    this.scoreSubmittedMatches = 0;
}
oyCrosswordMenu.prototype.setCellState = function(x, y, _7) {
    this.cache[x + "_" + y] = _7;
};
oyCrosswordMenu.prototype.getCellState = function(x, y) {
    return this.cache[x + "_" + y];
};
oyCrosswordMenu.prototype.bind = function() {
    this.inputCache = this.puzz.inputCache;
    this.startOn = new Date();
};
oyCrosswordMenu.prototype.unbind = function() {
    this.inputCache = null;
};
oyCrosswordMenu.prototype.focusNewCell = function(x, y) {
    this.xpos = x;
    this.ypos = y;
};
oyCrosswordMenu.prototype.invalidateMenu = function() {
    if (this.currentMenu != null) {
        this.currentMenu();
    }
};
oyCrosswordMenu.prototype.installWelcomeMenu = function() {
    this.currentMenu = this.installWelcomeMenu;
    var _c = document.getElementById("oygPuzzleFooter");
    _c.innerHTML = "";
    var _d = this;
    var _e = escape(this.name);
    _e = _e.replace(/%20/g, " ");
    this.addNoneWordAction(_c, "Welcome! ");
    var _f = document.getElementById("oygWelcomeLink");
    
    this.addNewLine(_c);
    this.addAction(_c, "Start Now", "Starting...", "strt", function() {
        _d.puzz.bind();
        _d.puzz.hlist.clickItem(0);
        _d.installContextMenu();
        document.getElementById("oygStatic").innerHTML = "";
        _d.footer.stateOk("Enjoy the game!");
    });
    this.footer.stateOk("Ready to begin!");
    this.server.trackAction(this.puzz.uid, "wlm");
};
oyCrosswordMenu.prototype.installContextMenu = function() {
    this.currentMenu = this.installContextMenu;
    var _10 = document.getElementById("oygPuzzleFooter");
    _10.innerHTML = "";
    var _11 = this.hlist.getClueIndexForPoint(this.xpos, this.ypos);
    var _12 = this.vlist.getClueIndexForPoint(this.xpos, this.ypos);
    if (!this.canReveal) {
        this.addNoneWordAction(_10, "Reveal Disabled");
    } else {
        if (_11 != -1) {
            var _13 = "Reveal <b>" + (_11 + 1) + "A</b>";
            if (!this.hlist.clues[_11].completed()) {
                this.addRevealWordAction(this.hlist.clues[_11], _10, _13);
            } else {
                this.addAction(_10, _13, "", null, null);
            }
        }
        if (_12 != -1) {
            var _13 = "Reveal <b>" + (_12 + 1) + "D</b>";
            if (!this.vlist.clues[_12].completed()) {
                this.addRevealWordAction(this.vlist.clues[_12], _10, _13);
            } else {
                this.addAction(_10, _13, "", null, null);
            }
        }
    }
    if (!this.canCheck) {
        this.addNoneWordAction(_10, "Check Disabled");
    } else {
        var _13 = "Check <b>" + (_11 + 1) + "A</b>";
        if (_11 != -1) {
            if (!this.hlist.clues[_11].completed()) {
                this.addCheckWordAction(this.hlist.clues[_11], _10, _13);
            } else {
                this.addAction(_10, _13, "", null, null);
            }
        }
        var _13 = "Check <b>" + (_12 + 1) + "D</b>";
        if (_12 != -1) {
            if (!this.vlist.clues[_12].completed()) {
                this.addCheckWordAction(this.vlist.clues[_12], _10, _13);
            } else {
                this.addAction(_10, _13, "", null, null);
            }
        }
        var _14 = this;
        this.addAction(_10, "Check <b>All</b>", "Checking All...", "chkll", function() {
            _14.checkAll();
            _14.invalidateMenu();
            return false;
        });
        this.addNewLine(_10);
        var _14 = this;
        this.addSubmitLeaveMenuItems(_10);
    }
    this.footer.update();
    var _15 = false;
    for (var i = 0; i < this.clues.length; i++) {
        if (!this.clues[i].completed()) {
            _15 = true;
            break;
        }
    }
    if (!_15) {
        this.over = true;
    }
    if (this.over) {
        this.over = true;
        this.puzz.unbind();
        this.installDoneMenu();
    }
};
oyCrosswordMenu.prototype.installDoneMenu = function() {
    this.currentMenu = this.installDoneMenu;
    var _17 = document.getElementById("oygPuzzleFooter");
    _17.innerHTML = "";
    this.addNoneWordAction(_17, "Game Over!");
    this.addNewLine(_17);
    var msg = "You have <b>" + this.score + "</b> points";
    if (this.rank != -1) {
        msg += " (rank <b>" + this.rank + "</b>)";
    }
    msg += ".";
    this.addNoneWordAction(_17, msg);
    this.addNewLine(_17);
    msg = "<b>Congratulations!!</b>";
    this.addNoneWordAction(_17, msg);
    this.addNewLine(_17);
    msg = "Please give this code to your sales rep for a <b>$50</b> discount on machines or parts.";
    this.addNoneWordAction(_17, msg);
    this.addNewLine(_17);
    msg = "<b>UTNHOL08CW</b>";
    this.addNoneWordAction(_17, msg);
    this.addNewLine(_17);
    var _19 = this;
    this.addSubmitLeaveMenuItems(_17);
    this.footer.stateOk("Game over!");
    this.server.trackAction(this.puzz.uid, "ovr");
    this.footer.update();
};
oyCrosswordMenu.prototype.addSubmitLeaveMenuItems = function(_1a) {
    var _1b = "Submit <b>Score</b>";
    
    var _1c = this;
    this.addAction(_1a, "Leave <b>Game</b>", "Leaving...", "lv", function() {
        _1c.leaveGameEarly(_1c.puzz.leaveGameUrl);
        _1c.footer.stateOk("Done");
        return false;
    });
};
oyCrosswordMenu.prototype.leaveGameEarly = function(url) {
    this.footer.stateBusy("Leaving...");
    var _1e = true;
    if (this.puzz.started && !this.over) {
        _1e = confirm("Game is in progress. Do you want to leave the game?");
    }
    if (_1e) {
        var loc = this.puzz.appHome + "/index.html#p101|December2008Newsletter";
        if (url != null) {
            loc = unescape(url);
        }
        window.location = loc;
    }
    this.footer.stateOk("Done");
};
oyCrosswordMenu.prototype.addAction = function(_20, _21, _22, _23, _24) {
    _21 = _21.replace(" ", "&nbsp;");
    var _25 = document.createElement("SPAN");
    _25.innerHTML = " &nbsp; ";
    _20.appendChild(_25);
    var _25 = document.createElement("A");
    _25.innerHTML = _21;
    _25.href = "";
    if (!_24) {
        _25.className = "oyMenuActionDis";
        _25.onclick = function() {
            return false;
        };
    } else {
        _25.className = "oyMenuAction";
        var _26 = this;
        _25.onclick = function() {
            _26.footer.stateBusy(_22);
            setTimeout(function() {
                _24();
                _26.server.trackAction(_26.puzz.uid, _23);
            }, 100);
            return false;
        };
    }
    _20.appendChild(_25);
};
oyCrosswordMenu.prototype.addNewLine = function(_27) {
    var _28 = document.createElement("SPAN");
    _28.innerHTML = "<span style='font-size: 4px;'><br />&nbsp;<br /></span>";
    _27.appendChild(_28);
};
oyCrosswordMenu.prototype.addNoneWordAction = function(_29, _2a) {
    var _2b = document.createElement("SPAN");
    _2b.className = "oyMenuActionNone";
    _2b.innerHTML = _2a;
    _29.appendChild(_2b);
    var _2b = document.createElement("SPAN");
    _2b.innerHTML = " ";
    _29.appendChild(_2b);
};
oyCrosswordMenu.prototype.addCheckWordAction = function(_2c, _2d, _2e) {
    var _2f = this;
    this.addAction(_2d, _2e, "Checking...", "chk", function() {
        _2f.checkWord(_2c);
        _2f.invalidateMenu();
        return false;
    });
};
oyCrosswordMenu.prototype.addRevealWordAction = function(_30, _31, _32) {
    var _33 = this;
    this.addAction(_31, _32, "Revealing...", "rvl", function() {
        _33.revealWord(_30);
        _33.invalidateMenu();
        return false;
    });
};
oyCrosswordMenu.prototype.getCurrentValueFor = function(x, y) {
    var _36 = this.inputCache.getElement(x, y).value;
    if (_36 == " " || _36 == "") {
        _36 = null;
    }
    return _36;
};
oyCrosswordMenu.prototype.getCellPosListFor = function(_37, _38, top) {
    var all = new Array();
    for (var i = 0; i < _37.len; i++) {
        all.push(this.charToPos(_37, i));
    }
    return all;
};
oyCrosswordMenu.prototype.charToPos = function(_3c, _3d) {
    var pos = new function() {};
    if (_3c.dir == 0) {
        pos.x = _3c.xpos + _3d;
        pos.y = _3c.ypos;
    } else {
        pos.x = _3c.xpos;
        pos.y = _3c.ypos + _3d;
    }
    return pos;
};
oyCrosswordMenu.prototype.showAnswer = function(_3f, _40) {
    for (var i = 0; i < _3f.len; i++) {
        var pos = this.charToPos(_3f, i);
        var _43 = this.inputCache.getElement(pos.x, pos.y);
        if (!_43.readOnly) {
            _43.readOnly = true;
            _43.value = _3f.answer.charAt(i).toUpperCase();
            this.setCellState(pos.x, pos.y, _40);
            var _44 = document.getElementById("oyCell" + pos.x + "_" + pos.y);
            switch (_40) {
            case 1:
                _44.className = "oyCellGuessed";
                break;
            case 2:
                _44.className = "oyCellRevealed";
                break;
            default:
                alert("Bad state code!");
            }
        }
    }
    this.puzz.invalidate();
};
oyCrosswordMenu.prototype.checkWordStatus = function(_45) {
    var _46 = new function() {};
    _46.wrong = 0;
    _46.isComplete = true;
    _46.buf = "";
    for (var i = 0; i < _45.len; i++) {
        var _48;
        if (_45.dir == 0) {
            _48 = this.getCurrentValueFor(_45.xpos + i, _45.ypos);
        } else {
            _48 = this.getCurrentValueFor(_45.xpos, _45.ypos + i);
        }
        if (_48 == null) {
            _46.isComplete = false;
            _46.buf += ".";
        } else {
            _46.buf += _48;
        }
        if (_48 != _45.answer.charAt(i).toUpperCase()) {
            _46.wrong++;
        }
    }
    return _46;
};
oyCrosswordMenu.prototype.askNickName = function(_49) {
    if (_49) {
        _49 = "Score: " + _49 + ". ";
    } else {
        _49 = "";
    }
    if (this.name == null) {
        this.name = "";
    }
    var _4a = this.name;
    this.name = window.prompt(_49 + "Enter your NICK NAME or E-MAIL.\n" + "Without e-mail, the score is recorded, but you aren't eligible for the prizes.", this.name);
    var _4b = true;
    if (this.name == null || this.name == "") {
        this.name = _4a;
        _4b = false;
    }
    if (this.name != null && this.name != "") {
        oySetCookieForPeriod("OYG_NICK_NAME", this.name, 1000 * 60 * 60 * 24 * 360, "/");
        return _4b;
    } else {
        this.name = "Anonymous";
        return false;
    }
};
oyCrosswordMenu.prototype.getScoreForMatch = function(_4c) {
    return _4c.len;
};
oyCrosswordMenu.prototype.getDeductsForReveal = function(_4d) {
    return _4d.len * 2;
};
oyCrosswordMenu.prototype.getDeductionForCheck = function(_4e) {
    var _4f = 3;
    var _50 = (_4e.len - _4e.len % _4f) / _4f;
    if (_50 < 1) {
        _50 = 1;
    }
    return _50;
};
oyCrosswordMenu.prototype.revealWord = function(_51) {
    this.deducts += this.getDeductsForReveal(_51);
    this.reveals++;
    this.showAnswer(_51, 2);
    _51.revealed = true;
    _51.matched = false;
    var _52 = this.checkWordStatus(_51);
    this.footer.stateOk("Revealed [" + _52.buf + "]!");
};
oyCrosswordMenu.prototype.checkAll = function() {
    var _53 = 0;
    var _54 = 0;
    for (var i = 0; i < this.clues.length; i++) {
        if (this.clues[i].completed()) {
            continue;
        }
        var _56 = this.checkWordStatus(this.clues[i]);
        if (_56.isComplete) {
            _53++;
            this.checks++;
            this.deducts += this.getDeductionForCheck(this.clues[i]);
            if (_56.wrong == 0) {
                this.showAnswer(this.clues[i], 1);
                this.score += this.getScoreForMatch(this.clues[i]);
                this.clues[i].matched = true;
                this.clues[i].revealed = false;
                _54++;
                this.matches++;
            }
        }
    }
    if (_53 == 0) {
        this.footer.stateError("No complete words found!");
    } else {
        this.footer.stateOk("Checked " + _53 + ", " + _54 + " matched!");
    }
};
oyCrosswordMenu.prototype.checkWord = function(_57) {
    var _58 = this.checkWordStatus(_57);
    if (!_58.isComplete) {
        this.footer.stateError("The word [" + _58.buf + "] is incomplete!");
    } else {
        this.checks++;
        this.deducts += this.getDeductionForCheck(_57);
        if (_58.wrong != 0) {
            this.footer.stateError("[" + _58.buf + "] didn't match!");
        } else {
            this.matches++;
            this.showAnswer(_57, 1);
            this.score += this.getScoreForMatch(_57);
            _57.revealed = false;
            _57.matched = true;
            this.footer.stateOk("[" + _58.buf + "] matched!");
        }
    }
};
oyCrosswordMenu.prototype.submitScore = function() {
    if (this.matches == 0) {
        this.footer.stateError("Nothing to submit yet!");
        alert("Nothing to submit yet!\nUncover some words first.");
    } else {
        var ms = new Date().getTime() - this.puzz.menu.startOn.getTime();
        this.server.submitScore(this, this.puzz.uid, this.score, this.deducts, this.checks, this.reveals, this.matches, ms, this.name, this.puzz.clues);
        this.footer.stateBusy("Submitting score...");
    }
};
function oyCrosswordFooter(_1) {
    this.puzz = _1;
}
oyCrosswordFooter.prototype.bind = function() {
    var _2 = this;
    this.clockTime = setInterval(function() {
        _2.clockUpdate();
    }, 1000);
};
oyCrosswordFooter.prototype.unbind = function() {
    clearInterval(this.clockTime);
    this.clockTime = null;
};
oyCrosswordFooter.prototype.stateOk = function(_3) {
    var _4 = document.getElementById("oygState");
    _4.innerHTML = "<b>&gt;</b> " + _3 + "&nbsp;";
    _4.className = "ousStateOk";
};
oyCrosswordFooter.prototype.stateBusy = function(_5) {
    var _6 = document.getElementById("oygState");
    _6.innerHTML = "<b>&gt;</b> " + _5 + "&nbsp;";
    _6.className = "ousStateBusy";
};
oyCrosswordFooter.prototype.stateError = function(_7) {
    var _8 = document.getElementById("oygState");
    _8.innerHTML = "<b>&gt;</b> " + _7 + "&nbsp;";
    _8.className = "ousStateError";
};
oyCrosswordFooter.prototype.clockUpdate = function() {
    var _9 = function(i) {
        if (i < 10) {
            i = "0" + i;
        }
        return i;
    };
    if (this.puzz.started) {
        var ms = new Date().getTime() - this.puzz.menu.startOn.getTime();
        var _c = Math.round(ms / 1000);
        var _d = 0;
        if (_c >= 60) {
            _d = Math.round(_c / 60);
            _c = _c % 60;
        }
        document.getElementById("oygFooterClock").innerHTML = "&nbsp;Time: <b>" + _9(_d) + "</b>:<b>" + _9(_c) + "</b>";
    }
};
oyCrosswordFooter.prototype.update = function() {
    var _e = "";
    if (!this.puzz.started) {
        _e += "Game has not yet started!";
    } else {
        _e += "Score: <b>" + this.puzz.menu.score + "</b> points";
        if (this.puzz.menu.rank != -1) {
            _e += " (rank <b>" + this.puzz.menu.rank + "</b>)";
        }
    }
    document.getElementById("oygFooterStatus").innerHTML = _e;
};
function oyGridElementCache(w, h, ns) {
    this.ns = ns;
    this.cache = new Array();
    for (var i = 0; i < h; i++) {
        for (var j = 0; j < w; j++) {
            var key;
            key = this.ns + j + "_" + i;
            this.cache[key] = document.getElementById(key);
        }
    }
}
oyGridElementCache.prototype.getElement = function(x, y) {
    return this.cache[this.ns + x + "_" + y];
};
var ie4 = (document.all) ? true: false;
var ns4 = (document.layers) ? true: false;
var ns6 = (document.getElementById && !document.all) ? true: false;
function oyShowLayer(lay) {
    if (ie4) {
        document.all[lay].style.visibility = "visible";
        document.all[lay].style.display = "block";
    }
    if (ns4) {
        document.layers[lay].visibility = "show";
    }
    if (ns6) {
        document.getElementById([lay]).style.visibility = "visible";
        document.getElementById([lay]).style.display = "block";
    }
}
function oyHideLayer(lay) {
    if (ie4) {
        document.all[lay].style.visibility = "hidden";
        document.all[lay].style.display = "none";
    }
    if (ns4) {
        document.layers[lay].visibility = "hide";
    }
    if (ns6) {
        document.getElementById([lay]).style.visibility = "hidden";
        document.getElementById([lay]).style.display = "none";
    }
}
function oySetCookie(_19, _1a, _1b, _1c, _1d, _1e) {
    document.cookie = _19 + "=" + escape(_1a) + ((_1b) ? "; expires=" + _1b.toGMTString() : "") + ((_1c) ? "; path=" + _1c: "") + ((_1d) ? "; domain=" + _1d: "") + ((_1e) ? "; secure": "");
}
function oyGetCookie(_1f) {
    var dc = document.cookie;
    var _21 = _1f + "=";
    var _22 = dc.indexOf("; " + _21);
    if (_22 == -1) {
        _22 = dc.indexOf(_21);
        if (_22 != 0) {
            return null;
        }
    } else {
        _22 += 2;
    }
    var end = document.cookie.indexOf(";", _22);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(_22 + _21.length, end));
}
function oySetCookieForPeriod(_24, _25, _26, _27, _28, _29) {
    var _2a = new Date();
    _2a.setTime(_2a.getTime() + _26);
    oySetCookie(_24, _25, _2a, _27, _28, _29);
}
function oyBrowserDetection() {
    this.agt = navigator.userAgent.toLowerCase();
    this.browser = "";
    this.version = 0;
    this.compleVersion = 0;
    this.isIE = false;
    this.isNetscape = false;
    this.isFirefox = false;
    this.isGood = false;
    this.sf = false;
    this.isWin = ((this.agt.indexOf("win") != -1) || (this.agt.indexOf("16bit") != -1));
    this.isMac = (this.agt.indexOf("mac") != -1);
    this.isLinux = (this.agt.indexOf("linux") != -1);
    if (navigator.userAgent.indexOf("MSIE") != -1 && navigator.userAgent.indexOf("AOL") == -1) {
        this.browser = "IE";
        this.isIE = true;
        reg = /(MSIE)(.)(\d+)(.)(\d+)/i;
        ar = reg.exec(navigator.userAgent);
        this.version = ar[3];
        this.compleVersion = ar[3] + ar[4] + ar[5];
    } else {
        if (navigator.userAgent.indexOf("Firefox") != -1) {
            this.browser = "Firefox";
            this.isFirefox = true;
            reg = /(Firefox)(.)(\d+)(.)(\d+)/i;
            ar = reg.exec(navigator.userAgent);
            this.version = ar[3];
            this.compleVersion = ar[3] + ar[4] + ar[5];
        } else {
            if (navigator.userAgent.indexOf("Netscape") != -1) {
                this.browser = "Netscape";
                this.isNetscape = true;
                reg = /(Netscape)(.)(\d+)(.)(\d+)/i;
                ar = reg.exec(navigator.userAgent);
                this.version = ar[3];
                this.compleVersion = ar[3] + ar[4] + ar[5];
            } else {
                if (navigator.userAgent.indexOf("Safari") != -1) {
                    this.sf = true;
                }
            }
        }
    }
    if ((this.isIE && this.version >= 5) || (this.isNetscape && this.version >= 6) || (this.isFirefox && this.version >= 1)) {
        this.isGood = true;
    }
}
function oygBind(_2b) {
    var _2c = new oyBrowserDetection().isGood;
    if (!_2c) {
        var msg = "Your current browser is not ideal for accessing this site.\n" + "We support Microsoft IE 6.0+, Firefox 1.0+, Netscape6.0+ versions.\n\n" + "It might still work OK, do you want to try?";
        if (confirm(msg)) {
            _2c = true;
        }
    }
    if (!_2c) {
        oygError = "This browser is not supported.";
    } else {
        var div = document.getElementById("oygContext");
        if (div == null) {
            oygError = "Bad template file.";
        } else {
            var _2f = document.getElementById("oygPuzzle");
            if (_2f == null) {
                oygError = "Failed to load puzzle file.";
            } else {
                _2b.init();
                _2b.render();
                _2b.menu.installWelcomeMenu();
            }
        }
    }
}
function oygNextRandomInt() {
    var rnd = "" + Math.random();
    var idx = rnd.indexOf(".");
    return rnd.substring(idx + 1);
}
oygInit = true;
oygError = null;
function oyCrosswordPuzzle(_1, _2, ns, _4, _5, _6, w, h) {
    this.guid = _1;
    this.uid = oygNextRandomInt();
    this.appHome = _2;
    this.ns = ns;
    this.title = _4;
    this.desc = _5;
    this.w = w;
    this.h = h;
    this.clues = _6;
    this.xpos = 0;
    this.ypos = 0;
    this.focused = null;
    this.dir = 0;
    this.leaveGameUrl = null;
    this.copyrightGameUrl = null;
    this.publisher = null;
    this.menu = null;
    this.canReveal = true;
    this.canCheck = true;
    this.reorderClues();
    this.started = false;
}
oyCrosswordPuzzle.prototype.reorderClues = function() {
    var _9 = [].concat(this.clues);
    var _a = [];
    for (var i = 0; i < this.clues.length; i++) {
        for (var j = 0; j < this.clues.length; j++) {
            if (this.clues[i] == null || this.clues[j] == null || i == j) {
                continue;
            }
            if (this.clues[i].xpos == this.clues[j].xpos && this.clues[i].ypos == this.clues[j].ypos) {
                _a.push(this.clues[i]);
                _a.push(this.clues[j]);
                this.clues[i] = null;
                this.clues[j] = null;
            }
        }
    }
    this.hclues = [];
    this.vclues = [];
    for (var i = 0; i < _a.length; i++) {
        if (_a[i].dir == 0) {
            this.hclues.push(_a[i]);
        } else {
            this.vclues.push(_a[i]);
        }
    }
    for (var i = 0; i < this.clues.length; i++) {
        if (this.clues[i] == null) {
            continue;
        }
        if (this.clues[i].dir == 0) {
            this.hclues.push(this.clues[i]);
        } else {
            this.vclues.push(this.clues[i]);
        }
    }
    this.clues = _9;
};
oyCrosswordPuzzle.prototype.init = function() {
    this.hlist = new oyClueList(this, "Across", this.hclues, "oygHClue", "H");
    this.vlist = new oyClueList(this, "Down", this.vclues, "oygVClue", "V");
    var _d = this;
    document.getElementById("oygHeader").innerHTML = "<span class='oyHeaderTitle'>" + this.title + "</span><br><span class='oyHeaderDesc'>" + this.desc + "</span>";
    var _e = "<table border='0' cellspacing='0' cellpadding='0' width='100%'><tr>";
    _e += "<td class='oyFooter' id='oygFooterStatus' align='left'></td>";
    _e += "<td class='oyFooter' id='oygFooterClock' align='right'></td>";
    _e += "</tr>";
    var cr = "&nbsp;";
    if (this.publisher != null) {
        cr = this.publisher;
    }
    _e += "<tr><td class='oyCopyright' colspan='2' align='center'><a class='oysTextLink' id='oygCopyright' href=''>" + cr + "</a></tr>";
    _e += "</table>";
    document.getElementById("oygFooter").innerHTML = _e;
    document.getElementById("oygCopyright").onclick = function() {
        _d.menu.leaveGameEarly(_d.copyrightGameUrl);
        return false;
    };
    var _10 = "<img id='oygTrackAction' width='1px' height='1px'>";
    var _11 = document.getElementById("oygHeaderMenu");
    _11.innerHTML = _10 + "<a id=\"oygHeaderMenuBtn\" href=\"\"><img style=\"padding: 4px;\" src=\"./imgs/whereto.gif\" border=\"0\" alt=\"Leave Game\"></a>";
    document.getElementById("oygHeaderMenuBtn").onclick = function() {
        _d.menu.leaveGameEarly(_d.leaveGameUrl);
        return false;
    };
    this.footer = new oyCrosswordFooter(this);
    this.footer.stateBusy("Starting up...");
    this.menu = new oyCrosswordMenu(this);
};
oyCrosswordPuzzle.prototype.render = function() {
    var buf = "";
    buf += "<table border='0' cellspacing='0' cellpadding='0' style='border-collapse: collapse;'>";
    for (var i = 0; i < this.h; i++) {
        var row = "<tr>";
        for (var j = 0; j < this.w; j++) {
            row += "<td class='oyCellEmpty' id='oyCell" + j + "_" + i + "'></td>";
        }
        buf += row + "</tr>";
    }
    buf += "</table>";
    var _16 = 25;
    var _17 = 400;
    var _18 = this.w * _16;
    if (_18 < _17) {
        _18 = _17;
    }
    _18 += "px";
    var _19 = document.getElementById("oygPuzzleFooter");
    _19.style.width = _18;
    var _19 = document.getElementById("oygState");
    _19.style.width = _18;
    var _19 = document.getElementById("oygPuzzle");
    _19.style.width = _18;
    _19.innerHTML = buf;
    for (var i = 0; i < this.hlist.clues.length; i++) {
        this.renderHorz(this.hlist.clues[i]);
    }
    for (var i = 0; i < this.vlist.clues.length; i++) {
        this.renderVert(this.vlist.clues[i]);
    }
    var _19 = document.getElementById("oygListH");
    _19.innerHTML = "";
    _19.className = "oyPanelDivHidden";
    var _19 = document.getElementById("oygListV");
    _19.innerHTML = "";
    _19.className = "oyPanelDivHidden";
};
oyCrosswordPuzzle.prototype.renderVert = function(_1a) {
    for (var i = 0; i < _1a.len; i++) {
        var key = "oyCell" + _1a.xpos + "_" + (_1a.ypos + i);
        var _1d = document.getElementById(key);
        _1d.className = "oyCellFull";
    }
};
oyCrosswordPuzzle.prototype.renderHorz = function(_1e) {
    for (var i = 0; i < _1e.len; i++) {
        var key = "oyCell" + (_1e.xpos + i) + "_" + _1e.ypos;
        var _21 = document.getElementById(key);
        _21.className = "oyCellFull";
    }
};
oyCrosswordPuzzle.prototype.fillVert = function(_22, idx) {
    for (var i = 0; i < _22.len; i++) {
        var key = "oyCell" + _22.xpos + "_" + (_22.ypos + i);
        var _26 = document.getElementById(key);
        this.fillIn(_26, _22.xpos, _22.ypos + i, i, idx, 1);
        this.menu.setCellState(_22.xpos, _22.ypos + i, 0);
    }
};
oyCrosswordPuzzle.prototype.fillHorz = function(_27, idx) {
    for (var i = 0; i < _27.len; i++) {
        var key = "oyCell" + (_27.xpos + i) + "_" + _27.ypos;
        var _2b = document.getElementById(key);
        this.fillIn(_2b, _27.xpos + i, _27.ypos, i, idx, 0);
        this.menu.setCellState(_27.xpos + i, _27.ypos, 0);
    }
};
oyCrosswordPuzzle.prototype.fillIn = function(_2c, x, y, i, idx, dir) {
    if (i == 0) {
        _2c.style.backgroundImage = "url(\"./imgs/" + (idx + 1) + ".gif\")";
    }
    _2c.innerHTML = "<input id='oyInput" + x + "_" + y + "' class='oyCellInput' autocomplete='off' type='text' size='1' maxlength='1' value=''>";
};
oyCrosswordPuzzle.prototype.bind = function() {
    var _32 = document.getElementById("oygListH");
    _32.className = "oyPanelDiv";
    _32.innerHTML = this.hlist.render();
    var _32 = document.getElementById("oygListV");
    _32.className = "oyPanelDiv";
    _32.innerHTML = this.vlist.render();
    var _33 = 0;
    for (var i = 0; i < this.hlist.clues.length; i++) {
        this.fillHorz(this.hlist.clues[i], _33);
        _33++;
    }
    var _35 = 0;
    for (var i = 0; i < this.vlist.clues.length; i++) {
        this.fillVert(this.vlist.clues[i], _35);
        _35++;
    }
    this.inputCache = new oyGridElementCache(this.w, this.h, "oyInput");
    for (var i = 0; i < this.h; i++) {
        for (var j = 0; j < this.w; j++) {
            this.bindItem(j, i);
        }
    }
    this.menu.bind();
    this.footer.bind();
    this.hlist.bind();
    this.vlist.bind();
    this.footer.update();
    this.started = true;
};
oyCrosswordPuzzle.prototype.unbind = function() {
    for (var i = 0; i < this.h; i++) {
        for (var j = 0; j < this.w; j++) {
            var _39 = this.inputCache.getElement(j, i);
            if (_39 != null) {
                _39.onclick = null;
                _39.onkeydown = null;
                _39.onchange = null;
            }
        }
    }
    this.hlist.unbind();
    this.vlist.unbind();
    this.footer.unbind();
    this.menu.unbind();
};
oyCrosswordPuzzle.prototype.bindItem = function(x, y) {
    var _3c = this.inputCache.getElement(x, y);
    if (_3c != null) {
        var _3d = this;
        _3c.onclick = function() {
            _3d.unfocusOldCell();
            _3d.focusNewCell(x, y, false);
        };
        _3c.onkeydown = function(e) {
            return _3d.handleKeyDown(x, y, e);
        };
        _3c.onkeypress = function(e) {
            return _3d.handleKeyPress(x, y, e);
        };
    }
};
oyCrosswordPuzzle.prototype.focusLists = function(x, y) {
    var _42 = this.hlist.getClueIndexForPoint(x, y);
    this.hlist.selectItem(_42);
    var _43 = this.vlist.getClueIndexForPoint(x, y);
    this.vlist.selectItem(_43);
};
oyCrosswordPuzzle.prototype.focusCellList = function(all, _45) {
    for (var i = 0; i < all.length; i++) {
        var _47 = document.getElementById("oyCell" + all[i].x + "_" + all[i].y);
        var _48 = this.menu.getCellState(all[i].x, all[i].y);
        if (_47 != null) {
            if (_45 && _48 == 0) {
                _47.className = "oyCellFocused";
            } else {
                this.restoreCellState(_47, all[i].x, all[i].y);
            }
        }
    }
};
oyCrosswordPuzzle.prototype.unfocusOldWord = function() {
    if (this.focused != null) {
        this.focusCellList(this.menu.getCellPosListFor(this.focused), false);
        this.focused = null;
    }
};
oyCrosswordPuzzle.prototype.focusNewWord = function(x, y) {
    var _4b = this.hlist.getClueIndexForPoint(x, y);
    var _4c = this.vlist.getClueIndexForPoint(x, y);
    var _4d = null;
    if (_4b != -1 && _4c != -1) {
        if (this.dir == 0) {
            _4d = this.hlist.clues[_4b];
        } else {
            _4d = this.vlist.clues[_4c];
        }
    } else {
        if (_4b != -1) {
            _4d = this.hlist.clues[_4b];
        }
        if (_4c != -1) {
            _4d = this.vlist.clues[_4c];
        }
    }
    return _4d;
};
oyCrosswordPuzzle.prototype.focusNewCell = function(x, y, _50, _51) {
    if (_51 != null) {
        this.focused = _51;
    } else {
        this.focused = this.focusNewWord(x, y);
    }
    if (this.focused != null) {
        this.dir = this.focused.dir;
        this.focusCellList(this.menu.getCellPosListFor(this.focused), true);
    }
    var _52 = document.getElementById("oyCell" + x + "_" + y);
    if (_52 != null) {
        _52.className = "oyCellActive";
        this.focusLists(x, y);
        if (_50) {
            var _52 = this.inputCache.getElement(x, y);
            _52.focus();
        }
    }
    this.xpos = x;
    this.ypos = y;
    this.menu.focusNewCell(x, y);
    this.menu.invalidateMenu();
};
oyCrosswordPuzzle.prototype.unfocusOldCell = function() {
    var _53 = document.getElementById("oyCell" + this.xpos + "_" + this.ypos);
    if (_53 != null) {
        this.restoreCellState(_53, this.xpos, this.ypos);
    }
    this.unfocusOldWord();
};
oyCrosswordPuzzle.prototype.invalidate = function() {
    this.unfocusOldCell();
    this.focusNewCell(this.xpos, this.ypos, true);
};
oyCrosswordPuzzle.prototype.restoreCellState = function(_54, x, y) {
    var _57 = this.menu.getCellState(x, y);
    switch (_57) {
    case - 1: _54.className = "oyCellEmpty";
        break;
    case 0:
        _54.className = "oyCellFull";
        break;
    case 1:
        _54.className = "oyCellGuessed";
        break;
    case 2:
        _54.className = "oyCellRevealed";
        break;
    default:
        alert("Bad state code!");
    }
};
oyCrosswordPuzzle.prototype.isValidChar = function(c) {
    return (c >= "A" && c <= "Z") || c == " ";
};
oyCrosswordPuzzle.prototype.moveToPrevCell = function(x, y) {
    if (this.dir == 0) {
        x--;
    } else {
        y--;
    }
    var _5b = this.menu.getCellState(x, y);
    if (_5b != -1) {
        var _5c = this.inputCache.getElement(x, y);
        if (_5c != null) {
            this.unfocusOldCell();
            this.focusNewCell(x, y, false);
            _5c.focus();
        }
    }
};
oyCrosswordPuzzle.prototype.moveToNextCell = function(x, y) {
    if (this.dir == 0) {
        x++;
    } else {
        y++;
    }
    var _5f = this.menu.getCellState(x, y);
    if (_5f != -1) {
        var _60 = this.inputCache.getElement(x, y);
        if (_60 != null) {
            this.unfocusOldCell();
            this.focusNewCell(x, y, false);
            _60.focus();
        }
    }
};
oyCrosswordPuzzle.prototype.handleKeyPress = function(x, y, e) {
    if (!e) {
        e = window.event;
    }
    var _64 = (e.which) ? e.which: e.keyCode;
    var c = String.fromCharCode(_64).toUpperCase();
    if (_64 == 32) {
        c = " ";
    }
    if (this.isValidChar(c)) {
        var _66 = this.inputCache.getElement(x, y);
        if (!_66.readOnly) {
            _66.value = c.toUpperCase();
        }
        this.moveToNextCell(x, y);
    }
    return false;
};
oyCrosswordPuzzle.prototype.handleKeyDown = function(x, y, e) {
    if (!e) {
        e = window.event;
    }
    var _6a = (e.which) ? e.which: e.keyCode;
    var dir = (_6a >= 37 && _6a <= 40) || _6a == 8;
    if (dir) {
        var _6c = null;
        switch (_6a) {
        case 8:
            this.moveToPrevCell(x, y);
            break;
        case 37:
            while (true) {
                if (x > 0) {
                    x = x - 1;
                    _6c = this.inputCache.getElement(x, y);
                    if (_6c != null) {
                        break;
                    }
                } else {
                    break;
                }
            }
            break;
        case 39:
            while (true) {
                if (x < this.w - 1) {
                    x = x + 1;
                    _6c = this.inputCache.getElement(x, y);
                    if (_6c != null) {
                        break;
                    }
                } else {
                    break;
                }
            }
            break;
        case 38:
            while (true) {
                if (y > 0) {
                    y = y - 1;
                    _6c = this.inputCache.getElement(x, y);
                    if (_6c != null) {
                        break;
                    }
                } else {
                    break;
                }
            }
            break;
        case 40:
            while (true) {
                if (y < this.h - 1) {
                    y = y + 1;
                    _6c = this.inputCache.getElement(x, y);
                    if (_6c != null) {
                        break;
                    }
                } else {
                    break;
                }
            }
            break;
        }
        if (_6c != null) {
            this.unfocusOldCell();
            this.focusNewCell(x, y, false);
            _6c.focus();
        }
    }
    return true;
};
function oygEndpoint() {
    this.cookie = oygNextRandomInt();
    this.seq = 0;
    this.oob = 0;
    this.badcookie = 0;
}
oygEndpoint.noendpoint = 0;
function oygCompletionPort(_1, _2) {
    this.endpoint = _1;
    _1.seq++;
    this.seq = _1.seq;
    this.onError = null;
    this.onTimeout = null;
    this.onComplete = null;
    this.onDone = null;
    this.timeout = 15 * 1000;
    this.ajax = new JSONscriptRequest(_2 + "&seq=" + this.seq + "&cookie=" + _1.cookie);
}
oygCompletionPort.prototype.init = function() {
    this.ajax.init();
    var _3 = this;
    this.timer = setTimeout(function() {
        var _4 = _3.onTimeout;
        _3.finit();
        if (_4 != null) {
            _4();
        }
    }, this.timeout);
    this.ajax.submit();
};
oygCompletionPort.prototype.finit = function() {
    this.onError = null;
    this.onTimeout = null;
    this.onComplete = null;
    this.ajax.finit();
    this.ajax = null;
    clearTimeout(this.timer);
    this.timer = null;
};
function oyServer(_5, ns) {
    this.appHome = _5;
    this.ns = ns;
    this.ep = new oygEndpoint();
    this.md5 = new oySign();
    this.trackSeq = 0;
    this.trackURL = this.appHome + "/app/trackAction.php";
    this.submitURL = this.appHome + "/app/submitScore.php";
}
oyServer.prototype.computeMatrix = function(_7) {
    var _8 = new function() {};
    var _9 = "";
    var _a = "";
    for (var i = 0; i < _7.length; i++) {
        if (_7[i].matched) {
            _a += "1";
            _9 += _7[i].answer;
        } else {
            _a += "0";
        }
    }
    _8.states = _a;
    _8.concat = _9;
    return _8;
};
oyServer.prototype.trackAction = function(_c, _d) {
    if (_d != null) {
        
        this.trackSeq++;
    }
};
oyServer.prototype.submitScore = function(_13, uid, _15, _16, _17, _18, _19, _1a, _1b, _1c) {
    var key = uid;
    var _1e = this.computeMatrix(_1c);
    var _1f = this.md5.hex_hmac_md5(key, _1e.concat);
    var _20 = "uid=" + key + "&ns=" + escape(this.ns) + "&states=" + _1e.states + "&concat=" + _1f + "&score=" + _15 + "&deducts" + _16 + "&checks=" + _17 + "&reveals=" + _18 + "&matches=" + _19 + "&time=" + _1a + "&name=" + escape(_1b);
    var _21 = this.md5.hex_hmac_md5(key, _20);
    var _22 = "uid=" + key + "&data=" + escape(_20) + "&sign=" + _21;
    var url = this.submitURL + "?" + _22;
    this.submitScoreAjaxAnywhere(this.ep, _13, url, _19);
};
oyServer.prototype.submitScoreAjaxAnywhere = function(ep, _25, url, _27) {
    var _28 = _25;
    var cp = new oygCompletionPort(ep, url);
    cp.onComplete = function(_2a) {
        _28.scoreSubmittedMatches = _27;
        _28.rank = _2a.rank;
        _28.invalidateMenu();
        _28.footer.stateOk("Score submitted!");
    };
    cp.onTimeout = function() {
        _28.footer.stateError("Timeout waiting for server to reply!");
        alert("Failed to submit score. Server didn't reply!");
    };
    cp.onError = function(msg) {
        _28.footer.stateError("Failed to submit score!");
        alert("Failed to submit score. Server replied with:\n\n" + msg);
    };
    oygSubmitScoreCompletionPoint = cp;
    cp.init();
};
var oygSubmitScoreCompletionPoint;
function oygSubmitScoreJSONComplete(_2c, seq) {
    var cp = oygSubmitScoreCompletionPoint;
    if (cp != null) {
        if (_2c.envelope.cookie == cp.endpoint.cookie) {
            if (_2c.envelope.seq == cp.seq) {
                var _2f = cp.onComplete;
                var _30 = cp.onError;
                cp.finit();
                if (_2c.envelope.success) {
                    if (_2f != null) {
                        _2f(_2c.data);
                    }
                } else {
                    if (_30 != null) {
                        _30(_2c.envelope.msg);
                    }
                }
            } else {
                cp.endpoint.oob++;
            }
        } else {
            cp.endpoint.badcookie++;
        }
    } else {
        oygEndpoint.noendpoint++;
    }
}
function oySign() {
    this.hexcase = 0;
    this.b64pad = "";
    this.chrsz = 8;
    this.calculate = function(s) {
        return this.hex_md5(s);
    };
    this.test = function(s) {
        return this.md5_vm_test();
    };
}
oySign.prototype.hex_md5 = function(s) {
    return this.binl2hex(this.core_md5(this.str2binl(s), s.length * this.chrsz));
};
oySign.prototype.b64_md5 = function(s) {
    return this.binl2b64(this.core_md5(this.str2binl(s), s.length * this.chrsz));
};
oySign.prototype.str_md5 = function(s) {
    return this.binl2str(this.core_md5(this.str2binl(s), s.length * this.chrsz));
};
oySign.prototype.hex_hmac_md5 = function(_6, _7) {
    return this.binl2hex(this.core_hmac_md5(_6, _7));
};
oySign.prototype.b64_hmac_md5 = function(_8, _9) {
    return this.binl2b64(this.core_hmac_md5(_8, _9));
};
oySign.prototype.str_hmac_md5 = function(_a, _b) {
    return this.binl2str(this.core_hmac_md5(_a, _b));
};
oySign.prototype.md5_vm_test = function() {
    return this.hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
};
oySign.prototype.core_md5 = function(x, _d) {
    x[_d >> 5] |= 128 << ((_d) % 32);
    x[(((_d + 64) >>> 9) << 4) + 14] = _d;
    var a = 1732584193;
    var b = -271733879;
    var c = -1732584194;
    var d = 271733878;
    for (var i = 0; i < x.length; i += 16) {
        var _13 = a;
        var _14 = b;
        var _15 = c;
        var _16 = d;
        a = this.md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
        d = this.md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
        c = this.md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
        b = this.md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
        a = this.md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
        d = this.md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
        c = this.md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
        b = this.md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
        a = this.md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
        d = this.md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
        c = this.md5_ff(c, d, a, b, x[i + 10], 17, -42063);
        b = this.md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
        a = this.md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
        d = this.md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
        c = this.md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
        b = this.md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
        a = this.md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
        d = this.md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
        c = this.md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
        b = this.md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
        a = this.md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
        d = this.md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
        c = this.md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
        b = this.md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
        a = this.md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
        d = this.md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
        c = this.md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
        b = this.md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
        a = this.md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
        d = this.md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
        c = this.md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
        b = this.md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
        a = this.md5_hh(a, b, c, d, x[i + 5], 4, -378558);
        d = this.md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
        c = this.md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
        b = this.md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
        a = this.md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
        d = this.md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
        c = this.md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
        b = this.md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
        a = this.md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
        d = this.md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
        c = this.md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
        b = this.md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
        a = this.md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
        d = this.md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
        c = this.md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
        b = this.md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
        a = this.md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
        d = this.md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
        c = this.md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
        b = this.md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
        a = this.md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
        d = this.md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
        c = this.md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
        b = this.md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
        a = this.md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
        d = this.md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
        c = this.md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
        b = this.md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
        a = this.md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
        d = this.md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
        c = this.md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
        b = this.md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
        a = this.safe_add(a, _13);
        b = this.safe_add(b, _14);
        c = this.safe_add(c, _15);
        d = this.safe_add(d, _16);
    }
    return new Array(a, b, c, d);
};
oySign.prototype.md5_cmn = function(q, a, b, x, s, t) {
    return this.safe_add(this.bit_rol(this.safe_add(this.safe_add(a, q), this.safe_add(x, t)), s), b);
};
oySign.prototype.md5_ff = function(a, b, c, d, x, s, t) {
    return this.md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
};
oySign.prototype.md5_gg = function(a, b, c, d, x, s, t) {
    return this.md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
};
oySign.prototype.md5_hh = function(a, b, c, d, x, s, t) {
    return this.md5_cmn(b^c^d, a, b, x, s, t);
};
oySign.prototype.md5_ii = function(a, b, c, d, x, s, t) {
    return this.md5_cmn(c^ (b | (~d)), a, b, x, s, t);
};
oySign.prototype.core_hmac_md5 = function(key, _3a) {
    var _3b = this.str2binl(key);
    if (_3b.length > 16) {
        _3b = this.core_md5(_3b, key.length * this.chrsz);
    }
    var _3c = new Array(16),
    opad = new Array(16);
    for (var i = 0; i < 16; i++) {
        _3c[i] = _3b[i]^909522486;
        opad[i] = _3b[i]^1549556828;
    }
    var _3e = this.core_md5(_3c.concat(this.str2binl(_3a)), 512 + _3a.length * this.chrsz);
    return this.core_md5(opad.concat(_3e), 512 + 128);
};
oySign.prototype.safe_add = function(x, y) {
    var lsw = (x & 65535) + (y & 65535);
    var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
    return (msw << 16) | (lsw & 65535);
};
oySign.prototype.bit_rol = function(num, cnt) {
    return (num << cnt) | (num >>> (32 - cnt));
};
oySign.prototype.str2binl = function(str) {
    var bin = new Array();
    var _47 = (1 << this.chrsz) - 1;
    for (var i = 0; i < str.length * this.chrsz; i += this.chrsz) {
        bin[i >> 5] |= (str.charCodeAt(i / this.chrsz) & _47) << (i % 32);
    }
    return bin;
};
oySign.prototype.binl2str = function(bin) {
    var str = "";
    var _4b = (1 << this.chrsz) - 1;
    for (var i = 0; i < bin.length * 32; i += this.chrsz) {
        str += String.fromCharCode((bin[i >> 5] >>> (i % 32)) & _4b);
    }
    return str;
};
oySign.prototype.binl2hex = function(_4d) {
    var _4e = this.hexcase ? "0123456789ABCDEF": "0123456789abcdef";
    var str = "";
    for (var i = 0; i < _4d.length * 4; i++) {
        str += _4e.charAt((_4d[i >> 2] >> ((i % 4) * 8 + 4)) & 15) + _4e.charAt((_4d[i >> 2] >> ((i % 4) * 8)) & 15);
    }
    return str;
};
oySign.prototype.binl2b64 = function(_51) {
    var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    var str = "";
    for (var i = 0; i < _51.length * 4; i += 3) {
        var _55 = (((_51[i >> 2] >> 8 * (i % 4)) & 255) << 16) | (((_51[i + 1 >> 2] >> 8 * ((i + 1) % 4)) & 255) << 8) | ((_51[i + 2 >> 2] >> 8 * ((i + 2) % 4)) & 255);
        for (var j = 0; j < 4; j++) {
            if (i * 8 + j * 6 > _51.length * 32) {
                str += this.b64pad;
            } else {
                str += tab.charAt((_55 >> 6 * (3 - j)) & 63);
            }
        }
    }
    return str;
};