﻿	var obj_list_of_input;
	var str_id_jobtype_list = "jobtype_checkbox_list"
	var str_id_jobtype_list_loader = "jobtype_checkbox_list_loading"
	
	function display_my_children_checkbox()
	{
		var str_display = (this.checked ? "block" : "none");

		for (var i = 0; i < obj_list_of_input.length; i++) {
			if ((obj_list_of_input[i].value.substring(0, 2) == this.value) && (obj_list_of_input[i].value.length > 2)) {
				// Uncheck child (if parent is uncheck)
				if (!this.checked)
					obj_list_of_input[i].checked = false;
				
				// Hide child
				obj_list_of_input[i].parentNode.style.display = str_display;
			}
		}
	}

	function hideSubJobtypes()
	{
		var b_is_parent_checked = false;
		var list_of_items_hidden = new Array();
		
		if (document.getElementById(str_id_jobtype_list))
		{
			obj_list_of_input = document.getElementById(str_id_jobtype_list).getElementsByTagName("INPUT");

			for (var i = 0; i < obj_list_of_input.length; i++)
			{
				if (obj_list_of_input[i].value.length > 2)
				{
					// Hide children items (if parent not checked)
					if (!b_is_parent_checked)
					{
						obj_list_of_input[i].parentNode.style.display = "none";
						list_of_items_hidden.push(obj_list_of_input[i].parentNode);
						 
						// If one children are checked, redisplay hidden checkbox and go next parent checkbox
						if (obj_list_of_input[i].checked)
						{
							for (var j = 0; j < list_of_items_hidden.length; j++)
							{
								list_of_items_hidden[j].style.display = "block";
							}
							b_is_parent_checked = true;
						}
					}
				}
				else
				{
					// Add function to show children
					obj_list_of_input[i].onclick = display_my_children_checkbox;

					// Display children if parent are checked
					b_is_parent_checked = obj_list_of_input[i].checked;

					// Reset list
					list_of_items_hidden = new Array();
				}
			}
			if (document.getElementById(str_id_jobtype_list_loader)) { document.getElementById(str_id_jobtype_list_loader).style.display = "none"; }
			document.getElementById(str_id_jobtype_list).style.display = "block";
		}
	}

