// JavaScript Document
function hide_categories(){
	var my_divs = $("mainContent").getElementsByTagName("div");
	for(var i=0; i < my_divs.length; i++){
		if(my_divs[i].getAttribute("class") == "menu_category" ){
			//alert(my_divs[i].id);
			Element.hide(my_divs[i].id);
		}
	}
}

	
var app_tabs = new Object();
	app_tabs[0] = "personal_info";
	app_tabs[1] = "job_info";
	app_tabs[2] = "education";
	app_tabs[3] = "general";
	app_tabs[4] = "employers";
	app_tabs[5] = "references";
	app_tabs[6] = "service";
	app_tabs[7] = "criminal";
	app_tabs[8] = "submit";	
	
function hide_fieldsets(){
	//Hide everything		
	Element.hide('personal_info');
	Element.hide('job_info');
	Element.hide('education');
	Element.hide('general');
	Element.hide('employers');
	Element.hide('references');
	Element.hide('service');
	Element.hide('criminal');
	Element.hide('submit');
	}
	
function hide_ol(){
	document.getElementById("application_tabs").style.display = "none";
	}
	
function make_tabs(){
	var i = 0;
	var j = 0;
	var new_tabs = "";
	for (i in app_tabs){ 
		j++;
		new_tabs += "<li><a href=\"#" + app_tabs[i] + "\" onclick=\"hide_fieldsets()\; Effect.toggle('" + app_tabs[i] + "');\">" + j + "</a></li>";
		}		
	document.getElementById("application_tabs").innerHTML = new_tabs;
	}
	
function make_prev(current_tab){
	var prev_tab = current_tab - 1;
	if (prev_tab < 0 ){
		// this relies on the object defined above
		prev_tab = 8;
		}
	my_link = "<p class=\"prev_next\"><a href=\"#" + app_tabs[prev_tab] + "\" onclick=\"hide_fieldsets()\; Effect.toggle('" + app_tabs[prev_tab] + "'); return false\;\">Previous</a></p>";
	document.write(my_link);
}

function make_next(current_tab){
	var next_tab = current_tab + 1;
	my_link = "<p class=\"prev_next\"><a href=\"#" + app_tabs[next_tab] + "\" onclick=\"hide_fieldsets()\; Effect.toggle('" + app_tabs[next_tab] + "'); return false\;\">Next</a></p>";
	document.write(my_link);
}
	
function make_prev_next(current_tab){
	var next_tab = current_tab + 1;
	var prev_tab = current_tab - 1;
	if (prev_tab < 0 ){
		// this relies on the object defined above
		prev_tab = 8;
		}
	my_link = "<p class=\"prev_next\"><a href=\"#" + app_tabs[prev_tab] + "\" onclick=\"hide_fieldsets()\; Effect.toggle('" + app_tabs[prev_tab] + "'); return false\;\">Previous</a>";
	my_link += " | ";
	my_link += "<a href=\"#" + app_tabs[next_tab] + "\" onclick=\"hide_fieldsets()\; Effect.toggle('" + app_tabs[next_tab] + "'); return false\;\">Next</a></p>";
	document.write(my_link);
}
		
function check_submit() {
	var unChecked = false;
	var chkBox = document.getElementById("agreement");
	var btn = document.getElementById("submit_btn");
	if (!chkBox.checked){
		unChecked = true;
	}
	if (unChecked){
		btn.disabled = true;
	}else{
		btn.disabled = false;
		btn.focus;
	}
}

function disable_submit(){
	var btn = document.getElementById("submit_btn");
	btn.disabled = true;
	//alert(btn.getAttribute("disabled"));
}

function validate(){
	if($("first_name").value == ''){
		alert("Please enter your First Name");
		hide_fieldsets();
		Effect.Appear('personal_info');
		$("first_name").setAttribute("class", "badField");
		return false;
	}
	if($("last_name").value == ''){
		alert("Please enter your Last Name");
		hide_fieldsets();
		Effect.Appear('personal_info');
		$("last_name").setAttribute("class", "badField");
		return false;
	}
	if($("email").value == ''){
		alert("Please enter your Email Address");
		hide_fieldsets();
		Effect.Appear('personal_info');
		$("email").setAttribute("class", "badField");
		return false;
	}
	var emailFilter=/^.+@.+\..{2,3}$/;
	if(!(emailFilter.test($("email").value))){
		alert("Please enter a valid email Address.");
		hide_fieldsets();
		Effect.Appear('personal_info');
		$("email").setAttribute("class", "badField");
		return false;
		}
	if($("phone").value == ''){
		alert("Please enter your Phone");
		hide_fieldsets();
		Effect.Appear('personal_info');
		$("phone").setAttribute("class", "badField");
		return false;
	}
	if($("start_date").value == ''){
		alert("Please enter the Date you can start.");
		hide_fieldsets();
		Effect.Appear('job_info');
		$("start_date").setAttribute("class", "badField");
		return false;
	}
	return true;
}
