function enablenext() {
	if ( document.thisForm.hexperience.options[document.thisForm.hexperience.selectedIndex].text != "None" ) {
		document.thisForm.oexperience.disabled = false
		document.thisForm.favorite.disabled = false
		document.thisForm.cardiology.selectedIndex = 0
		document.thisForm.dermatology.selectedIndex = 0
		document.thisForm.emergency.selectedIndex = 0
		document.thisForm.endocrinology.selectedIndex = 0
		document.thisForm.family.selectedIndex = 0
		document.thisForm.gi.selectedIndex = 0
		document.thisForm.gu.selectedIndex = 0
		document.thisForm.infectious.selectedIndex = 0
		document.thisForm.neurology.selectedIndex = 0
		document.thisForm.oncology.selectedIndex = 0
		document.thisForm.orthopedics.selectedIndex = 0
		document.thisForm.psychiatry.selectedIndex = 0
		document.thisForm.pulmonary.selectedIndex = 0
		document.thisForm.radiology.selectedIndex = 0
		document.thisForm.vascular.selectedIndex = 0
		document.thisForm.otherexp.selectedIndex = 0
		document.thisForm.cardiology.disabled = true
		document.thisForm.dermatology.disabled = true
		document.thisForm.emergency.disabled = true
		document.thisForm.endocrinology.disabled = true
		document.thisForm.family.disabled = true
		document.thisForm.gi.disabled = true
		document.thisForm.gu.disabled = true
		document.thisForm.infectious.disabled = true
		document.thisForm.neurology.disabled = true
		document.thisForm.oncology.disabled = true
		document.thisForm.orthopedics.disabled = true
		document.thisForm.psychiatry.disabled = true
		document.thisForm.pulmonary.disabled = true
		document.thisForm.radiology.disabled = true
		document.thisForm.vascular.disabled = true
		document.thisForm.otherexp.disabled = true
	} else {
		document.thisForm.oexperience.selectedIndex = 0
		document.thisForm.favorite.selectedIndex = 0
		document.thisForm.oexperience.disabled = true
		document.thisForm.favorite.disabled = true
		document.thisForm.cardiology.disabled = false
		document.thisForm.dermatology.disabled = false
		document.thisForm.emergency.disabled = false
		document.thisForm.endocrinology.disabled = false
		document.thisForm.family.disabled = false
		document.thisForm.gi.disabled = false
		document.thisForm.gu.disabled = false
		document.thisForm.infectious.disabled = false
		document.thisForm.neurology.disabled = false
		document.thisForm.oncology.disabled = false
		document.thisForm.orthopedics.disabled = false
		document.thisForm.psychiatry.disabled = false
		document.thisForm.pulmonary.disabled = false
		document.thisForm.radiology.disabled = false
		document.thisForm.vascular.disabled = false
		document.thisForm.otherexp.disabled = false
	}
}

function enablecomp() {
	if ( document.thisForm.owncomputer.options[document.thisForm.owncomputer.selectedIndex].text != "Yes" ) {
		document.thisForm.os_type.selectedIndex = 0
		document.thisForm.modem_type.selectedIndex = 0
		document.thisForm.cdrom.selectedIndex = 0
		document.thisForm.os_type.disabled = true
		document.thisForm.modem_type.disabled = true
		document.thisForm.cdrom.disabled = true
	} else {
		document.thisForm.os_type.disabled = false
		document.thisForm.modem_type.disabled = false
		document.thisForm.cdrom.disabled = false
	}
}

