function errorHandler()
{
	var error = new Array();
	var zip_reg = /\d{5}/;
	var	phone_reg = /\d{3}\-\d{3}\-\d{4}/;
	var time_reg = /^(([1-9]{1})|([0-1][1-2])|(0[1-9])|([1][0-2])):([0-5][0-9])/;
	var date_reg = /^((((0[13578])|([13578])|(1[02]))[\/](([1-9])|([0-2][0-9])|(3[01])))|(((0[469])|([469])|(11))[\/](([1-9])|([0-2][0-9])|(30)))|((2|02)[\/](([1-9])|([0-2][0-9]))))[/]\d{4}$|^\d{4}$/;
	var partialdate_reg = /^((0[1-9])|(1[0-2]))\/(\d{4})$/;

	//fname
	if(document.application.elements['fname'].value == "")
	{
		error.push('First Name');
		document.application.fname.style.background = "#dd3c34";
	}
	else
	{
		document.application.fname.style.background = "";
	}
	
	//lname
	if(document.application.lname.value == "")
	{
		error.push('Last Name');
		document.application.lname.style.background = "#dd3c34";
	}
	else
	{
		document.application.lname.style.background = "";
	}
	
	//mintial
	if(document.application.mintial.value == "")
	{
		error.push('Middle Initial');
		document.application.mintial.style.background = "#dd3c34";
	}
	else
	{
		document.application.mintial.style.background = "";
	}
	
	//address
	if(document.application.address.value == "")
	{
		error.push('Address');
		document.application.address.style.background = "#dd3c34";
	}
	else
	{
		document.application.address.style.background = "";
	}
	
	//city
	if(document.application.city.value == "")
	{
		error.push('City');
		document.application.city.style.background = "#dd3c34";
	}
	else
	{
		document.application.city.style.background = "";
	}
	
	//state
	if(document.application.state.value == "")
	{
		error.push('State');
		document.application.state.style.background = "#dd3c34";
	}
	else
	{
		document.application.state.style.background = "";
	}
	
	//zip_code
	if(!zip_reg.test(document.application.zip_code.value))
	{
		error.push('Zip Code');
		document.application.zip_code.style.background = "#dd3c34";
	}
	else
	{
		document.application.zip_code.style.background = "";
	}

	//h_phone
	if(!phone_reg.test(document.application.h_phone.value))
	{
		error.push('Home Phone');
		document.application.h_phone.style.background = "#dd3c34";
	}
	else
	{
		document.application.h_phone.style.background = "";
	}
	
	
	//h_time
	if(!time_reg.test(document.application.h_time.value))
	{
		error.push('Best Time to Reach you at Home');
		document.application.h_time.style.background = "#dd3c34";
	}
	else
	{
		document.application.h_time.style.background = "";
	}
	
	//home_time
	if(document.application.home_time.value == "")
	{
		error.push('Best Time to Reach you at Home - AM or PM');
		document.application.home_time.style.background = "#dd3c34";
	}
	else
	{
		document.application.home_time.style.background = "";
	}
	
	//email_address
	if(document.application.email_address.value == "")
	{
		error.push('Email Address');
		document.application.email_address.style.background = "#dd3c34";
	}
	else
	{
		document.application.email_address.style.background = "";
	}
	
	//position_app
	if(document.application.elements['position_app[]'].value == "-Select-")
	{
		error.push('Postion(s) applied for');
		document.application.elements['position_app[]'].style.background = "#dd3c34";
	}
	else
	{
		document.application.elements['position_app[]'].style.background = "";
	}
	
	
	

	

	//work_availablity_date
	if(!date_reg.test(document.application.work_availablity_date.value))
	{
		error.push('Date Available for work');
		document.application.work_availablity_date.style.background = "#dd3c34";
	}
	else
	{
		document.application.work_availablity_date.style.background = "";
	}	
	
	//desired_salary
	if((document.application.desired_salary_money.value == "00.00") && (document.application.desired_salary_per_hour.value == "")) 
	{
		error.push('Enter a Desired Salary or Hourly Rate');
		document.application.desired_salary_per_hour.style.background = "#dd3c34";
		document.application.desired_salary_money.style.background = "#dd3c34";
	}
	else
	{
		document.application.desired_salary_per_hour.style.background = "";
		document.application.desired_salary_money.style.background = "";
	}
	
	////////////Start of the Validation////////
	var emp_name = document.forms['application'].elements['emp_name[]'];
	var emp_phone = document.forms['application'].elements['emp_phone[]'];
	var emp_address = document.forms['application'].elements['emp_address[]'];
	var emp_city = document.forms['application'].elements['emp_city[]'];
	var emp_state = document.forms['application'].elements['emp_state[]'];
	var emp_zip_code = document.forms['application'].elements['emp_zip_code[]'];
	var emp_start_title = document.forms['application'].elements['emp_start_title[]'];
	var supervisor_name = document.forms['application'].elements['supervisor_name[]'];
	var supervisor_title = document.forms['application'].elements['supervisor_title[]'];
	var emp_reason = document.forms['application'].elements['emp_reason[]'];
	var emp_work = document.forms['application'].elements['emp_work[]'];
	var emp_response = document.forms['application'].elements['emp_response[]'];
	var job_fav = document.forms['application'].elements['job_fav[]'];
	var job_dislike = document.forms['application'].elements['job_dislike[]'];
	var emp_start_date = document.forms['application'].elements['emp_start_date[]'];
	var emp_end_date = document.forms['application'].elements['emp_end_date[]'];
	var comp_strt_money = document.forms['application'].elements['comp_strt_money[]'];
	var comp_strt_other_money = document.forms['application'].elements['comp_strt_other_money[]'];
	var comp_strt_per = document.forms['application'].elements['comp_strt_per[]'];
	var comp_final_money = document.forms['application'].elements['comp_final_money[]'];
	var comp_final_per = document.forms['application'].elements['comp_final_per[]'];
	var comp_final_other_money = document.forms['application'].elements['comp_final_other_money[]'];
	
	
	if(emp_name['length'] == null)
	{
			//emp_name
			if(emp_name.value == "")
			{
				error.push('Employment History - Name');
				emp_name.style.background = "#dd3c34";
			}
			else
			{
				emp_name.style.background = "";
			}
			
			//emp_city
			if(emp_city.value == "")
			{
				error.push('Employment History - City');
				emp_city.style.background = "#dd3c34";
			}
			else
			{
				emp_city.style.background = "";
			}
			
			//emp_state
			if(emp_state.value == "")
			{
				error.push('Employment History - State');
				emp_state.style.background = "#dd3c34";
			}
			else
			{
				emp_state.style.background = "";
			}
			
			//emp_starting_title
			if(emp_start_title.value == "")
			{
				error.push('Employment History - Starting Job Title');
				emp_start_title.style.background = "#dd3c34";
			}
			else
			{
				emp_start_title.style.background = "";
			}
			
			//emp_reason
			if(emp_reason.value == "")
			{
				error.push('Employment History - Reason for Leaving')
				emp_reason.style.background = "#dd3c34";
			}
			else
			{
				emp_reason.style.background = "";
			}
			
			
			//emp_start_date
			if(!partialdate_reg.test(emp_start_date.value))
			{
				error.push('Employment History - Dates Employed')
				emp_start_date.style.background = "#dd3c34";
			}
			else
			{
				emp_start_date.style.background = "";
			}
			
			//emp_end_date
			if(!partialdate_reg.test(emp_end_date.value))
			{
				error.push('Employment History - Dates Employed')
				emp_end_date.style.background = "#dd3c34";
			}
			else
			{
				emp_end_date.style.background = "";
			}
		
	}
	else
	{
		for (i=0; i<emp_name.length; i++) 
		{
			//emp_name
			if(emp_name[i].value == "")
			{
				error.push('Employment History - Name');
				emp_name[i].style.background = "#dd3c34";
			}
			else
			{
				emp_name[i].style.background = "";
			}
			
			
			//emp_address
			if(emp_address[i].value == "")
			{
				error.push('Employment History - Address');
				emp_address[i].style.background = "#dd3c34";
			}
			else
			{
				emp_address[i].style.background = "";
			}
			
			//emp_city
			if(emp_city[i].value == "")
			{
				error.push('Employment History - City');
				emp_city[i].style.background = "#dd3c34";
			}
			else
			{
				emp_city[i].style.background = "";
			}
			
			//emp_state
			if(emp_state[i].value == "")
			{
				error.push('Employment History - State');
				emp_state[i].style.background = "#dd3c34";
			}
			else
			{
				emp_state[i].style.background = "";
			}
			
			//emp_reason
			if(emp_reason[i].value == "")
			{
				error.push('Employment History - Reason for Leaving')
				emp_reason[i].style.background = "#dd3c34";
			}
			else
			{
				emp_reason[i].style.background = "";
			}
			
			//emp_start_date
			if(!partialdate_reg.test(emp_start_date[i].value))
			{
				error.push('Employment History - Dates Employed')
				emp_start_date[i].style.background = "#dd3c34";
			}
			else
			{
				emp_start_date[i].style.background = "";
			}
			
			//emp_end_date
			if(!partialdate_reg.test(emp_end_date[i].value))
			{
				error.push('Employment History - Dates Employed')
				emp_end_date[i].style.background = "#dd3c34";
			}
			else
			{
				emp_end_date[i].style.background = "";
			}
		
		}
	}
		//////////////////End of Validation
		
	
	//emp_past_selection
	chosen = "";
	len = document.application.emp_past_selection.length;
	for (i = 0; i <len; i++) 
	{
		if (document.application.emp_past_selection[i].checked) 
		{
			chosen = document.application.emp_past_selection[i].value;
		}
	}
	if (chosen == "Yes") 
	{
		document.getElementById('emp_past').style.visibility = "visible";
		if(document.application.emp_past_explain.value == "")
		{
			error.push('Employment History - Explain reason for being fired or asked to resign')
			document.application.emp_past_explain.style.background = "#dd3c34";
		}
		else
		{
			document.application.emp_past_explain.style.background = "";
		}
	}
	else
	{
		document.getElementById('emp_past').style.visibility = "hidden";
	}

	var school = document.forms['application'].elements['school[]'];
	var school_from_date = document.forms['application'].elements['school_from_date[]'];
	var school_to_date = document.forms['application'].elements['school_to_date[]'];
	var grad_date = document.forms['application'].elements['grad_date[]'];
	
	
	if(school['length'] == null)
	{
			if(school.value == "")
			{
				error.push('Educational Background - Name')
				school.style.background = "#dd3c34";
			}
			else
			{
				school.style.background = "";
			}
			
			//school_from_date0
			if(!partialdate_reg.test(school_from_date.value))
			{
				error.push('Educational Background - From Date')
				school_from_date.style.background = "#dd3c34";
			}
			else
			{
				school_from_date.style.background = "";
			}
			
			//school_to_date0
			if(!partialdate_reg.test(school_to_date.value))
			{
				error.push('Educational Background - To Date')
				school_to_date.style.background = "#dd3c34";
			}
			else
			{
				school_to_date.style.background = "";
			}
			
			//grad_date0
			if(!partialdate_reg.test(grad_date.value))
			{
				error.push('Educational Background - Graduation Date')
				grad_date.style.background = "#dd3c34";
			}
			else
			{
				grad_date.style.background = "";
			}
	}
	else
	{
		for (i=0; i<school.length; i++) 
		{
			/////////// START VALIDATING EDUCATIONAL BACKGROUNDS ///////////////
			if(school[i].value == "")
			{
				error.push('Educational Background - Name')
				school[i].style.background = "#dd3c34";
			}
			else
			{
				school[i].style.background = "";
			}
			
			//school_from_date0
			if(!partialdate_reg.test(school_from_date[i].value))
			{
				error.push('Educational Background - From Date')
				school_from_date[i].style.background = "#dd3c34";
			}
			else
			{
				school_from_date[i].style.background = "";
			}
			
			//school_to_date0
			if(!partialdate_reg.test(school_to_date[i].value))
			{
				error.push('Educational Background - To Date')
				school_to_date[i].style.background = "#dd3c34";
			}
			else
			{
				school_to_date[i].style.background = "";
			}
			
			//grad_date0
			if(!partialdate_reg.test(grad_date[i].value))
			{
				error.push('Educational Background - Graduation Date')
				grad_date[i].style.background = "#dd3c34";
			}
			else
			{
				grad_date[i].style.background = "";
			}
		}
	}
	///////////////// END EDUCATIONAL BG CHECK /////////////////////
	
	if(document.application.ref_fname.value == "")
	{
		error.push('Reference 1 - First Name')
		document.application.ref_fname.style.background = "#dd3c34";
	}
	else
	{
		document.application.ref_fname.style.background = "";
	}
	
	if(document.application.ref_lname.value == "")
	{
		error.push('Reference 1 - Last Name')
		document.application.ref_lname.style.background = "#dd3c34";
	}
	else
	{
		document.application.ref_lname.style.background = "";
	}
	if(document.application.ref_relation.value == "")
	{
		error.push('Reference 1 - Relationship')
		document.application.ref_relation.style.background = "#dd3c34";
	}
	else
	{
		document.application.ref_relation.style.background = "";
	}
	if(document.application.ref_phone.value == "xxx-xxx-xxxx")
	{
		error.push('Reference 1 - Phone')
		document.application.ref_phone.style.background = "#dd3c34";
	}
	else
	{
		document.application.ref_phone.style.background = "";
	}
	if(document.application.ref_fname2.value == "")
	{
		error.push('Reference 2 - First Name')
		document.application.ref_fname2.style.background = "#dd3c34";
	}
	else
	{
		document.application.ref_fname2.style.background = "";
	}
	
	if(document.application.ref_lname2.value == "")
	{
		error.push('Reference 2 - Last Name')
		document.application.ref_lname2.style.background = "#dd3c34";
	}
	else
	{
		document.application.ref_lname2.style.background = "";
	}
	if(document.application.ref_relation2.value == "")
	{
		error.push('Reference 2 - Relationship')
		document.application.ref_relation2.style.background = "#dd3c34";
	}
	else
	{
		document.application.ref_relation2.style.background = "";
	}
	if(document.application.ref_phone2.value == "xxx-xxx-xxxx")
	{
		error.push('Reference 2 - Phone')
		document.application.ref_phone2.style.background = "#dd3c34";
	}
	else
	{
		document.application.ref_phone2.style.background = "";
	}
	if(document.application.ref_fname3.value == "")
	{
		error.push('Reference 3 - First Name')
		document.application.ref_fname3.style.background = "#dd3c34";
	}
	else
	{
		document.application.ref_fname3.style.background = "";
	}
	
	if(document.application.ref_lname3.value == "")
	{
		error.push('Reference 3 - Last Name')
		document.application.ref_lname3.style.background = "#dd3c34";
	}
	else
	{
		document.application.ref_lname3.style.background = "";
	}
	if(document.application.ref_relation3.value == "")
	{
		error.push('Reference 3 - Relationship')
		document.application.ref_relation3.style.background = "#dd3c34";
	}
	else
	{
		document.application.ref_relation3.style.background = "";
	}
	if(document.application.ref_phone3.value == "xxx-xxx-xxxx")
	{
		error.push('Reference 3 - Phone')
		document.application.ref_phone3.style.background = "#dd3c34";
	}
	else
	{
		document.application.ref_phone3.style.background = "";
	}
	//app_selection
	if(!date_reg.test(document.application.app_date.value))
	{
		error.push('Date of Application');
		document.application.app_date.style.background = "#dd3c34";
	}
	else
	{
		document.application.app_date.style.background = "";
	}

	//print all errors
	if(error.length > 0)
	{
		var msg = 'The following errors are:<br/><ul>';
		for(var i in error)
		{
			msg += '<li>' + error[i] + '</li>';	
		} 
		msg += '</ul>';
		document.getElementById('error_msg').innerHTML = msg;
		return false;
	}
	else
	{
		document.getElementById('error_msg').innerHTML = '';
		return true;
	} 
}
