function hideElement(sElement,IE6test)
{
  var x=document.getElementById(sElement);
  
  if (x) {
// 6/12/09 DES: looks like MS patched IE6 to both break this special handling and make it unnecessary
/*
    if ( IE6test ) { //test for IE
      x.style.visibility = 'hidden';
      x.style.marginTop = '-' + x.offsetHeight.toString() + 'px';
		// L7/8 templates use inline display which must be cleared.
		x.style.display = 'block';
    } else {
      x.style.display = 'none';
    }
*/
    x.style.display = 'none';
  }
}

function hideElementHorizontal(sElement,IE6test)
{
  var x=document.getElementById(sElement);

  if (x) {
// 06/12/09 DES: looks like MS patched IE6 to both break this special handling and make it unnecessary
/*
    if ( IE6test ) { //test for IE
      x.style.visibility = 'hidden';
      x.style.marginRight = '-' + x.offsetWidth.toString() + 'px';
    } else {
      x.style.display = 'none';
    }
*/
    x.style.display = 'none';
  }
}


// this function will move selected option object(s) from 
// one select element to another select element
function moveOption(sSelectFrom,sSelectTo)
{
  var oSelect1 = document.getElementById(sSelectFrom);
  var oSelect2 = document.getElementById(sSelectTo);

  var i;
  for (i = oSelect1.length - 1; i>=0; i--) {
    if (oSelect1.options[i].selected) {

      var oOption1 = oSelect1.options[i];
      var oOption2 = document.createElement('option');
      oOption2.text = oOption1.text;
      oOption2.value = oOption1.value;
      try {
        oSelect2.add(oOption2,null); // non-IE
        oSelect1.remove(i);
      }
      catch(ex) {
        oSelect2.add(oOption2); // IE
        oSelect1.remove(i);
      }
    }
  }
}

// this function will fill a text box with the values from a select element
function populateInput(sSelectFrom, sInputTo)
{
  var oSelect = document.getElementById(sSelectFrom);
  var oInput = document.getElementById(sInputTo);

  var i;
  var sList = "";
  for (i = oSelect.length - 1; i>=0; i--) {
    if (sList.length == 0) {
	   sList = oSelect.options[i].value;
	 }
	 else {
      sList = sList + ',' + oSelect.options[i].value;
	 }
  }
  oInput.value = sList;
}

// removes a class from an element
function removeClass(sObject,sClass)
{
  var oObject = document.getElementById(sObject);
  var retval = false;

  if ( oObject ) 
    {
    if ( oObject.className )
    {
      var aList = oObject.className.split(' ');
      var sClassUpper = sClass.toUpperCase();
      var sNewClassList = " ";
      for ( var i=0; i < aList.length; i++ )
      {
        if ( aList[i].toUpperCase() != sClassUpper )
        {
          sNewClassList = sNewClassList + ' ' + aList[i];
        }
        else
        {
          retval = true;  // class removed
        }
      }
      oObject.className = sNewClassList;
    }
  }

  return retval;
}


// adds a class to an element
function addClass(sObject,sClass)
{
  // remove the class first to avoid duplicates
  removeClass(sObject,sClass);

  var oObject = document.getElementById(sObject);
  var sNewClassList = sClass + ' ' + oObject.className;
  oObject.className = sNewClassList;
}


// adds a class to an element if it does not already exist.
// if it already has the class, it will remove it.
function toggleClass(sObject,sClass)
{
  // removeClass will return true if the class was found.
  if ( ! removeClass(sObject,sClass) ) 
  {
    // not found, add it
    var oObject = document.getElementById(sObject);
    var sNewClassList = sClass + ' ' + oObject.className;
    oObject.className = sNewClassList;
  }
}

// completely remove an element
function removeElement(sObject) {
  var oObject = document.getElementById(sObject);
  
  if ( oObject )
  {
    oObject.parentNode.removeChild(oObject);
  }
}