function checkvalid(form) {
	var Errors = new Array()
	var ErrorNo = 0
	var ErrorMsg = ''
	var ReturnVal = true
	var InvalidChar = 0


	if ( form.name.value.length == 0 || form.name.value.indexOf(" ") == -1 ) {
		ErrorNo++
		Errors[ErrorNo] = 'Applicant Full Name is Required\n'
	}
	if ( form.address1.value.length == 0 && form.address2.value.length == 0 ) {
		ErrorNo++
		Errors[ErrorNo] = 'Applicant Address is Required\n'
	}
	if ( form.city.value.length == 0 ) {
		ErrorNo++
		Errors[ErrorNo] = 'Applicant City is Required\n'
	}
	if ( form.state.value.length != 2 ) {
		ErrorNo++
		Errors[ErrorNo] = 'Applicant State is Required\n'
	}
	if ( form.zip5.value.length == 0 || form.zip5.value.length < 5 ) {
		ErrorNo++
		Errors[ErrorNo] = 'Applicant Zipcode is Required\n'
	}
	if ( !chkphone(form.dayphoneac.value,form.dayphoneex.value,form.dayphonenu.value,'dayphone') ) {
		ErrorNo++
		Errors[ErrorNo] = 'Day Telephone Number must be complete\n'
	}
	if ( form.nightphoneac.value.length > 0 || form.nightphoneex.value.length > 0 || form.nightphonenu.value.length > 0 ) {
		if ( !chkphone(form.nightphoneac.value,form.nightphoneex.value,form.nightphonenu.value,'nightphone') ) {
			ErrorNo++
			Errors[ErrorNo] = 'Evening Telephone Number must be complete\n'
		}
	}
	if ( form.faxphoneac.value.length > 0 || form.faxphoneex.value.length > 0 || form.faxphonenu.value.length > 0 ) {
		if ( !chkphone(form.faxphoneac.value,form.faxphoneex.value,form.faxphonenu.value,'faxphone') ) {
			ErrorNo++
			Errors[ErrorNo] = 'Fax Telephone Number must be complete\n'
		}
	}
	if ( chktext(form.email) ) {
		ErrorNo++
		Errors[ErrorNo] = 'Please enter your e-mail address\n'
	}
	if ( !IsEmailValid(form.email.value) ) {
		ErrorNo++
		Errors[ErrorNo] = 'Must be a valid e-mail address\n'
	}
	if ( chkselect(form.position) ) {
		ErrorNo++
		Errors[ErrorNo] = 'You must specify a position\n'
	}
	if ( chkselect(form.specialty9) ) {
		ErrorNo++
		Errors[ErrorNo] = 'You must specify a specialty\n'
	}
	if ( !chkselect(form.hexperience) ) {
		if ( chkselect(form.oexperience) ) {
			ErrorNo++
			Errors[ErrorNo] = 'Please list your Operation Experience\n'
		}
		if ( chkselect(form.favorite) ) {
			ErrorNo++
			Errors[ErrorNo] = 'Please choose your favorite type of work\n'
		}
	} else {
		if ( chkselect(form.cardiology) &&
			 chkselect(form.dermatology) &&
			 chkselect(form.emergency) &&
			 chkselect(form.endocrinology) &&
			 chkselect(form.family) &&
			 chkselect(form.gi) &&
			 chkselect(form.gu) &&
			 chkselect(form.infectious) &&
			 chkselect(form.neurology) &&
			 chkselect(form.oncology) &&
			 chkselect(form.orthopedics) &&
			 chkselect(form.psychiatry) &&
			 chkselect(form.pulmonary) &&
			 chkselect(form.radiology) &&
			 chkselect(form.vascular) &&
			 chkselect(form.otherexp) )
		{
			ErrorNo++
			Errors[ErrorNo] = 'Please choose at least 1 subspecialty\n'
		}
	}
	if ( chkselect(form.payunit) ) {
		ErrorNo++
		Errors[ErrorNo] = 'Unit of Payment is Required\n'
	}
	if ( form.units_produced.value.length == 0 ) {
		ErrorNo++
		Errors[ErrorNo] = 'Units Produced is Required\n'
	}
	var checkOK = "0123456789-";
	var checkStr = form.units_produced.value;
	var allValid = true;
	var decPoints = 0;
	var allNum = "";
	for (i = 0;  i < checkStr.length;  i++) {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
		if (j == checkOK.length) {
			allValid = false;
			break;
		}
		allNum += ch;
	}
	if (!allValid) {
		ErrorNo++
		Errors[ErrorNo] = 'Units Produced can contain only digits\n'
	}

	var chkVal = allNum;
	var prsVal = parseInt(allNum);
	if (chkVal != "" && !(prsVal >= "1" && prsVal <= "2500")) {
		ErrorNo++
		Errors[ErrorNo] = 'Units Produced must be between 1 and 2500\n'
	}
	/*
	if ( chkselect(form.owncomputer ) ) {
		ErrorNo++
		Errors[ErrorNo] = 'Question of Computer Ownership is Required\n'
	}
	if ( form.owncomputer.options[form.owncomputer.selectedIndex].text == "Yes" ) {
	*/
		if ( chkselect(form.os_type) ) {
			ErrorNo++
			Errors[ErrorNo] = 'Please select your computer operating system\n'
		}
		if ( chkselect(form.internet_access) ) {
			ErrorNo++
			Errors[ErrorNo] = 'Please select your internet access\n'
		}
		if ( chkselect(form.cdrom) ) {
			ErrorNo++
			Errors[ErrorNo] = 'Please select if you have a CDROM\n'
		}
	//}
	if ( chkselect(form.word_prog) ) {
		ErrorNo++
		Errors[ErrorNo] = 'Please select your word processing program\n'
	}
	if ( chkselect(form.shortcut_prog) ) {
		ErrorNo++
		Errors[ErrorNo] = 'Please select your shortcut program\n'
	}
	if ( chkselect(form.second_phone) ) {
		ErrorNo++
		Errors[ErrorNo] = 'Please select if you have a second phone line\n'
	}
	if ( chkselect(form.ldplan) ) {
		ErrorNo++
		Errors[ErrorNo] = 'Please select if you have an unlimited long distance calling plan\n'
	}
	if ( chkcheckbox(form.trnsc_type1) &&
		chkcheckbox(form.trnsc_type2) &&
		chkcheckbox(form.trnsc_type3) &&
		chkcheckbox(form.trnsc_type4) &&
		chkcheckbox(form.trnsc_type5) &&
		chkcheckbox(form.trnsc_type6) &&
		chkcheckbox(form.trnsc_type7) &&
		chkcheckbox(form.trnsc_type8) &&
		chkcheckbox(form.trnsc_type9) &&
		chkcheckbox(form.trnsc_type10) &&
		chkcheckbox(form.trnsc_type11) )
	{
		ErrorNo++
		Errors[ErrorNo] = 'Please select your transcriber type\n'
	}
	if ( chkselect(form.aamt_memb_no) ) {
		ErrorNo++
		Errors[ErrorNo] = 'Please select if you are a member of AAMT\n'
	}
	if ( chkselect(form.cmt_memb_no) ) {
		ErrorNo++
		Errors[ErrorNo] = 'Please select if you have CMT membership number\n'
	}
	if ( chktext(form.sunfrom) &&
		chktext(form.sunto) &&
		chktext(form.monfrom) &&
		chktext(form.monto) &&
		chktext(form.tuesfrom) &&
		chktext(form.tuesto) &&
		chktext(form.wedfrom) &&
		chktext(form.wedto) &&
		chktext(form.thufrom) &&
		chktext(form.thuto) &&
		chktext(form.frifrom) &&
		chktext(form.frito) &&
		chktext(form.satfrom) &&
		chktext(form.satto) )
	{
		ErrorNo++
		Errors[ErrorNo] = 'Please select your hours of availability\n'
	}
	/*
	if ( form.resumepaste.value.length < 200 && form.resumeattach.value.length == 0 ) {
		ErrorNo++
		Errors[ErrorNo] = 'Please attach or paste your resume\n'
	}
	*/
	if ( form.resumepaste.value.length == 0 ) {
		ErrorNo++
		Errors[ErrorNo] = 'Please paste your resume\n'
	}

	if ( ErrorNo > 0 ) {
		ErrorMsg = 'Invalid or incomplete data was found for following question' + (ErrorNo > 1 ? 's' : '') + ':\n\n'
		for (var i = 1; i <= ErrorNo; i++ ) {
			ErrorMsg += Errors[i]
		}
		ErrorMsg += '\nPlease correct them and resubmit.'
		window.alert(ErrorMsg)
		ReturnVal = false
	}
	return ReturnVal
}

