<!--
var printed;	//value to determine if the print dialog has been shown.
// Function added to modify field background in form fields 
function changeBackground(field, number) {
	if(number == 1) {
		field.style.background = "#ccccff";
	}
	
	if(number == 2) {
		field.style.background = "#ffffff";
	}
}
function validate_form(page,f) {
	
	switch(page) {
		case "1":		//validate page 1,this form is the 
			return validatePage1(f);	//same for all three apps, so only 
			break;						//the form object needs to be passed
		/*case "2":		//validate page 2, also the same for all three apps
			return validatePage2(f);
			break;*/
		case "2":		//validate page 3, also the same for all three apps
			return validatePage2(f);
			break;
		case "3":
			return validatePage3(f);
			break;
		case "4":
			return validatePage4(f);
		case "last":
			return validateLast(f);
			break;
		case "review":
			return validateAll(f);
			break;
	}
}
//this function clears any leading or trailing spaces
function trim(str) {
	return str.replace(/^\s*|\s*$/g,"");
}
function validateAll(f) {
	var pages = new Array("1","2","last");
	var i;
	var noProblems = true;
	
	for(i=0;i<pages.length;i++) {
		foundProblem = validate_form(pages[i],f);
		if(foundProblem == false) {
			return false;
		}
	}
	if(!printed) {
		if(window.print) {
			window.print();
			printed=true;
			f.Submit.value='Save';
			return false;
		}
		else {
			return confirm("Please print a copy of this page first.\n\nPress OK if you have already done so or Cancel to go back and print");
		}
	}
	return true;
}
//validate page 1
function validatePage1(f) {
	var temp;
	var errors = '';
	if(trim(f.ee.value) == "") {
		errors = errors + "Please enter your employee number\n";	
	}
	if(trim(f.First_Name.value) == "") {
		errors = errors + "First Name is a required field\n"; 
	}
	if(trim(f.middle_name.value) == "") {
		errors = errors + "Middle Name is a required field\n"; 
	}
	if(trim(f.Last_Name.value) == "") {
		errors = errors + "Last Name is a required field\n"; 
	}
	if(trim(f.Street_Address_1.value) == "") {
		errors = errors + "Street Address is a required field\n"; 
	}
	if(trim(f.City.value) == "") {
		errors = errors + "City is a required field\n"; 
	}
	if(trim(f.State.value) == "") {
		errors = errors + "State is a required field\n"; 
	}
	if(trim(f.Zip.value) == "") {
		errors = errors + "Zip Code is a required field\n"; 
	}
	if(trim(f.Area_code.value) == "") {
		errors = errors + "Home Phone Area Code is a required field\n"; 
	}
	if(trim(f.Prefix.value) == "" || trim(f.Suffix.value) == "") {
		errors = errors + "Telephone Number is a required field\n"; 
	}
	if(trim(f.prefix3.value) == "" || trim(f.suffix3.value) == "") {
		errors = errors + "Work Number is a required field\n"; 
	}
	temp = f.email_address.value;
	if(trim(temp) == "" || temp.indexOf('@') < 1) {
		errors = errors + "Email Address is a required field\n";
	}
	
	if(errors != '') {
		alert("The following errors occurred\n\n" + errors);
		return false;
	}
	else {
		return true;
	}
}

/*function validatePage2(f) {
	var errors = '';
	//if the user selected he speaks another language than the explain and fluency fields become required
	if(f.language[0].checked) {
		if(trim(f.langexplain.value) == '') {
			errors = errors + "Explanation of language skills is required\n";
		}
		if(trim(f.langlevel.value) == '') {
			errors = errors + "Language fluency is required\n";
		}
	}
	if(f.scholarship[0].checked && trim(f.finasstprog.value) == '') {
		errors = errors + "Please explain for which programs you received Tutition Reimbursement, CCC waiver, Auxiliary and/or Foundation Scholarhip assistance\n"; 	
	}
	if(errors != '') {
		alert("The following errors occurred\n\n" + errors);
		return false;
	}
	else {
		return true;
	}

}
*/
function validatePage2(f) {
	var errors = '';
	if(trim(f.curdept.value) == '') {
		errors = errors + "Current Department is a required field\n";
	}
	if(trim(f.cursuper.value) == '') {
		errors = errors + "Current Supervisor is a required field\n";
	}
	if(trim(f.curtitle.value) == '') {
		errors = errors + "Current Job Title is a required field\n";
	}
	if(trim(f.longy.value) == '' || trim(f.longm.value) == '') {
		errors = errors + "Please enter both number of years and number of months that you have worked at the hospital.\n";
	}
	/*if(trim(f.pastemployment.value) == '') {
		errors = errors + "Past Employment is a required field\n";
	}
	if(trim(f.Career_Goal_1.value) == '') {
		errors = errors + "Career Goal is a required field\n";
	}*/
	
	if(errors != '') {
		alert("The following errors occurred\n\n" + errors);
		return false;
	}
	else {
		return true;
	}
	
}

