function setPanelVis(divHeader, visible, blockORinline) 
{
  var divContent = document.getElementById(divHeader.id.replace("Header", "Content"));

  if (!divContent) return;
  if ((blockORinline != 'block') && (blockORinline != 'inline')) blockORinline = 'block';


  if (visible) 
  {
     divContent.style.display = blockORinline;
     divHeader.style.backgroundImage = 'url(generic/chevup.png)';
  } 
  else 
  {
     divContent.style.display = 'none';
     divHeader.style.backgroundImage = 'url(generic/chevdown.png)';
  }
}

function toggleFAQPanel(divHeader, blockORinline) 
{
  var divContent = document.getElementById(divHeader.id.replace("Header", "Content"));

  if (!divContent) return;
  if ((blockORinline != 'block') && (blockORinline != 'inline')) blockORinline = 'block';

  var visible = false;
  if (divContent.style.display == 'none') visible = true;

  if (visible) 
  {
     divContent.style.display = blockORinline;
     divHeader.style.backgroundImage = 'url(generic/chevup.png)';
  } 
  else 
  {
     divContent.style.display = 'none';
     divHeader.style.backgroundImage = 'url(generic/chevdown.png)';
  }
}

function togglePanel(divHeader, blockORinline) 
{
  var divContent = document.getElementById(divHeader.id.replace("Header", "Content"));

  if (!divContent) return;
  if ((blockORinline != 'block') && (blockORinline != 'inline')) blockORinline = 'block';

  var visible = false;
  if (divContent.style.display == 'none') visible = true;

  if (visible) 
  {
     divContent.style.display = blockORinline;
  } 
  else 
  {
     divContent.style.display = 'none';
  }
}

function toggleUnlinkedPanel(divPanelID, blockORinline) 
{
    var divContent = document.getElementById(divPanelID);

    if (!divContent) return;
    if ((blockORinline != 'block') && (blockORinline != 'inline')) blockORinline = 'block';

    var visible = false;
    if (divContent.style.display == 'none') visible = true;

    if (visible) 
    {
        divContent.style.display = blockORinline;
    } 
    else 
    {
        divContent.style.display = 'none';
    }
}

//Useful functions

function FindASPNETControl(ctrlType, ctrlName) 
{
    //to find the type, look in the browser view source ie input or select

    var ElemList = document.getElementsByTagName(ctrlType.toUpperCase());
    var ctrl = null;
    
    if (ElemList) 
    {
        for(var i=0; i < ElemList.length; i++)
        {
            var id = ElemList[i].id;
            
            try 
            {
                if (id.substring(id.length - ctrlName.length, id.length) == ctrlName)
                {
                    ctrl = ElemList[i];
                    break;
                }
            } 
            catch(e) 
            {
            }
        }
    }

    ElemList = null;
    return ctrl;
}

function KeepNumeric(objId)
{
    var str = "";
    
    str = FindASPNETControl("input", objId).value;
    
    if (str.charAt(0) != '0')
    {
      FindASPNETControl("input", objId).value = ""; 
    }
    else if (!IsNumeric(str))
    {
      FindASPNETControl("input", objId).value = str.replace(/[^0-9]/g, ''); 
    }
}

function IsNumeric(ObjVal)
{
    var NumericRegExp = "/^\d+$/";
    var regex = new RegExp(NumericRegExp);
    
    if (!regex.test(ObjVal))
    {
        return false;
    }
    else
    {
        return true;
    }
}
