
    <!--
      var currFieldName='';
      var currFieldOverName='';
      var currFieldOver;
      var blinkCount=0;
      var blinkInterval;

      var puzzleBasePath;
      var movePlace = new Array(1000);
      var moveVal = new Array(1000);
      var cellNames = new Array(100);
      var msgStrings = new Array(100);
      var cellFields = new Array(100);
      var cellClass = new Array(100);
      var mirrorVal = new Array(100);
      var cellNumFields = new Array(16);
      var bars = new Array(10);
      var chars = new Array(10);
      var counts = new Array(10);
      var numCount = new Array(12);
      var cur1,cur2,cur3,cur4,cur5,cur6,cur7,cur8,cur9,curX;
      var SudTable;
      var SudForm;
      var numMoves = 0;  
      var timerID = 0;
      var newGameTimerID = 0;
      var newGameTimerCount = 0;
      var effectTimerID = 0;
      var effectState = 0;
      var effectField = 0;
      var effectTimerCountValue = 10;
      var effectTimerCount = effectTimerCountValue;
      var effectTimerTimeoutValue = 150;
      var saveFieldBgnd="#ffffff";
      var tStart  = null;
      var currMouseValue = 'P';
      var loaded = 0;
      var loading = 0;
      var initEnded = 0;
      var firstTime = 1;
      var busy = 1;
      var gameEnded = 0;
      var cookie_name = "sudoku";
      var enablePoints = 1;
 
      var bravoTimerID;
      var bravoTimeout;
      var imgX;
      var imgY;
      var numBravoMoves;
      var stars;
      var imgX;
      var imgY;
      var bravoX;
      var bravoY;
      var startX;
      var startY;
      var numStars;
      var bravo;
      var cellTmp='0';
      var newGameLevel;

      rnd.today=new Date(); rnd.seed=rnd.today.getTime();

     function rnd() 
      {
        rnd.seed = (rnd.seed*9301+49297) % 233280;
        return rnd.seed/(233280.0);
      }

      function rand1(modulo) 
      {
        return Math.ceil(rnd()*modulo)-1;
      }

      function randOffset(offset) 
      {
        if ( Math.ceil(rnd()*2) == 2 ) return -offset;
        else return offset;
      }

      function randStep(step) 
      {
        if ( Math.ceil(rnd()*2) == 2 ) return -step;
        else return step;
      }

      function LoadBars()
      {
        try {
          for (i = 1; i < 9; i++)
          {
            for (j = 1; j < 9; j++)
            {
              bars[j] = i;
            }
          }
        }
        catch(err)
        {
	   alert("Error in function LoadBars : "+err.description);
        }
      }

      function Init()
      {
        try {
           if ( loaded==1 ) return;
           //if ( loading==1 ) return;
           //LoadBars();
           //LoadChars();
           LoadCurs();
           //LoadCounts();
           //initEnded = 1;
        }
        catch(err)
        {
	   alert("Error in function init : "+err.description);
        }
      }

      function getRealLeft(obj) 
      {
         xPos = obj.offsetLeft;
         tempEl = obj.offsetParent;

         while (tempEl != null) 
         {
           xPos += tempEl.offsetLeft;
           tempEl = tempEl.offsetParent;
         }

         return xPos;
      }

      function getRealTop(obj) 
      {
         yPos = obj.offsetTop;
         tempEl = obj.offsetParent;

         while (tempEl != null) 
         {
           yPos += tempEl.offsetTop;
           tempEl = tempEl.offsetParent;
         }

         return yPos;
      }

      function InitBravo() 
      {
        stars = new Array();
        imgX = new Array();
        imgY = new Array();
        numStars=10;
        var name;
        var str;
        var a55;
        var i;

        a55 = document.getElementById('A55');
        startX=getRealLeft(a55);
        startY=getRealTop(a55);

        for (i=0; i<numStars; i++)
        {
          id='str'+i;
          stars[i]= document.getElementById(id);
          imgX[i]=startX+(rand1(10)*randOffset(rand1(30)));
          imgY[i]=startY+(rand1(10)*randOffset(rand1(30)));
          stars[i].style.width = 30;
          stars[i].style.height = 30;
          stars[i].style.left=imgX[0]+'px';
          stars[i].style.top=imgY[0]+'px';
          stars[i].style.visibility='visible';
          name = 'images/bravo/star'+i+'.png';
          str  = "url("+name+")";
          stars[i].style.backgroundImage=str;
        }
 
        bravoX=getRealLeft(a55);
        bravoY=getRealTop(a55);
        bravo= document.getElementById('bravo');
        name = 'images/bravo/bravo.png';
        str  = "url("+name+")";
        bravo.style.backgroundImage=str;
        bravo.style.width = 140;
        bravo.style.height = 24;
        bravo.style.left=bravoX+'px';
        bravo.style.top=bravoY+'px';
        bravo.style.visibility='visible';

        numBravoMoves=55;
        bravoTimeout=70;
        bravoTimerID  = setTimeout("MoveImg()", bravoTimeout);
      }

      function MoveImg()
      {
        for (j=0;j<numStars; j++)
        {
          imgX[j]+=randStep(rand1(10));
          imgY[j]+=randStep(rand1(10));
          stars[j].style.left=imgX[j]+'px';
          stars[j].style.top=imgY[j]+'px';
        }

        bravoX+=randStep(rand1(4));
        bravoY+=randStep(rand1(4));
        bravo.style.left=bravoX+'px';
        bravo.style.top=bravoY+'px';

        bravoTimeout=80;
        if (numBravoMoves>0)
        {
          numBravoMoves--;
          bravoTimerID  = setTimeout("MoveImg()", bravoTimeout);
        }
        else
        {
          for (i=0; i<numStars; i++)
          {
            stars[i].style.visibility='hidden';
          }
          bravo.style.visibility='hidden';
          clearTimeout(bravoTimerID);
        }
      }

      function LoadChars()
      {
        try {
          for (i = 1; i < 9; i++)
          {
            for (j = 1; j < 9; j++)
            {
              chars[j] = i;
            }
          }
        }
        catch(err)
        {
	   alert("Error in function LoadChars : "+err.description);
        }
      }

      function PrintTable() 
      {
        if ( loaded!=1 ) return;
        try 
        {
             var num = document.getElementById("NumSudParam").value;
             var ourSite = document.getElementById("OurSite").value;
             if ( ourSite == 1 )
             {
             window.open(puzzleBasePath+"/downloadSudoku.php?ourSite=1&num="+num,
                          "creation",
                          "width=840,height=920,toolbar=0,scrollbars=1,location=0,status=1,menubar=1,resizable=0");
             }
             else
             {
             window.open(puzzleBasePath+"/downloadSudoku.php?num="+num,
                          "creation",
                          "width=840,height=920,toolbar=0,scrollbars=1,location=0,status=1,menubar=1,resizable=0");
             }
        }
        catch(err)
        {
	   alert("Error in function PrintTable : "+err.description);
        }
      }

      function S0( text, color, blink)  
      {
        try {
        SudForm.SudokuStatus.style.color=color;
        SudForm.SudokuStatus.value=text;
        if (blink)
        {
          startBlink();
        }
        }
        catch(err)
        {
	   alert("Error in function S0 : "+err.description);
        }
      }

      function HandleMouseOver ( fieldName )
      {
        if ( loaded!=1 ) return;
        try 
        {
          if ( loaded==1 )
          {
            currFieldOverName = fieldName;
            currFieldOver=cellFields[GetIndexByCellName(fieldName)];
	    currFieldOver.style.cursor=SudTable.style.cursor; 
          }
        }
        catch(err)
        {
	   alert("Error in function HandleMouseOver : "+err.description);
        }
      }

      function HandleMouseOut ( fieldName )
      {
        if ( loaded!=1 ) return;
        try {
        //document.getElementsByName(fieldName)[0].style.background='white'; 
        //document.getElementsByName(fieldName)[0].style.border='2px solid #fff'; 
        //document.getElementsByName(fieldName)[0].style.bordercolor='#ffffff'; 
        }
        catch(err)
        {
	   alert("Error in function HandleMouseOut : "+err.description);
        }
      }

      function HandleFieldFocus ( cellName )
      {
        if ( loaded!=1 ) return;
        try {
        currFieldName = cellName;
        }
        catch(err)
        {
	   alert("Error in function HandleFieldFocus : "+err.description);
        }
      }

      function HandleMouseClick ( cellName )
      {        
         if ( effectTimerCount < effectTimerCountValue ) return;
         if ( loaded!=1 ) return;
         try
         {
           var currVal;
           currFieldName = cellName;

	   //alert ("a="+document.getElementsByName(cellName)[0].readOnly);

          if ( !document.getElementsByName(cellName)[0].readOnly )
          {
           if ( ( currMouseValue >= '1' ) && ( currMouseValue <= '9' ) )
           {
             SetValue ( cellName, 1, currMouseValue );
           }
           else if ( currMouseValue == 'X' )
           {
             SetValue ( cellName, 0, ' ' );
           }
          }
        }
        catch(err)
        {
	   alert("Error in function HandleMouseClick : "+err.description);
        }
      }

      function ChangeVal(e) 
      {
        if ( loaded!=1 ) return;

        try 
        {
          var Key;
          var fieldId;
          var val;
          var valStr;
          var currVal;
          var conflictCellName = "";

          ClearStatus();

          if ( effectTimerCount < effectTimerCountValue ) return;
          if (currFieldName == '') return;

	  if (!e) var e = window.event;

          if (document.all)
          {
            Key = window.event.keyCode;
          }
          else
          {
            if (e)
            {
   	      if (e.which) Key = e.which;
	      else if (e.keyCode) Key = e.keyCode;
            }
          }
	
          fieldId = document.getElementsByName(currFieldName)[0].id; 

          if (Key == 27) return;

          if (fieldId.charAt(0)=='A')
          { 
            currVal = document.getElementsByName(currFieldName)[0].value; 

            //alert("Key  = "+Key);
            if ((Key >= 49) && (Key<=57))
            { 
              val = Key - 48;
              conflictCellName = CheckValue ( currFieldName, val );
              valStr = String.fromCharCode(Key);
              SetValue ( currFieldName, 0, valStr );
            }
            else if ((Key >= 97) && (Key<=105))
            { 
              val = Key - 96;
              conflictCellName = CheckValue ( currFieldName, val );
	      valStr = val + '';
              SetValue ( currFieldName, 0, valStr );
            }
            else if ((Key == 8) || (Key == 46) || (Key == 110))
            { 
              val = ' ';
              SetValue ( currFieldName, 0, ' ' );
            }

            else
            {
              if ( (currVal >= 1) && (currVal<=9) )
              {
                document.getElementsByName(currFieldName)[0].value=currVal; 
              }
              else
              {
                document.getElementsByName(currFieldName)[0].value=" "; 
              }
            }

            if ( conflictCellName != "" )
            {
              if ( (currVal >= 1) && (currVal<=9) )
              {
                document.getElementsByName(currFieldName)[0].value=currVal; 
              }
              else
              {
                document.getElementsByName(currFieldName)[0].value=" "; 
              }
            }
          }
        }
        catch(err)
        {
	   alert("Error in function ChangeVal : "+err.description);
        }
      } 

      function SetValue ( cellName, highlight, value )
      {        
        var currVal;
        try
        {
           var index,val;
           var conflictCellName = "";

           currVal = document.getElementsByName(cellName)[0].value;
           if (currVal != value)
           {
             conflictCellName = CheckValue ( cellName, value );

             if ( conflictCellName == "" )
             {
               index=GetIndexByCellName(cellName);
               mirrorVal[index] = value;

               document.getElementsByName(cellName)[0].value=value;
 
               if (highlight==1) HighlightCell ( cellName );
               else ClearHighlightCell ( cellName );

               SetNumCount();
               UpdateNumButtonState();

               AddUndoStep( cellName, currVal ) ;
               if (PuzzleIsFull())
               {
                 CheckSolution();
               }
             }
             else
             {
               index=GetIndexByCellName(conflictCellName);
               effectField = document.getElementsByName(conflictCellName)[0];
               if ( cellClass[index] == 0 )
               {
                 saveFieldBgnd="#ffffff";
               }
               else
               {
                 saveFieldBgnd="#eff3f8";
               }

               StartEffectTimer();
             }
           }
           else
           {
             //alert ("currVal="+currVal);
           }
        }
        catch(err)
        {
	   alert("Error in function SetValue : "+err.description);
        }
      }


      function StartEffectTimer() 
      {
        effectTimerID  = setTimeout("UpdateEffectTimer()", 
				    effectTimerTimeoutValue);
      }

      function StopEffectTimer()
      {
        if(effectTimerID) 
        {
          clearTimeout(effectTimerID);
          effectTimerID  = 0;
          effectState = 0;
        }
      }

      function UpdateEffectTimer() 
      {
         effectTimerCount--;
         if ( effectTimerCount > 1 )
         {
           if(effectTimerID) 
           {
             clearTimeout(effectTimerID);
           }

           if ( effectState == 0 ) 
           {
             effectField.style.background = 'White'; 
             effectState = 1;
           }
           else
           {
             effectField.style.background = 'Red'; 
             effectState = 0;
           }

           effectTimerID = setTimeout("UpdateEffectTimer()",
				    effectTimerTimeoutValue);
         }
         else
         {
           if(effectTimerID) 
           {
             clearTimeout(effectTimerID);
             effectTimerCount = effectTimerCountValue;
             effectField.style.background = saveFieldBgnd;
           }
         }
      }


      function CheckValue ( cellName, value )
      {        
        try
        {
           if ( (value >= 1) && (value<=9) )
           {
             var index;
             index  = GetIndexByCellName(cellName);

             var blockNum = GetBlockByIndex( index );
             var rowNum = GetRowByIndex( index );
             var columnNum = GetColumnByIndex( index );

             //info = "info=" + blockNum + rowNum + columnNum;
             //alert(info);

             cellName = CheckIfValueExistInRow(rowNum,value);
             if ( cellName != "" )
             {
               //alert("value found in " + cellName );
               return cellName;
             }

             cellName = CheckIfValueExistInColumn(columnNum,value);
             if ( cellName != "" )
             {
               //alert("value found in " + cellName );
               return cellName;
             }

             cellName = CheckIfValueExistInBlock(blockNum,value);
             if ( cellName != "" )
             {
               //alert("value found in " + cellName );
               return cellName;
             }
           }

           return "";
        }
        catch(err)
        {
	   alert("Error in function CheckValue : "+err.description);
        }
      }

      function CheckIfValueExistInRow(rowNum,value)
      {
        var cellValue;

        for (j=1; j<=9; j++)
        {
          var cellName = "A" + rowNum.toString() + j.toString();
          if ( document.getElementsByName(cellName)[0].value == value )
          {
            return cellName;
          }
        }

        return "";
      }


      function CheckIfValueExistInColumn(columnNum,value)
      {
        var cellValue;

        for (j=1; j<=9; j++)
        {
          var cellName = "A" + j.toString() + columnNum.toString();
          if ( document.getElementsByName(cellName)[0].value == value )
          {
            return cellName;
          }
        }

        return "";
      }

      function CheckIfValueExistInBlock(blockNum,value)
      {
        for (r=1; r<=3; r++)
        {
          for (c=1; c<=3; c++)
          {
            i = r + (Math.floor(blockNum / 3)) * 3;
            j = c + (blockNum % 3) * 3;
            var cellName = "A" + i.toString() + j.toString();
            if ( document.getElementsByName(cellName)[0].value == value )
            {
              return cellName;
            }
          }
        }

        return "";
      }


      function FillSolution() 
      {
        if ( loaded!=1 ) return;
        try 
        {
          for (i = 1; i <= 9; i++)
          {
            for (j = 1; j <= 9; j++)
            {
              var cellName = "A" + i.toString() + j.toString();
              document.getElementsByName(cellName)[0].value =
                       document.getElementsByName(cellName)[0].id.charAt(3);
            }
          }
        }
        catch(err)
        {
	   alert("Error in function FillSolution : "+err.description);
        }
      }


      function InitCellClass()
      {
        try 
        {
          for (j = 0; j <= 80; j++)
          {
            cellClass[j] = 0;
          }
          cellClass[3] = 1;
          cellClass[4] = 1;
          cellClass[5] = 1;
          cellClass[12] = 1;
          cellClass[13] = 1;
          cellClass[14] = 1;
          cellClass[21] = 1;
          cellClass[22] = 1;
          cellClass[23] = 1;

          cellClass[27] = 1;
          cellClass[28] = 1;
          cellClass[29] = 1;
          cellClass[36] = 1;
          cellClass[37] = 1;
          cellClass[38] = 1;
          cellClass[45] = 1;
          cellClass[46] = 1;
          cellClass[47] = 1;

          cellClass[33] = 1;
          cellClass[34] = 1;
          cellClass[35] = 1;
          cellClass[42] = 1;
          cellClass[43] = 1;
          cellClass[44] = 1;
          cellClass[51] = 1;
          cellClass[52] = 1;
          cellClass[53] = 1;

          cellClass[57] = 1;
          cellClass[58] = 1;
          cellClass[59] = 1;
          cellClass[66] = 1;
          cellClass[67] = 1;
          cellClass[68] = 1;
          cellClass[75] = 1;
          cellClass[76] = 1;
          cellClass[77] = 1;
        }
        catch(err)
        {
	   alert("Error in function InitCellClass : "+err.description);
        }
      }

      function SetNumCount()
      {
        try 
        {
          for (i = 0; i <= 9; i++)
          {
            numCount[i]=0;
          }
          
          for (i = 0; i <= 80; i++)
          {
            value = cellFields[i].value;
            
	    switch (value)
	    {
	      case '1': numCount[1]++; break;
	      case '2': numCount[2]++; break;
	      case '3': numCount[3]++; break;
	      case '4': numCount[4]++; break;
	      case '5': numCount[5]++; break;
	      case '6': numCount[6]++; break;
	      case '7': numCount[7]++; break;
	      case '8': numCount[8]++; break;
	      case '9': numCount[9]++; break;
	      default: ;
            }
          }
        }
        catch(err)
        {
	   alert("Error in function SetNumCount : "+err.description);
        }
      }


      function UpdateNumButtonState()
      {
        try 
        {
          for (i = 1; i <= 9; i++)
          {
	    if ( numCount[i] >= 9 )
            {
              SetNumButtonDone(cellNumFields[i-1]);
            }
            else
            {
              ResetNumButton(cellNumFields[i-1]);
            }
          }
        }
        catch(err)
        {
	   alert("Error in function UpdateNumButtonState : "+err.description);
        }
      }


      function LoadCurs()
      {
        try {
          var k;
          var cellName;

          if ( loaded == 1 ) return;
          loading = 1;

          // Delete the cookies with the old names (The names now are sudoku_daily and sudoku_ve 
          // ------------------------------------------------------------
          var cookie_date = new Date ( );  // current date & time
          cookie_date.setTime ( cookie_date.getTime() - 1 );
          document.cookie = "ve_sudoku" + "= ; expires=" + cookie_date.toGMTString();

          var cookie_date = new Date ( );  // current date & time
          cookie_date.setTime ( cookie_date.getTime() - 1 );
          document.cookie = "daily_sudoku" + "= ; expires=" + cookie_date.toGMTString();

          // ------------------------------------------------------------

          puzzleBasePath = document.getElementById("PuzzleBasePath").value; 
          //alert(puzzleBasePath);
          if (puzzleBasePath == '') 
          {
            loading = 0;
            return;
          }

          cursorsPath = document.getElementById("CursorPath").value; 
          //alert(cursorsPath); 
          if (cursorsPath == '') 
          {
            loading = 0;
            return;
          }

          //msgStrings[0] = cursorsPath;
          msgStrings[0] = document.getElementById("Msg0").value; 
          if (msgStrings[0] == '') 
          {
            loading = 0;
            return;
          }

          msgStrings[1] = document.getElementById("Msg1").value; 
          if (msgStrings[1] == '') 
          {
            loading = 0;
            return;
          }

          msgStrings[2] = document.getElementById("Msg2").value; 
          if (msgStrings[2] == '') 
          {
            loading = 0;
            return;
          }

          msgStrings[3] = document.getElementById("Msg3").value; 
          if (msgStrings[3] == '') 
          {
            loading = 0;
            return;
          }

          msgStrings[4] = document.getElementById("Msg4").value; 
          if (msgStrings[4] == '') 
          {
            loading = 0;
            return;
          }

          msgStrings[5] = document.getElementById("Msg5").value; 
          if (msgStrings[5] == '') 
          {
            loading = 0;
            return;
          }

          msgStrings[6] = document.getElementById("Msg6").value; 
          if (msgStrings[6] == '') 
          {
            loading = 0;
            return;
          }

          msgStrings[7] = document.getElementById("Msg7").value; 
          if (msgStrings[7] == '') 
          {
            loading = 0;
            return;
          }

          msgStrings[8] = document.getElementById("Msg8").value; 
          if (msgStrings[8] == '') 
          {
            loading = 0;
            return;
          }

          msgStrings[9] = document.getElementById("Msg9").value; 
          if (msgStrings[9] == '') 
          {
            loading = 0;
            return;
          }

          msgStrings[10] = document.getElementById("Msg10").value; 
          if (msgStrings[10] == '') 
          {
            loading = 0;
            return;
          }

          msgStrings[11] = document.getElementById("Msg11").value; 
          if (msgStrings[11] == '') 
          {
            loading = 0;
            return;
          }

          msgStrings[12] = document.getElementById("Msg12").value; 
          if (msgStrings[12] == '') 
          {
            loading = 0;
            return;
          }

          msgStrings[13] = document.getElementById("Msg13").value; 
          if (msgStrings[13] == '') 
          {
            loading = 0;
            return;
          }

          msgStrings[14] = document.getElementById("Msg14").value; 
          if (msgStrings[14] == '') 
          {
            loading = 0;
            return;
          }

          msgStrings[15] = document.getElementById("Msg15").value; 
          if (msgStrings[15] == '') 
          {
            loading = 0;
            return;
          }

          cur1 = document.getElementById("Cur1"); 
          if (cur1 == '') 
          {
            loading = 0;
            return;
          }
          
          cur2 = document.getElementById("Cur2"); 
          if (cur2 == '') 
          {
            loading = 0;
            return;
          }

          cur3 = document.getElementById("Cur3"); 
          if (cur3 == '') 
          {
            loading = 0;
            return;
          }

          cur4 = document.getElementById("Cur4"); 
          if (cur4 == '') 
          {
            loading = 0;
            return;
          }

          cur5 = document.getElementById("Cur5"); 
          if (cur5 == '') 
          {
            loading = 0;
            return;
          }

          cur6 = document.getElementById("Cur6"); 
          if (cur6 == '') 
          {
            loading = 0;
            return;
          }

          cur7 = document.getElementById("Cur7"); 
          if (cur7 == '') 
          {
            loading = 0;
            return;
          }

          cur8 = document.getElementById("Cur8"); 
          if (cur8 == '') 
          {
            loading = 0;
            return;
          }

          cur9 = document.getElementById("Cur9"); 
          if (cur9 == '') 
          {
            loading = 0;
            return;
          }

          curX = document.getElementById("CurX"); 
          if (curX == '') 
          {
            loading = 0;
            return;
          }

          curPath = 'url(' + cursorsPath + '/n1.cur),auto';
          cur1.style.cursor = curPath;
          curPath = 'url(' + cursorsPath + '/n2.cur),auto';
	  cur2.style.cursor = curPath;
          curPath = 'url(' + cursorsPath + '/n3.cur),auto';
	  cur3.style.cursor = curPath;
          curPath = 'url(' + cursorsPath + '/n4.cur),auto';
	  cur4.style.cursor = curPath;
          curPath = 'url(' + cursorsPath + '/n5.cur),auto';
	  cur5.style.cursor = curPath;
          curPath = 'url(' + cursorsPath + '/n6.cur),auto';
	  cur6.style.cursor = curPath;
          curPath = 'url(' + cursorsPath + '/n7.cur),auto';
	  cur7.style.cursor = curPath;
          curPath = 'url(' + cursorsPath + '/n8.cur),auto';
	  cur8.style.cursor = curPath;
          curPath = 'url(' + cursorsPath + '/n9.cur),auto';
	  cur9.style.cursor = curPath;
          curPath = 'url(' + cursorsPath + '/nx.cur),auto';
	  curX.style.cursor = curPath;

          cellNumFields[0] = document.getElementById('N1');
          if (cellNumFields[0] == '') 
          {
            loading = 0;
            return;
          }

          cellNumFields[1] = document.getElementById('N2');
          if (cellNumFields[1] == '') 
          {
            loading = 0;
            return;
          }

          cellNumFields[2] = document.getElementById('N3');
          if (cellNumFields[2] == '') 
          {
            loading = 0;
            return;
          }

          cellNumFields[3] = document.getElementById('N4');
          if (cellNumFields[3] == '') 
          {
            loading = 0;
            return;
          }

          cellNumFields[4] = document.getElementById('N5');
          if (cellNumFields[4] == '') 
          {
            loading = 0;
            return;
          }

          cellNumFields[5] = document.getElementById('N6');
          if (cellNumFields[5] == '') 
          {
            loading = 0;
            return;
          }

          cellNumFields[6] = document.getElementById('N7');
          if (cellNumFields[6] == '') 
          {
            loading = 0;
            return;
          }

          cellNumFields[7] = document.getElementById('N8');
          if (cellNumFields[7] == '') 
          {
            loading = 0;
            return;
          }

          cellNumFields[8] = document.getElementById('N9');
          if (cellNumFields[8] == '') 
          {
            loading = 0;
            return;
          }

          cellNumFields[9] = document.getElementById('NX');
          if (cellNumFields[9] == '') 
          {
            loading = 0;
            return;
          }

          SudTable = document.getElementById("SudTable"); 
          if (SudTable == '') 
          {
            loading = 0;
            return;
          }

          SudForm  = document.getElementById("SudokuForm"); 
          if (SudForm == '') 
          {
            loading = 0;
            return;
          }

          k=0;

          for (i = 1; i <= 9; i++)
          {
            for (j = 1; j <= 9; j++)
            {
              cellName = "A" + i.toString() + j.toString();
	      cellNames[k] = cellName;
              cellFields[k] = document.getElementsByName(cellName)[0];
              if (cellFields[k] == '') 
              {
                loading = 0;
                return;
              }
              mirrorVal[k] = cellFields[k].value;
              k++;
            }
          }

          InitCellClass();
          numMoves=0; 

          SetNumCount();
          UpdateNumButtonState();

            /*
	    alert (  '1 count is ' + numCount[1]);
	    alert (  '2 count is ' + numCount[2]);
	    alert (  '3 count is ' + numCount[3]);
	    alert (  '4 count is ' + numCount[4]);
	    alert (  '5 count is ' + numCount[5]);
	    alert (  '6 count is ' + numCount[6]);
	    alert (  '7 count is ' + numCount[7]);
	    alert (  '8 count is ' + numCount[8]);
	    alert (  '9 count is ' + numCount[9]);
            */

          S0( msgStrings[0], "green", false);  

          var table = document.getElementById("SudokuTable");

          if (table == '') 
          {
            loading = 0;
            return;
          }

          /* Initialization code. */
          if (table.addEventListener)
          {
      	    table.addEventListener('DOMMouseScroll', handle_wheel1, false);
          }
          table.onmousewheel = handle_wheel1;

          loaded=1;


          /* Delete a cookie, just for debugging */
          /*
          var cookie_date = new Date ( );  // current date & time
          cookie_date.setTime ( cookie_date.getTime() - 1 );
          document.cookie = cookie_name + "= ; expires=" + cookie_date.toGMTString();
          */
        } 
        catch(err)
        {
	   //alert("Error in function LoadCurs : "+err.description); 
        }
      }

      function ChangeMouseSelection ( delta )
      {
        if ( loaded!=1 ) return;
        try {
	if ( delta == 1 )
        {
          if ( currMouseValue == '1' ) MouseSelection ('2');
          else if ( currMouseValue == '2' ) MouseSelection ('3');
          else if ( currMouseValue == '3' ) MouseSelection ('4');
          else if ( currMouseValue == '4' ) MouseSelection ('5');
          else if ( currMouseValue == '5' ) MouseSelection ('6');
          else if ( currMouseValue == '6' ) MouseSelection ('7');
          else if ( currMouseValue == '7' ) MouseSelection ('8');
          else if ( currMouseValue == '8' ) MouseSelection ('9');
          else if ( currMouseValue == '9' ) MouseSelection ('X');
          else if ( currMouseValue == 'X' ) MouseSelection ('1');
        }
	else 
        {
          if ( currMouseValue == 'X' ) MouseSelection ('9');
          else if ( currMouseValue == '1' ) MouseSelection ('X');
          else if ( currMouseValue == '2' ) MouseSelection ('1');
          else if ( currMouseValue == '3' ) MouseSelection ('2');
          else if ( currMouseValue == '4' ) MouseSelection ('3');
          else if ( currMouseValue == '5' ) MouseSelection ('4');
          else if ( currMouseValue == '6' ) MouseSelection ('5');
          else if ( currMouseValue == '7' ) MouseSelection ('6');
          else if ( currMouseValue == '8' ) MouseSelection ('7');
          else if ( currMouseValue == '9' ) MouseSelection ('8');
        }
        }
        catch(err)
        {
	   alert("Error in function ChangeMouseSelection : "+err.description);
        }
      }

      function LoadCounts()
      {
        try {
          for (i = 1; i < 9; i++)
          {
            for (j = 1; j < 9; j++)
            {
              counts[j] = i;
            }
          }
        }
        catch(err)
        {
	   alert("Error in function LoadCounts : "+err.description);
        }
      }

      function MouseSelection ( value )
      {
        if ( loaded!=1 ) return;
        try {
          var cellField;
          var text;
          var clearText;

          clearText = 1;

          if ( loaded==1 )
          {
            UpdateHighlightByValue ( currMouseValue, value );
	    switch (value) 
	    {
	    	case '1': 
			SudTable.style.cursor = cur1.style.cursor; 
	                //text = "Click on a square to insert \'1\'      ";
                        text = msgStrings[3];
                        clearText = 0;
		        break;
		case '2': 
			SudTable.style.cursor = cur2.style.cursor; 
	                //text = "Click on a square to insert \'2\'      ";
                        text = msgStrings[4];
                        clearText = 0;
		        break;
		case '3': 
			SudTable.style.cursor = cur3.style.cursor; 
	                //text = "Click on a square to insert \'3\'      ";
                        text = msgStrings[5];
                        clearText = 0;
		        break;
	        case '4': 
			SudTable.style.cursor = cur4.style.cursor; 
	                //text = "Click on a square to insert \'4\'      ";
                        text = msgStrings[6];
                        clearText = 0;
		        break;
	        case '5': 
			SudTable.style.cursor = cur5.style.cursor; 
	                //text = "Click on a square to insert \'5\'      ";
                        text = msgStrings[7];
                        clearText = 0;
		        break;
	        case '6': 
			SudTable.style.cursor = cur6.style.cursor; 
	                //text = "Click on a square to insert \'6\'      ";
                        text = msgStrings[8];
                        clearText = 0;
		        break;
	        case '7': 
			SudTable.style.cursor = cur7.style.cursor; 
	                //text = "Click on a square to insert \'7\'      ";
                        text = msgStrings[9];
                        clearText = 0;
		        break;
	        case '8': 
			SudTable.style.cursor = cur8.style.cursor; 
	                //text = "Click on a square to insert \'8\'      ";
                        text = msgStrings[10];
                        clearText = 0;
		        break;
	        case '9': 
			SudTable.style.cursor = cur9.style.cursor; 
	                //text = "Click on a square to insert \'9\'      ";
                        text = msgStrings[11];
                        clearText = 0;
		        break;
	        case 'X': 
			SudTable.style.cursor = curX.style.cursor; 
	                //text = "Click on a square to clear it.   ";
                        text = msgStrings[12];
                        clearText = 0;
		        break;
	        case 'P': 
			SudTable.style.cursor = 'default'; 
 	                break;
		default : ;
            }
           
            if (currFieldOverName!='')
            {
  	      //document.getElementsByName(currFieldOverName)[0].style.cursor=SudTable.style.cursor; 
  	      currFieldOver.style.cursor=SudTable.style.cursor; 
            }
 
            if ( clearText == 0 )
            {
              S0( text, "blue", false);  
            }
            else
            {
              ClearStatus();
            }

	    //HighlightMouseNum(value);

            for (i = 0; i <= 80; i++)
            {
              cellField = cellFields[i];
              /*
     	      if ( cellField.value == value )
              {
                HighlightField ( cellField );
              }
  	      else if (cellField.value == currMouseValue)
              {
                if (firstTime==0)
                {
                  ClearHighlightField ( cellField );
                }
              }
              */

              /*
	      switch (value) 
	      {
	        case '1': 
		   cellField.style.cursor = cur1.style.cursor; 
		             break;
	        case '2': 
		   cellField.style.cursor = cur2.style.cursor; 
		             break;
	        case '3': 
		   cellField.style.cursor = cur3.style.cursor; 
		             break;
	        case '4': 
		   cellField.style.cursor = cur4.style.cursor; 
		             break;
	        case '5': 
		   cellField.style.cursor = cur5.style.cursor; 
		             break;
	        case '6': 
		   cellField.style.cursor = cur6.style.cursor; 
		             break;
	        case '7': 
		   cellField.style.cursor = cur7.style.cursor; 
		             break;
	        case '8': 
		   cellField.style.cursor = cur8.style.cursor; 
		             break;
	        case '9': 
		   cellField.style.cursor = cur9.style.cursor; 
		             break;
	        case 'X': 
		   cellField.style.cursor = curX.style.cursor; 
		             break;
	        case 'P': 
		   cellField.style.cursor = 'default';
		             break;
		default : ;
	      }
              */
            }

            currMouseValue = value;
            busy = 0;

            firstTime = 0;
          }
          return false;
        }
        catch(err)
        {
	   alert("Error in function MouseSelection : "+err.description);
        }
      }

      function HighlightMouseNum ( value )
      {
        try 
        {
	  switch (currMouseValue) 
	  {
	    case '1': 
                 ClearHighlightNum(cellNumFields[0]);
		 break;
            case '2': 
                 ClearHighlightNum(cellNumFields[1]);
	         break;
	    case '3': 
                 ClearHighlightNum(cellNumFields[2]);
	         break;
	    case '4': 
                 ClearHighlightNum(cellNumFields[3]);
	         break;
	    case '5': 
                 ClearHighlightNum(cellNumFields[4]);
	         break;
	    case '6': 
                 ClearHighlightNum(cellNumFields[5]);
	         break;
	    case '7': 
                 ClearHighlightNum(cellNumFields[6]);
	         break;
	    case '8': 
                 ClearHighlightNum(cellNumFields[7]);
	         break;
	    case '9': 
                 ClearHighlightNum(cellNumFields[8]);
	         break;
	    case 'X': 
                 ClearHighlightNum(cellNumFields[9]);
		 break;
            default : ;
	  }
	  switch (value) 
	  {
	    case '1': 
                 HighlightNum(cellNumFields[0]);
		 break;
            case '2': 
                 HighlightNum(cellNumFields[1]);
	         break;
	    case '3': 
                 HighlightNum(cellNumFields[2]);
	         break;
	    case '4': 
                 HighlightNum(cellNumFields[3]);
	         break;
	    case '5': 
                 HighlightNum(cellNumFields[4]);
	         break;
	    case '6': 
                 HighlightNum(cellNumFields[5]);
	         break;
	    case '7': 
                 HighlightNum(cellNumFields[6]);
	         break;
	    case '8': 
                 HighlightNum(cellNumFields[7]);
	         break;
	    case '9': 
                 HighlightNum(cellNumFields[8]);
	         break;
	    case 'X': 
                 HighlightNum(cellNumFields[9]);
		 break;
            default : ;
	  }
        }
        catch(err)
        {
	   alert("Error in function HighlightCurrNum : "+err.description);
        }
      }

      function ClearHighlightMouseNum()
      {
        try 
        {
          ClearHighlightNum('N1');
          ClearHighlightNum('N2');
          ClearHighlightNum('N3');
          ClearHighlightNum('N4');
          ClearHighlightNum('N5');
          ClearHighlightNum('N6');
          ClearHighlightNum('N7');
          ClearHighlightNum('N8');
          ClearHighlightNum('N9');
          ClearHighlightNum('NX');
          ClearHighlightNum('NP');
        }
        catch(err)
        {
	   alert("Error in function ClearHighlightMouseNum : "+err.description);
        }
      }

      function HighlightNum ( field )
      {
        try {
//	  field.style.background = '#aa9999'; 
	  field.style.background = '#c3c391'; 
        }
        catch(err)
        {
	   alert("Error in function HighlightNum : "+err.description);
        }
      }

      function ClearHighlightNum ( field )
      {
        try {
	  field.style.background = 'transparent'; 
        }
        catch(err)
        {
	   alert("Error in function ClearHighlightNum : "+err.description);
        }
      }

      function HighlightCell ( cellName )
      {
        try {
        //document.getElementsByName(cellName)[0].style.background = 'Tomato'; 
	//document.getElementsByName(cellName)[0].style.border =
	//      				'2px solid #f0f'; 
	//document.getElementsByName(cellName)[0].style.border = '2px solid #ff4500';
	document.getElementsByName(cellName)[0].style.border = '2px solid red';
        }
        catch(err)
        {
	   alert("Error in function HighlightCell : "+err.description);
        }
      }

      function ClearHighlightCell ( cellName )
      {
        try {
        //document.getElementsByName(cellName)[0].style.background = 'white'; 
	document.getElementsByName(cellName)[0].style.border =
   	    			'2px solid #fff'; 
        }
        catch(err)
        {
	   alert("Error in function ClearHighlightCell : "+err.description);
        }
      }

      function HighlightField ( field )
      {
        try {
  	  //field.style.border = '2px solid cyan';
  	  //field.style.border = '2px solid blue';
  	  //field.style.border = '2px solid #0000ee';
  	  //field.style.border = '2px solid #bb5599';
  	  field.style.border = '2px solid red';
        }
        catch(err)
        {
	  alert("Error in function HighlightField : "+err.description);
        }
      }

      function ClearHighlightField ( field )
      {
        try {
	  field.style.border = '2px solid #fff'; 
        }
        catch(err)
        {
	   alert("Error in function ClearHighlightField : "+err.description);
        }
      }

      function ClearAllHighlights()
      {
        try {
        for (i = 0; i <= 80; i++)
        {
           ClearHighlightCell ( cellNames[i] );
        }
        }
        catch(err)
        {
	   alert("Error in function ClearAllHighlightCell : "+err.description);
        }
      }

      function HandleTableMouseWheel(e)
      {
        if ( loaded!=1 ) return;
        try 
        { 
          if ((loaded==1) && (firstTime==0))
          {
            if (busy==0)
            {
              if (((currMouseValue>='1') && (currMouseValue<='9')) ||
                   (currMouseValue == 'X'))
              {
                busy = 1;
	        window.event.returnValue = false;
                HandleMouseWheel(e);
              }
            }
          }
        }
        catch(err)
        {
	   alert("Error in function HandleTableMouseWheel : "+err.description);
        }
      } 

      function HandleMouseWheel(e)
      {
        try 
        {
          if (busy==1)
          {
            if ( ( ( currMouseValue >= '1' ) && ( currMouseValue <= '9' ) ) ||
                 ( currMouseValue == 'X'  ) )
            {
   	      //window.event.returnValue = false;

     	      if (!e) e = window.event;

   	      if ( e.wheelDelta <= 0 || e.detail > 0) 
              { 
                ChangeMouseSelection(1); 
              }
	      else 
              { 
                ChangeMouseSelection(-1); 
              }
              busy =0;
            }
          }
        }
        catch(err)
        {
	   alert("Error in function HandleMouseWheel : "+err.description);
        }
      } 

      function GetIndexByCellName( cellName )
      {
        try {
          var index=-1;
          for (i = 0; i <= 80; i++)
          {
            if ( cellName == cellNames[i] )
            {
              index = i;
              break;
            }
          }
          return index;
        }
        catch(err)
        {
	   alert("Error in function GetIndexByCellName : "+err.description);
        }
      }
     
      function GetBlockByIndex( index )
      {
        try 
        {
	  switch (index) 
	  {
	    case 0:
            case 1:
            case 2:
            case 9:
            case 10:
            case 11:
            case 18:
            case 19:
            case 20: blockNum = 0; break;

	    case 3:
            case 4:
            case 5:
            case 12:
            case 13:
            case 14:
            case 21:
            case 22:
            case 23: blockNum = 1; break;

	    case 6:
	    case 7:
            case 8:
            case 15:
            case 16:
            case 17:
            case 24:
            case 25:
            case 26: blockNum = 2; break;

	    case 27:
            case 28:
            case 29:
            case 36:
            case 37:
            case 38:
            case 45:
            case 46:
            case 47: blockNum = 3; break;

	    case 30:
            case 31:
            case 32:
            case 39:
            case 40:
            case 41:
            case 48:
            case 49:
            case 50: blockNum = 4; break;

	    case 33:
            case 34:
            case 35:
            case 42:     
            case 43:
            case 44:
            case 51:
            case 52:
            case 53: blockNum = 5; break;

	    case 54:
            case 55:
            case 56:
            case 63:
            case 64:
            case 65:
            case 72:
            case 73:
            case 74: blockNum = 6; break;

	    case 57:
            case 58:
            case 59:
            case 66:
            case 67:
            case 68:
            case 75:
            case 76:
            case 77: blockNum = 7; break;

	    case 60:
            case 61:
            case 62:
            case 69:
            case 70:
            case 71:
            case 78:
            case 79:
            case 80: blockNum = 8; break;

            default : blockNum=0;
          }
          return blockNum;
        }
        catch(err)
        {
	   alert("Error in function GetBlockByIndex : "+err.description);
        }
      }
     
      function GetRowByIndex( index )
      {
        try 
        {
          if ( index < 9 ) rowNum = 1;
          else if ( index < 18 ) rowNum = 2;
          else if ( index < 27 ) rowNum = 3;
          else if ( index < 36 ) rowNum = 4;
          else if ( index < 45 ) rowNum = 5;
          else if ( index < 54 ) rowNum = 6;
          else if ( index < 63 ) rowNum = 7;
          else if ( index < 72 ) rowNum = 8;
          else rowNum = 9;

          return rowNum;
        }
        catch(err)
        {
	   alert("Error in function GetRowByIndex : "+err.description);
        }
      }


      function GetColumnByIndex( index )
      {
        try 
        {
	  switch (index) 
	  {
	    case 0:
            case 9:
            case 18:
            case 27:
            case 36:
            case 45:
            case 54:
            case 63:
            case 72: columnNum = 1; break;

	    case 1:
            case 10:
            case 19:
            case 28:
            case 37:
            case 46:
            case 55:
            case 64:
            case 73: columnNum = 2; break;

	    case 2:
            case 11:
            case 20:
            case 29:
            case 38:
            case 47:
            case 56:
            case 65:
            case 74: columnNum = 3; break;

	    case 3:
            case 12:
            case 21:
            case 30:
            case 39:
            case 48:
            case 57:
            case 66:
            case 75: columnNum = 4; break;

	    case 4:
            case 13:
            case 22:
            case 31:
            case 40:
            case 49:
            case 58:
            case 67:
            case 76: columnNum = 5; break;

	    case 5:
            case 14:
            case 23:
            case 32:
            case 41:
            case 50:
            case 59:
            case 68:
            case 77: columnNum = 6; break;

	    case 6:
            case 15:
            case 24:
            case 33:
            case 42:
            case 51:
            case 60:
            case 69:
            case 78: columnNum = 7; break;

	    case 7:
            case 16:
            case 25:
            case 34:
            case 43:
            case 52:
            case 61:
            case 70:
            case 79: columnNum = 8; break;

	    case 8:
            case 17:
            case 26:
            case 35:
            case 44:
            case 53:
            case 62:
            case 71:
            case 80: columnNum = 9; break;

            default : columnNum=0;
          }
          return columnNum;
        }
        catch(err)
        {
	   alert("Error in function GetColumnByIndex : "+err.description);
        }
      }
          
      function UpdateHighlightByValue ( oldValue , newValue )
      {
        try {
          if (oldValue != newValue)
          {
            for (i = 0; i <= 80; i++)
            {
              if ( mirrorVal[i] == oldValue )
              {
                ClearHighlightField ( cellFields[i] );
              }
              else if ( mirrorVal[i] == newValue )
              {
                HighlightField ( cellFields[i] );
              }
            }
          }
        }
        catch(err)
        {
	   alert("Error in function UpdateHighlightByValue : "+err.description);
        }
      }
     
      function RestartSolution() 
      {
        if ( loaded!=1 ) return;

        if ( gameEnded == 1 ) return;

        enablePoints = 1;

        try 
        {
          var cellName;
          for (i = 0; i <= 80; i++)
          {
            var cellName = cellNames[i];
            
            text = document.getElementsByName(cellName)[0].id;
            if (text.charAt(0)=='R')
            {
              document.getElementsByName(cellName)[0].value = text.charAt(3);
              mirrorVal[i] = cellFields[i].value;
            }
            else
            {
              document.getElementsByName(cellName)[0].value = '';
              mirrorVal[i] = 0;
            }
            ClearHighlightCell ( cellName );
          }
          ClearStatus();
          numMoves=0; 
          MouseSelection ( 'P' );
          SetNumCount();
          UpdateNumButtonState();
        }
        catch(err)
        {
	   alert("Error in function RestartSolution : "+err.description);
        }
      }

      function SendToPrinter() 
      {
        if ( loaded!=1 ) return;
        try {
        if (window.print) {
          window.print() ;  
        } 
        }
        catch(err)
        {
	   alert("Error in function SendToPrinter : "+err.description);
        }
      }

      function UndoStep() 
      {
        var index;
        var cellName;

        if ( loaded!=1 ) return;

        if ( gameEnded == 1 ) return;

        ClearStatus();

        if ( numMoves > 0 )
        {
          cellName = movePlace[numMoves];
          document.getElementsByName(cellName)[0].value=moveVal[numMoves];
          index=GetIndexByCellName(cellName);
          mirrorVal[index] = moveVal[numMoves];
      	  if ( document.getElementsByName(movePlace[numMoves])[0].value !=  
		 currMouseValue )
          {
            ClearHighlightCell ( movePlace[numMoves] );
          }
          numMoves--;
        }
        SetNumCount();
        UpdateNumButtonState();
      }

      function AddUndoStep( cellName, currVal ) 
      {
	numMoves++;
        movePlace[numMoves]=cellName;
        moveVal[numMoves]=currVal; 
      }

      function ZoomLarge() 
      {
        if ( loaded!=1 ) return;
        for (i = 1; i <= 9; i++)
        {
          for (j = 1; j <= 9; j++)
          {
             var cellName = "A" + i.toString() + j.toString();
             var text = document.getElementsByName(cellName)[0].id;

             if (text.charAt(0)!='R')
             {
               document.getElementsByName(cellName)[0].className = "bigcl1";
             }
             else
             {
               document.getElementsByName(cellName)[0].className = "bigcl11";
             }
          }
        }
      }

      function ZoomMedium() 
      {
        if ( loaded!=1 ) return;
        for (i = 1; i <= 9; i++)
        {
          for (j = 1; j <= 9; j++)
          {
             var cellName = "A" + i.toString() + j.toString();
             var text = document.getElementsByName(cellName)[0].id;
             
             if (text.charAt(0)!='R')
             {
               document.getElementsByName(cellName)[0].className = "midcl1";
             }
             else
             {
               document.getElementsByName(cellName)[0].className = "midcl11";
             }
          }
        }
      }

      function ZoomSmall() 
      {
        if ( loaded!=1 ) return;
        for (i = 1; i <= 9; i++)
        {
          for (j = 1; j <= 9; j++)
          {
             var cellName = "A" + i.toString() + j.toString();
             var text = document.getElementsByName(cellName)[0].id;
             if (text.charAt(0)!='R')
             {
               document.getElementsByName(cellName)[0].className = "cl1";
             }
             else
             {
               document.getElementsByName(cellName)[0].className = "cl11";
             }
          }
        }
      }

      function PuzzleIsFull()  
      {
        var cellValue;
        var puzzleFull;

        puzzleFull=1;

        for (i = 0; i <= 80; i++)
        {
          cellValue=(document.getElementsByName(cellNames[i]))[0].value;
          if ( (cellValue<'1') || (cellValue>'9') )
          {
            puzzleFull=0;
            break;
          }
        }
        return puzzleFull;
      }

      function CheckSolution()  
      {
        var text;
        var res=1;       

        if ( loaded!=1 ) return false;

        if ( gameEnded == 1 ) return false;

        for (i = 1; i <= 9; i++)
        {
          for (j = 1; j <= 9; j++)
          {
            var cellName = "A" + i.toString() + j.toString();

            var x=document.getElementsByName(cellName)
            var cellValue = x[0].value;

            if ( (cellValue<'1') || (cellValue>'9') )
            {
               // "Some cells are empty.Please complete the puzzle.";
               S0( msgStrings[2], "red", true);  
               res=0;
               break;        
            }

            if ( ( i==5 ) && (j==5) )
            {
              cellTmp=cellValue;
            }

          }
        }

        if (res==0) return false;

        for (m = 1; m <= 9; m++)
        {
          res = CheckRow(m);
          if (res==0)
          {
             //text = "Duplicate number in row "+m;
             S0( msgStrings[13]+m, "red", true);  
             break;        
          }

          res = CheckColumn(m);
          if (res==0)
          {
             //text = "Duplicate number in column "+m;
             S0( msgStrings[14]+m, "red", true);  
             break;        
          }

          res = CheckBlock(m-1);
          if (res==0)
          {
             //text = "Wrong solution. Please try again";
             S0( msgStrings[15], "red", true);  
             break;
          }
        }

        if (res==0) return false;

        MouseSelection ( 'P' );

        memberId = document.getElementById("MemberId").value;
        if ( (memberId!=0) && ( enablePoints == 1 ))
        {
          updatePoints()
        }

        // Clear the cookie
        var cookie_date = new Date ( );  // current date & time
        cookie_date.setTime ( cookie_date.getTime() - 1 );
        document.cookie = cookie_name + "= ; expires=" + cookie_date.toGMTString();

	for (i=0; i<=80; i++)
        {
           cellField = cellFields[i];
           cellField.readOnly = true;
        }
        gameEnded = 1;

        // "Congratulations!! You have solved the puzzle!!";
        S0( msgStrings[1], "green", true);  
        StopTimer();

        return true;
      }

      function CheckRow(rowNum)
      {
        var cellValue;
        var arr = new Array();
        var i;
 
        for (k=0; k<9; k++)
        {
          arr[k] = 0;
        }

        i=rowNum;
        for (j=1; j<=9; j++)
        {
          var cellName = "A" + i.toString() + j.toString();
          cellValue = document.getElementsByName(cellName)[0].value;
          
          if ( (cellValue>='1') && (cellValue<='9') )
          {
            arr[cellValue-'1']=1;
          }
        }

        for (k=0; k<9; k++)
        {
          if (arr[k]!=1) return 0;
        }

        return 1;
      }

      function CheckColumn(columnNum)
      {
        var cellValue;
        var arr = new Array();
        var i;
 
        for (k=0; k<9; k++)
        {
          arr[k] = 0;
        }

        j=columnNum;
        for (i=1; i<=9; i++)
        {
          var cellName = "A" + i.toString() + j.toString();
          cellValue = document.getElementsByName(cellName)[0].value;
          
          if ( (cellValue>='1') && (cellValue<='9') )
          {
            arr[cellValue-'1']=1;
          }
        }

        for (k=0; k<9; k++)
        {
          if (arr[k]!=1) return 0;
        }

        return 1;
      }

      function CheckBlock(blockNum)
      {
        var cellValue;
        var arr = new Array();
 
        for (k=0; k<9; k++)
        {
          arr[k] = 0;
        }

        for (r=1; r<=3; r++)
        {
          for (c=1; c<=3; c++)
          {
            i = r + (Math.floor(blockNum / 3)) * 3;
            j = c + (blockNum % 3) * 3;
            var cellName = "A" + i.toString() + j.toString();
            cellValue = document.getElementsByName(cellName)[0].value;
          
            if ( (cellValue>='1') && (cellValue<='9') )
            {
              arr[cellValue-'1']=1;
            }
          }
        }

        for (k=0; k<9; k++)
        {
          if (arr[k]!=1) return 0;
        }
        return 1;
      }

      function doBlink() 
      {
        if (blinkCount>0)
        {
          blinkCount++;
        }

        if (blinkCount>=5)
        {
          blinkCount=0;
          clearInterval(blinkInterval);
          SudForm.SudokuStatus.style.visibility = "";
          if ( gameEnded == 1 )
          {
            InitBravo();
          }
        }
        else
        {
          SudForm.SudokuStatus.style.visibility =
             SudForm.SudokuStatus.style.visibility == "" ? "hidden" : "";
        }
      }

      function ClearStatus() 
      {
         blinkCount=0;
         clearInterval(blinkInterval);
         SudForm.SudokuStatus.value=" ";
      }

      function startBlink() 
      {
        // Make sure it is IE4
        //if (document.all)
        {
          if (blinkCount==0)
          {
            blinkCount=1;
            blinkInterval = setInterval("doBlink()",700);
          }
        }
      }

      //window.onload = startBlink;

      function ResetTimer() 
      {
        if ( loaded!=1 ) return;
        tStart = null;
        SudForm.theTimeText.value = " 00:00";
      }

      function StartTimer() 
      {
        if ( loaded!=1 ) return;
        tStart   = new Date();
        SudForm.theTimeText.value = " 00:00";
        timerID  = setTimeout("UpdateTimer()", 1000);
      }

      function StopTimer()
      {
        if ( loaded!=1 ) return;
        if(timerID) 
        {
          clearTimeout(timerID);
          timerID  = 0;
        }
        tStart = null;
      }

      function UpdateTimer() 
      {
         if(timerID) 
         {
           clearTimeout(timerID);
         }

         if (!tStart)
         {
           tStart   = new Date();
         }

         var   tDate = new Date();
         var   tDiff = tDate.getTime() - tStart.getTime();

         tDate.setTime(tDiff);

         minutes = tDate.getMinutes();
         seconds = tDate.getSeconds();

	 if (seconds < 10) 
	 { 
           seconds = '0' + seconds; 
         }

	 if (minutes < 10) 
	 { 
           minutes = '0' + minutes; 
         }

         SudForm.theTimeText.value = " " + minutes + ":" + seconds;
   
         timerID = setTimeout("UpdateTimer()", 1000);
      }

      function SetNumButtonDone ( field )
      {
        try {
          //alert(field.id);
          field.className="ClassNumberSelectionDone";
        }
        catch(err)
        {
	   alert("Error in function SetNumButtonDone : "+err.description);
        }
      }

      function ResetNumButton ( field )
      {
        try {
          if ( field != null )
          {
            //alert(field.id);
            field.className="ClassNumberSelection";
          }
        }
        catch(err)
        {
	   alert("Error in function ResetNumButton : "+err.description);
        }
      }

      function SaveGame() 
      {
        if ( loaded!=1 ) return;

        if ( gameEnded == 1 ) return;

        try 
        {
          var str;
          var exdate=new Date()
          var checked;

          str = "";
          str=exdate+'@';
          exdate.setDate(exdate.getDate()+7)

          level = document.getElementById("LevelSudParam").value;

          str=str + level;
          str=str+'@';

          num = document.getElementById("NumSudParam").value;

          str=str + num;
          str=str+'@';
 
          for (i = 0; i <= 80; i++)
          {
            var cellName = cellNames[i];
            
            str = str + document.getElementsByName(cellName)[0].id;
          }
          str=str+'@';

          for (i = 0; i <= 80; i++)
          {
            var cellName = cellNames[i];

            if ( document.getElementsByName(cellName)[0].value == '' )
            {
              str = str + '0';
            }
            else
            {
              str = str + document.getElementsByName(cellName)[0].value;
            }
          }
          str=str+'@';

          document.cookie= cookie_name + "=" +escape(str)+
                          ";expires="+exdate.toGMTString()

          alert ("The puzzle has been saved")
        }
        catch(err)
        {
	   alert("Error in function SaveGame : "+err.description);
        }
      }

