function IsVer() {   
  this.major = parseInt(navigator.appVersion);
  this.minor = parseFloat(navigator.appVersion);
  var agt = navigator.userAgent.toLowerCase();
  this.ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
  this.ie5up = (this.ie && !this.ie3 && !this.ie4);
  this.nav = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1)
              && (agt.indexOf('compatible') == -1)));
  this.nav6up = (this.nav && (this.major >= 5));
}

function tableMOvr(src, clrOver, clrText){
  src.style.cursor = 'hand';
  src.bgColor = clrOver;
  src.style.color = clrText;
  src.color = clrText;
}

function tableMOut(src, clrIn, clrText){
  src.style.cursor = 'default';
  src.bgColor = clrIn;
  src.style.color = clrText;
  src.color = clrText;
}

function setText(src, fieldname, text){
  if (document.all) {  // IE
    src.innerText = text;
  } else if (document.layers) {  // NS 4
    document[fieldname].document.open();
    document[fieldname].document.write(text)
    document[fieldname].document.close()
  } else {  // NS 6
    document.getElementById(fieldname).innerHTML = text;
  }
}

function setHTMLText(src, fieldname, text) {
  if (document.all) {  // IE
    src.innerHTML = text;
  } else if (document.layers) {  // NS 4
    document[fieldname].document.open();
    document[fieldname].document.write(text)
    document[fieldname].document.close()
  } else {  // NS 6
    document.getElementById(fieldname).innerHTML = text;
  }
}

function setImage(name, image){
  if (document.images) {
    name.src = image;
  }
}

function textClr(src, color, bold) {
  src.style.color = color;
  if (bold) {
   src.style.fontWeight='bold';
  } else {
   src.style.fontWeight='normal';
  }
}

function mOvr(src, clrOver){
  src.style.cursor = 'hand';
  src.bgColor = clrOver;
}

function mOut(src, clrIn){
  src.style.cursor = 'default';
  src.bgColor = clrIn;
}

function textMOvr(src, clrOver, clrText){
  src.style.cursor = 'hand';
  src.style.background = clrOver;
  src.style.color = clrText;
}

function textMOut(src, clrIn, clrText){
  src.style.cursor = 'default';
  src.style.background = clrIn;
  src.style.color = clrText;
}


function buttonMOvr(src, clrOver, clrText){
  src.style.cursor = 'hand';
  src.style.background = clrOver;
  src.style.color = clrText;
}

function buttonMOut(src, clrIn, clrText){
  src.style.cursor = 'default';
  src.style.background = clrIn;
  src.style.color = clrText;
}

function displayNewWindow(location) {
  today = new Date() 
  thisMinutes = today.getMinutes()
  thisSeconds = today.getSeconds()
  newWindow = window.open(location, 'newWin'+thisMinutes+thisSeconds, 'scrollbars=yes,resizable=yes');
  self.name = "mainWin" + thisMinutes + thisSeconds;
}

function displayNewSizeWindow(location, height, width, leftPos, topPos) {
  newWindow = window.open(location,'newWin',
                          'scrollbars=no,resizable=yes,location=no,toolbar=no,left=' + 
                           leftPos + ',top=' + topPos + ',height=' + height + ',width=' + width);
  self.name = "mainWin";
}

function validEmail(email) {
  invalidChars = " /:,;"
  // Cannot be empty
  if (email == "") {
    return false;
  }
  // Does it contain any invalid characters?
  for (i = 0; i < invalidChars.length; i++) {
    badChar = invalidChars.charAt(i);
    if (email.indexOf(badChar,0) > -1) {
      return false;
    }
  }
  // There must be one "@" symbol
  atPos = email.indexOf("@",1)
  if (atPos == -1) {
    return false;
  }
  // and only one "@" symbol
  if (email.indexOf("@", atPos+1) != -1) {
    return false;
  }
  // At least one "." after the "@"
  periodPos = email.indexOf(".",atPos)
  if (periodPos == -1) {
    return false;
  }
  // Must be at least 2 characters after the "."
  if (periodPos+3 > email.length) {
    return false;
  }
  return true;
}

