

	function clear_fields(x)
	{
		x.ht_num.value			= "";
		x.ht_make.value			= "";
		x.ht_model.value			= "";

		setsel (x.ht_lang, "English");
	
	} <!-- end of function -->



	function saveList(x) {
		var strValues 			= "";
		var boxLength 			= x.ht_list.length;
		var count 				= 0;

		x.ht_qty.value 			= "";							// reset each time

		if (boxLength == 0) 		return;

		for (i = 0; i < boxLength; i++) {
			if (count == 0) {
				strValues = x.ht_list.options[i].value;
			}
			else {
				strValues = strValues + "," + x.ht_list.options[i].value;
			}
			count++;
		}


		x.ht_qty.value = strValues;

		//alert (x.ht_qty.value);

	} <!-- end of function -->




	function add_option (x) {

		var boxLength 			= x.ht_list.length;

		if (chkval(x) == false)		return;

		var lang				= rtnsel (x.ht_lang);

		var selectedText			= x.ht_num.value + ";" + lang + ";" + x.ht_make.value + ";" + x.ht_model.value;
		var selectedValue 		= selectedText;

		newoption 				= new Option(selectedText, selectedValue, false, false);
		x.ht_list.options[boxLength] 	= newoption;

		saveList(x);

		clear_fields(x);
	
	} <!-- end of function -->




	function modify_option (x) {
		var boxLength 			= x.ht_list.length;

		if (chkval(x) == false)		return;

		var lang				= rtnsel (x.ht_lang);

		var selectedText			= x.ht_num.value + ";" + lang + ";" + x.ht_make.value + ";" + x.ht_model.value;
		var selectedValue 		= selectedText;


		for (i = 0; i < boxLength; i++) {
			if (x.ht_list.options[i].selected) {
				x.ht_list.options[i].text 	= selectedText;
				x.ht_list.options[i].value 	= selectedValue;
				clear_fields(x);
				break;
			}
		}

		saveList(x);

	} <!-- end of function -->




	function delete_option (x) {
		var boxLength 			= x.ht_list.length;

		for (i = 0; i < boxLength; i++) {
			if (x.ht_list.options[i].selected) {
				$f			= confirm ("Are you sure?");
				if ($f == false)	return;

				x.ht_list.options[i] = null;
				break;
			}
		}

		saveList(x);

		clear_fields(x);

	} <!-- end of function -->




	function update_inputbox (x) {
	
		var boxLength 			= x.ht_list.length;

		for (i = 0; i < boxLength; i++) {
			if (x.ht_list.options[i].selected) {

				var txt 		= x.ht_list.options[i].text;

				var ary		= txt.split (";");
				x.ht_num.value	= ary[0];
				x.ht_make.value	= ary[2];
				x.ht_model.value	= ary[3];

				setsel (x.ht_lang, ary[1]);

				return;	
			}
		}

	} <!-- end of function -->




	function rtnsel (x) {

		var boxLength 			= x.length;

		for (i = 0; i < boxLength; i++) {

			if (x.options[i].selected && x.options[i].value != "0")
				return x.options[i].value; 
		}

		return "";

	} <!-- end of function -->




	function setsel (x, val) {

		var boxLength 			= x.length;

		for (i = 0; i < boxLength; i++) {

			//alert (x.options[i].value + " ... " + val);

			if (x.options[i].value == val)
				x.options[i].selected = true;
			else
				x.options[i].selected = false;
		}

		return true;

	} <!-- end of function -->




	function chkval (x) {

		if (x.ht_num.value == "" && x.ht_make.value == "" && x.ht_model.value == "")	return false;

		submitOK="True";
		var message = "Please: \n";

		if (x.ht_num.value == "" || x.ht_num.value == 0)
 		{ message += "- Enter the number of guides that you require\n";			submitOK="False"; }

		if (x.ht_make.value == "")
 		{ message += "- Enter the Make of the Model that you require\n";			submitOK="False"; }

		if (x.ht_model.value == "")
 		{ message += "- Enter the Model that you require\n";					submitOK="False"; }

		if (submitOK=="False"){
 			message += "- Check that the Guides will be in the language that you require\n";
 			alert(message)
 			return false;
 		}
 			

		return true;

	} <!-- end of function -->