function PopupWindow( URL, WindowName, MenuOption, WindowHeight, WindowWidth )
{
  MAX_WINDOW_HEIGHT = 685;
  MAX_WINDOW_WIDTH = 780;

  if (WindowHeight > MAX_WINDOW_HEIGHT)
  {
    WindowHeight = MAX_WINDOW_HEIGHT;
  }
  if (WindowWidth > MAX_WINDOW_WIDTH)
  {
    WindowWidth = MAX_WINDOW_WIDTH;
  }

  xcoord=(MAX_WINDOW_WIDTH-WindowWidth)/2;
  ycoord=(MAX_WINDOW_HEIGHT-WindowHeight)/2;

  WindowOptions = 'dependent,scrollbars,resizable,toolbar=no,menubar=' + MenuOption + ',height=' + WindowHeight + ',width=' + WindowWidth + ',left=' + xcoord + ',top=' + ycoord + ',screenX=' + xcoord + ',screenY=' + ycoord;
  n = window.open(URL,WindowName,WindowOptions);
  n.focus();  
}

function ReplaceImage ( CurrentImage, NewImage )
{
  CurrentImage.src = NewImage.src;
}

function SetPage ( PageNumber )
{
  document.forms[0].CurrentPage.value = PageNumber;
  document.forms[0].submit();
}

function ScrollPage ( PageNumber, Scroll )
{
  ThePageNumber = parseInt(PageNumber) + parseInt( Scroll );
  document.forms[0].CurrentPage.value = ThePageNumber;
  document.forms[0].submit();
}

function Previous ( )
{
  if ( document.forms[0].CurrentPage.value > 1 )
  {
    document.forms[0].CurrentPage.value = document.forms[0].CurrentPage.value - 1;
    document.forms[0].Command.value = "";
    document.forms[0].submit();
  }
}

function Next ( )
{
  if ( document.forms[0].LastPage.value == 0 )
  {
    CurrentPage = parseInt ( document.forms[0].CurrentPage.value );
    document.forms[0].CurrentPage.value = CurrentPage + 1;
    document.forms[0].submit();
  }
}

function FormatNumberForDisplay ( input )
{
  if ( !parseInt ( input ) )
  {
    return "$0.00";
  }
  
  number = input.toString ();

  numberLeftOfDecimal = number.indexOf(".");
  if ( numberLeftOfDecimal == -1 )
  {
    numberLeftOfDecimal = number.length;
    numberRightOfDecimal = 0;
  }
  else
  {
    numberRightOfDecimal = number.length - ( numberLeftOfDecimal + 1 )
  }

  theOutput = "$";
  theDigit = 0;
  for ( var i = numberLeftOfDecimal; i > 0; i-- )
  {
    theChar = number.substring ( theDigit, theDigit + 1);
    theOutput = theOutput + theChar;
    if ( ( i % 3 == 1 ) && ( i > 1 ) )
    {
      theOutput = theOutput + ",";
    }
    theDigit++;
  }
  
  if ( number.indexOf(".") >= 0 )
  {
    theDigit ++;
  }

  theOutput = theOutput + ".";
  
  for ( var i = 1; i <= 2; i ++ )
  {
    if ( i > numberRightOfDecimal )
    {
      theOutput = theOutput + "0";
    }
    else
    {
      theOutput = theOutput + number.substring( theDigit, theDigit + 1 );
    }
   theDigit++;
  }
  return theOutput;
}

function roundOff(value, precision)
{
  value = "" + value //convert value to string
  precision = parseInt(precision);

  var whole = "" + Math.round(value * Math.pow(10, precision));
  var decPoint = whole.length - precision;

  if(decPoint != 0)
  {
    result = whole.substring(0, decPoint);
    result += ".";
    result += whole.substring(decPoint, whole.length);
  }
  else
  {
    result = whole;
  }
  return result;
}

function isEmailAddr( EmailAddress )
{
  var theStr = new String( EmailAddress );
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
    {
      return true;
    }
  }
  return false;
}
