//main switcher of all checkboxes
function SelectAll(state, formName) 
{
  return SelectAllInputs(state, formName, 'CH', 'checkbox');
}

//main switcher of all radio inputs
function SelectAllRadio(state, formName, inputID)
{
  return SelectAllInputs(state, formName, inputID, 'radio');
}

//main abstract switcher of all inputs
function SelectAllInputs(state, formName, inputID, inputType)
{
  var item;
  document.body.style.cursor='wait';
  formName = (formName || '0');
  inputID = inputID.toUpperCase();
  for (i = 0; i < document.forms[formName].elements.length ; i++)
  {
    item = document.forms[formName].elements[i];
    if ((item.type==inputType) && (item.id.toUpperCase()==inputID) && !item.disabled)
    {
      item.checked = state;
    }
  }
  defaultCursor();
}

// on|off the highlighting of row
function SelectRow(CB)
{
  if (CB.checked)  {  hL(CB);}
  else  {  dL(CB);}
}

//high-light the row
function hL(E)
{
  while (E.tagName!="TR")
  {  E=E.parentElement;}
  E.className="H";
}

//de-high-light the row
function dL(E)
{
  while (E.tagName!="TR")
  {  E=E.parentElement;}
  E.className="";
}

function stateSelect(ProductID, ObjId)
{
  if(document.getElementById('td'+ProductID)!==null)
  {
    with (document.getElementById('td'+ProductID))
    {
      if(childNodes[0]!==null && childNodes[0].tagName=="SELECT")
      {
        childNodes[0].value = ObjId;
        childNodes[0].name  = 'sel[' + ProductID + ']';
      }
    }
  }
  return 0;
}