// ---------------------------------------------------------------

      function RestoreGame() 
      {
        if ( loaded!=1 ) return;

        if ( gameEnded == 1 ) return;

        try 
        {
          var t;
          var numCount;
          t="";
          numCount=0;

	  if (document.cookie.length>0)
	  {
	    c_start=document.cookie.indexOf(cookie_name + "=")
	    if (c_start!=-1)
	    { 
	      c_start=c_start + cookie_name.length+1 
	      c_end=document.cookie.indexOf(";",c_start)
	      if (c_end==-1) c_end=document.cookie.length
              //alert(document.cookie)
    
              value = unescape(document.cookie.substring(c_start,c_end))
       
              c_start=0
              c_end=value.indexOf("@",c_start)
              gameDate = unescape(value.substring(c_start,c_end))
              //alert(gameDate)

              c_start=c_end+1
              c_end=value.indexOf("@",c_start)
              level = unescape(value.substring(c_start,c_end))
              //alert(level)

              c_start=c_end+1
              c_end=value.indexOf("@",c_start)
              num = unescape(value.substring(c_start,c_end))
              //alert(num)

              c_start=c_end+1;
              c_end=value.indexOf("@",c_start)
              game = unescape(value.substring(c_start,c_end))
              //alert(game)

              c_start=c_end+1;
              c_end=value.indexOf("@",c_start)
              currGame = unescape(value.substring(c_start,c_end))
              //alert(currGame)

              for (i=0; i<=80; i++)
              {
                cellField = cellFields[i];
                cellValue = currGame.charAt(i);
                if ( cellValue == '0' )
                {
                  cellField.value = '';
                  mirrorVal[i] = 0;
                }
                else
                {
                  cellField.value = cellValue;
                  mirrorVal[i] = cellField.value;
                  numCount++;
                }
              
                if ( game.charAt(i*4) == 'A')
                {
                  if ( cellClass[i] == 0 )
                  {
                    cellField.className="cl1";
                  }
                  else
                  {
                    cellField.className="cl2";
                  }
                  cellField.readOnly=false;
                  str = 'A' + cellField.id.charAt(1)
                            + cellField.id.charAt(2)
                            + cellValue;
                  cellField.id=str;
                }
                else
                {
                  if ( cellClass[i] == 0 )
                  {
                    cellField.className="cl11";
                  }
                  else
                  {
                    cellField.className="cl22";
                  }
                  cellField.readOnly=true;
                  str = 'R' + cellField.id.charAt(1)
                            + cellField.id.charAt(2)
                            + cellValue;
                  cellField.id=str;
                } 
                ClearHighlightField ( cellField );
              }

              //alert (numCount);
              if (numCount>64)
              {
                enablePoints = 0;
              }

              document.getElementById("LevelSudParam").value = level;
              sudokuLevelText = document.getElementsByName("SudokuLevelText")[0];

             if (level == 1)
             {
               sudokuLevelText.value = document.getElementById("EasyLevelStr").value;
               sudokuLevelText.style.color = "#33aa33";
             }   	   

   	     else if (level == 2)
             {
               sudokuLevelText.value = document.getElementById("MediumLevelStr").value;
               sudokuLevelText.style.color = "#5555ee";
             }   	    

   	     else if (level == 3)
             {
               sudokuLevelText.value = document.getElementById("HardLevelStr").value;
               sudokuLevelText.style.color = "#cc44cc";
             }   	    

   	     else if (level == 4)
             {
               sudokuLevelText.value = document.getElementById("VeryHardLevelStr").value;
               sudokuLevelText.style.color = "#ee2222";
             }

              document.getElementById("NumSudParam").value = num;

              ClearStatus();
              numMoves=0; 
              MouseSelection ( 'P' );
              SetNumCount();
              UpdateNumButtonState();
            } 
          }
        }
        catch(err)
        {
	   alert("Error in function RestoreGame : "+err.description);
        }
      }


      var newGameReady;

      function StartNewGameTimer() 
      {
        newGameReady=0;
        execGetNewGame(newGameLevel);
        newGameTimerCount = 90;
        newGameTimerID  = setTimeout("UpdateNewGameTimer()", 10);
      }

      function UpdateNewGameTimer() 
      {
        newGameTimerCount--;

        if (newGameTimerCount>0)
        {
          for (j = 0; j<2; j++)
          {
            for (i = 0; i <= 80; i++)
            {
              cellFields[i].className="cl11";
              cellFields[i].value=rand1(9)+1;
            }
          }
          if (newGameReady==0)
          {
            newGameTimerID  = setTimeout("UpdateNewGameTimer()", 10);
          }
          else
          {
            StopNewGameTimer();
          }
        }
        else
        {
          StopNewGameTimer();
        }
      }

      function StopNewGameTimer() 
      {
        if(newGameTimerID) 
        {
          clearTimeout(newGameTimerID);
          newGameTimerID  = 0;
          if (newGameReady==1)
          {
            updateNewGame();
          }
          else
          {
            //
          }
        }
      }


      var xmlHttp

      function getNewGame(level)
      {
        if ( loaded!=1 ) return;

        try 
        {
          StartNewGameTimer();
          newGameLevel=level;
        }
        catch(err)
        {
	   alert("Error in function getNewGame : "+err.description);
        }
     } 


     function execGetNewGame(level)
     {
        var url;

        if ( loaded!=1 ) return;

        try 
        {
	  xmlHttp=GetXmlHttpObject();

          if (xmlHttp==null)
          {
            alert ("Browser does not support HTTP Request.")
            return
          } 

          url=puzzleBasePath+"/newpuzzle.php"

          gameEnded = 0;
          enablePoints = 1;

//          alert("level="+level)
          url=url+"?level="+level

  	  xmlHttp.onreadystatechange=stateChanged 
  	  xmlHttp.open("GET",url,true)
          xmlHttp.send(null)
        }
        catch(err)
        {
	   alert("Error in function execGetNewGame : "+err.description);
        }
     } 

     function stateChanged() 
     { 
         if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
         { 
           newGameReady=1;
           //document.getElementById("theGame").innerHTML=xmlHttp.responseText 
           // alert (xmlHttp.responseText);
         }
     } 


     function updateNewGame() 
     { 
       try 
       {
             var t;
             t="";

             value = unescape(xmlHttp.responseText)
       
             c_start=0
             c_end=value.indexOf("@",c_start)
             gameDate = unescape(value.substring(c_start,c_end))
             //alert(gameDate)

             c_start=c_end+1
             c_end=value.indexOf("@",c_start)
             level = unescape(value.substring(c_start,c_end))
             //alert(level)

             c_start=c_end+1
             c_end=value.indexOf("@",c_start)
             num = unescape(value.substring(c_start,c_end))
             //alert(num)

             c_start=c_end+1;
             c_end=value.indexOf("@",c_start)
             game = unescape(value.substring(c_start,c_end))
             //alert(game)

             c_start=c_end+1;
             c_end=value.indexOf("@",c_start)
             currGame = unescape(value.substring(c_start,c_end))
             //alert(currGame)

             for (i=0; i<=80; i++)
             {
               cellField = cellFields[i];
               cellValue = currGame.charAt(i);

               if ( cellValue == '0' )
               {
                 cellField.value = '';
                 mirrorVal[i] = 0;
               }
               else
               {
                 cellField.value = cellValue;
                 mirrorVal[i] = cellField.value;
               }
               if ( game.charAt(i*4) == 'A')
               {
                 if ( cellClass[i] == 0 )
                 {
                   cellField.className="cl1";
                 }
                 else
                 {
                   cellField.className="cl2";
                 }
                 cellField.readOnly=false;
                 str = 'A' + cellField.id.charAt(1) + 
                             cellField.id.charAt(2) + 
                             cellValue;
                 cellField.id=str;
               }
               else
               {
                 if ( cellClass[i] == 0 )
                 {
                   cellField.className="cl11";
                 }
                 else
                 {
                   cellField.className="cl22";
                 }
                 cellField.readOnly=true;
                 str = 'R' + cellField.id.charAt(1) + 
                             cellField.id.charAt(2) + 
                             cellValue;
                 cellField.id=str;
               } 
               ClearHighlightField ( cellField );
             }

             document.getElementById("LevelSudParam").value = level;
             sudokuLevelText = document.getElementsByName("SudokuLevelText")[0];
   	     if (level == 1)
             {
               sudokuLevelText.value = document.getElementById("EasyLevelStr").value;
               sudokuLevelText.style.color = "#33aa33";
             }   	   

   	     else if (level == 2)
             {
               sudokuLevelText.value = document.getElementById("MediumLevelStr").value;
               sudokuLevelText.style.color = "#5555ee";
             }   	    

   	     else if (level == 3)
             {
               sudokuLevelText.value = document.getElementById("HardLevelStr").value;
               sudokuLevelText.style.color = "#cc44cc";
             }   	    

   	     else if (level == 4)
             {
               sudokuLevelText.value = document.getElementById("VeryHardLevelStr").value;
               sudokuLevelText.style.color = "#ee2222";
             }

             document.getElementById("NumSudParam").value = num;

             ClearStatus();
             numMoves=0; 
             SetNumCount();
             UpdateNumButtonState();
       }
       catch(err)
       {
         alert("Error in function stateChanged : "+err.description);
       }
     } 


     function GetXmlHttpObject1()
     { 
       var objXMLHttp=null
       try 
       {
         if (window.XMLHttpRequest)
         {
           objXMLHttp=new XMLHttpRequest()
         }
         else if (window.ActiveXObject)
         {
           objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
         }
       }
       catch(err)
       {
         alert("Error in function GetXmlHttpObject : "+err.description);
       }
       return objXMLHttp
     }

     function GetXmlHttpObject()
     { 
       try
       {
         return new ActiveXObject('Msxml2.XMLHTTP');
       }
       catch(e)
       {
         try
         {
           return new ActiveXObject('Microsoft.XMLHTTP');
         }
         catch(e)
         {
           return new XMLHttpRequest();
         }
       }
     }


