tover = new Array('FNAME,your first name',
                  'LNAME,your last name',
                  'GENDER,your gender',
                  'ADDR,your street address',
                  'CITY,your city',
                  'ZIP,your zip code',
                  'state,your state',
                  'DOB,your date of birth',
                  'SSN,your social security number',
                  'INFOSOURCE,how you found out about us'
                 );

todel = new Array('FNAME,your first name',
                  'LNAME,your last name',
                  'DOB,your date of birth',
                  'SSN,your social security number',
                  'EMAIL,your e-mail address',
                  'PASSWORD,your password'
                 );

function go() {
	 if ((document.forms[0].ORGAN.value != 'Y') &&
	     (document.forms[0].TISSUE.value != 'Y') &&
	     (document.forms[0].EYES.value != 'Y')) {
	   alert("Please select ORGANS, TISSUES, or EYES for your donation preference.");
	
	   return false;
	 }
	
	 if (!document.forms[0].IS_DONOR.checked) {
	   alert("This system only records people who want to be organ and tissue donors.  Please select the 'YES!' option before proceeding.");
	
	   return false;
	 }
	
	 for (var i = 0;i < tover.length;i++) {
	   var tocom = tover[i].indexOf(',');
	
	   eval("var dfv = document.forms[0]." + tover[i].substr(0, tocom) + ";");
	
	   if (dfv.value == '') {
	     alert("Please enter " + tover[i].substr(tocom + 1));
	
	     dfv.focus();
	
	     return false;
	   }
	 }
	
	 // Testing the DOB entry
	 var dobRegEx  =  new RegExp("^[0-9]{2}/[0-9]{2}/[0-9]{4}$");
	 if (document.forms[0].DOB.value == 'mm / dd / yyyy') {
	   alert("Please enter your date of birth");
	   document.forms[0].DOB.focus();
	   return false;
	 }
	 else if( document.forms[0].DOB.value.search(dobRegEx) == -1 || document.forms[0].DOB.value == '00/00/0000' ) {
		 alert("You have improperly entered your date of birth.  Please use the format mm/dd/yyyy.");
		 document.forms[0].DOB.focus();
		 return false;
	 }
	 
	 // Testing the SSN entry
	 var ssnRegEx = new RegExp("^[0-9]{9}$");
	 if( document.forms[0].SSN.value.search(ssnRegEx) == -1 ) {
		 alert("You have improperly entered your social security number.  Please only enter numbers (no dashes).");
		 document.forms[0].SSN.focus();
		 return false;
	 }

	 if (((document.forms[0].PASSWORD.value != '') || (document.forms[0].PASSWORDCONFIRM.value != '')) && (document.forms[0].PASSWORD.value != document.forms[0].PASSWORDCONFIRM.value)) {
	   alert("Your passwords do not match!");
	
	   return false;
	 }

	 document.forms[0].method = 'POST';
	 document.forms[0].action = 'signup_confirmation.php';
	
	 return true;
}


function dmvgo() {
	 if ((document.forms[0].ORGAN.value != 'Y') &&
	     (document.forms[0].TISSUE.value != 'Y') &&
	     (document.forms[0].EYES.value != 'Y')) {
	   alert("Please select ORGANS, TISSUES, or EYES for your donation preference.");
	
	   return false;
	 }
	
	 for (var i = 0;i < tover.length;i++) {
	   var tocom = tover[i].indexOf(',');
	
	   eval("var dfv = document.forms[0]." + tover[i].substr(0, tocom) + ";");
	
	   if (dfv.value == '') {
	     alert("Please enter " + tover[i].substr(tocom + 1));
	
	     dfv.focus();
	
	     return false;
	   }
	 }
	
	 if (document.forms[0].DOB.value == 'mm / dd / yyyy') {
	   alert("Please enter your date of birth");
	
	   document.forms[0].DOB.focus();
	
	   return false;
	 }
	
	 if (((document.forms[0].PASSWORD.value != '') || (document.forms[0].PASSWORDCONFIRM.value != '')) && (document.forms[0].PASSWORD.value != document.forms[0].PASSWORDCONFIRM.value)) {
	   alert("Your passwords do not match!");
	
	   return false;
	 }
	
	 document.forms[0].method = 'POST';
	 document.forms[0].action = 'dmv_confirmation.php';
	
	 return true;
}


function doanim(x) {
     var display = '';
     var question = "";
	 if (x.options[x.selectedIndex].value == 'W') {
       question = "What is the name and city of your workplace?";
	 } else if (x.options[x.selectedIndex].value == 'L') {
	   question = "What is the name of your club?";
	 } else if (x.options[x.selectedIndex].value == 'O') {
	   question = "Please tell us how you learned about save7lives.org.";
	 } else if (x.options[x.selectedIndex].value == 'D') {
	   question = "Please tell us the name and city of the school.";
	 } else if (x.options[x.selectedIndex].value == 'G') {
	   question = "Please tell us the name and city of your organization.";
	 } else if (x.options[x.selectedIndex].value == 'S') {
      question = "Where was the Sign-up Drive?";
	 } else if (x.options[x.selectedIndex].value == 'Y') {
	   question = "Please tell us the name of the event and the city it was held in.";
	 } else {
	   display = 'none';
	 }
     document.forms[0].INFOOTHER.style.display = display;
     document.forms[0].INFOOTHER.value = '';
     if (!document.getElementById('info-other-question')) {
       document.forms[0].INFOOTHER.parentNode.parentNode.getElementsByTagName('TD')[0].appendChild(document.createElement('div')).id = 'info-other-question';
     }
     document.getElementById('info-other-question').innerHTML = question;
}


function addem() {
	 document.forms[0].method = 'POST';
	 document.forms[0].action = 'do_signup.php';
}


function go_dmv() {
	 document.forms[0].method = 'POST';
	 document.forms[0].action = 'dmv_find_success.php';
}


function go_del() {
	 for (var i = 0;i < todel.length;i++) {
	   var tocom = todel[i].indexOf(',');
	
	   eval("var dfv = document.forms[0]." + todel[i].substr(0, tocom) + ";");
	
	   if (dfv.value == '') {
	     alert("Please enter " + todel[i].substr(tocom + 1));
	
	     dfv.focus();
	
	     return false;
	   }
 }

	 if (document.forms[0].DOB.value == 'mm / dd / yyyy') {
	   alert("Please enter your date of birth");
	
	   document.forms[0].DOB.focus();
	
	   return false;
	 }
	
	 document.forms[0].method = 'POST';
	 document.forms[0].action = 'removal_success.php';
	
	 return true;
}


function go_req() {
	 document.forms[0].method = 'POST';
	 document.forms[0].action = 'send_password.php';
	
	 return true;
}


function go_login() {
	 document.forms[0].method = 'POST';
	 document.forms[0].action = 'account.php';
	
	 return true;
}


function go_update() {
	 document.forms[0].method = 'POST';
	 document.forms[0].action = 'update.php';
	
	 return true;
}


function maxmi(x) {
	 if (x.value.length > 1) {
	   alert("Please enter only a single letter for your middle initial.");
	
	   x.value = x.value.substr(0, 1);
	
	   x.focus();
	 }
}