

function LoadMenuValues(menu1Name, menu2Name, menu1Arr, menu2Arr, firstTitle)

{

	menu1 = FindFormElementByName(menu1Name);

	menu2 = FindFormElementByName(menu2Name);



	if (menu1 == null || menu2 == null)

	{

		return;

	}



	var index = menu1.selectedIndex;

	var value = menu1.options[index].value;



	ClearMenu(menu2);



	if (value != "") 

	{

		var x = 0;

		var found = false;

		while(menu1Arr.length > x)

		{

			if (value == menu1Arr[x])

			{

				found = true;

				break;

			}

			

			x++;

		}



		if (found)

		{

			arrOptions = menu2Arr[x];



			var option = new Option(firstTitle);

			option.value = "";

			menu2.options[0] = option;

		

			for (y = 0; y < arrOptions.length; y++) 

			{

				menu2.options[menu2.options.length] = arrOptions[y];

			}

		}

	}

}



function FindFormElementByName(name)

{

	for (var i = 0; i < document.forms[0].elements.length; i++) 

	{

		if (document.forms[0].elements[i] && document.forms[0].elements[i].name == name) 

		{

			return document.forms[0].elements[i];			

		}

	}



	return null;

}



function ClearMenu(menu, leaveFirst)

{

	lastIndex = 0;

	if (leaveFirst)

	{

		lastIndex = 1;

	}



	while (menu.options.length != lastIndex) 

	{

		var a = menu.options.length - 1;

		menu.options[a] = null;

	}

}