// Display the wait form window.
var waitWindow = null;
function displayWaitWindow(clr) {
  var isVer = new IsVer(); 
  if (isVer.ie5up || isVer.nav6up) {
    waitWindow = window.open('', 'WaitWin', 'scrollbars=no,resizable=yes,location=no,toolbar=no');
    waitWindow.document.close();
    waitWindow.document.write('<html><head><title>One List - PLEASE WAIT...</title></head><body bgColor="#FFFFFF" style="font-family: Arial; font-size: 10pt">');
    waitWindow.document.writeln('<br><br><center><table border="0"><tr>');
    waitWindow.document.writeln('<td>');
    waitWindow.document.writeln("<img border='0' name=waitImage src='/images/Hourglass.gif'>");
    waitWindow.document.writeln('</td>');
    waitWindow.document.writeln('<td valign="middle" style="font-family:arial;font-size:10pt">');
    waitWindow.document.writeln("<font color=" + clr + "><b>Processing Request, Please Wait...</b></font>");
    waitWindow.document.writeln('</td>');
    waitWindow.document.writeln('</tr></table></center>');
    waitWindow.document.write("</body></html>");
    //waitWindow.focus();
  }
}

function closeWaitWindow() {
  var isVer = new IsVer(); 
  if (isVer.ie5up || isVer.nav6up) {
    if (eval("waitWindow") == false) {
      return;
    }
    if (!waitWindow || waitWindow == null) {
      return;    
    }
    if (waitWindow.closed) {
      return;
    }
    waitWindow.document.close();
    waitWindow.document.clear;
    waitWindow.document.writeln('<html><head><title>One List - Finished Process</title></head><body bgColor="#FFFFFF" style="font-family: Arial; font-size: 10pt">');
    waitWindow.document.writeln('<center><a href="javascript:window.close();">Finished Process: Click Here to Close Window</a></center>');
    waitWindow.document.write("</body></html>");
    waitWindow.focus();
    waitWindow.document.close();
    waitWindow.close();
    waitWindow = null;
  }
}

function tableHighlight(src, color, on) {
  src.style.borderColor = color;
  if (on) {
    src.border = "1";
  } else {
    src.border = "0";
  }
  if (document.all) {
    if (on) {
      src.style.cursor = 'hand';
    } else {
      src.style.cursor = 'default';
    }
  } 
}

function newLocation(url) {
  document.location = url;
}

function strFromChar(searchStr, searchChar) {
  // If the search string or char is empty, then return an empty string.
  if (searchStr == "" || searchChar == "") {
    return "";
  }
  // If the search character is not found, then return an empty string.
  charPos = searchStr.indexOf(searchChar.charAt(0), 0);
  if (charPos == -1) {
    return "";
  }
  // Form the new string and return it.
  newStr = "";
  for (i = charPos; i < searchStr.length; i++) {
    newStr = newStr + searchStr.charAt(i);
  }
  return newStr;
}

function formatNumber(value, decplaces) {
  var inStr = "" + value;
  var outStr = "";
  deccnt = -1;
  for (i = 0; i < inStr.length; i++) {
    if (deccnt == decplaces) {
      break;
     }
    nextChar = inStr.charAt(i)
    if (nextChar == "." || deccnt >= 0) {
      deccnt++;
    }
    outStr = outStr + nextChar;
  }
  return outStr;
}

function playAudio(src, fieldname, sample) {
  setHTMLText(src, fieldname, '<embed src="' +sample+ '" name="mplayer" width="318" height="40" autostart="true" loop="false">');
}

function submitWaitForm(srcForm, clr) {
  var isVer = new IsVer(); 
  if (isVer.ie5up || isVer.nav6up) {
    displayWaitWindow(clr);
  }
  srcForm.submit()
}