////////////////////////////////////////////////////////

      function endGame()
      {
        memberId = document.getElementById("MemberId").value;
        if ( (memberId!=0) && ( enablePoints == 1 ))
        {
          updatePoints()
        }
      }

      var xmlHttp2

      function updatePoints()
      {
        var url;

        if ( loaded!=1 ) return;

        try 
        {
	  xmlHttp2=GetXmlHttpObject();

          if (xmlHttp2==null)
          {
            alert ("Browser does not support HTTP Request.")
            return
          } 

          var level    = document.getElementById("LevelSudParam").value;
          //alert("level="+level)

          var memberId = document.getElementById("MemberId").value;
          var num = document.getElementById("NumSudParam").value;

  	  xmlHttp2.onreadystatechange=stateChanged2

          var url=puzzleBasePath+"/updatepoints.php"

          var params = "member_id="+memberId+"&level="+level+"&num="+num+"&val="+cellTmp
          xmlHttp2.open("POST", url, true,"","");

	  //Send the proper header information along with the request
          xmlHttp2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
          xmlHttp2.setRequestHeader("Content-length", params.length);
          xmlHttp2.setRequestHeader("Connection", "close");

          xmlHttp2.send(params)
        }
        catch(err)
        {
	   alert("Error in function updatePoints : "+err.description);
        }
     } 

     function stateChanged2() 
     { 
          // alert(xmlHttp2.readyState)
       try 
       {
         if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
         { 
           value = unescape(xmlHttp2.responseText)

           if (value == -1)
           {
             window.location = "logout.php";
           }
           else if (value == "")
           {
           }
           else
           {
             document.getElementById("total_points").value=value;
           }
         }
       }
       catch(err)
       {
         alert("Error in function stateChanged2 : "+err.description);
       }
     } 

     function handle_wheel1(event)
      {
        try 
        { 
          if ((loaded==1) && (firstTime==0))
          {
            if (busy==0)
            {
              if (((currMouseValue>='1') && (currMouseValue<='9')) ||
                   (currMouseValue == 'X'))
              {
                busy = 1;
 
                if (!event)
                {
                  event = window.event;
  	          window.event.returnValue = false;
                }

                if (event.preventDefault)
                {
                  event.preventDefault();
                }

 	        //event.returnValue = false;
                HandleMouseWheel(event);
              }
            }
          }
        }
        catch(err)
        {
   	  alert("Error in function Handle_Wheel1 : "+err.description);
        }
      }


      function InitTab() 
      {
        try 
        {
          if ( initEnded == 0 ) return;
          if ( loaded == 1 ) return;
          if ( loading == 1 ) return;
          //LoadCurs();
        }
        catch(err)
        {
	   alert("Error in function InitTab : "+err.description);
        }
      }

    //-->

