// This code makes Dinger Jeff's Hero 

	var chooseFrame = null;
	var chooseVoltage = 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("AF50", "AF63", "AF75", "AF95", "AF110", "AF145", "AF185", "AF210", "AF260", "AF300", "AF400", "AF460", "AF580", "AF750", "AF1250", "AF1350", "AF1650", "AF2050");	
		var framesMech = new Array("AF50M", "AF63M", "AF75M", "AF95M", "AF110M", "AF145M", "AF185M", "AF210M", "AF260M", "AF300M", "AF400M", "AF460M", "AF580M", "AF750M");
		var framesRev = new Array("AF50R", "AF63R", "AF75R", "AF95R", "AF110R", "AF145R", "AF185R", "AF210R", "AF260R", "AF300R", "AF400R", "AF460R", "AF580R", "AF750R");	
		
		
		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");
		
		Box3.selectedIndex = 0;
		Box4.selectedIndex = 0;
		Box5.selectedIndex = 0;
		
		
		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 frameSelect()
	{
	
		var VoltageXref = new Array("BCD", "BCD", "BCD", "BCD", "BCD", "BCD", "BCD", "BCD", "BCD", "BCD", "ACDE", "ACDE", "ACDE", "ACDE", "ACD", "D", "D", "D");
		
		var VoltageText = new Array("24-60 DC", "20-60 DC", "48-130 AC/DC", "100-250 AC/DC", "250-500 AC/DC"); 
		
		var Voltages = new Array("68", "72", "69", "70", "71");				
		
		var Box2=document.getElementById("frame");
		var Box3=document.getElementById("powerpole");
		var Box4=document.getElementById("coilvoltage");
		var Box5=document.getElementById("auxcontacts");
		
		var thisVoltage = null;
		chooseVoltage = null;
		
		Box3.selectedIndex = 0;
		Box4.selectedIndex = 0;
		Box5.selectedIndex = 0;
		
		Box4.options.length = 0;
		var y=document.createElement('option');
		y.text = "Please Select";
		Box4.options[0] = y;
		
		if (Box2.selectedIndex == 0)
			return;  // Get out, get out NOW before someone sees you!
		
		thisVoltage = VoltageXref[Box2.selectedIndex -1];
		
		chooseVoltage = new Array();
		
				
		var index = 1;
		if (thisVoltage.indexOf("A") > -1 )
		{
			y=document.createElement('option');
			y.text = VoltageText[0];
			Box4.options[index] = y;
			chooseVoltage.push(Voltages[0]);
			index++;
			
		}
		if (thisVoltage.indexOf("B") > -1 )
		{
			y=document.createElement('option');
			y.text = VoltageText[1];
			Box4.options[index] = y;
			chooseVoltage.push(Voltages[1]);
			index++;
		}
		if (thisVoltage.indexOf("C") > -1 )
		{
			y=document.createElement('option');
			y.text = VoltageText[2];
			Box4.options[index] = y;
			chooseVoltage.push(Voltages[2]);
			index++;
		}
		if (thisVoltage.indexOf("D") > -1 )
		{
			y=document.createElement('option');
			y.text = VoltageText[3];
			Box4.options[index] = y;
			chooseVoltage.push(Voltages[3]);
			index++;
		}
		if (thisVoltage.indexOf("E") > -1 )
		{
			y=document.createElement('option');
			y.text = VoltageText[4];
			Box4.options[index] = y;
			chooseVoltage.push(Voltages[4]);
			index++;
		}
	}
	
	
	
	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 Contacts = new Array("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 = chooseVoltage[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 = "";
		}
	
	}
