var SudokuJS = 
{
    Sudoku_TextBoxValidate : function (textboxControl, a, b, c, d)
    {
        var objTextBoxControl = document.getElementById(textboxControl);
        var Number1 = 1;
        var Number2 = 9;
        if (objTextBoxControl.value.length != 0)
        {
            switch (this.isIntegerInRange(objTextBoxControl.value, Number1, Number2))
            {
             case true:
                if (objTextBoxControl.value < 1 || objTextBoxControl.value >9)
                    {
                        if (b == 2 && d == 2 && a == 2 && c == 2)
                        {
                            objTextBoxControl.className = "Sudoku_TextBox_InvalidValue_Last";
                        }
                        else if (b == 2 && d ==2)
                        {
                            objTextBoxControl.className = "Sudoku_TextBox_InvalidValue_Right";
                        }
                        else if (a == 2 && c == 2)
                        {
                            objTextBoxControl.className = "Sudoku_TextBox_InvalidValue_Bottom";
                        }
                        else
                        {
                            objTextBoxControl.className = "Sudoku_TextBox_InvalidValue";
                        }
                        objTextBoxControl.focus()
                    }
                    else
                    {
                        //CheckForValidValue(objTextBoxControl, a, b, c, d);
                        if (b == 2 && d == 2 && a == 2 && c == 2)
                        {
                            objTextBoxControl.className = "Sudoku_TextBox_Last";
                        }
                        else if (b == 2 && d ==2)
                        {
                            objTextBoxControl.className = "Sudoku_TextBox_Right";
                        }
                        else if (a == 2 && c == 2)
                        {
                            objTextBoxControl.className = "Sudoku_TextBox_Bottom";
                        }
                        else
                        {
                            objTextBoxControl.className = "Sudoku_TextBox";
                        }
                    }
                break;
             case false:
                objTextBoxControl.className ="Sudoku_TextBox_InvalidValue";
            }
        }
    },
    
    CheckForValidValue : function (objTextBoxControl_EnteredValue, a, b, c, d)
    {
        var iLoop = 0, jLoop = 0, kLoop = 0, lLoop = 0;
        var nIndex_EnteredValue, nIndex;
        //Check within the 9 values BOX
        for (kLoop=0;kLoop<9;kLoop++)
        {
            for (lLoop=0;lLoop<9;lLoop++)
            {
                nIndex = a * 27 + b * 9 + kLoop * 3 + lLoop * 1;
                alert("txtEntry_" + nIndex);
                var objTextBoxControl = document.getElementById("txtEntry_" + nIndex);
                
                if (kLoop != c && lLoop != d)
                {
                    if (objTextBoxControl.value ==objTextBoxControl_EnteredValue.value)
                    {
                    alert(123);
                    }
                
                }
            }
        }
         
    },
    
    Sudoku_TextBoxBlur : function (textboxControl, a, b, c, d)
    {
        this.Sudoku_TextBoxValidate(textboxControl, a, b, c, d);
    },
    
    isIntegerInRange : function  (s, a, b)
    {   
        if ((s == null) || (s.length == 0))
        if (this.isIntegerInRange.arguments.length == 1) return false;
        else return (this.isIntegerInRange.arguments[1] == true);
        if (!this.isInteger(s, false)) return false;
        var num = parseInt (s);
        return ((num >= a) && (num <= b));
    },
    
    isInteger : function  (s)
    {
      var i;

      if (s == null || s.length == 0)
      if (this.isInteger.arguments.length == 1) return 0;
      else return (this.isInteger.arguments[1] == true);

      for (i = 0; i < s.length; i++)
      {
         var c = s.charAt(i);

         if (!((c >= "0") && (c <= "9"))) return false;
      }

      return true;
    },
    
    ShowWaitingMessage : function ()
    {
        var objDivWaitingMessage = document.getElementById('DivWaitingMessage');
        objDivWaitingMessage.style.display = 'block';
    },
    
    HideWaitingMessage : function ()
    {
        var objDivWaitingMessage = document.getElementById('DivWaitingMessage');
        objDivWaitingMessage.style.display = 'none';
    }
}