function chkselect(selection) {
	var isOK = 0
	var tempindex
	
	tempindex = selection.selectedIndex
	if ( selection.options[tempindex].text == '(Select One)' ) {
		isOK = 1
	}
	return isOK
}

function chkcheckbox(checkbox) {
	var isOK = 0
	var tempindex
	
	if ( checkbox.checked == false ) {
		isOK = 1
	}
	return isOK
}

function chktext(textfield) {
	var isOK = 0
	var tempindex
	
	if ( textfield.value == '' ) {
		isOK = 1
	}
	return isOK
}

function chkphone(inputValue1,inputValue2,inputValue3,inputName) {
	var isOK = 1
	if (inputValue1.length == 3) {
		for ( var i=0; i<3; i++ ) {
			if ( inputValue1.charAt(i) == ' ' ) {
				isOK = 0
			}
		}
	} else {
		isOK = 0
	}
	
	if (isOK == 1 && inputValue2.length == 3) {
		for ( var i=0; i<3; i++ ) {
			if ( inputValue2.charAt(i) == ' ' ) {
				isOK = 0
			}
		}
	} else {
		isOK = 0
	}
	
	if (isOK == 1 && inputValue3.length == 4) {
		for ( var i=0; i<4; i++ ) {
			if ( inputValue3.charAt(i) == ' ' ) {
				isOK = 0
			}
		}
	} else {
		isOK = 0
	}
	return isOK
}