function validatePage3(f) {
	var errors = '';
	
	/*if(trim(f.pathmemo.value) == "") {
		errors = errors + "* Please describe any previous career path assistance or job shadow experience you have participated in as an Employee\n";	
	}
	if(trim(f.carrmemo.value) == "") {
		errors = errors + "* To the best of your knowledge and through your research, please summarize the general tasks of your career options.\n";	
	}
	if(trim(f.unsureed.value) == "") {
		errors = errors + "* If you are unsure of the education requirements to achieve your goals, please indicate that here.\n";	
	}
	if(trim(f.discaropt.value) == "") {
		errors = errors + "* Discuss the reasons for considering each of your career options.\n";	
	}*/
	if(trim(f.cpagoals.value) == "") {
		errors = errors + "* What are your goals for this Career Path Assistance? If participating in a Job Shadow interests you, please indicate that here.\n";	
	}
	
	if(errors != '') {
		alert("The following errors occurred\n\n" + errors);
		return false;
	}
	else {
		return true;
	}
}

function validateLast(f) {
	var errors = '';
	
	/*if(trim(f.Memo_Education.value) == "") {
		errors = errors + "Discuss your academic goals. Include the academic training programs you are considering to achieve your goals\n";	
	}
	if(trim(f.School_Name.value) == "") {
		errors = errors + "School Name is a required field\n";
	}
	if(trim(f.schaddress.value) == "") {
		errors = errors + "School Address is a required field\n";
	}
	if(trim(f.School_City.value) == "") {
		errors = errors + "School City is a required field\n";
	}
	if(trim(f.School_State.value) == "") {
		errors = errors + "School State is a required field\n";
	}
	if(trim(f.schzip.value) == "") {
		errors = errors + "School Zip Code is a required field\n";
	}
	if(trim(f.Degree_Program.value) == "") {
		errors = errors + "Degree Program is a required field\n";
	}
	if(trim(f.gpa.value) == "") {
		errors = errors + "GPA is a required field\n";
	}*/
	if(trim(f.nopp.value) == "") {
		errors = errors + "Please tell us how you found out about this opportunity\n";
	}
	if(errors != '') {
		alert("The following errors occurred\n\n" + errors);
		return false;
	}
	else {
		return true;
	}
}
/*
function validateLast(f) {
	var numQuestions = 5;
	
	var i;
	var errors = '';
	var temp;
	
	for(i=1;i<=numQuestions;i++) {
		temp = "Question" + i;
		if(trim(f.elements[temp].value) == "") {
			errors = errors + "Please answer question " + i + "\n";
		}
	}
	if(errors != '') {
		alert("The following errors occurred\n\n" + errors);
		return false;
	}
	else {
		return true;
	}
}*/
/*
function MM_findObj(n, d) { //v4.01
  var p,i,x;  
  if(!d) d=document; 
  if((p=n.indexOf("?"))>0 && parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
  }
  if(!(x=d[n]) && d.all){
	  x=d.all[n];
  }
  for (i=0;!x&&i<d.forms.length;i++) {
	  x=d.forms[i][n];
  }
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) {
	  x=MM_findObj(n,d.layers[i].document);
  }
  if(!x && d.getElementById) {
	  x=d.getElementById(n);
  }
  return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min
  var max,errors='';
  var args=MM_validateForm.arguments;
  
  for (i=0; i<(args.length-2); i+=3) {
	  test=args[i+2]; 
	  val=MM_findObj(args[i]);
	  if (val) {
		  nm=val.name; 
		  if ((val=val.value)!="") {
			  if (test.indexOf('isEmail')!=-1) { 
				  p=val.indexOf('@');
				  if (p<1 || p==(val.length-1)) { 
				  	errors+='- '+nm+' must contain an e-mail address.\n'; 
				  }
			  } 
			  else if (test!='R') { 
				  num = parseFloat(val);
				  if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
				  if (test.indexOf('inRange') != -1) { 
					  p=test.indexOf(':');
					  min=test.substring(8,p); max=test.substring(p+1);
					  if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
	  			  } 
	  		  } 
		 } 
	  	else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; 
	  }
  } 
  
  if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}*/

