/* ****************************
       form checker
***************************** */

function isEmail( string ) {
  if ( _proxy_jslib_handle(string, 'search', '', 1, 0)(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) return true;
  else return false;
} 

function isName( string ) {
  if ( _proxy_jslib_handle(string, 'search', '', 1, 0)(/^([A-Za-z0-9]?\W?\'?[A-Za-z0-9]+\W?)+$/) != -1 ) return true;
  else return false;
}

function isPassword( string ) {
  if ( _proxy_jslib_handle(string, 'search', '', 1, 0)(/^\w+$/) != -1 ) return true;
  else return false;
}

function verify(thisForm) {
  var count = 1;
  var errstring = "Please fix the following errors: \n";
	errstring +="----------------------------\n";
  var err = false;
  if( !  _proxy_jslib_handle(thisForm.signupName, 'value', '', 0, 0) ){
	errstring += "(" + count + ") You must enter a name (or nickname).\n";
	count++;
	err = true;
  } else{
	    if(!isName( _proxy_jslib_handle(thisForm.signupName, 'value', '', 0, 0))){
			errstring += "(" + count + ") Your name contains illegal characters.\n";
		    count++;
			err = true;
		}
  }
  if(! _proxy_jslib_handle(thisForm.signupEmail, 'value', '', 0, 0) ){
	errstring += "(" + count + ") You must enter an email address.\n";
	count++;
	err = true;
  } else {
		if(!isEmail( _proxy_jslib_handle(thisForm.signupEmail, 'value', '', 0, 0))){
		  errstring += "(" + count + ") You must enter a valid email address.\n";
		  errstring += "\t (Cannot have any spaces or illegal characters. \n";
		  errstring += "\t Should be in the general form of:  YourName@domain.xxx \n";
		  errstring += "\t where domain.xxx is your domain such as aol.com, hotmail.com, etc.) \n";
		  count++;
		  err = true;
	    }
  }
  if( _proxy_jslib_handle(thisForm.password, 'value', '', 0, 0) == ""){
	errstring += "(" + count + ") You must enter a password. \n";
	count++;
	err = true;
  } else{
	    if(!isPassword( _proxy_jslib_handle(thisForm.password, 'value', '', 0, 0))){
			errstring += "(" + count + ") Your password contains illegal characters.\n";
			count++;
			err = true;
		} else {
			if( _proxy_jslib_handle(thisForm.password2, 'value', '', 0, 0) !=  _proxy_jslib_handle(thisForm.password, 'value', '', 0, 0)){
				errstring += "(" + count + ") Your password fields must match.\n";
			    count++;
				err = true;
			}
		}
  }

  if(thisForm.month.selectedIndex == "0" || thisForm.day.selectedIndex == "0" || thisForm.year.selectedIndex == "60"){
	errstring += "(" + count + ") You must enter your birthday. \n";
	count++;
	err = true;
  }

  if(!thisForm.gender[0].checked && !thisForm.gender[1].checked){	
	errstring += "(" + count + ") You must enter your gender. \n";
	count++;
	err = true;
  }


  if(err) alert(errstring + "\nSee the help link above for assistance.");
  return (!err);
} ;
_proxy_jslib_flush_write_buffers() ;