function IsEmailValid(InputEmail) {

	var EmailOk  = true

	if (InputEmail.length == 0) {
		return EmailOk
	}
	var AtSym    = InputEmail.indexOf('@')
	var Period   = InputEmail.lastIndexOf('.')
	var Space    = InputEmail.indexOf(' ')
	var Length   = InputEmail.length - 1   // Array is from 0 to length-1

	if ((AtSym < 1) || (Period <= AtSym+1) || (Period == Length ) || (Space  != -1)) {
	    EmailOk = false
	}
	return EmailOk
}

function sendtoupdate() {
	if ( checkvalid(document.thisForm) ) { 
		document.thisForm.submit()
	}
}
  
function checkSpecialty(that) {
  var specialty = that.options[that.selectedIndex].value;
  var subspecialties = document.getElementById('subspecialties');
  var experiences = document.getElementById('experiences');
  var radiology = document.getElementById('radiology');
  var multispecialty = document.getElementById('multispecialty');
  var favorite = document.getElementById('favorite');

  favorite.options.length = 0;

  switch (specialty) {
    case 'Hospital Medical Records':
      subspecialties.style.display = 'none';
      experiences.style.display = 'block';
      radiology.style.display = 'none';
      multispecialty.style.display = 'none';

      favorite.options[favorite.options.length] = new Option('(Select One)', '');
      favorite.options[favorite.options.length] = new Option('HP', 'HP');
      favorite.options[favorite.options.length] = new Option('CON', 'CON');
      favorite.options[favorite.options.length] = new Option('OP', 'OP');
      favorite.options[favorite.options.length] = new Option('DS', 'DS');
      break;

    case 'Hospital Radiology':
      subspecialties.style.display = 'none';
      experiences.style.display = 'none';
      radiology.style.display = 'block';
      multispecialty.style.display = 'none';

      favorite.options[favorite.options.length] = new Option('Radiology', 'Radiology');
      break;

    case 'Clinic Notes':
      subspecialties.style.display = 'block';
      experiences.style.display = 'none';
      radiology.style.display = 'none';
      multispecialty.style.display = 'block';

      favorite.options[favorite.options.length] = new Option('Clinic Notes', 'Clinic Notes');
      break;

    default:
      subspecialties.style.display = 'block';
      experiences.style.display = 'block';
      radiology.style.display = 'block';
      multispecialty.style.display = 'block';

      favorite.options[favorite.options.length] = new Option('(Select One)', '');
      favorite.options[favorite.options.length] = new Option('HP', 'HP');
      favorite.options[favorite.options.length] = new Option('CON', 'CON');
      favorite.options[favorite.options.length] = new Option('OP', 'OP');
      favorite.options[favorite.options.length] = new Option('DS', 'DS');
      favorite.options[favorite.options.length] = new Option('Radiology', 'Radiology');
      favorite.options[favorite.options.length] = new Option('Clinic Notes', 'Clinic Notes');
      break;
  }
}

function checkExperience(that) {
  hexperience = document.getElementById('hexperience');
  oexperience = document.getElementById('oexperience');
  rexperience = document.getElementById('rexperience');
  hexperienceValue = hexperience.options[hexperience.selectedIndex].value;
  oexperienceValue = oexperience.options[oexperience.selectedIndex].value;
  rexperienceValue = rexperience.options[rexperience.selectedIndex].value;
  subspecialties = document.getElementById('subspecialties');

  if ('NO' == hexperienceValue && 'NO' == oexperienceValue && 'NO' == rexperienceValue) {
      subspecialties.style.display = 'block';
  } else {
      subspecialties.style.display = 'none';
  }
}

