
	// used by tax calculator
	var jsel_formnames = new Array(3);
	var jsel_buttonname = null;

	function jsel_onloadEvent()
	{
		// if when loaded there's a make selected, fix up dependent menus for that selection
		if ((document.proDep[jsel_formnames[1]].disabled) && (document.proDep[jsel_formnames[0]].selectedIndex != 0))
		{
			jsel_tcProcessBackSelect(0);
		}
	}
	// active code: attach to onload event
	jsel_addLoadEvent(jsel_onloadEvent);

	function jselLocal_findArray(arrayFuel,mak,ref)
	{
		// simple linear search for now - nasty
		for (var i=0 ; i<arrayFuel.length ; ++i)
		{
			var sub = arrayFuel[i];
			if ((sub[0]==mak) && (sub[1]==ref))
			{
				return(arrayFuel[i]);
				break;
			}
		}
	}

	function jsel_tcSetupForm( field_one, field_two, field_three, button_four)
	{
		jsel_formnames[0] = field_one;
		jsel_formnames[1] = field_two;
		jsel_formnames[2] = field_three;
		jsel_buttonname = button_four;
		jsel_callbackInit(3);
	}

	function jsel_tcSetupMenus(arrayMake,matchMake)
	{
		// fml = first menu length
		fml = jsel_makeMenu(arrayMake,document.proDep[jsel_formnames[0]],0+1);
		if (fml == 2)
		{
			var scomp = document.proDep[jsel_formnames[0]];
			scomp.selectedIndex = 1;
			scomp.style.display = 'none';
			document.getElementById('sel_makelbl').style.display = 'none';
			jsel_tcProcessSelect( 1, scomp);
		}
		jsel_tcSetupMenusMatch( arrayMake, matchMake, 0);
	}
	
	function jsel_tcSetupMenusMatch(searchArray, matchstr, level)
	{
		var matchPos = -1;
		if (matchstr == null)
			return;
			
		if (searchArray == null)
		{
			searchArray = document.proDep[jsel_formnames[level]].options;
			for (var i=0 ; i<searchArray.length ; ++i)
			{
				if (searchArray[i].value == matchstr)
				{
					matchPos = i;
					break;
				}
			}
		} else {
			for (var i=0 ; i<searchArray.length ; ++i)
			{
				if (searchArray[i] == matchstr)
				{
					matchPos = i;
					break;
				}
			}
		}
		// action find/result
		if (matchPos != -1)
		{
			var scomp = document.proDep[jsel_formnames[level]];
			scomp.selectedIndex = matchPos;
			jsel_tcProcessSelectDirect(level+1, matchPos);
		}
	}

	function jsel_tcProcessSelectDirect( num, ref)
	{
		if (num == 1)
		{
			if (ref == 0)
			{
				jsel_blankMenu(document.proDep[jsel_formnames[1]]);
				jsel_blankMenu(document.proDep[jsel_formnames[2]]);
				bhv_dis(jsel_buttonname);
			} else {
				sml = jsel_makeMenu(arrayModel[ref],document.proDep[jsel_formnames[1]],1,null);
				if (sml == 2)
				{
					var scomp = document.proDep[jsel_formnames[1]];
					scomp.selectedIndex = 1;
					num = 2;
					ref = 1;
				} else {
					jsel_blankMenu(document.proDep[jsel_formnames[2]]);
					bhv_dis(jsel_buttonname);
				}
			}
		}
		if (num == 2)
		{
			if (ref == 0)
			{
				jsel_blankMenu(document.proDep[jsel_formnames[2]]);
				bhv_dis(jsel_buttonname);
			} else {
				var mak = document.proDep[jsel_formnames[0]].selectedIndex;
				var mod = document.proDep[jsel_formnames[1]].selectedIndex;
				bhv_en(jsel_buttonname);
				bhv_set('MakeModel', arrayMake[mak]+","+arrayModel[mak][mod]);
				tml = jsel_makeMenu(jselLocal_findArray(arrayFuel,mak,ref),document.proDep[jsel_formnames[2]],2,arrayLookupFuel);
				if (tml == 2)
				{
					var tcomp = document.proDep[jsel_formnames[2]];
					tcomp.selectedIndex = 1;
					num = 3;
					ref = 1;
				}
			}
		}
		if (num == 3)
		{
			if (ref == 0)
			{
				//bhv_dis(jsel_buttonname);
			} else {
				var mak = document.proDep[jsel_formnames[0]].selectedIndex;
				var mod = document.proDep[jsel_formnames[1]].selectedIndex;

				bhv_en(jsel_buttonname);
				bhv_set('MakeModel', arrayMake[mak]+","+arrayModel[mak][mod]);
			}
		}
		jsel_callbackProcess(num);
	}


	// used by geography
	function jsel_processSelectGeneric( sel, othername, tickname, otherarray, skip)
	{
		var ref = sel.selectedIndex;
		var otr = document.proDep[othername];
		var refname = sel.options[ref].value;
		if (ref == 0)
		{
			oref = 0;
			document.proDep[tickname].checked = false;
		} else {
			// have to lookup by name (form & part-sub menu constraints)
			oref = 0;
			for (var i=1 ; i<otherarray.length ; ++i)
			{
				if (otherarray[i][0] == refname)
				{
					oref = i;
					break;
				}
			}
		}

		// remember what's currently selected, then change the other menu
		prevsel = otr.options[otr.selectedIndex].value;
		jsel_makeMenu(otherarray[oref],document.proDep[othername],skip,null);

		// now re-select that which was previously selected in the other menu
		osel = 0;
		for (var i=1 ; i<otr.options.length ; ++i)
		{
			if (otr.options[i].value == prevsel)
			{
				osel = i;
				break;
			}
		}
		otr.selectedIndex = osel;
	}


