// JavaScript Document
	var step1, step2, step3, step4, step5, processing, processingmessage,errormessage, errormessages, quickApp, errorJobNum;
	function ShowNextStep(stepnum){
		changeMessage("Checking values for step "+stepnum);
		switch(stepnum){
			case 1: { 
						hide(step1);
						show(processing);
						if(checkValues(step1)){
							hide(processing);
							show(step2);
						}
						break;
					}		
			case 2: { 
						hide(step2);
						show(processing);
						if(checkValues(step2)){
							hide(processing);
							show(step3);
						}
						break;
					}		
			case 3: { 
						hide(step3);
						show(processing);
						if(checkValues(step3)){
							hide(processing);
							show(step4);
						}
						break;
					}		
			case 4: { 
						hide(step4);
						show(processing);
						if(checkValues(step4)){
							hide(processing);
							show(step5);
							document.frmRequitment.submit();
						}
						break;
					}		
					
		}
		return;
	}
	
	function showResumeBuilder (URL){
		window.open(URL,"ResumeBuilder","width=550, height=500, dependent=yes, scrollbars=yes, menubar=no, location=no, status=no");
	}
	
	
	function submitQuickApp(){
		hide(quickApp);
		show(processing);
		if(checkQuickAppValues()){
			hide(processing);
			show(step5);
			document.frmRequitment.submit();
		}
	}
	
	function checkQuickAppValues(){
		var errors="";
//		if(!ValidateAlphaNum(document.frmRequitment.step1_jobdesc.value))
//				errors+="* Job Name<br>";
		if(!ValidateName(document.frmRequitment.step1_fname.value))
				errors+="* First Name<br>";
		if(document.frmRequitment.step1_lname.value.length<2)
				errors+="* Last Name<br>";
		if(!ValidateEmail(document.frmRequitment.step1_email.value))
				errors+="* Email<br>";
		if(document.frmRequitment.step1_phtype1.value=="-1")
				errors+="* Type of Phone<br>";
		if(!ValidatePhone(document.frmRequitment.step1_phone1.value))
				errors+="* Phone Number<br>";
		if(document.frmRequitment.step2_profession.value=="-1")
				errors+="* Profession<br>";
		if(document.frmRequitment.step3_loc1.value=="-1")
				errors+="* Desired Locations<br>";
//		if(document.frmRequitment.step4_coments.value=="")
//				errors+="* Comments<br>";
		if(errors==""){
			return true;
		}else{
			errormessage.innerHTML="<p>Error, please check: </p>"
				+errors
				+"<p><input type='button' value='Back' onClick='hide(errormessages);show(quickApp);'></p>";
			hide(processing);
			show(errormessages);
			return false;
		}
	}
	
	function checkJobNum(){
		if(document.frmRequitment.step1_jobdesc.value==""){
			hide(step1);
			show(errorJobNum);
		}
	}
	
	function reposition(){
		window.scrollTo(0,0);
	}
	
	function changeMessage(message){
		changeContent(processingmessage,message);
		return;
	}
	
	function changeContent(object, content){
		object.innerHTML=content;
		return;	
	}
	
	function hide(div_to_hide){
		div_to_hide.style.visibility="hidden";
		return;	
	}
	
	function show(div_to_show){
		div_to_show.style.visibility="visible";
		reposition();
		return;	
	}	
	
/************************************************
 bool ValidateEmail(string input)
 Return true or false
 if the email is valid or not.
 checks for @ and .
**************************************************/
function ValidateEmail(theinput){
 var s=theinput;
 if(s.search)
  return (s.search(new RegExp("^([-!#$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,4}$","gi"))>=0);
 if(s.indexOf)
 {
  at_character=s.indexOf('@');
  if(at_character<=0 || at_character+4>s.length)
   return false;
 }
 if(s.length<6)
  return false;
 else
  return true;
}
 
/************************************************
 bool ValidatePhone(string input)
 Return true or false
 if the phone number is valid or not.
 acepts - and + symbols
**************************************************/
function ValidatePhone(theinput){
 var s=theinput;
 if(s.search)
  return (s.search(new RegExp("[-+0-9]+","gi"))>=0);
 if(s.length<5)
  return false;
 else
  return true;
}
 

