/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *



Sudoku 2009 - The - Puzzler.com



 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
/**************************************************************************************************************************/
/**************************************************************************************************************************/
var Initialise = false;
var ScoreAdded = false;
var MakeTheTable = false;
var Error = "Failed to load or execute required JavaScript files.";
var initial_count = new Array();
var rows_limit = 0;
// Set to 0 to disable limitation
/**************************************************************************************************************************/
function SudokuLine(_1, _2, _3){
   this.initalList = _1;
   this.sign = _2;
   this.solutionlist = _3;
   this.revealed = false;
   this.matched = false;
}
/**************************************************************************************************************************/
SudokuLine.prototype.completed = function(){
   return this.matched || this.revealed;
};
/**************************************************************************************************************************/
function SudokuMenu(sudokuPuzzle) {

   this.puzz = sudokuPuzzle;
   this.footer = sudokuPuzzle.footer;
   this.canReveal = sudokuPuzzle.canReveal;
   this.canCheck = sudokuPuzzle.canCheck;
   this.clues = sudokuPuzzle.clues;
   this.currentMenu = null;
   this.over = null;
   this.cache = new Array();
   this.checks = 0;
   this.reveals = 0;
   this.deducts = 0;
   this.matches = 0;
   this.score = 0;
   this.rank = - 1;
   this.xpos = sudokuPuzzle.xpos;
   this.ypos = sudokuPuzzle.ypos;
   this.name = oyGetCookie("OYG_NICK_NAME");
   this.scoreSubmittedMatches = 0;


   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;
     }
   }


   if(this.name == null || this.name == ""){
      this.name = "Anonymous";
   }

   this.server = new Server(this.puzz.appHome, this.puzz.ns);

};
/**************************************************************************************************************************/
SudokuMenu.prototype.setCellState = function(x, y, cellValue){
   this.cache[x + "_" + y] = cellValue;
};
/**************************************************************************************************************************/
SudokuMenu.prototype.getCellState = function(x, y){
   return this.cache[x + "_" + y];
};
/**************************************************************************************************************************/
SudokuMenu.prototype.bind = function(){
   this.inputCache = this.puzz.inputCache;
   this.startOn = new Date();
};
/**************************************************************************************************************************/
SudokuMenu.prototype.unbind = function(){
   this.inputCache = null;
};
/**************************************************************************************************************************/
SudokuMenu.prototype.focusNewCell = function(x, y){
   this.xpos = x;
   this.ypos = y;
};
/**************************************************************************************************************************/
SudokuMenu.prototype.invalidateMenu = function(){

   if(this.currentMenu != null){
      this.currentMenu();
   }
};
/**************************************************************************************************************************/
SudokuMenu.prototype.installWelcomeMenu = function(){

   this.currentMenu = this.installWelcomeMenu;
   var puzzleFooter = document.getElementById("PuzzleFooter");
   puzzleFooter.innerHTML = "";

   var _d = this;
   var _e = escape(this.name);
   _e = _e.replace(/%20/g, " ");

   this.addNoneWordAction(puzzleFooter, "Welcome, <a class='oysTextLink' href='' id='oygWelcomeLink'>" + _e + "</a>! ");
   var _f = document.getElementById("oygWelcomeLink");

   _f.onclick = function(){
      _d.askNickName();
      _d.invalidateMenu();
      return false;
   };

   this.addNewLine(puzzleFooter);
   this.addAction(puzzleFooter, "Start Now", "Starting...", "strt", function()
   {
      _d.puzz.bind();
      _d.installContextMenu();
      document.getElementById("Static").innerHTML = "";
      _d.footer.stateOk("Enjoy the game!");

   }

   );
   
   var _10 = document.getElementById("Copyright");
   this.addAction(_10, "Go!", "Leaving...", "lv", function()
   {
      window.location.href = 'http://www.the-puzzler.com/sudokuOnlineMed.html?Puzzle=' + document.getElementById('sudokuNumber').value;
   }
   );

   this.footer.stateOk("Ready to begin!");

};
/**************************************************************************************************************************/
SudokuMenu.prototype.installContextMenu = function(){

   this.currentMenu = this.installContextMenu;
   var _10 = document.getElementById("PuzzleFooter");
   _10.innerHTML = "";
   if( ! this.canReveal){
      this.addNoneWordAction(_10, "Reveal Disabled");
   } 

   if( ! this.canCheck) {
      this.addNoneWordAction(_10, "Check Disabled");
   } else {
      var _14 = this;
      this.addAction(_10, "Check <b>Square</b>", "Checking...", "chkll", function()
        {
           _14.checkSquare();
           _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();
   }
};
/**************************************************************************************************************************/
SudokuMenu.prototype.installDoneMenu = function() {

   this.currentMenu = this.installDoneMenu;
   var _17 = document.getElementById("PuzzleFooter");
   _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);
   var _19 = this;
   this.addSubmitLeaveMenuItems(_17);
   this.footer.stateOk("Game over!");
   this.footer.update();

};
/**************************************************************************************************************************/
SudokuMenu.prototype.addSubmitLeaveMenuItems = function(_1a){

   // var _1b = "Submit <b>Score</b>";
   // if(this.matches > 0 && this.scoreSubmittedMatches < this.matches)
   // {
   // var _1c = this;
   // this.addAction(_1a, _1b, "Submitting score...", "sbmt", function()
   // {
   // _1c.submitScore();
   // _1c.invalidateMenu();
   // return false;
   // }
   // );
   // }
   // else
   // {
   // this.addAction(_1a, _1b, "", null, null);
   // }
   var _1c = this;
   this.addAction(_1a, "Leave <b>Game</b>", "Leaving...", "lv", function()
     {
       _1c.leaveGameEarly(_1c.puzz.leaveGameUrl);
       _1c.footer.stateOk("Done");
       return false;

     }
   );
};
/**************************************************************************************************************************/
SudokuMenu.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 + "/app/leaveGame.php?ns=" + this.puzz.ns;
     if(url != null){
       loc = unescape(url);
     }
     window.location = loc;
   }

   this.footer.stateOk("Done");
};
/**************************************************************************************************************************/
SudokuMenu.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 = "MenuButtonsDis";
  
     _25.onclick = function(){
       return false;
     };
   } else {
       _25.className = "MenuButtons";
 
       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);
};
/**************************************************************************************************************************/
SudokuMenu.prototype.addNewLine = function(_27){
   var _28 = document.createElement("SPAN");
   _28.innerHTML = "<span style='font-size: 4px;'><br />&nbsp;<br /></span>";
   _27.appendChild(_28);
};
/**************************************************************************************************************************/
SudokuMenu.prototype.addNoneWordAction = function(_29, _2a){

   var _2b = document.createElement("SPAN");
   _2b.className = "MenuButtonsNone";
   _2b.innerHTML = _2a;
   _29.appendChild(_2b);

   var _2b = document.createElement("SPAN");
   _2b.innerHTML = " ";
   _29.appendChild(_2b);
};
/**************************************************************************************************************************/
SudokuMenu.prototype.addCheckWordAction = function(_2c, _2d, _2e){

   var _2f = this;
   this.addAction(_2d, _2e, "Checking...", "chk", function()
   {
      _2f.invalidateMenu();
      return false;
   }
   );
};
/**************************************************************************************************************************/
SudokuMenu.prototype.addRevealWordAction = function(_30, _31, _32){

   var _33 = this;
   this.addAction(_31, _32, "Revealing...", "rvl", function()
   {
      _33.revealWord(_30);
      _33.invalidateMenu();
      return false;
   }
   );
};
/**************************************************************************************************************************/
SudokuMenu.prototype.getCurrentValueFor = function(x, y){

   var _36 = this.inputCache.getElement(x, y).value;
   if(_36 == " " || _36 == "")
   {
      _36 = null;
   }
   return _36;
};
/**************************************************************************************************************************/
SudokuMenu.prototype.charToPos = function(_3c, _3d){

   pos.x = _3c.xpos;
   pos.y = _3c.ypos + _3d;
   return pos;
};
/**************************************************************************************************************************/
SudokuMenu.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 = "GuessedCell";
               break;
            case 2 :
               _44.className = "RevealedCell";
               break;
            default :
               alert("Bad state code!");
         }
      }
   }

   this.puzz.invalidate();
};
/**************************************************************************************************************************/
SudokuMenu.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 + "Log-on feature is yet to come!\n" + "Scoring feature will be active soon. Enjoy the game!", 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;
   }
};
/**************************************************************************************************************************/
SudokuMenu.prototype.getScoreForMatch = function(_4c){
   return _4c.len;
};
/**************************************************************************************************************************/
SudokuMenu.prototype.getDeductsForReveal = function(_4d){
   return _4d.len * 2;
};
/**************************************************************************************************************************/
SudokuMenu.prototype.getDeductionForCheck = function(_4e){
   var _4f = 3;
   var _50 = (_4e.len - _4e.len % _4f) / _4f;
   if(_50 < 1){
      _50 = 1;
   }
   return _50;
};
/**************************************************************************************************************************/
SudokuMenu.prototype.revealWord = function(_51){
   this.deducts += this.getDeductsForReveal(_51);
   this.reveals ++ ;
   this.showAnswer(_51, 2);
   _51.revealed = true;
   _51.matched = false;
};
/**************************************************************************************************************************/
SudokuMenu.prototype.checkSquare = function(){
  var ValidSquare = false;
  if ((this.xpos < 0) || (this.ypos < 0)){
    var outstr = "Valid Square not selected!";
   } else {
      var cellSelected = this.inputCache.getElement(this.xpos, this.ypos);
      if (cellSelected.readOnly) {
	    var outstr = "Cell selected is read only!";  
	  } else {
	      if (cellSelected.value != "") {
	        ValidSquare = true;
			
			var myArray = this.clues[this.ypos].solutionlist.split(",");
			  if (myArray[this.xpos] == cellSelected.value) {
			    var _44 = document.getElementById("oyCell" + this.xpos + "_" + this.ypos);
				_44.className = "RevealedCell";				
			    var outstr = "Match Found!";
                this.footer.stateOk(outstr); 
			  } else {
			    var outstr = "Does Not Match!";
                this.footer.stateOk(outstr); 
			  }
			  			
		  } else {
		      var outstr = "Cell selected must have a value to check against!"; 
		  }
		}
   }
   
   if (! ValidSquare) {
     this.footer.stateError(outstr);
   }

  // if ((MakeTheTable) && ! (ScoreAdded)) {
  //    ScoreAdded = true;
  //    addRow('mytable');
  //    this.footer.stateOk(outstr + "<br>Congratulations, you made a high score!<br>Please enter your name below and hit \"Submit\"");
  // } else {
  //     this.footer.stateOk(outstr + "<br>Sorry, didn't make the high scores table!");
  // }
   
};
/**************************************************************************************************************************/
SudokuMenu.prototype.submitScore = function(nameofUser){
   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();
      var state = document.getElementById("State");
      this.server.submitScore(this, this.score, this.matches, nameofUser);
      if (state.className != "StateOk") {
         this.footer.stateBusy("Submitting score...");
      }
   }
};
/**************************************************************************************************************************/
function SudokuFooter(_1){
   this.puzz = _1;
}
/**************************************************************************************************************************/
SudokuFooter.prototype.bind = function(){
   var _2 = this;
   this.clockTime = setInterval(function(){
      _2.clockUpdate();
   }, 1000);
};
/**************************************************************************************************************************/
SudokuFooter.prototype.unbind = function(){
   clearInterval(this.clockTime);
   this.clockTime = null;
};
/**************************************************************************************************************************/
SudokuFooter.prototype.stateOk = function(_3){
   var _4 = document.getElementById("State");
   _4.innerHTML = "<b>&gt;</b> " + _3 + "&nbsp;";
   _4.className = "StateOk";
};
/**************************************************************************************************************************/
SudokuFooter.prototype.stateBusy = function(_5){
   var _6 = document.getElementById("State");
   _6.innerHTML = "<b>&gt;</b> " + _5 + "&nbsp;";
   _6.className = "StateBusy";
};
/**************************************************************************************************************************/
SudokuFooter.prototype.stateError = function(_7){
   var _8 = document.getElementById("State");
   _8.innerHTML = "<b>&gt;</b> " + _7 + "&nbsp;";
   _8.className = "StateError";
};
/**************************************************************************************************************************/
SudokuFooter.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>";
   }
};
/**************************************************************************************************************************/
SudokuFooter.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.isOpera = false;
   this.isChrome = 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;
               this.isChrome = true;
            } else {
               if(navigator.userAgent.indexOf("Opera") != - 1) {
                  this.browser = "Opera";
                  this.isOpera = true;
                  reg = /(Opera)(.)(\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("Chrome") != - 1) {
                     this.browser = "Chrome";
                     this.isChrome = true;
                  }
               }
            }
         }
      }
   }

   if((this.isIE && this.version >= 5) || (this.isNetscape && this.version >= 6) || (this.isFirefox && this.version >= 1) || (this.isOpera && this.version >= 9) || (this.isChrome)) {
      this.isGood = true;
   }
}
/**************************************************************************************************************************/
function Connect(_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+, Chrome 1.0+ and Opera 9.0+ versions.\n\n" + "It might still work OK, do you want to try?";

      if(confirm(msg)) {
         _2c = true;
      }
   }

   if( ! _2c){
      Error = "This browser is not supported.";
   }  else {
      var div = document.getElementById("MainContext");
      if(div == null) {
         Error = "Bad template file.";
      } else {
         var _2f = document.getElementById("Puzzle");
         if(_2f == null) {
            Error = "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);
};
/**************************************************************************************************************************/
Initialise = true;
Error = null;
/**************************************************************************************************************************/
function SudokuPuzzle(_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.leaveGameUrl = null;
   this.copyrightGameUrl = null;
   this.publisher = null;
   this.menu = null;
   this.canReveal = true;
   this.canCheck = true;
   this.reorderClues();
   this.started = false;
};
/**************************************************************************************************************************/
SudokuPuzzle.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.hlist = [];

   for(var i = 0; i < _a.length; i ++ ){
      this.hlist.push(_a[i]);
   }

   for(var i = 0; i < this.clues.length; i ++ ) {
      if(this.clues[i] == null) {
         continue;
      }
      this.hlist.push(this.clues[i]);
   }
   this.clues = _9;
};
/**************************************************************************************************************************/
SudokuPuzzle.prototype.init = function() {

   var _d = this;
   document.getElementById("aHeader").innerHTML = "<span class='HeaderTitle'>" + 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 id='Copyright' class='oyCopyright' colspan='3' align='center'>" + cr;
   _e += "<input type=text  id='sudokuNumber' name='mytext' />";
   _e += "</table>";
     
   document.getElementById("Footer").innerHTML = _e;
   
   this.footer = new SudokuFooter(this);
   this.footer.stateBusy("Starting up...");
   this.menu = new SudokuMenu(this);
};
/**************************************************************************************************************************/
SudokuPuzzle.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>";
      var rowNum = i % 3;
      for(var j = 0; j < this.w; j ++ ) {
         var colNum = j % 3;
         if ((colNum == 0) && (rowNum == 0)) {
            row += "<td class='ReadOnlyTopLeftCell' id='oyCell"+j+"_"+i+"'></td>";
         } else if ((colNum == 1) && (rowNum == 0)) {
            row += "<td class='ReadOnlyTopCell' id='oyCell"+j+"_"+i+"'></td>";
         } else if ((colNum == 2) && (rowNum == 0)) {
            row += "<td class='ReadOnlyTopRightCell' id='oyCell"+j+"_"+i+"'></td>";
         } else if ((colNum == 0) && (rowNum == 1)) {
            row += "<td class='ReadOnlyLeftCell' id='oyCell"+j+"_"+i+"'></td>";
         } else if ((colNum == 2) && (rowNum == 1)) {
            row += "<td class='ReadOnlyRightCell' id='oyCell"+j+"_"+i+"'></td>";
         } else if ((colNum == 0) && (rowNum == 2)) {
            row += "<td class='ReadOnlyBottomLeftCell' id='oyCell"+j+"_"+i+"'></td>";
         } else if ((colNum == 1) && (rowNum == 2)) {
            row += "<td class='ReadOnlyBottomCell' id='oyCell"+j+"_"+i+"'></td>";
         } else if ((colNum == 2) && (rowNum == 2)) {
            row += "<td class='ReadOnlyBottomRightCell' id='oyCell"+j+"_"+i+"'></td>";
         } else {
            row += "<td class='ReadOnlyCell' 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("PuzzleFooter");
   _19.style.width = _18;
   var _19 = document.getElementById("State");
   _19.style.width = _18;
   var _19 = document.getElementById("Puzzle");
   _19.style.width = _18;
   _19.innerHTML = buf;
   this.renderVert();
};
/**************************************************************************************************************************/
SudokuPuzzle.prototype.renderVert = function(){

   for(var i = 0; i < this.hlist.length; i ++ ) {
      var myArray = this.hlist[i].initalList.split(",");
      for(var j = 0; j < myArray.length; j ++ ) {
         var key = "oyCell" + j + "_" + i;
         var _1d = document.getElementById(key);
         if (myArray[j] != ""){
           _1d.className = "ReadOnlyCell";
         } else {
            _1d.className = "InputWhiteCell";
         }
      }
   }

};
/**************************************************************************************************************************/
SudokuPuzzle.prototype.fillHorz = function(_22, idx) {

   var myArray = _22.initalList.split(",");
   for(var i = 0; i < myArray.length; i ++ ) {
      var key = "oyCell" + idx + "_" + i;
      var _26 = document.getElementById(key);
      this.fillIn(_26, idx, i);
      this.menu.setCellState(idx, i, myArray[i]);
   }
};
/**************************************************************************************************************************/
SudokuPuzzle.prototype.fillIn = function(_2c, x, y) {
   
   var colNum = x % 3;
   var rowNum = y % 3;

   if ((colNum == 0) && (rowNum == 0)) {
      _2c.innerHTML = "<input id='oyInput"+x+"_"+y+"' class='oyCellInputTopLeft' autocomplete='off' type='text' size='1' maxlength='2' value=''>";
   } else if ((colNum == 1) && (rowNum == 0)) {
      _2c.innerHTML = "<input id='oyInput"+x+"_"+y+"' class='oyCellInputTop' autocomplete='off' type='text' size='1' maxlength='2' value=''>";
   } else if ((colNum == 2) && (rowNum == 0)) {
      _2c.innerHTML = "<input id='oyInput"+x+"_"+y+"' class='oyCellInputTopRight' autocomplete='off' type='text' size='1' maxlength='2' value=''>";
   } else if ((colNum == 0) && (rowNum == 1)) {
      _2c.innerHTML = "<input id='oyInput"+x+"_"+y+"' class='oyCellInputLeft' autocomplete='off' type='text' size='1' maxlength='2' value=''>";
   } else if ((colNum == 2) && (rowNum == 1)) {
      _2c.innerHTML = "<input id='oyInput"+x+"_"+y+"' class='oyCellInputRight' autocomplete='off' type='text' size='1' maxlength='2' value=''>";
   } else if ((colNum == 0) && (rowNum == 2)) {
      _2c.innerHTML = "<input id='oyInput"+x+"_"+y+"' class='oyCellInputBottomLeft' autocomplete='off' type='text' size='1' maxlength='2' value=''>";
   } else if ((colNum == 1) && (rowNum == 2)) {
      _2c.innerHTML = "<input id='oyInput"+x+"_"+y+"' class='oyCellInputBottom' autocomplete='off' type='text' size='1' maxlength='2' value=''>";
   } else if ((colNum == 2) && (rowNum == 2)) {
      _2c.innerHTML = "<input id='oyInput"+x+"_"+y+"' class='oyCellInputBottomRight' autocomplete='off' type='text' size='1' maxlength='2' value=''>";
   } else {
      _2c.innerHTML = "<input id='oyInput"+x+"_"+y+"' class='oyCellInput' autocomplete='off' type='text' size='1' maxlength='2' value=''>";
   }
};
/**************************************************************************************************************************/
SudokuPuzzle.prototype.bind = function(){

   var _35 = 0;
   for(var i = 0; i < this.clues.length; i ++ ){
     this.fillHorz(this.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);
      }
   }
   for(var i = 0; i < this.hlist.length; i ++ ) {
      var numberList = this.hlist[i].initalList.split(",");
      for(j = 0; j < numberList.length; j ++ ) {
         var _42 = this.inputCache.getElement(j, i);
         if (_42 != null) {
            _42.value = numberList[j];
            if (_42.value != "") {
               _42.readOnly = true;
            } else {
               _42.readOnly = false;
            }
         }
      }
   }

   this.menu.bind();
   this.footer.bind();
   this.footer.update();
   this.started = true;
};
/**************************************************************************************************************************/
SudokuPuzzle.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.footer.unbind();
   this.menu.unbind();
};
/**************************************************************************************************************************/
SudokuPuzzle.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);
      };
   }
};
/**************************************************************************************************************************/
SudokuPuzzle.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 = "FocusedCell";
         } else {
            this.restoreCellState(_47, all[i].x, all[i].y);
         }
      }
   }
};
/**************************************************************************************************************************/
SudokuPuzzle.prototype.focusNewCell = function(x, y, _50, _51){
   if(_51 != null) {
      this.focused = _51;
   }
   
   var _52 = document.getElementById("oyCell" + x + "_" + y);
   if(_52 != null) {
      _52.className = "oyCellActive";
      if(_50) {
         var _52 = this.inputCache.getElement(x, y);
         if (_52 != null) {
            _52.focus();
         }
      }
   }

   if (_52 != null) {
      this.xpos = x;
      this.ypos = y;
      this.menu.focusNewCell(x, y);
      this.menu.invalidateMenu();
   }

};
/**************************************************************************************************************************/
SudokuPuzzle.prototype.unfocusOldCell = function() {

   var _53 = document.getElementById("oyCell" + this.xpos + "_" + this.ypos);
   if(_53 != null) {
      this.restoreCellState(_53, this.xpos, this.ypos);
   }
};
/**************************************************************************************************************************/
SudokuPuzzle.prototype.invalidate = function() {
   this.unfocusOldCell();
   this.focusNewCell(this.xpos, this.ypos, true);
};
/**************************************************************************************************************************/
SudokuPuzzle.prototype.restoreCellState = function(_54, x, y) {

   var _57 = this.menu.getCellState(y, x);
   if (_57 != "") {
      _54.className = "ReadOnlyCell";
   } else {
      _54.className = "InputWhiteCell";
   }
};
/**************************************************************************************************************************/
SudokuPuzzle.prototype.isValidChar = function(c){
   return (c >= "A" && c <= "Z") || c == " ";
};
/**************************************************************************************************************************/
SudokuPuzzle.prototype.isValidNumber = function(c) {
   return (c >= "1" && c <= "9");
};
/**************************************************************************************************************************/
SudokuPuzzle.prototype.moveToPrevCell = function(x, y) {
   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();
      }
   }
};
/**************************************************************************************************************************/
SudokuPuzzle.prototype.moveToNextCell = function(x, y) {
   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();
      }
   }
};
/**************************************************************************************************************************/
SudokuPuzzle.prototype.CheckWithBoundary = function(xpos1, ypos1, xpos2, ypos2, keyPress)
{

   var foundKey = false;
   for(var i = xpos1; i <= xpos2; i ++ ) {
      for(var j = ypos1; j <= ypos2; j ++ ) {

         var _66 = this.inputCache.getElement(j, i);
         if (_66.value == keyPress) {
            foundKey = true;
            return true;
            break;
         }
      }
      if (foundKey == true) {
         break;
      }
   }

}
;
/**************************************************************************************************************************/
SudokuPuzzle.prototype.KeyPressedinBox = function(a1, keyPress){

   if ((this.xpos >= 0) && (this.xpos <= 2) && (this.ypos >= 0) && (this.ypos <= 2)) {
      if (this.CheckWithBoundary(0, 0, 2, 2, keyPress) == true) {
         return true;
      } else {
         return false;
      }
   } else if ((this.xpos >= 2) && (this.xpos <= 5) && (this.ypos >= 0) && (this.ypos <= 2)) {
      if (this.CheckWithBoundary(0, 3, 2, 5, keyPress) == true) {
         return true;
      } else {
         return false;
      }
   } else if ((this.xpos >= 6) && (this.xpos <= 8) && (this.ypos >= 0) && (this.ypos <= 2)) {
      if (this.CheckWithBoundary(0, 6, 2, 8, keyPress) == true) {
         return true;
      } else {
         return false;
      }
   } else if ((this.xpos >= 0) && (this.xpos <= 2) && (this.ypos >= 3) && (this.ypos <= 5)) {
      if (this.CheckWithBoundary(3, 0, 5, 2, keyPress) == true) {
         return true;
      } else {
         return false;
      }
   } else if ((this.xpos >= 3) && (this.xpos <= 5) && (this.ypos >= 3) && (this.ypos <= 5)) {
      if (this.CheckWithBoundary(3, 3, 5, 5, keyPress) == true) {
         return true;
      } else {
         return false;
      }
   } else if ((this.xpos >= 6) && (this.xpos <= 8) && (this.ypos >= 3) && (this.ypos <= 5)) {
      if (this.CheckWithBoundary(3, 6, 5, 8, keyPress) == true) {
         return true;
      } else {
         return false;
      }
   } else if ((this.xpos >= 0) && (this.xpos <= 2) && (this.ypos >= 6) && (this.ypos <= 8)) {
      if (this.CheckWithBoundary(6, 0, 8, 2, keyPress) == true) {
         return true;
      } else {
         return false;
      }
   } else if ((this.xpos >= 3) && (this.xpos <= 5) && (this.ypos >= 6) && (this.ypos <= 8)) {
      if (this.CheckWithBoundary(6, 3, 8, 5, keyPress) == true) {
         return true;
      } else {
         return false;
      }
   } else if ((this.xpos >= 6) && (this.xpos <= 8) && (this.ypos >= 6) && (this.ypos <= 8)) {
      if (this.CheckWithBoundary(6, 6, 8, 8, keyPress) == true) {
         return true;
      } else {
         return false;
      }
   }

};
/**************************************************************************************************************************/
SudokuPuzzle.prototype.KeyPressInRow = function(a1, keyPress) {
   if (this.CheckWithBoundary(this.ypos, 0, this.ypos, 8, keyPress) == true)  {
      return true;
   } else {
      return false;
   }
};
/**************************************************************************************************************************/
SudokuPuzzle.prototype.KeyPressInColumn = function(a1, keyPress){

   if (this.CheckWithBoundary(0, this.xpos, 8, this.xpos, keyPress) == true) {
      return true;
   } else {
      return false;
   }
};
/**************************************************************************************************************************/
SudokuPuzzle.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.isValidNumber(c)) {
      var _66 = this.inputCache.getElement(x, y);
      if( ! _66.readOnly) {
         if (this.KeyPressedinBox(_66, c) == true) {
            this.footer.stateError("Number already in box");
         } else if (this.KeyPressInRow(_66, c) == true) {
            this.footer.stateError("Number already in row");
         } else if (this.KeyPressInColumn(_66, c) == true) {
            this.footer.stateError("Number already in column");
         } else {
            _66.value = c;
         }
      }
   }
   return false;
};
/**************************************************************************************************************************/
SudokuPuzzle.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);
   if(dir) {
     var _6c = null;
     switch(_6a)
     {
        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) {
       var moveToPosition = true;
       if (_6c.readOnly == true) {
         i = 1;
         if  (_6a == 37) {
           while (_6c.readOnly == true) {
             if ((x - i) < 0 ) {
               moveToPosition = false;
               break;
             }
             _6c = this.inputCache.getElement(x - i, y);
             if (_6c.readOnly) {
               i = i + 1
             };
           }
           if (moveToPosition) {
             this.unfocusOldCell();
             this.focusNewCell(x - i, y, false);
             _6c.focus();
           }
         } else if  (_6a == 38) {
             while (_6c.readOnly == true) {
               if ((y - i) < 0 ) {
                 moveToPosition = false;
                 break;
               }
               _6c = this.inputCache.getElement(x, y - i);
               if (_6c.readOnly) {
                 i = i + 1
               };
             }
             if (moveToPosition) {
			   this.unfocusOldCell();
               this.focusNewCell(x, y - i, false);
               _6c.focus();
             }
           } else if  (_6a == 39) {
               while (_6c.readOnly == true) {
                 if ((x + i) > 8) {
                   moveToPosition = false;
                   break;
                 }
                 _6c = this.inputCache.getElement(x + i, y);
                 if (_6c.readOnly) {
                   i = i + 1 
				 };
               }
               if (moveToPosition) {
                 this.unfocusOldCell();
                 this.focusNewCell(x + i, y, false);
                 _6c.focus();
               }
            } else if  (_6a == 40) {
                while (_6c.readOnly == true) {
                  if ((y + i) > 8) {
                    moveToPosition = false;
                    break;
                  }
                  _6c = this.inputCache.getElement(x, y + i);
                  if (_6c.readOnly) {
                    i = i + 1
                  };
               }
               if (moveToPosition) {
                 this.unfocusOldCell();
                 this.focusNewCell(x, y + i, false);
                 _6c.focus();
               }
            }
         } else {
             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 CompletionPort(_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);
}
/**************************************************************************************************************************/
CompletionPort.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();
};
/**************************************************************************************************************************/
CompletionPort.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 Server(_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/submitScore2.php";
};
/**************************************************************************************************************************/
Server.prototype.computeMatrix = function(_7) {

   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;
};
/**************************************************************************************************************************/
// Server.prototype.trackAction = function(_c, _d)
// {
// if(_d != null)
// {
// var _e = escape(_c);
// var _f = "uid=" + _e + "&ns=" + escape(this.ns) + "&verb=" + escape(_d);
// var _10 = this.md5.hex_hmac_md5(_e, _f);
// var _11 = "data=" + escape(_f) + "&sign=" + _10 + "&seq=" + this.trackSeq;
// var url = this.trackURL + "?" + _11;
// document.getElementById("oygTrackAction").src = url;
// this.trackSeq ++ ;
// }
// }
// ;
/**************************************************************************************************************************/
Server.prototype.submitScore = function(_13, _15, _19, nameOfUser) {
   var url = this.submitURL + "?" + "name=" + nameOfUser + "&score=" + _15;
   this.submitScoreAjaxAnywhere(this.ep, _13, url, _19, _15);
};
/**************************************************************************************************************************/
Server.prototype.submitScoreAjaxAnywhere = function(ep, _25, url, _27, score) {

   var _28 = _25;
   var cp = new CompletionPort(ep, url);
   cp.onComplete = function() {
     _28.scoreSubmittedMatches = _27;
     _28.invalidateMenu();
   } ;

   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();
   cp.oygSubmitScoreJSONComplete();
};
/**************************************************************************************************************************/
CompletionPort.prototype.oygSubmitScoreJSONComplete = function() {

   //   var oygSubmitScoreCompletionPoint;
   // var cp = oygSubmitScoreCompletionPoint;
   if(this != null) {
     var _2f = this.onComplete;
     var _30 = this.onError;
     this.finit();
     if(_2f != null) {
       _2f();
     }
   }
};
/**************************************************************************************************************************/
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;
};
/**************************************************************************************************************************/
/**************************************************************************************************************************/