
    <!--
      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 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 tStart  = null;
      var currMouseValue = 'P';
      var loaded = 0;
      var loading = 0;
      var initEnded = 0;
      var firstTime = 1;
      var busy = 1;
      var gameEnded = 0;
      var gameEnded = 0;
      var cookie_name = "sudoku_ve";

      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;

      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 Fill1Solution() 
      {
        try {
        for (i = 1; i <= 9; i++)
        {
          for (j = 1; j <= 9; j++)
          {
            var idName = "A" + i.toString() + j.toString();
            document.getElementById(idName).value =
                     document.getElementById(idName).name.charAt(3);
            var idName = "R" + i.toString() + j.toString();
            document.getElementById(idName).value =
                     document.getElementById(idName).name.charAt(3);
            var idName = "D" + i.toString() + j.toString();
            document.getElementById(idName).value =
                     document.getElementById(idName).name.charAt(3);
            var idName = "S" + i.toString() + j.toString();
            document.getElementById(idName).value =
                     document.getElementById(idName).name.charAt(3);
            var idName = "T" + i.toString() + j.toString();
            document.getElementById(idName).value =
                     document.getElementById(idName).name.charAt(3);
          }
        if (document.layers)
          Key = e.which;
        else
          Key = window.event.keyCode;
        text = "Congratulations!! You have solved the puzzle!!";
        S0( text, "red", true);  
             text = "Wrong solution (error in column "+m+"). Please try again";
             S0( text, "red", true);  

        }
        }
        catch(err)
        {
	   alert("Error in function Fill1Solution : "+err.description);
        }
      }

      function Restart1Solution() 
      {
        try {
        for (i = 1; i <= 9; i++)
        {
          for (j = 1; j <= 9; j++)
          {
            var idName = "A" + i.toString() + j.toString();
            
            text = document.getElementById(idName).name;
            var idName = "T" + i.toString() + j.toString();
            
           text = "Congratulations!! You have solved the puzzle!!";
           S0( text, "red", true);  
            if (document.layers)
              Key = e.which;
            else
              Key = window.event.keyCode;

             text = "Wrong solution (error in column "+m+"). Please try again";
             S0( text, "red", true);  
            text = document.getElementById(idName).name;
            var idName = "D" + i.toString() + j.toString();
            
             text = "Wrong solution (error in column "+m+"). Please try again";
             S0( text, "red", true);  
            text = document.getElementById(idName).name;
            var idName = "R" + i.toString() + j.toString();
            
            text = document.getElementById(idName).name;
            if (text.charAt(0)=='R')
            {
              document.getElementById(idName).value = text.charAt(3);
            }
            else
            {
              document.getElementById(idName).value = '';
            }
          }
        }
        if (document.layers)
          Key = e.which;
        else
          Key = window.event.keyCode;

        ClearStatus();
        }
        catch(err)
        {
	   alert("Error in function Restart1Solution : "+err.description);
        }
      }

      function Print1Table() 
      {
        if ( loaded!=1 ) return;
        try {
        if (window.print) 
        {
          text = "Congratulations!! You successfully solved the Sudoku puzzle.";
          S0( text, "red", true);  
          for (j = 1; j <= 9; j++)
          {
            if (document.layers)
              Key = e.which;
            else
              Key = window.event.keyCode;

             text = "Wrong solution (error in column "+m+"). Please try again";
             S0( text, "red", true);  
            var idName = "A" + i.toString() + j.toString();
            document.getElementById(idName).value =
                     document.getElementById(idName).name.charAt(3);
            var idName = "R" + i.toString() + j.toString();
            document.getElementById(idName).value =
                     document.getElementById(idName).name.charAt(3);
             text = "Wrong solution (error in column "+m+"). Please try again";
             S0( text, "red", true);  
            var idName = "T" + i.toString() + j.toString();
            document.getElementById(idName).value =
                     document.getElementById(idName).name.charAt(3);
            var idName = "L" + i.toString() + j.toString();
            document.getElementById(idName).value =
                     document.getElementById(idName).name.charAt(3);
            var idName = "F" + i.toString() + j.toString();
            document.getElementById(idName).value =
                     document.getElementById(idName).name.charAt(3);
          }
          for (k = 1; k <= 9; k++)
          {
            var idName = "A" + i.toString() + j.toString();
            document.getElementById(idName).value =
                     document.getElementById(idName).name.charAt(3);
          }
          for (l = 1; l <= 9; l++)
          {
            var idName = "A" + i.toString() + j.toString();
            document.getElementById(idName).value =
                     document.getElementById(idName).name.charAt(3);
          }
          window.print();  
        } 
        }
        catch(err)
        {
	   alert("Error in function Print1Solution : "+err.description);
        }
      }

      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;