/************************************************
 bool ValidateNumber(string input)
 Return true or false
 if the number is valid or not.
 acepts only digits
**************************************************/
function ValidateNumber(theinput){
 var s=theinput;
 if(s.search)
  return (s.search(new RegExp("[0-9]+","gi"))>=0);
 if(s.length<10)
  return false;
 else
  return true;
}

	/******************************************************************
	 bool ValidateAlphaNum(string input)
	 Return true or false
	 if the name is valid or not.
	 acepts only leters (>=5)
	******************************************************************/
	function ValidateAlphaNum(theinput){
		var s=theinput;
		if(s.search)
			return (s.search(new RegExp("^[^0-9]{5,}$","gi"))>=0);
		else
			return false;
	}

	/******************************************************************
	 bool ValidateName(string input)
	 Return true or false
	 if the name is valid or not.
	 acepts only leters (>=5)
	******************************************************************/
	function ValidateName(theinput){
		var s=theinput;
		if(s.search)
			return (s.search(new RegExp("^[a-zA-Z ]{2,}$","gi"))>=0);
		else
			return false;
	}

	/******************************************************************
	 bool ValidateDate(string input)
	 Return true or false
	 if the date is valid or not.
	 acepts format (MM/DD/YYY)
	******************************************************************/
	function ValidateDate(theinput){
		var $valid=false
		var $s=theinput;
		var $formatIsGood=false;
		var $month;
		var $day;
		var $ano;
		if($s.search){
			if($s.search(new RegExp("^[0-1]{1}[0-9]{1}/[0-3]{1}[0-9]{1}/[1-2]{1}[0-9]{3}$","gi"))>=0){
				$formatIsGood=true;
				$month = parseInt($s.substr(0,2));
				$day = parseInt($s.substr(3,2));
				$ano = parseInt($s.substr(6,4));
			}
			if($s.search(new RegExp("^[1-9]{1}/[0-3]{1}[0-9]{1}/[1-2]{1}[0-9]{3}$","gi"))>=0){
				$formatIsGood=true;
				$month = parseInt($s.substr(0,1));
				$day = parseInt($s.substr(2,2));
				$ano = parseInt($s.substr(5,4));
			}
			if($s.search(new RegExp("^[0-1]{1}[0-9]{1}/[1-9]{1}/[1-2]{1}[0-9]{3}$","gi"))>=0){
				$formatIsGood=true;
				$month = parseInt($s.substr(0,2));
				$day = parseInt($s.substr(3,1));
				$ano = parseInt($s.substr(5,4));
			}
			if($s.search(new RegExp("^[1-9]{1}/[1-9]{1}/[1-2]{1}[0-9]{3}$","gi"))>=0){
				$formatIsGood=true;
				$month = parseInt($s.substr(0,1));
				$day = parseInt($s.substr(2,1));
				$ano = parseInt($s.substr(4,4));
			}
		
		}


		// Test if month is valid
		if($formatIsGood && (1<=$month) && ($month<=31)){
			// Test if day is valid
			switch ($month) {
			case 2 :
				  if (($ano % 4 == 0) && (($ano % 100 != 0) || ($ano % 400 == 0))){
					if((1<=$day)&&($day<=29)) $valid = true; 
				  } else if((1<=$day)&&($day<=28)) $valid = true; 
				  break
			case 4:
            case 6:
            case 9:
            case 11:
				  if((1<=$day)&&($day<=30)){
					 $valid = true; 
				  }
				  break
			case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
			  if((1<=$day)&&($day<=31)){
				 $valid = true; 
			  }
			  break
			} 
		}
		return $valid
	}

	/******************************************************************
	 bool ValidateDoc(string input)
	 Return true or false
	 if the document is valid or not.
	 acepts .doc and .pdf
	******************************************************************/
	function ValidateDoc(theinput){
		var s=theinput;
		if(s.search)
			return (s.search(new RegExp("\.doc$","gi"))>=0
					|| s.search(new RegExp("\.pdf$","gi"))>=0);
		else
			return false;
	}

	/******************************************************************
	 bool ValidateSalary(string input)
	 Return true or false
	 if the salary is valid or not.
	 acepts $n{n},nn]
	******************************************************************/
	function ValidateSalary(theinput){
		var s=theinput;
		if(s.search)
			return (s.search(new RegExp("^[0-9]{1,}$","gi"))>=0);
		else
			return false;
	}

	function checkValues(divobject){
		var errors="";
		var setepX="step1";
		switch(divobject.id){
			case "1": { 
//						if(document.frmRequitment.step1_jobdesc.value.length<1)
//								errors+="* Job Numbere<br>";
						if(!ValidateName(document.frmRequitment.step1_fname.value))
								errors+="* First Name<br>";
						if(document.frmRequitment.step1_lname.value.length<2)
								errors+="* Last Name<br>";
//						if(!ValidateEmail(document.frmRequitment.step1_email.value))
//								errors+="* Email<br>";
//						if(!document.frmRequitment.step1_mayemail[0].checked
//							&& !document.frmRequitment.step1_mayemail[1].checked)
//								errors+="* May We Email You?<br>";
						if(document.frmRequitment.step1_phtype1.value=="-1")
								errors+="* Type of Phone<br>";
						if(!ValidatePhone(document.frmRequitment.step1_phone1.value))
								errors+="* Phone Number<br>";
						if(document.frmRequitment.step1_address1.value=="")
								errors+="* Address<br>";
						if(document.frmRequitment.step1_country.value=="-1")
								errors+="* Country<br>";
						if(document.frmRequitment.step1_st.value=="")
								errors+="* State/Province<br>";
						if(!ValidateAlphaNum(document.frmRequitment.step1_city.value))
								errors+="* City<br>";
						if((document.frmRequitment.step1_zip.value.length>5)||
								(document.frmRequitment.step1_zip.value.length<1))
								errors+="* Zip<br>";

						stepX="step1";
						break;
					}		
			case "2": { 
/*						if(document.frmRequitment.step4_specialty.value=="-1")
								errors+="* Area of Specialty<br>";
						if(document.frmRequitment.step4_yrexo.value=="-1")
								errors+="* Years of Experience<br>";
						if(document.frmRequitment.step2_profession.value=="-1")
								errors+="* Profession<br>";
						if(document.frmRequitment.step2_reftype.value=="-1")
								errors+="* How did you find us?<br>";
						if(document.frmRequitment.step2_refsource.value.length<5)
								errors+="* What was the referral source?<br>";

						if(document.frmRequitment.step2_liccert[0].checked){
							if(document.frmRequitment.step2_liccertno.value.length<5)
									errors+="* License/Cert.#<br>";
*/							if((document.frmRequitment.step2_licexp.value!="")&&(!ValidateDate(document.frmRequitment.step2_licexp.value)))
									errors+="* Expiration Date<br>";
/*							if(document.frmRequitment.step2_licstate.value=="-1")
									errors+="* License State<br>";
						} else if(!document.frmRequitment.step2_liccert[1].checked)
								errors+="* I currently have a License/Certification<br>"
*/
						stepX="step2";
						break;
					}		
			case "3": { 
/*							if(document.frmRequitment.step3_emptype.value.length<5)
									errors+="* Employment Type<br>";
							if(!ValidateSalary(document.frmRequitment.step3_salary.value))
									errors+="* Salary Desired<br>";
							if(!document.frmRequitment.step3_employed[0].checked
								&& !document.frmRequitment.step3_employed[1].checked)
									errors+="* Are you currently employed?<br>";
							if(!document.frmRequitment.step3_contactem[0].checked
								&& !document.frmRequitment.step3_contactem[1].checked)
									errors+="* If so, may we contact your present employer?<br>";
							if(!document.frmRequitment.step3_appbefore[0].checked
								&& !document.frmRequitment.step3_appbefore[1].checked)
									errors+="* Ever applied to this company before?<br>";
*/							if((document.frmRequitment.step3_availdate.value!="")&&(!ValidateDate(document.frmRequitment.step3_availdate.value)))
									errors+="* Available Date<br>";
/*							if(document.frmRequitment.step3_loc1.value=="-1")
									errors+="* Desired Location<br>";
							if(document.frmRequitment.step3_loc1sun.value=="-1"
							   || document.frmRequitment.step3_loc1mon.value=="-1"
							   || document.frmRequitment.step3_loc1tue.value=="-1"
							   || document.frmRequitment.step3_loc1wed.value=="-1"
							   || document.frmRequitment.step3_loc1thu.value=="-1"
							   || document.frmRequitment.step3_loc1fri.value=="-1"
							   || document.frmRequitment.step3_loc1sat.value=="-1")
									errors+="* Desired days per week for Location<br>";
							if(document.frmRequitment.step3_loc2.value=="-1")
									errors+="* 2nd Preference<br>";
							if(document.frmRequitment.step3_loc2sun.value=="-1"
							   || document.frmRequitment.step3_loc2mon.value=="-1"
							   || document.frmRequitment.step3_loc2tue.value=="-1"
							   || document.frmRequitment.step3_loc2wed.value=="-1"
							   || document.frmRequitment.step3_loc2thu.value=="-1"
							   || document.frmRequitment.step3_loc2fri.value=="-1"
							   || document.frmRequitment.step3_loc2sat.value=="-1")
									errors+="* Desired days per week for 2nd Preference<br>";
							if(document.frmRequitment.step3_loc3.value=="-1")
									errors+="* 3rd Preference<br>";
							if(document.frmRequitment.step3_loc3sun.value=="-1"
							   || document.frmRequitment.step3_loc3mon.value=="-1"
							   || document.frmRequitment.step3_loc3tue.value=="-1"
							   || document.frmRequitment.step3_loc3wed.value=="-1"
							   || document.frmRequitment.step3_loc3thu.value=="-1"
							   || document.frmRequitment.step3_loc3fri.value=="-1"
							   || document.frmRequitment.step3_loc3sat.value=="-1")
									errors+="* Desired days per week for 3rd Preference<br>";
*/
						stepX="step3";
						break;
					}		
			case "4": { 
							if(document.frmRequitment.fileResume.value!=""
							   && !ValidateDoc(document.frmRequitment.fileResume.value))
									errors+="* Fill Out below or Attach your resume<br>";
/*
							if((document.frmRequitment.eh1_from.value!="")&&(!ValidateDate(document.frmRequitment.eh1_from.value)))
									errors+="* Date From (1)<br>";
							if((document.frmRequitment.eh1_to.value!="")&&(!ValidateDate(document.frmRequitment.eh1_to.value)))
									errors+="* to (1)<br>";
							if((document.frmRequitment.eh2_from.value!="")&&(!ValidateDate(document.frmRequitment.eh2_from.value)))
									errors+="* Date From (2)<br>";
							if((document.frmRequitment.eh2_to.value!="")&&(!ValidateDate(document.frmRequitment.eh2_to.value)))
									errors+="* to (2)<br>";
							if((document.frmRequitment.eh3_from.value!="")&&(!ValidateDate(document.frmRequitment.eh3_from.value)))
									errors+="* Date From (3)<br>";
							if((document.frmRequitment.eh3_to.value!="")&&(!ValidateDate(document.frmRequitment.eh3_to.value)))
									errors+="* to (3)<br>";
							
							
							
							if(document.frmRequitment.eh1_employer.value.length<5)
									errors+="* Employer Name<br>";
							if(document.frmRequitment.eh1_address.value.length<5)
									errors+="* Employer Address<br>";
							if(document.frmRequitment.eh1_supName.value.length<5)
									errors+="* Contact Person<br>";
							if(!ValidatePhone(document.frmRequitment.eh1_supPhone.value))
									errors+="* Contact Phone<br>";
							if(document.frmRequitment.eh1_position.value.length<5)
									errors+="* Position<br>";
							if(!ValidateSalary(document.frmRequitment.eh1_wage.value))
									errors+="* Salary<br>";
*/
						stepX="resumebuilder";
						break;
					}		
		}

		if(errors==""){
			return true;
		}else{
			errormessage.innerHTML="<p>Error, please check: </p>"
				+errors
				+"<p><input type='button' value='Back' onClick='hide(errormessages);show("+stepX+");'></p>";
			hide(processing);
			show(errormessages);
			return false;
		}

	}

	
	function changeState(){
		div = document.getElementById("states");
		if(document.frmRequitment.step1_country.value=="USA"){
			div.innerHTML = "<select name=\"step1_st\" id=\"step1_st\">"+
							"<option value=\"\">Select State</option>"+
							"<option value=\"Alabama\">Alabama</option>"+
							"<option value=\"Alaska\">Alaska</option>"+
							"<option value=\"Arizona\">Arizona</option>"+
							"<option value=\"Arkansas\">Arkansas</option>"+
							"<option value=\"California\">California</option>"+
							"<option value=\"Colorado\">Colorado</option>"+
							"<option value=\"Connecticut\">Connecticut</option>"+
							"<option value=\"Delaware\">Delaware</option>"+
							"<option value=\"Dist Of Columbia\">Dist Of Columbia</option>"+
							"<option value=\"Florida\">Florida</option>"+
							"<option value=\"Georgia\">Georgia</option>"+
							"<option value=\"Hawaii\">Hawaii</option>"+
							"<option value=\"Idaho\">Idaho</option>"+
							"<option value=\"Illinois\">Illinois</option>"+
							"<option value=\"Indiana\">Indiana</option>"+
							"<option value=\"Iowa\">Iowa</option>"+
							"<option value=\"Kansas\">Kansas</option>"+
							"<option value=\"Kentucky\">Kentucky</option>"+
							"<option value=\"Louisiana\">Louisiana</option>"+
							"<option value=\"Maine\">Maine</option>"+
							"<option value=\"Maryland\">Maryland</option>"+
							"<option value=\"Massachusetts\">Massachusetts</option>"+
							"<option value=\"Michigan\">Michigan</option>"+
							"<option value=\"Minnesota\">Minnesota</option>"+
							"<option value=\"Mississippi\">Mississippi</option>"+
							"<option value=\"Missouri\">Missouri</option>"+
							"<option value=\"Montana\">Montana</option>"+
							"<option value=\"Nebraska\">Nebraska</option>"+
							"<option value=\"Nevada\">Nevada</option>"+
							"<option value=\"New Hampshire\">New Hampshire</option>"+
							"<option value=\"New Jersey\">New Jersey</option>"+
							"<option value=\"New Mexico\">New Mexico</option>"+
							"<option value=\"New York\">New York</option>"+
							"<option value=\"North Carolina\">North Carolina</option>"+
							"<option value=\"North Dakota\">North Dakota</option>"+
							"<option value=\"Ohio\">Ohio</option>"+
							"<option value=\"Oklahoma\">Oklahoma</option>"+
							"<option value=\"Oregon\">Oregon</option>"+
							"<option value=\"Pennsylvania\">Pennsylvania</option>"+
							"<option value=\"Rhode Island\">Rhode Island</option>"+
							"<option value=\"South Carolina\">South Carolina</option>"+
							"<option value=\"South Dakota\">South Dakota</option>"+
							"<option value=\"Tennessee\">Tennessee</option>"+
							"<option value=\"Texas\">Texas</option>"+
							"<option value=\"Utah\">Utah</option>"+
							"<option value=\"Vermont\">Vermont</option>"+
							"<option value=\"Virginia\">Virginia</option>"+
							"<option value=\"Washington\">Washington</option>"+
							"<option value=\"West Virginia\">West Virginia</option>"+
							"<option value=\"Wisconsin\">Wisconsin</option>"+
							"<option value=\"Wyoming\">Wyoming</option>"+
							"<option value=\"Alberta\">Alberta</option>"+
							"<option value=\"American Somoa\">American Somoa</option>"+
							"<option value=\"British Columbia\">British Columbia</option>"+
							"<option value=\"Guam\">Guam</option>"+
							"<option value=\"Manitoba\">Manitoba</option>"+
							"<option value=\"New Brunswick\">New Brunswick</option>"+
							"<option value=\"Newfoundland\">Newfoundland</option>"+
							"<option value=\"Nova Scotia\">Nova Scotia</option>"+
							"<option value=\"Ontario\">Ontario</option>"+
							"<option value=\"Prince Edward Isle\">Prince Edward Isle</option>"+
							"<option value=\"Quebec\">Quebec</option>"+
							"<option value=\"Saskatchewan\">Saskatchewan</option>"+
							"<option value=\"Virgin Island\">Virgin Island</option>"+
							"<option value=\"Yukon\">Yukon</option>"+
							"    </select>";
		} else
			div.innerHTML="<input type=\"text\" name=\"step1_st\" id=\"step1_st\" value=\"\" />";
		return;
}

