String.prototype.right = function(count)
{
  return this.substr(this.length - count);
}

String.prototype.left = function(count)
{
  return this.substr(0, count);
}

String.prototype.ltrim = function()
{
  return this.replace(/^\s+/,'');
}

String.prototype.rtrim = function()
{
  return this.replace(/\s+$/,'');
}

String.prototype.trim = function()
{
  return this.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,"");
}

String.prototype.fulltrim = function()
{
  return this.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,"").replace(/\s+/g," ");
}

function PopupWin(strURL, nWidth, nHeight)
{
  var strOpts = "height=" + nHeight + ",width=" + nWidth + ",scrollbars";
  window.open(strURL + "&popupwin=1", 'newWin', strOpts);
}

function HighliteCB(objCheckbox)
{
  objLabel = objCheckbox.parentNode;

  if (objCheckbox.checked)
  {
    objLabel.style.backgroundColor = '#0a246a';
    objLabel.style.color = '#fff';
  }
  else
  {
    objLabel.style.backgroundColor = '#fff';
    objLabel.style.color = '#000';
  }
}

function HighliteRadio(objRadio)
{
  objRadios = objRadio.form.elements[objRadio.name];
  for (var i = 0; i < objRadios.length; i++)
  {
    objLabel = objRadios[i].parentNode;

    if (objRadios[i].checked)
    {
      objLabel.style.backgroundColor = '#0a246a';
      objLabel.style.color = '#fff';
    }
    else
    {
      objLabel.style.backgroundColor = '#fff';
      objLabel.style.color = '#000';
    }
  }
}

function MoveToLinkedLB(strLinked, strAvail)
{
  var objAvail  = document.getElementById(strAvail);
  var objLinked = document.getElementById(strLinked);

  for (var i = 0; i < objAvail.length; i++)
  {
    if (objAvail.options[i].selected == true)
    {
       objLinked.options[objLinked.length] = 
         new Option(objAvail.options[i].text, objAvail.options[i].value);
       objAvail.options[i] = null;
       i = i - 1;
    }
  }
}

function MoveToAvailLB(strLinked, strAvail)
{
  var objAvail  = document.getElementById(strAvail);
  var objLinked = document.getElementById(strLinked);

  for (var i = 0; i < objLinked.length; i++)
  {
    if (objLinked.options[i].selected == true)
    {
      objAvail.options[objAvail.length] = 
        new Option(objLinked.options[i].text, objLinked.options[i].value);
      objLinked.options[i] = null;
      i = i - 1;
    }
  }
}

function ListboxValue(strListbox)
{
  var objListbox = document.getElementById(strListbox);
  var result = "";
  var delim = "";

  for (var i = 0; i < objListbox.options.length; i++)
  {
    result = result + delim + objListbox.options[i].value;
    delim = ",";
  }

  return result;
}

function SelectAll(strListbox)
{
  var objListbox = document.getElementById(strListbox);

  for (var i = 0; i < objListbox.length; i++)
    objListbox.options[i].selected = true;
}

function ToggleLayer(strLayer)
{
  if (document.getElementById)
  {
    // this is the way the standards work

    var style2 = document.getElementById(strLayer).style;
    style2.display = style2.display ? "" : "none";
  }

  else if (document.all)
  {
    // this is the way old MSIE versions work

    var style2 = document.all[strLayer].style;
    style2.display = style2.display ? "" : "none";
  }

  else if (document.layers)
  {
    // this is the way NS4 works

    var style2 = document.layers[strLayer].style;
    style2.display = style2.display ? "" : "none";
  }
}

function ShowLayer(strLayer)
{
  if (document.getElementById)
    document.getElementById(strLayer).style.display = "";

  else if (document.all)
    document.all[strLayer].style.display = "";

  else if (document.layers)
    document.layers[strLayer].style.display = "";
}

function HideLayer(strLayer)
{
  if (document.getElementById)
    document.getElementById(strLayer).style.display = "none";

  else if (document.all)
    document.all[strLayer].style.display = "none";

  else if (document.layers)
    document.layers[strLayer].style.display = "none";
}
