//	var script_path = "/Orkev/public_html/scripts/";
// following line untested
 	var script_path = "/scripts/";

	
	// on page load, update select boxes, including subcatagory box
	function amend_lists()
	{
		amend_region_list('show', '', '');
		amend_catagory_list('show', '', '');
	}
	
	
	// on page load, update select boxes, no subcatagory box
	function amend_lists2()
	{
		amend_region_list('show', '', '');
		amend_catagory_list2('show', '', '');
	}



// ----------------------------------------
	
	// updates subregions select box using selected region
	function show_subregions(formname, str)
	{
		$.ajax({
			type: "GET",
			url: script_path+"populate_subregions.php",
			data: 	"q="+str+"&sid="+Math.random(),
			success: function(html){
				var temp = new Array();
				formname.subregions.options.length=0 // reset select list to empty
				var subregionsList=formname.subregions;
				temp = html.split('|'); // parse database results into array
				for (i=0; i<temp.length-1; i=i+2) // output array to select list
					subregionsList.options[subregionsList.options.length]=new Option(temp[i], temp[i+1])
			}
		});
	}

	// amends updatable div for region selections
	// action = del, add, or show
	// reg and subreg used for del action, hold region and subregion numbers to be deleted
	function amend_region_list(action, reg, subreg)
	{
		var regionSel = document.getElementById("regions").value;
		var subregionSel = document.getElementById("subregions").value;
		var RArray = document.getElementById("region_str").value;
		if(reg!='')
			regionSel = reg;
		if(subreg!='')
			subregionSel = subreg;
				
		$.ajax({
			type: "GET",
			url: script_path+"populate_selections_div.php",
			data: 	"sel="+regionSel+"&ssel="+subregionSel+"&rarray="+RArray+"&act="+action+"&div=reg",
			success: function(html){
				var temp = new Array();
				temp = html.split('~'); // parse database results into array
				document.getElementById("region_selections").innerHTML = temp[0];
				document.getElementById("region_str").value= temp[1];
			}
		});
	}

	// updates subcatagories select box using selected catagory
	function show_subjobs(formname, str)
	{
		$.ajax({
			type: "GET",
			url: script_path+"populate_subjobs.php",
			data: 	"q="+str+"&sid="+Math.random(),
			success: function(html){
				var temp = new Array();
				formname.subcatagories.options.length=0 // reset select list to empty
				var jobsList=formname.subcatagories;
				temp = html.split('|'); // parse database results into array
				for (i=0; i<temp.length-1; i=i+2) // output array to select list
					jobsList.options[jobsList.options.length]=new Option(temp[i], temp[i+1])
			}
		});
	}

	
	// amends updatable div for catagory selections with catagory and subcatagory select boxes
	// action = del, add, or show
	// cat and subcat used for del action, hold catagory and subcatagory numbers to be deleted
	function amend_catagory_list(action, cat, subcat)
	{
		var CatagorySel = document.getElementById("catagories").value;
		var SubCatagorySel = document.getElementById("subcatagories").value;
		var CArray = document.getElementById("catagory_str").value;
		if(cat!='')
			CatagorySel = cat;
		if(subcat!='')
			SubCatagorySel = subcat;
				
		$.ajax({
			type: "GET",
			url: script_path+"populate_selections_div.php",
			data: 	"sel="+CatagorySel+"&ssel="+SubCatagorySel+"&rarray="+CArray+"&act="+action+"&div=cat",
			success: function(html){
				var temp = new Array();
				temp = html.split('~'); // parse database results into array
				document.getElementById("catagory_selections").innerHTML = temp[0];
				document.getElementById("catagory_str").value= temp[1];
			}
		});
	}

	// amends updatable div for catagory selections with no subcatagory select box
	// action = del, add, or show
	// cat and subcat used for del action, hold catagory and subcatagory numbers to be deleted
	function amend_catagory_list2(action, cat, subcat)
	{
		var CatagorySel = document.getElementById("catagories").value;
		var CArray = document.getElementById("catagory_str").value;
		if(cat!='')
			CatagorySel = cat;
				
		$.ajax({
			type: "GET",
			url: script_path+"populate_selections_div.php",
			data: 	"sel="+CatagorySel+"&ssel=9999&rarray="+CArray+"&act="+action+"&div=cat&show_subcat=no",
			success: function(html){
				var temp = new Array();
				temp = html.split('~'); // parse database results into array
				document.getElementById("catagory_selections").innerHTML = temp[0];
				document.getElementById("catagory_str").value= temp[1];
			}
		});
	}

