// form validation functions
// April 2004 - John-Erik Omland-StudioNorth

 function isValidEmail(emailFieldValue) {

  var result = false
  var theStr = new String(emailFieldValue)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;

  // assume max len of ".com" part is 4
  var validEmailFormat = RegExp( "/^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,4})+$/" );
    if ( validEmailFormat.test(emailFieldValue) ){
//       emailField.focus();
       return (true)
    } else {
//       alert("Invalid E-mail Address! Please re-enter.")
//       emailField.focus();
       return (false)
    }
 }
 // =================

 function isSet( fieldObj ) {
    if( fieldObj.value == "" )
       return( false );
    else 
	   return (true);
 }
 // =================
 
 function isValidInt( fieldObj ) {
    if( !parseInt(fieldObj.value, 10) ){
       fieldObj.focus();
       alert("Invalid integer! Please re-enter.")
       return( false );
    } else {
       fieldObj.value = '' +parseInt(fieldObj.value, 10);
	   return (true);
	}
 }
 // =================
 
 function isValidPhone( fieldObj ) {
  var validPhoneFormat = RegExp( "/^\\d+([\\.- ]\\d+)*/" );
    if ( validPhoneFormat.test(fieldObj.value) ){
       return (true)
    }
    fieldObj.focus();
    alert("Invalid phone num! Please re-enter.")
    return (false)
 }
 // =================
  
 function reportError( errMsg ) {
 var errTmpltFile = "../errorTemplate.htm";
//       var errWin = window.open( "about:blank", "errWin", "resizable=no,scrollbars=no,width=400,height=300" );
       var errWin = window.open( errTmpltFile, "errWin", "resizable=no,scrollbars=no,width=400,height=300" );
       var pageStr = "<html><body bgcolor=WHITE>";
       pageStr += errMsg;
       pageStr += "<p align='center'>Click <a href='javascript:self.colse();'>here</a> to close windoe and continue.</p>";
       pageStr += "</body></html>";
//       errWin.content = pageStr;
//       errWin.location.href = 'javascript:pageStr';
       errWin.document.open();
       errWin.document.write(pageStr);
       errWin.document.close();
 }
 // =================
  
 function popupWindowFile( errMsg, HTMLtemplateFile, width, height ) {
       var options = "scrollbars=yes,width="+width+",height="+height;
 
       errWin = window.open( HTMLtemplateFile, "errWin", options );
 }
 // =================

