// -----------------------------------------------
// javascript utilities include
// -----------------------------------------------
function menuMouseOver(fld)
{
  fld.className = "mnu_highlight_a";
}

function menuMouseOut(fld)
{
  fld.className = "mnu_a";
}


function menuMouseOverGettingStarted(fld)
{
  fld.className = "mnu_highlight_gettingstarted_a";
}

function menuMouseOutGettingStarted(fld)
{
  fld.className = "mnu_gettingstarted_a";
}




function newsrollMouseOver(fld)
{
  fld.className = "newsroll_recent_item_col_2_headline_inner_a_highlight";
}

function newsrollMouseOut(fld)
{
  fld.className = "newsroll_recent_item_col_2_headline_inner_a";
}


// ------------------------------------------------------------------
// ltrim(string) : Returns a copy of a string without leading spaces.
// ------------------------------------------------------------------
function util_ltrim(str)
{
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(0)) != -1) {
      // We have a string with leading blank(s)...

      var j = 0, i = s.length;

      // Iterate from the far left of string until we
      // don't have any more whitespace...
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;

      // Get the substring from the first non-whitespace
      // character to the end of the string...
      s = s.substring(j, i);
   }
   return s;
}



// ------------------------------------------------------------------
// rtrim(string) : Returns a copy of a string without trailing spaces.
// ------------------------------------------------------------------
function util_rtrim(str)
{
   // We don't want to trip JUST spaces, but also tabs,
   // line feeds, etc.  Add anything else you want to
   // "trim" here in Whitespace
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      // We have a string with trailing blank(s)...

      var i = s.length - 1;       // Get length of string

      // Iterate from the far right of string until we
      // don't have any more whitespace...
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;


      // Get the substring from the front of the string to
      // where the last non-whitespace character is...
      s = s.substring(0, i+1);
   }

   return s;
}



// -------------------------------------------------------------
// trim(string) : Returns a copy of a string without leading or trailing spaces
// -------------------------------------------------------------
function util_trim(str)
{
   return util_rtrim(util_ltrim(str));
}



// ----------------------------------------------
// gets a field value
// ----------------------------------------------
function util_getfieldvalue(formReference, fieldname)
{

  var objString = "formReference." + fieldname;
  var obj = eval(objString);
  var s = obj.value;
  return s;
}


// -----------------------------------------------
// formats a number to money
// -----------------------------------------------
function util_mfmt(pfloatvalue)
{
  return pfloatvalue.toFixed(2);
}

// -----------------------------------------------------------
// gets an element value as a float
// -----------------------------------------------------------
function util_getElementValueAsFloat(el)
{
  var s = util_trim(el.value);
  var v = util_getTextValueAsFloat(s);
  return v;
}


// -----------------------------------------------------------
// gets a text (string) value as float
// -----------------------------------------------------------
function util_getTextValueAsFloat(s)
{
  var v = parseFloat(s,10);
  if (isNaN(v)) {
    v = 0;
  }
  return v;
}

