//
// this file contains code used by all of the pages
//


//
// browser checks
//
var isDOM    = (document.getElementById) ? true : false;
var isOpera  = (navigator.userAgent.indexOf('Opera') != -1) ;

var isDall   = (document.all) ? true : false;
var isIE     = (document.all && !isOpera) ? true : false;
var isIE4    = isIE && !isDOM;
var isIE5    = isIE && isDOM ;
var isIE55   = (isIE5) && (navigator.appVersion.indexOf('MSIE 5.5') != -1);

var isMac    = (navigator.appVersion.indexOf('Mac') != -1);
var isIE5Mac = isIE5 && isMac;

var isIEWin  = isIE && !isMac;
var isIE4Win = isIE4 && isIEWin;
var isIE5Win = isIE5 && isIEWin;


var isNS     = navigator.appName == ("Netscape");
var isNS4    = (document.layers) ? true : false;
var isNS6    = (navigator.vendor == ("Netscape6") || navigator.product == ("Gecko"));

var err_count =0;
var err_email = 'email@somewhere.com';
var errorPage = '/jserror.html' ;



function doPageLoad() {

}


function setClass(theObj, theClassName) {
  if (!isIE) return;
  theObj.className = theClassName
}



function thiserr(msg,url,line) {
 var w=window.open(
			'errorPage', 
			"errWindow" + err_count++,  // name - force to be unique
			"toolbar=no," +
			"location=no," +
			"directories=no," +
			"status=no," +
			"menubar=no," +
			"scrollbars=no," +
			"resizable=no," +
			"width=420," +
			"height=240");
 w.focus;
 var d = w.document;
 d.err_form.err_msg.value = msg;
 d.err_form.err_doc.value = url;
 d.err_form.err_line.value = line;
 d.err_form.err_browser.value = navigator.appName + ' ' + navigator.appVersion;
 return true;
}


//
// establish error routine
//
// self.onerror = thiserr;

function popUp(url, width, height) {

 var features =
   'toolbar=no,' +
   'location=no,' +
   'directories=no,' +
   'status=no,' +
   'menubar=no,' +
   'scrollbars=no,' +
   'resizable=no,' +
   'width=' + width + ',' + 
   'height=' + height;
   
 var name = width + 'x' + height ;
 var w=window.open(url, name, features) ;
 w.focus() ;

 return false ;
 
}

function getObjectRef(objName) {
 var obj = null ;

 if (isDOM)
  obj = document.getElementById(objName)
 else
   if (isIE)
    obj = document.all[objName];

 return obj;

}

function helpPopUp(theObj, theNum) {
 if (isNS4) return ;
 var div = getObjectRef('div' + theNum)

 if (! (div == null)) {
   div.style.display = 'block';
   div.style.visibility = 'visible';
 }  

}

function helpPopDown(theNum) {
 if (isNS4) return ;
 var div = getObjectRef('div' + theNum)
 if (! (div == null)) {
   div.style.visibility = 'hidden';
   div.style.display = 'none'
 }  
}

// function isNumeric
// accepts : theChar
// returns : true if a digit, false otherwise

function isNumeric (theChar) {
  return (theChar >= '0' && theChar <= '9');
}

// function NumDigitsInStr
// accepts : theStr
// returns : the number of digits in theStr 0..whatever

function numDigitsInStr(theStr) {
  var numDigits = 0;
  for (var i=0; i < theStr.length; i++)
   if (isNumeric(theStr.charAt(i))) numDigits++
  return numDigits ;
}

// isNumericString
// accepts : strTest    string to test
// Returns : true if strTest is all numeric, false otherwise

function isNumericString (theStr) {
  return (theStr.length > 0) && (numDigitsInStr(theStr) == theStr.length);
}

// validateEmail
// accepts: email address
// returns: true if properly constructed

function validateEmail(email) {
  var exp = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/ ;
  var emChk = email.search(exp);
  return (emChk != -1) ;
}
