// This code makes Dinger Jeff's Hero 

	var chooseFrame = null;
	
	// this function resets all of the boxes to their default "please Choose" and clears the input box
	function reset()
	{
		var Box1=document.getElementById("contactortype");
		var Box2=document.getElementById("frame");
		var Box3=document.getElementById("powerpole");
		var Box4=document.getElementById("coilvoltage");
		var Box5=document.getElementById("auxcontacts");
		var TxtBox=document.getElementById("parttextfield");
		
		Box1.selectedIndex = 0;
		Box2.selectedIndex = 0;
		Box3.selectedIndex = 0;
		Box4.selectedIndex = 0;
		Box5.selectedIndex = 0;
		TxtBox.value = "";
		
	}
		
	
	function typeSelect()
	{
	
		var x=0;
	
		var framesNonr = new Array("A9", "A12", "A16", "A26", "A30", "A40", "A50", "A63", "A75", "A95", "A110", "A145", "A185", "A210", "A260", "A300");	
		var framesMech = new Array("A9M", "A12M", "A16M", "A26M", "A30M", "A40M", "A50M", "A63M", "A75M", "A95M", "A110M", "A145M", "A185M", "A210M", "A260M", "A300M");
		var framesRev = new Array("A9R", "A12R", "A16R", "A26R", "A30R", "A40R", "A50R", "A63R", "A75R", "A95R", "A110R", "A145R", "A185R", "A210R", "A260R", "A300R");	

		var Box1=document.getElementById("contactortype");
		var Box2=document.getElementById("frame");
		var TxtBox=document.getElementById("parttextfield");
		
		
		if (Box1.selectedIndex == 1)
		{
			chooseFrame = framesNonr;
		}
		
		if (Box1.selectedIndex == 2)
		{
			chooseFrame = framesMech;
		}
		
		if (Box1.selectedIndex == 3)
		{
			chooseFrame = framesRev;
		}
		
		if (Box1.selectedIndex == 0)
		{
			chooseFrame = null;
		}
		
		// Clear Box 2
		Box2.options.length = 0;		
		
		// if Box one says "Please select" we should put only one element into the select
		if (Box1.selectedIndex == 0)
		{
			var y=document.createElement('option');
			y.text = "Please Select";
			Box2.options[0] = y;
		}
		// fill the select box with necessary data
		for (x = 0; x <= chooseFrame.length; x++)
		{
			var y=document.createElement('option');
			
			if (x == 0)
			{
				y.text = "Please Select";
				//Box2.add(y, null);
				Box2.options[0] = y;
			}
			else
			{
				y.text = chooseFrame[x-1];
				Box2.options[x] = y;
			}
		}
		// clear the text box
		TxtBox.value = "";
			
		
	}
	
	
	function valueSelect()
	{
		var firstNumber = null;
		var secondNumber = null;
		var thirdNumber = null;
		var fourthNumber = null;
				
		// variables to hold form objects
		
		var Box2=document.getElementById("frame");
		var Box3=document.getElementById("powerpole");
		var Box4=document.getElementById("coilvoltage");
		var Box5=document.getElementById("auxcontacts");
		var TxtBox=document.getElementById("parttextfield");
		
		// arrays to hold text values that correspond to the Selected Items in the Drop Downs		

		var Poles = new Array("30", "40", "22");		
		var Voltages = new Array("81", "83", "84", "84", "34", "80", "36", "80", "42", "85", "86", "86", "51", "55", "53", "55");		
		var Contacts = new Array("10", "01", "11", "00", "22");
					
		/*********** first number *******************/

		if (Box2.selectedIndex == 0)
		{
			firstNumber = null;
		}
		else
		{
			firstNumber = chooseFrame[Box2.selectedIndex - 1];
		}
		
		/************ Second Number ****************/
		if (Box3.selectedIndex == 0)
		{
			secondNumber = null;
		}
		else
		{
			secondNumber = Poles[Box3.selectedIndex - 1];
		}
		
		/************ Third Number *****************/
		if (Box4.selectedIndex == 0)
		{
			fourthNumber = null;
		}
		else
		{
			fourthNumber = Voltages[Box4.selectedIndex - 1];
		}
		
		/************ Fourth Number ***************/
		
		if (Box5.selectedIndex == 0)
		{
			thirdNumber = null;
		}
		else
		{
			thirdNumber = Contacts[Box5.selectedIndex - 1];
		}
		
		/****************Display Output****************/
		
		if (firstNumber != null && secondNumber != null && thirdNumber != null && fourthNumber != null)
		{
			TxtBox.value = firstNumber + "-" + secondNumber + "-" + thirdNumber + "-" + fourthNumber;
		}
		else
		{
			// if they return any of the lists to "Please Select" then clear the output
			TxtBox.value = "";
		}
	
	}