//alert('55');
           RestartSolution();
        }
        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;

        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 Reload1Solution() 
      {
        try {
        for (i = 1; i <= 9; i++)
        {
          for (j = 1; j <= 9; j++)
          {
            var idName = "A" + i.toString() + j.toString();
            document.getElementById(idName).value =
                     document.getElementById(idName).name.charAt(3);
            var idName = "D" + i.toString() + j.toString();
            document.getElementById(idName).value =
                     document.getElementById(idName).name.charAt(3);
            var idName = "B" + i.toString() + j.toString();
            document.getElementById(idName).value =
                     document.getElementById(idName).name.charAt(3);
            var idName = "R" + i.toString() + j.toString();
            document.getElementById(idName).value =
                     document.getElementById(idName).name.charAt(3);
            var idName = "Y" + i.toString() + j.toString();
            document.getElementById(idName).value =
                     document.getElementById(idName).name.charAt(3);
          }
        }
        SudokuForm.SudokuStatus.color=color;
        SudokuForm.SudokuStatus.value=text;
        if (blinkCount)
        {
          startBlink();
        }
        }
        catch(err)
        {
	   alert("Error in function Reload1Solution : "+err.description);
        }
      }

      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 
        {
             num = document.getElementById("NumSudParam").value;
             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 ( 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;

        ClearStatus();

        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;
            valStr = String.fromCharCode(Key);
            SetValue ( currFieldName, 0, valStr );
          }
          else if ((Key >= 97) && (Key<=105))
          { 
            val = Key - 96;
	    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;
              //color = GetColorByVal ( currVal );
              //document.getElementsByName(currFieldName)[0].style.color=color;
              document.getElementsByName(currFieldName)[0].className = GetClassNameByVal ( currVal );
            }
              else
            {
              document.getElementsByName(currFieldName)[0].value=" "; 
            }
          }
        }
        }
        catch(err)
        {
	   alert("Error in function ChangeVal : "+err.description);
        }
      } 


      function GetClassNameByVal ( val )
      {
        try 
        {
          if (val==1)
          {
            className = "cl111";
          }
          else if (val==2)
          {
            className = "cl112";
          }
          else if (val==3)
          {
            className = "cl113";
          }
          else if (val==4)
          {
            className = "cl114";
          }
          else if (val==5)
          {
            className = "cl115";
          }
          else if (val==6)
          {
            className = "cl116";
          }
          else if (val==7)
          {
            className = "cl117";
          }
          else if (val==8)
          {
            className = "cl118";
          }
          else if (val==9)
          {
            className = "cl119";
          }
        }        
        catch(err)
        {
	   alert("Error in function GetClassNameByVal : "+err.description);
        }
        return className;
      }

      function GetColorByVal ( val )
      {
        try 
        {
	     switch (val) 
	     {
	        case '1': 
                   return '#ff0000'; 
		             break;
	        case '2': 
                   return '#00dd00'; 
		             break;
	        case '3': 
                   return '#0000ff'; 
		             break;
	        case '4': 
                   return '#a0a000'; 
		             break;
	        case '5': 
                   return '#00bbbb'; 
		             break;
	        case '6': 
                   return '#ff00ff'; 
		             break;
	        case '7': 
                   return '#aa0000'; 
		             break;
	        case '8': 
                   return '#009900'; 
		             break;
	        case '9': 
                   return '#000000'; 
		             break;
		default : return '#000000';
	     }
        }
        catch(err)
        {
	   alert("Error in function GetColorByVal : "+err.description);
        }
      }


      function SetValue ( cellName, highlight, value )
      {        
        var currVal;
        try
        {
           var index;

           currVal = document.getElementsByName(cellName)[0].value;
           if (currVal != value)
           {
             index=GetIndexByCellName(cellName);
             mirrorVal[index] = value;

             cellField = document.getElementsByName(cellName)[0];
             //color = GetColorByVal ( value );
             //document.getElementsByName(cellName)[0].style.color=color;
             //document.getElementsByName(cellName)[0].value=value;
             cellField.className = GetClassNameByVal ( value );
             cellField.value=value;

             if (highlight==1) HighlightCell ( cellName );
             else ClearHighlightCell ( cellName );

             AddUndoStep( cellName, currVal ) ;
             if (PuzzleIsFull())
             {
               CheckSolution();
             }
           }
        }
        catch(err)
        {
	   alert("Error in function SetValue : "+err.description);
        }
      }

      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 LoadCurs()
      {
        try
        {
          var k;
          var cellName;
          var imagesPath

          if ( loaded == 1 ) return;
          loading = 1;

          puzzleBasePath = document.getElementById("PuzzleBasePath").value; 
          //alert(puzzleBasePath);
          if (puzzleBasePath == '') 
          {
            loading = 0;
            return;
          }

          imagesPath = document.getElementById("CursorPath").value; 
          //alert(imagesPath); 
          if (imagesPath == '') 
          {
            loading = 0;
            return;
          }

          //msgStrings[0] = imagesPath;
          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(' + imagesPath + '/n1.cur),auto';
          cur1.style.cursor = curPath;
          curPath = 'url(' + imagesPath + '/n2.cur),auto';
	  cur2.style.cursor = curPath;
          curPath = 'url(' + imagesPath + '/n3.cur),auto';
	  cur3.style.cursor = curPath;
          curPath = 'url(' + imagesPath + '/n4.cur),auto';
	  cur4.style.cursor = curPath;
          curPath = 'url(' + imagesPath + '/n5.cur),auto';
	  cur5.style.cursor = curPath;
          curPath = 'url(' + imagesPath + '/n6.cur),auto';
	  cur6.style.cursor = curPath;
          curPath = 'url(' + imagesPath + '/n7.cur),auto';
	  cur7.style.cursor = curPath;
          curPath = 'url(' + imagesPath + '/n8.cur),auto';
	  cur8.style.cursor = curPath;
          curPath = 'url(' + imagesPath + '/n9.cur),auto';
	  cur9.style.cursor = curPath;
          curPath = 'url(' + imagesPath + '/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++;
            }
          }

          numMoves=0; 

          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 Mouse1Selection ( value )
      {
        try {
        for (i = 1; i <= 9; i++)
        {
          for (j = 1; j <= 9; j++)
          {
             var cellName = "A" + i.toString() + j.toString();
 
     	     if ( document.getElementsByName(cellName)[0].value == value )
             {
               HighlightCell ( cellName );
             }
	     else
             {
               ClearHighlightCell ( cellName );
             }

	     switch (value) 
	     {
	        case '1': 
		   document.getElementsByName(cellName)[0].style.cursor =
			     document.all.item("Cur1").style.cursor; 
		             break;
	        case '2': 
		   document.getElementsByName(cellName)[0].style.cursor =
			     document.all.item("Cur2").style.cursor; 
		             break;
	        case '3': 
		   document.getElementsByName(cellName)[0].style.cursor =
			     document.all.item("Cur3").style.cursor; 
		             break;
	        case '4': 
		   document.getElementsByName(cellName)[0].style.cursor =
			     document.all.item("Cur4").style.cursor; 
		             break;
	        case '5': 
		   document.getElementsByName(cellName)[0].style.cursor =
			     document.all.item("Cur5").style.cursor; 
		             break;
	        case '6': 
		   document.getElementsByName(cellName)[0].style.cursor =
			     document.all.item("Cur6").style.cursor; 
		             break;
	        case '7': 
		   document.getElementsByName(cellName)[0].style.cursor =
			     document.all.item("Cur7").style.cursor; 
		             break;
	        case '8': 
		   document.getElementsByName(cellName)[0].style.cursor =
			     document.all.item("Cur8").style.cursor; 
		             break;
	        case '9': 
		   document.getElementsByName(cellName)[0].style.cursor =
			     document.all.item("Cur9").style.cursor; 
		             break;
	        case 'X': 
		   document.getElementsByName(cellName)[0].style.cursor =
			     document.all.item("CurX").style.cursor; 
		             break;
	        case 'P': 
		   document.getElementsByName(cellName)[0].style.cursor = 'default';
		             break;
		default : ;
	     }
          }

	    switch (value) 
	    {
	    	case '1': 
			SudTable.style.cursor = cur1.style.cursor; 
	                text = "Click on a square to insert \'1\'      ";
		             break;
		case '2': 
			SudTable.style.cursor = cur2.style.cursor; 
	                text = "Click on a square to insert \'2\'      ";
		             break;
		case '3': 
			SudTable.style.cursor = cur3.style.cursor; 
	                text = "Click on a square to insert \'3\'      ";
		             break;
	        case '4': 
			SudTable.style.cursor = cur4.style.cursor; 
	                text = "Click on a square to insert \'4\'      ";
		             break;
	        case '5': 
			SudTable.style.cursor = cur5.style.cursor; 
	                text = "Click on a square to insert \'5\'      ";
		             break;
	        case '6': 
			SudTable.style.cursor = cur6.style.cursor; 
	                text = "Click on a square to insert \'6\'      ";
		             break;
	        case '7': 
			SudTable.style.cursor = cur7.style.cursor; 
	                text = "Click on a square to insert \'7\'      ";
		             break;
	        case '8': 
			SudTable.style.cursor = cur8.style.cursor; 
	                text = "Click on a square to insert \'8\'      ";
		             break;
	        case '9': 
			SudTable.style.cursor = cur9.style.cursor; 
	                text = "Click on a square to insert \'9\'      ";
		             break;
	        case 'X': 
			SudTable.style.cursor = curX.style.cursor; 
	                text = "Click on a square to clear it.   ";
		             break;
	        case 'P': 
			SudTable.style.cursor = 'default'; 
	                text = "                                         ";
		             break;
		default : ;
            }


        }
        currMouseValue = value;
        }
        catch(err)
        {
	   alert("Error in function MouseSelection1 : "+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 Mouse2Selection ( value )
      {
        try {
        var cellName;

        if ( loaded==1 )
        {
	    switch (value) 
	    {
	    	case '1': 
			SudTable.style.cursor = cur1.style.cursor; 
	                text = "Click on a square to insert \'1\'      ";
		             break;
		case '2': 
			SudTable.style.cursor = cur2.style.cursor; 
	                text = "Click on a square to insert \'2\'      ";
		             break;
		case '3': 
			SudTable.style.cursor = cur3.style.cursor; 
	                text = "Click on a square to insert \'3\'      ";
		             break;
	        case '4': 
			SudTable.style.cursor = cur4.style.cursor; 
	                text = "Click on a square to insert \'4\'      ";
		             break;
	        case '5': 
			SudTable.style.cursor = cur5.style.cursor; 
	                text = "Click on a square to insert \'5\'      ";
		             break;
	        case '6': 
			SudTable.style.cursor = cur6.style.cursor; 
	                text = "Click on a square to insert \'6\'      ";
		             break;
	        case '7': 
			SudTable.style.cursor = cur7.style.cursor; 
	                text = "Click on a square to insert \'7\'      ";
		             break;
	        case '8': 
			SudTable.style.cursor = cur8.style.cursor; 
	                text = "Click on a square to insert \'8\'      ";
		             break;
	        case '9': 
			SudTable.style.cursor = cur9.style.cursor; 
	                text = "Click on a square to insert \'9\'      ";
		             break;
	        case 'X': 
			SudTable.style.cursor = curX.style.cursor; 
	                text = "Click on a square to clear it.   ";
		             break;
	        case 'P': 
			SudTable.style.cursor = 'default'; 
	                text = "                                         ";
		             break;
		default : ;
            }

          for (i = 0; i <= 80; i++)
          {
             cellName = cellNames[i];
     	     if ( document.getElementsByName(cellName)[0].value == value )
             {
               HighlightCell ( cellName );
             }
	     else
             {
               if (firstTime==0)
               {
                 ClearHighlightCell ( cellName );
               }
             }
          }

	  var table = document.getElementsByName("SudokuTable");

          switch (value) 
	  {
	     case '1': 
      	           table.cursor = document.all.item("Cur1").style.cursor; 
		             break;
	        case '2': 
      	           table.cursor = document.all.item("Cur2").style.cursor; 
		             break;
	        case '3': 
      	           table.cursor = document.all.item("Cur3").style.cursor; 
		             break;
	        case '4': 
      	           table.cursor = document.all.item("Cur4").style.cursor; 
		             break;
	        case '5': 
      	           table.cursor = document.all.item("Cur5").style.cursor; 
		             break;
	        case '6': 
      	           table.cursor = document.all.item("Cur6").style.cursor; 
		             break;
	        case '7': 
      	           table.cursor = document.all.item("Cur7").style.cursor; 
		             break;
	        case '8': 
      	           table.cursor = document.all.item("Cur8").style.cursor; 
		             break;
	        case '9': 
      	           table.cursor = document.all.item("Cur9").style.cursor; 
		             break;
	        case 'X': 
      	           table.cursor = document.all.item("CurX").style.cursor; 
		             break;
	        case 'P': 
		   table.cursor = 'default';
		             break;
		default : ;
          }
          currMouseValue = value;
          firstTime = 0;
         }
        }
        catch(err)
        {
	   alert("Error in function MouseSelection : "+err.description);
        }
      }

      function Mouse3Selection ( value )
      {
        try {
        var cellName;

        if ( loaded==1 )
        {
          for (i = 0; i <= 80; i++)
          {
             cellName = cellNames[i];
     	     if ( document.getElementsByName(cellName)[0].value == value )
             {
               HighlightCell ( cellName );
             }
	     else
             {
               if (firstTime==0)
               {
                 ClearHighlightCell ( cellName );
               }
             }

	     switch (value) 
	     {
	        case '1': 
		   document.getElementsByName(cellName)[0].style.cursor = 
			       document.all.item("Cur1").style.cursor; 
		             break;
	        case '2': 
		   document.getElementsByName(cellName)[0].style.cursor = 
			       document.all.item("Cur2").style.cursor; 
		             break;
	        case '3': 
		   document.getElementsByName(cellName)[0].style.cursor =
			       document.all.item("Cur3").style.cursor; 
		             break;
	        case '4': 
		   document.getElementsByName(cellName)[0].style.cursor = 
			       document.all.item("Cur4").style.cursor; 
		             break;
	        case '5': 
		   document.getElementsByName(cellName)[0].style.cursor = 
			       document.all.item("Cur5").style.cursor; 
		             break;
	        case '6': 
		   document.getElementsByName(cellName)[0].style.cursor = 
			       document.all.item("Cur6").style.cursor; 
		             break;
	        case '7': 
		   document.getElementsByName(cellName)[0].style.cursor = 
			       document.all.item("Cur7").style.cursor; 
		             break;
	        case '8': 
		   document.getElementsByName(cellName)[0].style.cursor = 
			       document.all.item("Cur8").style.cursor; 
		             break;
	        case '9': 
		   document.getElementsByName(cellName)[0].style.cursor = 
			       document.all.item("Cur9").style.cursor; 
		             break;
	        case 'X': 
		   document.getElementsByName(cellName)[0].style.cursor =
			       document.all.item("CurX").style.cursor; 
		             break;
	        case 'P': 
		   document.getElementsByName(cellName)[0].style.cursor = 'default';
		             break;
		default : ;
	     }
          }
	    switch (value) 
	    {
	    	case '1': 
			SudTable.style.cursor = cur1.style.cursor; 
	                text = "Click on a square to insert \'1\'      ";
		             break;
		case '2': 
			SudTable.style.cursor = cur2.style.cursor; 
	                text = "Click on a square to insert \'2\'      ";
		             break;
		case '3': 
			SudTable.style.cursor = cur3.style.cursor; 
	                text = "Click on a square to insert \'3\'      ";
		             break;
	        case '4': 
			SudTable.style.cursor = cur4.style.cursor; 
	                text = "Click on a square to insert \'4\'      ";
		             break;
	        case '5': 
			SudTable.style.cursor = cur5.style.cursor; 
	                text = "Click on a square to insert \'5\'      ";
		             break;
	        case '6': 
			SudTable.style.cursor = cur6.style.cursor; 
	                text = "Click on a square to insert \'6\'      ";
		             break;
	        case '7': 
			SudTable.style.cursor = cur7.style.cursor; 
	                text = "Click on a square to insert \'7\'      ";
		             break;
	        case '8': 
			SudTable.style.cursor = cur8.style.cursor; 
	                text = "Click on a square to insert \'8\'      ";
		             break;
	        case '9': 
			SudTable.style.cursor = cur9.style.cursor; 
	                text = "Click on a square to insert \'9\'      ";
		             break;
	        case 'X': 
			SudTable.style.cursor = curX.style.cursor; 
	                text = "Click on a square to clear it.   ";
		             break;
	        case 'P': 
			SudTable.style.cursor = 'default'; 
	                text = "                                         ";
		             break;
		default : ;
            }

          currMouseValue = value;
          firstTime = 0;
        }
        }
        catch(err)
        {
	   alert("Error in function MouseSelection : "+err.description);
        }
      }

      function Mouse4Selection ( value )
      {
        try {
          var cellName;

          if ( loaded==1 )
          {
            for (i = 0; i <= 80; i++)
            {
              cellName = cellNames[i];
     	      if ( document.getElementsByName(cellName)[0].value == value )
              {
                HighlightCell ( cellName );
              }
  	      else
              {
                if (!firstTime)
                {
                  ClearHighlightCell ( cellName );
                }
              }

	      switch (value) 
	      {
	        case '1': 
		   document.getElementsByName(cellName)[0].style.cursor = 
			       document.all.item("Cur1").style.cursor; 
		             break;
	        case '2': 
		   document.getElementsByName(cellName)[0].style.cursor = 
			       document.all.item("Cur2").style.cursor; 
		             break;
	        case '3': 
		   document.getElementsByName(cellName)[0].style.cursor =
			       document.all.item("Cur3").style.cursor; 
		             break;
	        case '4': 
		   document.getElementsByName(cellName)[0].style.cursor = 
			       document.all.item("Cur4").style.cursor; 
		             break;
	        case '5': 
		   document.getElementsByName(cellName)[0].style.cursor = 
			       document.all.item("Cur5").style.cursor; 
		             break;
	        case '6': 
		   document.getElementsByName(cellName)[0].style.cursor = 
			       document.all.item("Cur6").style.cursor; 
		             break;
	        case '7': 
		   document.getElementsByName(cellName)[0].style.cursor = 
			       document.all.item("Cur7").style.cursor; 
		             break;
	        case '8': 
		   document.getElementsByName(cellName)[0].style.cursor = 
			       document.all.item("Cur8").style.cursor; 
		             break;
	        case '9': 
		   document.getElementsByName(cellName)[0].style.cursor = 
			       document.all.item("Cur9").style.cursor; 
		             break;
	        case 'X': 
		   document.getElementsByName(cellName)[0].style.cursor =
			       document.all.item("CurX").style.cursor; 
		             break;
	        case 'P': 
		   document.getElementsByName(cellName)[0].style.cursor = 'default';
		             break;
		default : ;
	      }
            }
	    switch (value) 
	    {
	    	case '1': 
			SudTable.style.cursor = cur1.style.cursor; 
	                text = "Click on a square to insert \'1\'      ";
		             break;
		case '2': 
			SudTable.style.cursor = cur2.style.cursor; 
	                text = "Click on a square to insert \'2\'      ";
		             break;
		case '3': 
			SudTable.style.cursor = cur3.style.cursor; 
	                text = "Click on a square to insert \'3\'      ";
		             break;
	        case '4': 
			SudTable.style.cursor = cur4.style.cursor; 
	                text = "Click on a square to insert \'4\'      ";
		             break;
	        case '5': 
			SudTable.style.cursor = cur5.style.cursor; 
	                text = "Click on a square to insert \'5\'      ";
		             break;
	        case '6': 
			SudTable.style.cursor = cur6.style.cursor; 
	                text = "Click on a square to insert \'6\'      ";
		             break;
	        case '7': 
			SudTable.style.cursor = cur7.style.cursor; 
	                text = "Click on a square to insert \'7\'      ";
		             break;
	        case '8': 
			SudTable.style.cursor = cur8.style.cursor; 
	                text = "Click on a square to insert \'8\'      ";
		             break;
	        case '9': 
			SudTable.style.cursor = cur9.style.cursor; 
	                text = "Click on a square to insert \'9\'      ";
		             break;
	        case 'X': 
			SudTable.style.cursor = curX.style.cursor; 
	                text = "Click on a square to clear it.   ";
		             break;
	        case 'P': 
			SudTable.style.cursor = 'default'; 
	                text = "                                         ";
		             break;
		default : ;
            }


	    switch (value) 
	    {
	    	case '1': 
			SudTable.style.cursor = document.all.item("Cur1").style.cursor; 
		             break;
		case '2': 
			SudTable.style.cursor = document.all.item("Cur2").style.cursor; 
		             break;
		case '3': 
			SudTable.style.cursor = document.all.item("Cur3").style.cursor; 
		             break;
	        case '4': 
			SudTable.style.cursor = document.all.item("Cur4").style.cursor; 
		             break;
	        case '5': 
			SudTable.style.cursor = document.all.item("Cur5").style.cursor; 
		             break;
	        case '6': 
			SudTable.style.cursor = document.all.item("Cur6").style.cursor; 
		             break;
	        case '7': 
			SudTable.style.cursor = document.all.item("Cur7").style.cursor; 
		             break;
	        case '8': 
			SudTable.style.cursor = document.all.item("Cur8").style.cursor; 
		             break;
	        case '9': 
			SudTable.style.cursor = document.all.item("Cur9").style.cursor; 
		             break;
	        case 'X': 
			SudTable.style.cursor = document.all.item("CurX").style.cursor; 
		             break;
	        case 'P': 
			SudTable.style.cursor = 'default'; 
		             break;
		default : ;
            }

            currMouseValue = value;
            firstTime = 0;
          }
          return false;
        }
        catch(err)
        {
	   alert("Error in function MouseSelection : "+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';
          HighlightField ( document.getElementsByName(cellName)[0]);
        }
        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';
          color = GetColorByVal ( field.value );
  	  field.style.border = '2px solid '+color;
        }
        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 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;

        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' );
        }
        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];
          //color = GetColorByVal ( moveVal[numMoves] );
          //document.getElementsByName(cellName)[0].style.color=color;
          document.getElementsByName(cellName)[0].className = GetClassNameByVal ( moveVal[numMoves] );

          index=GetIndexByCellName(cellName);
          mirrorVal[index] = moveVal[numMoves];
      	  if ( document.getElementsByName(movePlace[numMoves])[0].value !=  
		 currMouseValue )
          {
            ClearHighlightCell ( movePlace[numMoves] );
          }
          numMoves--;
        }
      }

      function AddUndoStep( cellName, currVal ) 
      {
        if (numMoves==0)
        {
          StartTimer();
        }
	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 (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 = CheckSquare(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)
        {
          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();

        endPuzzle();

        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 CheckSquare(squareNum)
      {
        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(squareNum / 3)) * 3;
            j = c + (squareNum % 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);
           clockID  = 0;
         }

         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 HandleMouseOverButton ( fieldName )
      {
        try 
        {
          if ( loaded==1 )
          {
            document.getElementsByName(fieldName)[0].style.BorderStyle='inset'; 
            document.getElementsByName(fieldName)[0].style.background='#c8c8c8'; 
            document.getElementsByName(fieldName)[0].style.color='#000044'; 

          }
        }
        catch(err)
        {
	   alert("Error in function HandleMouseOverButton : "+err.description);
        }
      }

      function HandleMouseOutButton ( fieldName )
      {
        try 
        {
          if ( loaded==1 )
          {
              document.getElementsByName(fieldName)[0].style.BorderStyle='outset'; 
              document.getElementsByName(fieldName)[0].style.background='#e8e8e8'; 
              document.getElementsByName(fieldName)[0].style.color='#2266aa'; 
          }
        }
        catch(err)
        {
	   alert("Error in function HandleMouseOutButton : "+err.description);
        }
      }


      function BHandleMouseOverButton ( fieldName )
      {
        try 
        {
          if ( loaded==1 )
          {
            //document.getElementsByName(fieldName)[0].style.BorderStyle='outset'; 
            //document.getElementsByName(fieldName)[0].style.background='#114411'; 
            //document.getElementsByName(fieldName)[0].style.border='4px solid'; 
            document.getElementsByName(fieldName)[0].style.color='#000044'; 
//            document.getElementsByName(fieldName)[0].style.BorderColor='#336633'; 
//            document.getElementsByName(fieldName)[0].style.BorderLeftColor='#336633'; 
  //          document.getElementsByName(fieldName)[0].style.BorderBottomColor='#aaaa66'; 
    //        document.getElementsByName(fieldName)[0].style.BorderRightColor='#aaaa66'; 
          }
        }
        catch(err)
        {
	   alert("Error in function HandleMouseOverButton : "+err.description);
        }
      }

      function BHandleMouseOutButton ( fieldName )
      {
        try 
        {
          if ( loaded==1 )
          {
//              document.getElementsByName(fieldName)[0].Style.color='#444433'; 
  //          document.getElementsByName(fieldName)[0].style.background='#007700'; 
//              document.getElementsByName(fieldName)[0].Style.border='4px solid'; 
            //document.getElementsByName(fieldName)[0].style.color='#000044'; 
           // document.getElementsByName(fieldName)[0].Style.BorderTopColor='#0000ff'; 
            document.getElementsByName(fieldName)[0].style.BorderLeftColor='#0000ff'; 
          }
        }
        catch(err)
        {
	   alert("Error in function HandleMouseOutButton : "+err.description);
        }
      }


      function HandleMouseOverNumSel ( value )
      {
        if ( loaded!=1 ) return;
        try 
        {
	  switch (value) 
	  {
	    case '1': 
                 HighlightNumTemp(cellNumFields[0]);
		 break;
            case '2': 
                 HighlightNumTemp(cellNumFields[1]);
	         break;
	    case '3': 
                 HighlightNumTemp(cellNumFields[2]);
	         break;
	    case '4': 
                 HighlightNumTemp(cellNumFields[3]);
	         break;
	    case '5': 
                 HighlightNumTemp(cellNumFields[4]);
	         break;
	    case '6': 
                 HighlightNumTemp(cellNumFields[5]);
	         break;
	    case '7': 
                 HighlightNumTemp(cellNumFields[6]);
	         break;
	    case '8': 
                 HighlightNumTemp(cellNumFields[7]);
	         break;
	    case '9': 
                 HighlightNumTemp(cellNumFields[8]);
	         break;
	    case 'X': 
                 HighlightNumTemp(cellNumFields[9]);
		 break;
            default : ;
	  }
        }
        catch(err)
        {
	   alert("Error in function HighlightCurrNum : "+err.description);
        }
      }

      function AHandleMouseOutNumSel ( value )
      {
        try 
        {
	  switch (currMouseValue) 
	  {
	    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 : {
		  switch (value) 
		  {
		    case '1': 
        	         ClearHighlightNumTemp(cellNumFields[0]);
			 break;
	            case '2': 
        	         ClearHighlightNumTemp(cellNumFields[1]);
		         break;
		    case '3': 
        	         ClearHighlightNumTemp(cellNumFields[2]);
	        	 break;
		    case '4': 
        	         ClearHighlightNumTemp(cellNumFields[3]);
		         break;
		    case '5': 
        	         ClearHighlightNumTemp(cellNumFields[4]);
	        	 break;
		    case '6': 
        	         ClearHighlightNumTemp(cellNumFields[5]);
		         break;
		    case '7': 
                	 ClearHighlightNumTemp(cellNumFields[6]);
		         break;
		    case '8': 
                	 ClearHighlightNumTemp(cellNumFields[7]);
		         break;
		    case '9': 
                	 ClearHighlightNumTemp(cellNumFields[8]);
		         break;
		    case 'X': 
                	 ClearHighlightNumTemp(cellNumFields[9]);
			 break;
	            default : 
	   	    }
                }
	  }
        }
        catch(err)
        {
	   alert("Error in function HandleMouseOutButton : "+err.description);
        }
      }


      function HandleMouseOutNumSel ( value )
      {
        if ( loaded!=1 ) return;
        try 
        {
	  switch (value) 
	  {
	    case '1': 
                 HandleHighlightNumTempOut ( cellNumFields[0],
                                             value,currMouseValue );
		 break;
            case '2': 
                 HandleHighlightNumTempOut ( cellNumFields[1],
                                             value,currMouseValue );
	         break;
	    case '3': 
                 HandleHighlightNumTempOut ( cellNumFields[2],
                                             value,currMouseValue );
	         break;
	    case '4': 
                 HandleHighlightNumTempOut ( cellNumFields[3],
                                             value,currMouseValue );
	         break;
	    case '5': 
                 HandleHighlightNumTempOut ( cellNumFields[4],
                                             value,currMouseValue );
	         break;
	    case '6': 
                 HandleHighlightNumTempOut ( cellNumFields[5],
                                             value,currMouseValue );
	         break;
	    case '7': 
                 HandleHighlightNumTempOut ( cellNumFields[6],
                                             value,currMouseValue );
	         break;
	    case '8': 
                 HandleHighlightNumTempOut ( cellNumFields[7],
                                             value,currMouseValue );
	         break;
	    case '9': 
                 HandleHighlightNumTempOut ( cellNumFields[8],
                                             value,currMouseValue );
	         break;
	    case 'X': 
                 HandleHighlightNumTempOut ( cellNumFields[9],
                                             value,currMouseValue );
		 break;
            default : ;
	  }
        }
        catch(err)
        {
	   alert("Error in function HandleMouseOutButton : "+err.description);
        }
      }


      function HandleHighlightNumTempOut ( field,value,currValue )
      {
        if (value == currValue)
        {
          HighlightNum(field);
        }
        else
        {
          ClearHighlightNumTemp(field);
        }
      }

      function ClearHighlightNumTemp ( field )
      {
        try {
          field.style.BorderStyle='outset'; 
          field.style.background='#ffffff'; 
          field.style.color='#262d8b'; 
        }
        catch(err)
        {
	   alert("Error in function ClearTempHighlightNum : "+err.description);
        }
      }

      function HighlightNumTemp ( field )
      {
        try {
          field.style.BorderStyle='inset'; 
          field.style.background='#c8c8c8'; 
          field.style.color='#000044'; 
        }
        catch(err)
        {
	   alert("Error in function HighlightNumTemp : "+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 = 1;

          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;
          t="";

          //alert("Restore");
	  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
                {
                  //color = GetColorByVal ( cellValue );
                  //cellField.style.color=color;
                  cellField.className = GetClassNameByVal ( cellValue );
                  cellField.value = cellValue;
                  mirrorVal[i] = cellField.value;
                }
              
                if ( game.charAt(i*4) == 'A')
                {
                  cellField.readOnly=false;
                  str = 'A' + cellField.id.charAt(1)
                            + cellField.id.charAt(2)
                            + cellValue;
                  cellField.id=str;
                }
                else
                {
                  cellField.className = GetClassNameByVal ( cellValue );
                  cellField.readOnly=true;
                  str = 'R' + cellField.id.charAt(1)
                            + cellField.id.charAt(2)
                            + cellValue;
                  cellField.id=str;
                } 
                ClearHighlightField ( cellField );
              }

              document.getElementById("NumSudParam").value = num;

              ClearStatus();
              numMoves=0; 
              MouseSelection ( 'P' );
            } 
          }
        }
        catch(err)
        {
	   alert("Error in function RestoreGame : "+err.description);
        }
      }


      var xmlHttp

      function getNewGame()
      {
        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;

  	  xmlHttp.onreadystatechange=stateChanged 
  	  xmlHttp.open("GET",url,true)
          xmlHttp.send(null)
        }
        catch(err)
        {
	   alert("Error in function getNewGame : "+err.description);
        }
     } 

     function stateChanged() 
     { 
//       alert(xmlHttp.readyState)
       try 
       {
         if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
         { 
           //document.getElementById("theGame").innerHTML=xmlHttp.responseText 
           //  alert (xmlHttp.responseText);

             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
               {
                 //color = GetColorByVal ( cellValue );
                 //cellField.style.color=color;
                 cellField.className = GetClassNameByVal ( cellValue );

                 cellField.value = cellValue;
                 mirrorVal[i] = cellField.value;
               }
               if ( game.charAt(i*4) == 'A')
               {
                 cellField.readOnly=false;
                 str = 'A' + cellField.id.charAt(1) + 
                             cellField.id.charAt(2) + 
                             cellValue;
                 cellField.id=str;
               }
               else
               {
                 cellField.readOnly=true;
                 str = 'R' + cellField.id.charAt(1) + 
                             cellField.id.charAt(2) + 
                             cellValue;
                 cellField.id=str;
               } 
               ClearHighlightField ( cellField );
             }

             document.getElementById("NumSudParam").value = num;

             ClearStatus();
             ResetTimer();
             numMoves=0; 
         } 
       }
       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()
      {
          updatePoints()
      }

      var xmlHttp2

      function updatePoints()
      {
        if ( loaded!=1 ) return;

        try 
        {
	  xmlHttp2=GetXmlHttpObject();

          if (xmlHttp2==null)
          {
            alert ("Browser does not support HTTP Request.")
            return
          } 

          memberId = document.getElementById("MemberId").value;
          //alert(memberId);

  	  xmlHttp2.onreadystatechange=stateChanged2

          var url=puzzleBasePath+"/updatepoints.php"

          var params = "member_id="+memberId
          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
           {
             document.getElementById("total_points").value=value;
           }
         }
       }
       catch(err)
       {
         alert("Error in function stateChanged2 : "+err.description);
       }
     } 

     var xmlHttp3

     function endPuzzle()
     {
       var url;

       if ( loaded!=1 ) return;

       try 
       {
	 xmlHttp3=GetXmlHttpObject();

         if (xmlHttp3==null)
         {
           alert ("Browser does not support HTTP Request.")
           return
         } 

         var num = document.getElementById("NumSudParam").value;
         var memberId = document.getElementById("MemberId").value;
//         xmlHttp3.onreadystatechange=null;

         var url=puzzleBasePath+"/endpuzzle.php"

          var params = "member_id="+memberId+"&num="+num;
          xmlHttp3.open("POST", url, true,"","");

	  //Send the proper header information along with the request
          xmlHttp3.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
          xmlHttp3.setRequestHeader("Content-length", params.length);
          xmlHttp3.setRequestHeader("Connection", "close");

          xmlHttp3.send(params)
        }
        catch(err)
        {
	   alert("Error in function endpuzzle : "+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);
        }
      }

    //-->


