//------------------------------------------------------
//ShowControl
//------------------------------------------------------
function ShowControl(control)
{
//alert('showcontrol: control: ' + control);
try
  {
    var c = document.getElementById(control);
    if(c!=null)
    {
        //------------------------------------------------------
        //Get the Custom Properties from the COntrol
        //------------------------------------------------------
        var tmpType = 'obj' + control + '.Type';
        var Type = eval(tmpType);

        var tmpFirstRowContainsInstructions = 'obj' + control + '.FirstRowContainsInstructions';
        var FirstRowContainsInstructions = eval(tmpFirstRowContainsInstructions);

        var tmpHasEvents = 'obj' + control + '.HasEvents';
        var HasEvents = eval(tmpHasEvents);

        var tmpInputMask = 'obj' + control + '.InputMask';
        var InputMask = eval(tmpInputMask);

        var tmpInputMaskLength = 'obj' + control + '.InputMaskLength';
        var InputMaskLength = eval(tmpInputMaskLength);

        var tmpMaxLength = 'obj' + control + '.MaxLength';
        var MaxLength = eval(tmpMaxLength);

        var tmpMaxLengthMessage = 'obj' + control + '.MaxLengthMessage';
        var MaxLengthMessage = eval(tmpMaxLengthMessage);

        var tmpMessage = 'obj' + control + '.Message';
        var Message = eval(tmpMessage);

        var tmpAutoPostBack = 'obj' + control + '.AutoPostBack';
        var AutoPostBack = eval(tmpAutoPostBack);

        var tmpBGInfoColor = 'obj' + control + '.BGInfoColor';
        var BGInfoColor = eval(tmpBGInfoColor);

        var tmpHidden = 'obj' + control + '.Hidden';
        var Hidden = eval(tmpHidden);

        var tmpRequired = 'obj' + control + '.Required';
        var Required = eval(tmpRequired);

        var tmpNextControlToFocus = 'obj' + control + '.NextControlToFocus';
        var NextControlToFocus = eval(tmpNextControlToFocus);

        //------------------------------------------------------
        //------------------------------------------------------
        var MainDiv = document.getElementById(control + 'MainDiv');
        var RequiredDiv = document.getElementById(control + 'RequiredDiv');
        var MessageDiv = document.getElementById(control + 'MessageDiv');
        var MaxDiv = document.getElementById(control + 'MaxDiv');
        var MaskDiv = document.getElementById(control + "InputMaskDiv");

        if (MainDiv != null)
        {
            //Show the Div
            MainDiv.style.display='';

            //Mark the Control as not Hidden
            eval("obj" + control + ".Hidden='False';");
            
            if(Type=='TextBox')
            {
                if(Required=='True' && c.value.length <= 0)
                {
                    MainDiv.style.backgroundColor= BGInfoColor;
                    MainDiv.style.border='solid 1px #000';
                }
                else
                {
                    MainDiv.style.backgroundColor='transparent';
                    MainDiv.style.border='solid 0px #000';
                }
                
                if (MaxDiv != null)
                {
                    MaxDiv.style.display='';
                }
                
                ValidateBox(control);
                
            }
            if(Type=='DropDown')
            {
                //Show the MessageDiv
                if(MessageDiv != null)
                {
                    MessageDiv.style.display='';
                }
                
                if(FirstRowContainsInstructions=='True' && c.selectedIndex==0)
                {
                    MainDiv.style.backgroundColor= BGInfoColor;
                    MainDiv.style.border='solid 1px #000';
                    if(MessageDiv != null)
                    {
                        MessageDiv.style.display='';
                    }
                }
                else
                {
                    MainDiv.style.backgroundColor='transparent';
                    MainDiv.style.border='solid 0px #000';
                    if(MessageDiv != null)
                    {
                        MessageDiv.style.display='none';
                    }
                    
                }
                //Validate the Control
                ValidateDropDownControl(control);
                
                //Run the Events
                if(HasEvents=='True')
                {
                    var OnChange = 'Handle' + control + 'Events();';
                    eval(OnChange);
                }                
             }
             
        }
        else
        {
            alert('ShowControl: The object [' + control + '] Is null');
        }
        
        //---------------------------------------------------
        //When the control is displayed, reset the MainDiv
        //Properties and clear out the box
        //---------------------------------------------------
        var t = document.getElementById('obj' + control + 'Hidden');
        if (t!=null)
        {
            t.value = 'False';
        }
        //---------------------------------------------------
    }
  }
catch(err)
  {
      //SilentError
      alert('ShowControl: ' + err.description);
      throw err;
  }
}

//---------------------------------------------------
//HideControl
//---------------------------------------------------
function HideControl(control)
{
try
  {
    var o = document.getElementById(control);
    if(o != null)
    {
        var MainDiv = document.getElementById(control + 'MainDiv');
        
        if (MainDiv != null)
        {
            var t = document.getElementById('obj' + control + 'Hidden');
            if (t!=null)
            {
                t.value = 'True';
            }
                   //---------------------------------------------------
            //When the control is displayed, reset the MainDiv
            //Properties and clear out the box
            //---------------------------------------------------
            MainDiv.style.display='none';
            //---------------------------------------------------
        }
        else
        {
            //alert('HideControl: The object [' + control + '] Is null');
            //Silent Errors
        }
        
        //---------------------------------------------------
        //Event Handler
        //---------------------------------------------------
        var tmpType = 'obj' + control + '.Type';
        var Type = eval(tmpType);
        
        if(Type=='DropDown')
        {
            o.selectedIndex = 0;
        }
        if(Type=='TextBox')
        {
            o.value = '';
        }
        
        try
        {
            var EH = 'Handle' + control + 'Events();';
            eval(EH);
        }
        catch(se)
        {
            //Silent Error
            //alert('silent err1');        
        }
    }
    //---------------------------------------------------
  }
catch(err)
  {
    alert('HideControl: ' + err.description);
    throw err;
  }
}

function FocusControl(control)
{
try
{  
    var o = document.getElementById(control)
    if (o != null)
    {
        try
        {
            var tmpHidden = 'obj' + control + '.Hidden';
            var Hidden = eval(tmpHidden); 
            
            //Use the control that was passed in
            if(Hidden=='True')
            {
                //Skip it
            }
            else
            {
                //Use the default control
                o.focus();
            }
        }
        catch(err1)
        {
            //Silent Error
        }
    }
}
catch(err)
{
    //alert('FocusControl: ' + err.description);
    //throw err;
}
}
