// Javascript script include file

function FixNumber(fieldObj) {
  FixField(fieldObj, '$,%#');
}

function OpenWindow(url, width, height, scroll) {
  var cx = parseInt((screen.width-width)/2);
  var cy = parseInt((screen.height-height)/2);
  var opts = "width=" + width + ", height=" + height + ", left=" + cx + ", top=" + cy;
  if (scroll)
    opts += ", scrollbars=yes";
  var hwnd = window.open(url, "popup", opts);
  hwnd.focus();
}

function FixField(fieldObj, removeChars) {
  if (fieldObj && removeChars.length > 0) {
  	var re = new RegExp('[' + removeChars + ']');
    fieldObj.value = fieldObj.value.replace(re, '');
  }
}

function ToggleClass(objID, className) {
  var obj = null;
  if (document.all)
    obj = document.all[objID];
  else if (document.getElementById(objID))
    obj = document.getElementById(objID);
  
  if (obj)
  	obj.className = className;
}

function BeginFlashing(objID) {
  setTimeout("DoFlash('" + objID + "', 1)", 500);
}

function DoFlash(objID, state) {
  if (state == 1)
    newClass = "flashOn";
  else
    newClass = "flashOff";
 
  ToggleClass(objID, newClass);
    
  setTimeout("DoFlash('" + objID + "', " + (1 - state) + ")", 500);
}

