// global variables
			var LENGTHELEMENTS, TEMPELEMENTS, PRESSUREELEMENTS, VOLUMEELEMENTS, ANGLEELEMENTS, FORCEELEMENTS, AREAELEMENTS, POWERELEMENTS, ENERGYELEMENTS, BASESELEMENTS; // Variable containing an array of all the elements (i.e., form input boxes) in the length block.
			// end global variables

			function calculate(x){  // The value of x determines whether, say, the temperature block is
									// evaluated, or the length block, etc. A value of "all" or "" will
									// calculate all blocks (needed to work with enter keypress).
				var myBlock = x;
				switch(myBlock){
					case "length":
						convertLength();
						break;

					case "temp":
						convertTemp();
						break;

					case "pressure":
						convertPressure();
						break;

					case "volume":
						convertVolume();
						break;

					case "angle":
						convertAngle();
						break;

					case "force":
						convertForce();
						break;

					case "area":
						convertArea();
						break;

					case "power":
						convertPower();
						break;

					case "energy":
						convertEnergy();
						break;

					case "bases":
						convertBases();
						break;

					case "all" :
						convertAll();
						break;

					default :
						convertAll();
						break;
				}
			} // end calculate(x)


			function convertLength(){
				var inputValue = getInputValue("length"); // inputValue is an array.
				var inputField = getInputField("length"); // inputField is just a plain ol' variable.

				// Create variables which represent units of measurement.
				var feet, inches, mils, ft_chunk, in_chunk, mils_chunk, meters, cm, mm, m_chunk, cm_chunk, mm_chunk, microns, nano, angstroms, miles, km;

				if (inputValue != "" && inputValue != undefined && inputValue != null){ // If inputValue is not undefined
					if (inputValue[LENGTHELEMENTS.length] == "multi_ftinmil"){ // If inputValue is in ftinmil chunk
						var myValue = eval((inputValue[3][0] * 12)) + eval(inputValue[3][1]) + eval((inputValue[3][2] / 1000)); // myValue is in inches.
					}

					else if (inputValue[LENGTHELEMENTS.length] == "multi_mcmmm"){ // Else if inputValue in is mcmmm chunk
						var myValue = eval((inputValue [9][0] * 100)) + eval(inputValue[9][1]) + eval((inputValue[9][2] / 10)); // myValue in in cm.
						myValue /= 2.54; // Convert myValue to inches to maintain consistency with ftinmil chunk.
					}

					else{
						var myValue = inputValue[inputField];   // myValue is set to equal the value the user has input, which can be
																// determined by the inputField variable.
					}
				}

				else{ // Else if inputValue is undefined
					clearIt("length");
					return false;
				}

				switch(inputField){ // Convert all values to inches. (Later, they will be converted to the other units of measurement.)
					case 0: // feet
						inches = 12 * myValue;
						break;

					case 1: // inches
						inches = myValue;
						break;

					case 2: // mils
						inches = myValue / 1000;
						break;

					case 3: // Inside ft+in+milchunk
					case 4:
					case 5:
						inches = myValue;   // If any of these three cases hits, then myValue has already been converted to inches in
											// the above if/then/else statements.
						break;

					case 6: // meters
						inches = (100 / 2.54) * myValue;
						break;

					case 7: // cm
						inches = (1 / 2.54) * myValue;
						break;

					case 8: // mm
						inches = (1 / 25.4) * myValue;
						break;

					case 9: // Inside mcmmm chunk
					case 10:
					case 11:
						inches = myValue;   // If any of these three cases hits, then myValue has already been converted to inches in
											// the above if/then/else statements.
						break;

					case 12: // microns
						inches = myValue / 25400;
						break;

					case 13: // nanometers
						inches = myValue / 25400000;
						break;

					case 14: // angstroms
						inches = myValue / 254000000;
						break;

					case 15: // miles
					        inches = 63360 * myValue;
						break;

					case 16: // kilometers
					        inches = 39370.0787402 * myValue;
						break;

					default: // An error has occurred if this ever hits.
						clearIt("length");
						return false;
						break;
				}

				// Convert inches to other values now.
				feet = inches / 12;
				mils = 1000 * inches;
				meters = 0.0254 * inches;
				cm = 2.54 * inches;
				mm = 25.4 * inches;
				microns = 25400 * inches;
				nano = 25400000 * inches;
				angstroms = 254000000 * inches;
				miles = inches / 63360;
				km = inches / 39370.0787402;


				// Round values
				feet = roundDec(feet);
				inches = roundDec(inches);
				mils = roundDec(mils);
				meters = roundDec(meters);
				cm = roundDec(cm);
				mm = roundDec(mm);
				microns = roundDec(microns, 0); // Round to nearest tenth.
				nano = roundDec(nano, 0); // Round to nearest whole number.
				angstroms = roundDec(angstroms, 0); // Round to nearest whole number.
				miles = roundDec(miles);
				km = roundDec(km);


				// Convert chunk values
				ft_chunk = 0; // Whole feet
				in_chunk = 0; // Whole inches
				mils_chunk = 0; // Decimal portion of inches variable, multiplied by 1000
				var inchtest = inches; // inchtest is a dummy variable used to find specific values for ftinmil variables.

				ft_chunk = Math.floor(inchtest / 12);
				inchtest -= (ft_chunk * 12);
				in_chunk = Math.floor(inchtest);
				inchtest -= in_chunk;
				mils_chunk = 1000 * inchtest;
				mils_chunk = roundDec(mils_chunk); // Eliminate rounding errors.

				m_chunk = 0; // Whole meters
				cm_chunk = 0; // Whole centimeters
				mm_chunk = 0; // Whole millimeters

				m_chunk = Math.floor(meters);
				cm_chunk = Math.floor((meters-m_chunk) * 100);
				mm_chunk = 1000 * ((meters-m_chunk) - (cm_chunk / 100));
				mm_chunk = roundDec(mm_chunk); // Eliminate rounding errors.


				// Display variable values in form boxes.
				document.lengthform.feetbox.value = feet;
				document.lengthform.inchesbox.value = inches;
				document.lengthform.milsbox.value = mils;
				document.lengthform.feet_ftinmilbox.value = ft_chunk;
				document.lengthform.in_ftinmilbox.value = in_chunk;
				document.lengthform.mil_ftinmilbox.value = mils_chunk;
				document.lengthform.metersbox.value = meters;
				document.lengthform.cmbox.value = cm;
				document.lengthform.mmbox.value = mm;
				document.lengthform.m_mcmmmbox.value = m_chunk;
				document.lengthform.cm_mcmmmbox.value = cm_chunk;
				document.lengthform.mm_mcmmmbox.value = mm_chunk;
				document.lengthform.umbox.value = microns;
				document.lengthform.nmbox.value = nano;
				document.lengthform.angbox.value = angstroms;
				document.lengthform.milesbox.value = miles;
				document.lengthform.kmbox.value = km;
			} // end convertLength()

/*
			function convertTemp(){
				var inputValue = getInputValue("temp");
				var inputField = getInputField("temp");
				var tempC, tempF, tempK; // Create variables for temperatures Celsius, Fahrenheit, and Kelvin, respectively.
				switch (inputField){ // Convert all values to degrees Celsius (later they will be converted to other units of measurement).
					case 0: // Celsius
						tempC = inputValue;
						break;

					case 1: // Fahrenheit
						tempC = (inputValue - 32) / 1.8;
						break;

					case 2: // Kelvin
						tempC = (inputValue - 273.15);
						break;

					default: // An error has occurred.
						clearIt("temp");
						return false;
						break;
				}

				// Convert to other units of measurement now
				tempF = (1.8 * tempC) + 32;
				tempK = eval(tempC) + 273.15;

				// Round values
				tempC = roundDec(tempC);
				tempF = roundDec(tempF);
				tempK = roundDec(tempK);

				// Output variables to form values
				document.tempform.celsius.value = tempC;
				document.tempform.fahrenheit.value = tempF;
				document.tempform.kelvin.value = tempK;
			} // end convertTemp()
			*/


			function convertPressure(){
				var inputValue = getInputValue("pressure");
				var inputField = getInputField("pressure");
				var psi, micronhg, torr, inchhg, mbar, inchh2o, atmos, pa; // Create variables for pressure units of measurement.
				switch (inputField){ // Convert all values to torr (later they will be converted to other units).
					case 0: // PSI
						torr = (1 / 1.93367747046153e-02) * inputValue;
						break;

                                        case 1: // micron Hg
                                                torr = (1 / 1000.0) * inputValue;
                                                break;

					case 2: // mm Hg (torr) (0 degrees C)
						torr = inputValue;
						break;

					case 3: // inch Hg (60 degrees F)
						torr = (1 / 0.0393700731) * inputValue;
						break;

					case 4: // mBar
						torr = (1 / 1.33322368421) * inputValue;
						break;

					case 5: // inch H2O (60 degrees F)
						torr = (1 / 0.535240081226418) * inputValue;
						break;

					case 6: // atmosphere
						torr = (1 / 1.31578947368369e-03) * inputValue;
						break;

					case 7: // pascals (pa)
						torr = (1 / 133.322368421) * inputValue;
						break;

					default: // An error has occurred.
						clearIt("pressure");
						return false;
						break;
				}

				// Convert to other units of measurement.
				psi = (1.93367747046153e-02) * torr;
                                micronhg = 1000.0 * torr;
				inchhg = (0.0393700731) * torr;
				mbar = (1.33322368421) * torr;
				inchh2o = (0.535240081226418) * torr;
				atmos = (1.31578947368369e-03) * torr;
				pa = (133.322368421) * torr;

				// Round values
				psi = roundDec(psi, 6);
                                micronhg = roundDec(micronhg, 6);
				torr = roundDec(torr, 6);
				inchhg = roundDec(inchhg, 6);
				mbar = roundDec(mbar, 6);
				inchh2o = roundDec(inchh2o, 6);
				atmos = roundDec(atmos, 6);
				pa = roundDec(pa, 6);

				// Output variables to form values
				document.pressureform.psi.value = psi;
                document.pressureform.micronhg.value = micronhg;
				document.pressureform.torr.value = torr;
				document.pressureform.inchhg.value = inchhg;
				document.pressureform.mbar.value = mbar;
				document.pressureform.inchh2o.value = inchh2o;
				document.pressureform.atmos.value = atmos;
				document.pressureform.pa.value = pa;
			} // end convertPressure()


			function convertVolume(){
				var inputValue = getInputValue("volume");
				var inputField = getInputField("volume");
				var cc, liter, gallon, quart, pint, cubicfeet, fluidoz, cubicinch, cup; // Create variables for volume units of measurement.
				switch (inputField){ // Convert all values to cubic inches (later they will be converted to other units).
					case 0: // Milliliter/cc
						cubicinch = (1 / 16.387064) * inputValue;
						break;

					case 1: // Liter
						cubicinch = (1 / 0.016387064) * inputValue;
						break;

					case 2: // Gallon
						cubicinch = (1 / 4.32900432900433e-3) * inputValue;
						break;

					case 3: // Quart
						cubicinch = (1 / 1.73160173160173e-2) * inputValue;
						break;

					case 4: // Pint
						cubicinch = (1 / 3.46320346320346e-2) * inputValue;
						break;

					case 5: // Cubic feet
						cubicinch = (1/ 5.78703703703704e-4) * inputValue;
						break;

					case 6: // Fluid ounce
						cubicinch = (1/ 0.554112554112554) * inputValue;
						break;

					case 7: // Cubic inch
						cubicinch = inputValue;
						break;

					case 8: // Cup
						cubicinch = (1/ 6.92640692640693e-2) * inputValue;
						break;

					default: // An error has occurred.
						clearIt("volume");
						return false;
						break;
				}

				// Convert to other units of measurement.
				cc = 16.387064 * cubicinch;
				liter = 0.016387064 * cubicinch;
				gallon = 4.32900432900433e-3 * cubicinch;
				quart = 1.73160173160173e-2 * cubicinch;
				pint = 3.46320346320346e-2 * cubicinch;
				cubicfeet = 5.78703703703704e-4 * cubicinch;
				fluidoz = 0.554112554112554 * cubicinch;
				cup = 6.92640692640693e-2 * cubicinch;
				

				// Round values
				cc = roundDec(cc);
				liter = roundDec(liter);
				gallon = roundDec(gallon);
				quart = roundDec(quart);
				pint = roundDec(pint);
				cubicfeet= roundDec(cubicfeet);
				fluidoz = roundDec(fluidoz);
				cup = roundDec(cup);
				cubicinch = roundDec(cubicinch);

				// Output variables to form values
				document.volumeform.cc.value = cc;
				document.volumeform.liter.value = liter;
				document.volumeform.gallon.value = gallon;
				document.volumeform.quart.value = quart;
				document.volumeform.pint.value = pint;
				document.volumeform.cubicfeet.value = cubicfeet;
				document.volumeform.fluidoz.value = fluidoz;
				document.volumeform.cup.value = cup;
				document.volumeform.cubicinch.value = cubicinch;
			} // end convertVolume()


			function convertAngle(){
				var inputValue = getInputValue("angle");
				var inputField = getInputField("angle");

				// Create variables which represent units of measurement.
				var degrees, radians, milliradians, deg_chunk, min_chunk, sec_chunk, gradians;

				if (inputValue != "" && inputValue != undefined && inputValue != null){ // If inputValue is not undefined
					if (inputValue[ANGLEELEMENTS.length] == "multi_degminsec"){ // If inputValue is in deg+min+sec chunk
						var tempDeg, tempMin, tempSec; // Create temporary variables in which to store deg, min, and sec values, respectively.

						tempSec = inputValue[3][2]; // Just seconds value
						tempMin = eval(inputValue[3][1]) + eval(tempSec / 60); // Mins and secs as one decimal.
						tempDeg = eval(inputValue[3][0]) + eval(tempMin / 60); // Degrees, mins, and secs as one decimal.
						var myValue = tempDeg; // myValue is in degrees.
					}

					else{ // Else if inputValue is not in deg+min+sec chunk but instead in a "normal" input field
						var myValue = inputValue[inputField]; // myValue is set to equal the value the user has input, which can be
															  // determined by the inputField variable.
					}
				}

				else{ // Else if inputValue is undefined
					clearIt("angle");
					return false;
				}

				switch(inputField){ // Convert all values to degrees. (Later, they will be converted to other units of measurement.)
					case 0: // Degrees
						degrees = myValue;
						break;

					case 1: // Radians
						degrees = (180 / Math.PI) * myValue;
						break;

					case 2: // Milliradians
						degrees = (180 / Math.PI) * (myValue / 1000);
						break;

					case 3: // Inside deg+min+sec chunk
					case 4:
					case 5:
						degrees = myValue; // If any of these three cases hits, then myValue has already been converted to degrees
										   // in the above if/then/else statements.
						break;

					case 6: // Gradians
						degrees = (180 / 200) * myValue;
						break;

					default: // An error has occurred if this hits.
						clearIt("angle");
						return false;
						break;
				}

				if (degrees >= 360){ // If degrees >= 360, then reduce.
					degrees %= 360;
				}

				// Convert degrees to other values now.
				radians = (Math.PI / 180) * degrees;
				milliradians = (Math.PI / 180) * (1000 * degrees);
				gradians = (200 / 180) * degrees;

				// Round values
				degrees = roundDec(degrees);
				radians = roundDec(radians);
				milliradians = roundDec(milliradians);
				gradians = roundDec(gradians);

				// Convert chunk values
				deg_chunk = 0; // Whole degrees
				min_chunk = 0; // Whole minutes
				sec_chunk = 0; // Seconds (may be either whole or contain a decimal)

				deg_chunk = Math.floor(degrees);
				min_chunk = Math.floor(60 * (degrees - deg_chunk));
				sec_chunk = 60 * ((60 * (degrees - deg_chunk)) - Math.floor(60 * (degrees-deg_chunk)));
				sec_chunk = roundDec(sec_chunk); // Eliminate rounding errors.

				// Display values in form boxes
				document.angleform.deg.value = degrees;
				document.angleform.rad.value = radians;
				document.angleform.mrad.value = milliradians;
				document.angleform.deg_chunk.value = deg_chunk;
				document.angleform.min_chunk.value = min_chunk;
				document.angleform.sec_chunk.value = sec_chunk;
				document.angleform.grad.value = gradians;

			} // end convertAngle()


			function convertForce(){
				var inputValue = getInputValue("force");
				var inputField = getInputField("force");

				var kg, g, oz, lb, n, tons; // Create variables for kilograms, grams, ounces, pounds, newtons, and tons, respectively.

				switch(inputField){ // Convert all values to Newtons. (Later, they will be converted to other units).
					case 0: // Kilograms
						n = 9.8 * inputValue;
						break;

					case 1: // Grams
						n = (9.8 / 1000) * inputValue;
						break;

					case 2: // Ounces
						n = (9.8 / (16 * 2.20462262184878)) * inputValue;
						break;

					case 3: // Pounds
						n = (9.8 / 2.20462262184878) * inputValue;
						break;

					case 4: // Newtons
						n = inputValue;
						break;

					case 5: // Tons
						n = ((2000 * 9.8) / 2.20462262184878) * inputValue;
						break;

					default: // If this hits, an error has occurred.
						clearIt("force");
						return false;
						break;
				}

				// Convert to other units of measurement
				kg = n / 9.8;
				g = (1000 / 9.8) * n;
				oz = ((16 * 2.20462262184878) / 9.8) * n;
				lb = (2.20462262184878 / 9.8) * n;
				tons = (2.20462262184878 / (2000 * 9.8)) * n;

				// Round values
				kg = roundDec(kg);
				g = roundDec(g);
				oz = roundDec(oz);
				lb = roundDec(lb);
				tons = roundDec(tons);

				// Display values in form boxes
				document.forceform.kg.value = kg;
				document.forceform.g.value = g;
				document.forceform.oz.value = oz;
				document.forceform.lb.value = lb;
				document.forceform.n.value = n;
				document.forceform.tons.value = tons;

			} // end convertForce()


			function convertArea(){
				var inputValue = getInputValue("area"); // inputValue is an array.
				var inputField = getInputField("area"); // inputField is just a plain ol' variable.

				// Create variables which represent units of measurement.
				var feet, inches, mils, ft_chunk, in_chunk, mils_chunk, meters, cm, mm, microns, nano, angstroms;

				switch(inputField){ // Convert all values to inches. (Later, they will be converted to the other units of measurement.)
					case 0: // feet
						inches = 144 * inputValue;
						break;

					case 1: // inches
						inches = inputValue;
						break;

					case 2: // mils
						inches = inputValue / 1000000;
						break;

					case 3: // meters
						inches = Math.pow((100 / 2.54), 2) * inputValue;
						break;

					case 4: // cm
						inches = Math.pow((1 / 2.54), 2) * inputValue;
						break;

					case 5: // mm
						inches = Math.pow((1 / 25.4), 2) * inputValue;
						break;

					case 6: // microns
						inches = inputValue / Math.pow(25400, 2);
						break;

					case 7: // nanometers
						inches = inputValue / Math.pow(25400000, 2);
						break;

					case 8: // angstroms
						inches = inputValue / Math.pow(254000000, 2);
						break;

					default: // An error has occurred if this ever hits.
						clearIt("area");
						return false;
						break;
				}

				// Convert inches to other values now.
				feet = inches / 144;
				mils = 1000000 * inches;
				meters = Math.pow(0.0254, 2) * inches;
				cm = Math.pow(2.54, 2) * inches;
				mm = Math.pow(25.4, 2) * inches;
				microns = Math.pow(25400, 2) * inches;
				nano = Math.pow(25400000, 2) * inches;
				angstroms = Math.pow(254000000, 2) * inches;

				// Round values
				feet = roundDec(feet);
				inches = roundDec(inches);
				mils = roundDec(mils);
				meters = roundDec(meters);
				cm = roundDec(cm);
				mm = roundDec(mm);
				microns = roundDec(microns, 0); // Round to nearest tenth.
				nano = roundDec(nano, 0); // Round to nearest whole number.
				angstroms = roundDec(angstroms, 0); // Round to nearest whole number.


				// Display variable values in form boxes.
				document.areaform.feetbox.value = feet;
				document.areaform.inchesbox.value = inches;
				document.areaform.milsbox.value = mils;
				document.areaform.metersbox.value = meters;
				document.areaform.cmbox.value = cm;
				document.areaform.mmbox.value = mm;
				document.areaform.umbox.value = microns;
				document.areaform.nmbox.value = nano;
				document.areaform.angbox.value = angstroms;
			} // end convertArea()


			function convertPower(){
				var inputValue = getInputValue("power"); // inputValue is an array.
				var inputField = getInputField("power"); // inputField is just a plain ol' variable.

				// Create variables which represent units of measurement.
				var watts, hp;

				switch(inputField){ // Convert all values to watts. (Later, they will be converted to the other units of measurement.)
					case 0: // Watts
						watts = inputValue;
						break;

					case 1: // Horsepower
						watts = 745.69987158227 * inputValue;
						break;

					default: // An error has occurred if this ever hits.
						clearIt("power");
						return false;
						break;
				}

				// Convert inches to other values now.
				hp = (1 / 745.69987158227) * watts;

				// Round values
				watts = roundDec(watts);
				hp = roundDec(hp);


				// Display variable values in form boxes.
				document.powerform.watts.value = watts;
				document.powerform.hp.value = hp;
			} // end convertPower()


			function convertEnergy(){
				var inputValue = getInputValue("energy"); // inputValue is an array.
				var inputField = getInputField("energy"); // inputField is just a plain ol' variable.

				// Create variables which represent units of measurement.
				var kwatthr, btu, joules;

				switch(inputField){ // Convert all values to joules. (Later, they will be converted to the other units of measurement.)
					case 0: // Kilowatt Hours
						joules = 3600000 * inputValue;
						break;

					case 1: // BTU
						joules = (1 / 9.47817120313317e-4) * inputValue;
						break;

					case 2: // Joules
						joules = inputValue;
						break;

					default: // An error has occurred if this ever hits.
						clearIt("energy");
						return false;
						break;
				}

				// Convert inches to other values now.
				kwatthr = (1 / 3600000) * joules;
				btu = 9.47817120313317e-4 * joules;

				// Round values
				kwatthr = roundDec(kwatthr);
				btu = roundDec(btu);
				joules = roundDec(joules);


				// Display variable values in form boxes.
				document.energyform.kwatthr.value = kwatthr;
				document.energyform.btu.value = btu;
				document.energyform.joules.value = joules;
			} // end convertEnergy()


			function convertBases(){
				var inputValue = getInputValue("bases"); // inputValue is an array.
				var inputField = getInputField("bases"); // inputField is just a plain ol' variable.

				// Create variables which represent units of measurement.
				var hex, dec, oct, bin;

				// Cut off any decimals from inputValue here, without losing A-F hex characters.

				switch(inputField){
					case 0: // Hex
						dec = convToDec(inputValue, 16);
						break;

					case 1: // Dec
						dec = parseInt(inputValue);
						break;

					case 2: // Oct
						dec = convToDec(inputValue, 8);
						break;

					case 3: // Bin
						dec = convToDec(inputValue, 2);
						break;

					default: // If this hits, an error has occurred.
						clearIt("bases");
						return false;
						break;
				}

				// Now convert to other bases.
				hex = (parseInt(dec)).toString(16);
				oct = (parseInt(dec)).toString(8);
				bin = (parseInt(dec)).toString(2);

				// Check for illegal values
				if (isNaN(dec)){ // Assumes that if there's a real decimal value, then the other bases will also have real values.
								 // Be careful not to do isNaN() on a hex number, or else a legal value like 6AFE would return true.
					clearIt("bases");
					return false;
				}

				// Convert hex to uppercase
				hex = hex.toUpperCase();

				// Display values to input forms
				document.basesform.hex.value = hex;
				document.basesform.dec.value = dec;
				document.basesform.oct.value = oct;
				document.basesform.bin.value = bin;


			} // end convertBases()


			function convToDec(theInput, theBase){ // Converts a value (theInput) from a specified base (theBase) to decimal and returns that value.
				var myInput = theInput;
				var myBase = theBase;
				var bleh = 0; // Temporarily holds the value of the decimal conversion of the input number.
				if (myBase == 16){
					for (var i = 0; i < myInput.length; i++){ // For each character in the input field
						if (myInput.charAt(i) == "A" || myInput.charAt(i) == "a"){ // Convert letter values to decimal values.
							bleh += 10 * Math.pow(16, (myInput.length - 1 - i));
						}
						else if (myInput.charAt(i) == "B" || myInput.charAt(i) == "b"){
							bleh += 11 * Math.pow(16, (myInput.length - 1 - i));
						}
						else if (myInput.charAt(i) == "C" || myInput.charAt(i) == "c"){
							bleh += 12 * Math.pow(16, (myInput.length - 1 - i));
						}
						else if (myInput.charAt(i) == "D" || myInput.charAt(i) == "d"){
							bleh += 13 * Math.pow(16, (myInput.length - 1 - i));
						}
						else if (myInput.charAt(i) == "E" || myInput.charAt(i) == "e"){
							bleh += 14 * Math.pow(16, (myInput.length - 1 - i));
						}
						else if (myInput.charAt(i) == "F" || myInput.charAt(i) == "f"){
							bleh += 15 * Math.pow(16, (myInput.length - 1 - i));
						}
						else{
							bleh += myInput.charAt(i) * Math.pow(16, (myInput.length - 1 - i));
						}
					}
				}
				else{
					for (var i = 0; i < myInput.length; i++){ // For each character in the input field
						bleh += myInput.charAt(i) * Math.pow(myBase, (myInput.length - 1 - i));
					}
				}

				return bleh;
			} // end convToDec(theInput, theBase)


			function getInputValue(x){ // x designates the block in which you're searching--e.g., "temp", "length", etc.
				var myBlock = x;
				switch(myBlock){
					case "length":
						var inputValue = new Array(LENGTHELEMENTS.length);      // Sets the variable inputValue equal to an object
																				// containing an array with # of elements equal to the
																				// number of form array elements plus one. The very
																				// last element should be used by other functions to
																				// test whether inputValue contains a multi-dimensional
																				// array, which would be used to store three-value
																				// "chunks" (e.g., for ft+in+mil).

						for (var i = 0; i < LENGTHELEMENTS.length; i++){ // Loop each array element
							if (LENGTHELEMENTS[i].value != ""){ // If the current array element is not blank
								if (!isNaN(LENGTHELEMENTS[i].value)){ // If legal chars
									if (i >= 3 && i <= 5){ // If element is in ft+in+mil chunk
										inputValue[3] = new Array(3); // Create multi-dimensional array containing three sub-elements in position 3.
										if (LENGTHELEMENTS[3].value == ""){ // If blank value, then set to zero.
											inputValue[3][0] = 0;
										}
										else{
											inputValue[3][0] = LENGTHELEMENTS[3].value; // Else, set to the actual value.
										}
										if (LENGTHELEMENTS[4].value == ""){
											inputValue[3][1] = 0;
										}
										else{
											inputValue[3][1] = LENGTHELEMENTS[4].value;
										}
										if (LENGTHELEMENTS[5].value == ""){
											inputValue[3][2] = 0;
										}
										else{
											inputValue[3][2] = LENGTHELEMENTS[5].value;
										}

										inputValue[LENGTHELEMENTS.length] = "multi_ftinmil";
										return inputValue;
									}

									else if (i >= 9 && i <= 11){ // If element is in m+cm+mm chunk
										inputValue[9] = new Array(3); // Create multi-dimensional array containing three elements
										if (LENGTHELEMENTS[9].value == ""){ // If blank value, then set to zero.
											inputValue[9][0] = 0;
										}
										else{
											inputValue[9][0] = LENGTHELEMENTS[9].value;
										}
										if (LENGTHELEMENTS[10].value == ""){
											inputValue[9][1] = 0;
										}
										else{
											inputValue[9][1] = LENGTHELEMENTS[10].value;
										}
										if (LENGTHELEMENTS[11].value == ""){
											inputValue[9][2] = 0;
										}
										else{
											inputValue[9][2] = LENGTHELEMENTS[11].value;
										}

										inputValue[LENGTHELEMENTS.length] = "multi_mcmmm";
										return inputValue;
									}

									else{
										inputValue[i] = LENGTHELEMENTS[i].value;
										inputValue[LENGTHELEMENTS.length] = "single";
										return inputValue;
									}
								}

								else{ // If illegal chars
									clearIt("length");
									return false;
								}
							}
						}

						break;

					case "temp":
						var inputValue;
						for (var i = 0; i < TEMPELEMENTS.length; i++){ // Loop each array element
							if(!isNaN(TEMPELEMENTS[i].value)){ // If legal chars
								if (TEMPELEMENTS[i].value != ""){ // If the current array element is not blank
									inputValue = TEMPELEMENTS[i].value;
									return inputValue;
								}
							}

							else{ // If illegal chars
								clearIt("temp");
								return false;
							}
						}
						break;

					case "pressure":
						var inputValue;
						for (var i = 0; i < PRESSUREELEMENTS.length; i++){ // Loop each array element
							if(!isNaN(PRESSUREELEMENTS[i].value)){ // If legal chars
								if (PRESSUREELEMENTS[i].value != ""){ // If the current array element is not blank
									inputValue = PRESSUREELEMENTS[i].value;
									return inputValue;
								}
							}

							else{ // If illegal chars
								clearIt("pressure");
								return false;
							}
						}
						break;

					case "volume":
						var inputValue;
						for (var i = 0; i < VOLUMEELEMENTS.length; i ++){ // Loop each array element
							if(!isNaN(VOLUMEELEMENTS[i].value)){ // If legal chars
								if (VOLUMEELEMENTS[i].value != ""){ // If the current array element is not blank
									inputValue = VOLUMEELEMENTS[i].value;
									return inputValue;
								}
							}

							else{ // If illegal chars
								clearIt("volume");
								return false;
							}
						}
						break;

					case "angle":
						var inputValue = new Array(ANGLEELEMENTS.length);
						for (var i = 0; i < ANGLEELEMENTS.length; i++){ // Loop each array element
							if(!isNaN(ANGLEELEMENTS[i].value)){ // If legal chars
								if (ANGLEELEMENTS[i].value != ""){ // If the current array element is not blank
									if (i >= 3 && i <= 5){ // If element is in deg+min+sec chunk
										inputValue[3] = new Array(3); // Create multi-dimensional array containing three sub-elements in position 3.
										if (ANGLEELEMENTS[3].value == ""){ // If blank value, then set to zero.
											inputValue[3][0] = 0;
										}
										else{ // Else, set to the actual value
											inputValue[3][0] = ANGLEELEMENTS[3].value;
										}

										if (ANGLEELEMENTS[4].value == ""){ // If blank value, then set to zero.
											inputValue[3][1] = 0;
										}
										else{ // Else, set to the actual value
											inputValue[3][1] = ANGLEELEMENTS[4].value;
										}

										if (ANGLEELEMENTS[5].value == ""){ // If blank value, then set to zero.
											inputValue[3][2] = 0;
										}
										else{ // Else, set to the actual value
											inputValue[3][2] = ANGLEELEMENTS[5].value;
										}

										inputValue[ANGLEELEMENTS.length] = "multi_degminsec";
										return inputValue;
									}

									else{
										inputValue[i] = ANGLEELEMENTS[i].value;
										inputValue[ANGLEELEMENTS.length] = "single";
										return inputValue;
									}
								}
							}

							else{ // If illegal chars
								clearIt("angle");
								return false;
							}
						}
						break;

					case "force":
						var inputValue;
						for (var i = 0; i < FORCEELEMENTS.length; i++){ // Loop each array element
							if(!isNaN(FORCEELEMENTS[i].value)){ // If legal chars
								if (FORCEELEMENTS[i].value != ""){ // If the current array element is not blank
									inputValue = FORCEELEMENTS[i].value;
									return inputValue;
								}
							}

							else{ // If illegal chars
								clearIt("force");
								return false;
							}
						}
						break;

					case "area":
						var inputValue;
						for (var i = 0; i < AREAELEMENTS.length; i++){ // Loop each array element
							if(!isNaN(AREAELEMENTS[i].value)){ // If legal chars
								if (AREAELEMENTS[i].value != ""){ // If the current array element is not blank
									inputValue = AREAELEMENTS[i].value;
									return inputValue;
								}
							}

							else{ // If illegal chars
								clearIt("area");
								return false;
							}
						}
						break;

					case "power":
						var inputValue;
						for (var i = 0; i < POWERELEMENTS.length; i++){ // Loop each array element
							if(!isNaN(POWERELEMENTS[i].value)){ // If legal chars
								if (POWERELEMENTS[i].value != ""){ // If the current array element is not blank
									inputValue = POWERELEMENTS[i].value;
									return inputValue;
								}
							}

							else{ // If illegal chars
								clearIt("power");
								return false;
							}
						}
						break;

					case "energy":
						var inputValue;
						for (var i = 0; i < ENERGYELEMENTS.length; i++){ // Loop each array element
							if(!isNaN(ENERGYELEMENTS[i].value)){ // If legal chars
								if (ENERGYELEMENTS[i].value != ""){ // If the current array element is not blank
									inputValue = ENERGYELEMENTS[i].value;
									return inputValue;
								}
							}

							else{ // If illegal chars
								clearIt("energy");
								return false;
							}
						}
						break;

					case "bases":
						var inputValue;
						for (var i = 0; i < BASESELEMENTS.length; i++){ // Loop each array element
							if (BASESELEMENTS[i].value != ""){ // If the current array element is not blank
								inputValue = BASESELEMENTS[i].value;
								return inputValue;
							}
						}
						break;

					default:
						clearAll();
						return false;
						break;
				}
			} // end getInputValue(x)


			function getInputField(x){ // x designates the block in which you're searching--e.g., "temp", "length", etc.
				var myBlock = x;
				switch (myBlock){
					case "length":
						var inputField; // This is the first field in which data was entered.
						for (var i = 0; i < LENGTHELEMENTS.length; i++){ // Loop each array element
							if (LENGTHELEMENTS[i].value != ""){ // If the current array element is not blank
								inputField = i; // Set inputField equal to the array position.
								return inputField;
							}
						}
						break;

					case "temp":
						var inputField; // This is the first field in which the data was entered.
						for (var i = 0; i < TEMPELEMENTS.length; i++){ // Loop each array element
							if (TEMPELEMENTS[i].value != ""){ // If the current array element is not blank
								inputField = i; // Set inputField equal to the array position.
								return inputField;
							}
						}
						break;

					case "pressure":
						var inputField; // This is the first field in which the data was entered.
						for (var i = 0; i < PRESSUREELEMENTS.length; i++){ // Loop each array element
							if (PRESSUREELEMENTS[i].value != ""){ // If the current array element is not blank
								inputField = i;
								return inputField;
							}
						}
						break;

					case "volume":
						var inputField; // This is the first field in which the data was entered.
						for (var i = 0; i < VOLUMEELEMENTS.length; i++){ // Loop each array element
							if (VOLUMEELEMENTS[i].value != ""){ // If the current array element is not blank
								inputField = i;
								return inputField;
							}
						}
						break;

					case "angle":
						var inputField; // This is the first field in which the data was entered.
						for (var i = 0; i < ANGLEELEMENTS.length; i++){ // Loop each array element
							if (ANGLEELEMENTS[i].value != ""){ // If the current array element is not blank
								inputField = i;
								return inputField;
							}
						}
						break;

					case "force":
						var inputField; // This is the first field in which the data was entered.
						for (var i = 0; i < FORCEELEMENTS.length; i++){ // Loop each array element
							if (FORCEELEMENTS[i].value != ""){ // If the current array element is not blank
								inputField = i;
								return inputField;
							}
						}
						break;

					case "area":
						var inputField; // This is the first field in which data was entered.
						for (var i = 0; i < AREAELEMENTS.length; i++){ // Loop each array element
							if (AREAELEMENTS[i].value != ""){ // If the current array element is not blank
								inputField = i; // Set inputField equal to the array position.
								return inputField;
							}
						}
						break;

					case "power":
						var inputField; // This is the first field in which data was entered.
						for (var i = 0; i < POWERELEMENTS.length; i++){ // Loop each array element
							if (POWERELEMENTS[i].value != ""){ // If the current array element is not blank
								inputField = i; // Set inputField equal to the array position.
								return inputField;
							}
						}
						break;

					case "energy":
						var inputField; // This is the first field in which data was entered.
						for (var i = 0; i < ENERGYELEMENTS.length; i++){ // Loop each array element
							if (ENERGYELEMENTS[i].value != ""){ // If the current array element is not blank
								inputField = i; // Set inputField equal to the array position.
								return inputField;
							}
						}
						break;

					case "bases":
						var inputField; // This is the first field in which data was entered.
						for (var i = 0; i < BASESELEMENTS.length; i++){ // Loop each array element
							if (BASESELEMENTS[i].value != ""){ // If the current array element is not blank
								inputField = i; // Set inputField equal to the array position.
								return inputField;
							}
						}
						break;

					default:
						clearAll();
						return false;
						break;
				}
			} // end getInputField(x)


			function lengthArray(){ // Returns an array containing all the elements of the length block in sequential order.
				var feet = document.lengthform.feetbox;               // Element  0
				var inches = document.lengthform.inchesbox;           // Element  1
				var mils = document.lengthform.milsbox;               // Element  2
				var ft_triad = document.lengthform.feet_ftinmilbox;   // Element  3
				var in_triad = document.lengthform.in_ftinmilbox;     // Element  4
				var mil_triad = document.lengthform.mil_ftinmilbox;   // Element  5
				var meters = document.lengthform.metersbox;           // Element  6
				var centimeters = document.lengthform.cmbox;          // Element  7
				var millimeters = document.lengthform.mmbox;          // Element  8
				var m_triad = document.lengthform.m_mcmmmbox;         // Element  9
				var cm_triad = document.lengthform.cm_mcmmmbox;       // Element 10
				var mm_triad = document.lengthform.mm_mcmmmbox;       // Element 11
				var microns = document.lengthform.umbox;              // Element 12
				var nano = document.lengthform.nmbox;                 // Element 13
				var angstroms = document.lengthform.angbox;           // Element 14
				var miles = document.lengthform.milesbox;             // Element 15
				var km = document.lengthform.kmbox;                   // Element 16

				// The order in which these array elements are listed is crucial.
				var theArray = new Array(feet, inches, mils, ft_triad, in_triad, mil_triad, meters, centimeters, millimeters, m_triad, cm_triad, mm_triad, microns, nano, angstroms, miles, km);
				return theArray;
			} // end lengthArray()


			/*function tempArray(){ // Returns an array containing all the elements of the temperature block in sequential order.
				var celsius = document.tempform.celsius;       // Element 0
				var fahrenheit = document.tempform.fahrenheit; // Element 1
				var kelvin = document.tempform.kelvin;         // Element 2

				// The order in which these array elements are listed is crucial.
				var theArray = new Array(celsius, fahrenheit, kelvin);
				return theArray;
			} // end tempArray()*/


			function pressureArray(){ // Returns an array containing all the elements of the pressure block in sequential order.
				var psi = document.pressureform.psi; // Element 0
                                var micronhg = document.pressureform.micronhg; // Element 1
				var torr = document.pressureform.torr; // Element 2
				var inchhg = document.pressureform.inchhg; // Element 3
				var mbar = document.pressureform.mbar; // Element 4
				var inchh2o = document.pressureform.inchh2o; // Element 5
				var atmos = document.pressureform.atmos; // Element 6
				var pascals = document.pressureform.pa; // Element 7

				// The order in which these array elements are listed is crucial.
				var theArray = new Array(psi, micronhg, torr, inchhg, mbar, inchh2o, atmos, pascals);
				return theArray;
			} // end pressureArray()


			function volumeArray(){ // Returns an array containing all the elements of the volume block in sequential order.
				var cc = document.volumeform.cc;               // Element 0
				var liter = document.volumeform.liter;         // Element 1
				var gallon = document.volumeform.gallon;       // Element 2
				var quart = document.volumeform.quart;         // Element 3
				var pint = document.volumeform.pint;           // Element 4
				var cubicfeet = document.volumeform.cubicfeet; // Element 5
				var fluidoz = document.volumeform.fluidoz;     // Element 6
				var cubicinch = document.volumeform.cubicinch; // Element 7
				var cup = document.volumeform.cup;             // Element 8

				// The order in which these array elements are listed is cruicial.
				var theArray = new Array(cc, liter, gallon, quart, pint, cubicfeet, fluidoz, cubicinch, cup);
				return theArray;
			} // end volumeArray()


			function angleArray(){ // Returns an array containing all the elements of the angle block in sequential order.
				var degrees = document.angleform.deg;         // Element 0
				var radians = document.angleform.rad;         // Element 1
				var milliradians = document.angleform.mrad;   // Element 2
				var deg_chunk = document.angleform.deg_chunk; // Element 3
				var min_chunk = document.angleform.min_chunk; // Element 4
				var sec_chunk = document.angleform.sec_chunk; // Element 5
				var gradians = document.angleform.grad;       // Element 6

				// The order in which the array elements are listed is crucial.
				var theArray = new Array(degrees, radians, milliradians, deg_chunk, min_chunk, sec_chunk, gradians);
				return theArray;
			} // end angleArray()


			function forceArray(){ // Returns an array containing all the elements of the force block in sequential order.
				var kilograms = document.forceform.kg; // Element 0
				var grams = document.forceform.g;      // Element 1
				var ounces = document.forceform.oz;    // Element 2
				var pounds = document.forceform.lb;    // Element 3
				var newtons = document.forceform.n;    // Element 4
				var tons = document.forceform.tons;    // Element 5

				// The order in which the array elements are listed is crucial.
				var theArray = new Array(kilograms, grams, ounces, pounds, newtons, tons);
				return theArray;
			} // end forceArray()


			function areaArray(){ // Returns an array containing all the elements of the area block in sequential order.
				var feet = document.areaform.feetbox;               // Element 0
				var inches = document.areaform.inchesbox;           // Element 1
				var mils = document.areaform.milsbox;               // Element 2
				var meters = document.areaform.metersbox;           // Element 3
				var centimeters = document.areaform.cmbox;          // Element 4
				var millimeters = document.areaform.mmbox;          // Element 5
				var microns = document.areaform.umbox;              // Element 6
				var nano = document.areaform.nmbox;                 // Element 7
				var angstroms = document.areaform.angbox;           // Element 8

				// The order in which these array elements are listed is crucial.
				var theArray = new Array(feet, inches, mils, meters, centimeters, millimeters, microns, nano, angstroms);
				return theArray;
			} // end areaArray()


			function powerArray(){ // Returns an array containing all the elements of the power block in sequential order.
				var watts = document.powerform.watts;   // Element 0
				var horsepower = document.powerform.hp; // Element 1

				// The order in which these array elements are listed is crucial.
				var theArray = new Array(watts, horsepower);
				return theArray;
			} // end powerArray()


			function energyArray(){ // Returns an array containing all the elements of the energy block in sequential order.
				var kwatthr = document.energyform.kwatthr; // Element 0
				var btu = document.energyform.btu;         // Element 1
				var joules = document.energyform.joules;   // Element 2

				// The order in which these array elements are listed is crucial.
				var theArray = new Array(kwatthr, btu, joules);
				return theArray;
			} // end energyArray()


			function basesArray(){ // Returns an array containing all the elements of the bases block in sequential orader.
				var hex = document.basesform.hex; // Element 0
				var dec = document.basesform.dec; // Element 1
				var oct = document.basesform.oct; // Element 2
				var bin = document.basesform.bin; // Element 3

				// The order in which these array elements are listed is crucial.
				var theArray = new Array(hex, dec, oct, bin);
				return theArray;
			} // end basesArray()


			function convertAll(){ // This (surprisingly!) converts all units. Use when enter is pressed.
				convertLength();
				convertTemp();
				convertPressure();
				convertVolume();
				convertAngle();
				convertForce();
				convertArea();
				convertPower();
				convertEnergy();
				convertBases();
			} // end convertAll()


			function roundDec(x, y){ // Rounds a value to a specified number of decimal places and returns it.
				var myValue = x; // Starts as original value to be rounded, but will later become the rounded value itself.
				var sigDigits = y; // Amount of decimal places to which to round.
				if (y == "" || y == undefined || y == null){ // If no value is specified for number of significant digits, then set a predetermined value.
					sigDigits = 10;
				}
				else{
					sigDigits = y;
				}
				var div = Math.pow(10, sigDigits);
				myValue = Math.round(myValue * div) / div;
				return myValue;
			} // end roundDec(x, y)


			function clearIt(x){ // Clears the input fields of a block, where x specifies the block. Use x = "all" to clear all fields.
				var myBlock = x;
				switch(myBlock){
					case "length":
						for (var i = 0; i < LENGTHELEMENTS.length; i++){
							LENGTHELEMENTS[i].value = "";
						}
						break;

					case "temp":
						for (var i = 0; i < TEMPELEMENTS.length; i++){
							TEMPELEMENTS[i].value = "";
						}
						break;

					case "pressure":
						for (var i = 0; i < PRESSUREELEMENTS.length; i++){
							PRESSUREELEMENTS[i].value = "";
						}
						break;

					case "volume":
						for (var i = 0; i < VOLUMEELEMENTS.length; i++){
							VOLUMEELEMENTS[i].value = "";
						}
						break;

					case "angle":
						for (var i = 0; i < ANGLEELEMENTS.length; i++){
							ANGLEELEMENTS[i].value = "";
						}
						break;

					case "force":
						for (var i = 0; i < FORCEELEMENTS.length; i++){
							FORCEELEMENTS[i].value = "";
						}
						break;

					case "area":
						for (var i = 0; i < AREAELEMENTS.length; i++){
							AREAELEMENTS[i].value = "";
						}
						break;

					case "power":
						for (var i = 0; i < POWERELEMENTS.length; i++){
							POWERELEMENTS[i].value = "";
						}
						break;

					case "energy":
						for (var i = 0; i < ENERGYELEMENTS.length; i++){
							ENERGYELEMENTS[i].value = "";
						}
						break;

					case "bases":
						for (var i = 0; i < BASESELEMENTS.length; i++){
							BASESELEMENTS[i].value = "";
						}
						break;

					case "all":
						clearAll();
						break;

					default:
						clearAll();
						break;
				}
			} // end clear(x)


			function clearAll(){
				clearIt("length");
				clearIt("temp");
				clearIt("pressure");
				clearIt("volume");
				clearIt("angle");
				clearIt("force");
				clearIt("area");
				clearIt("power");
				clearIt("energy");
				clearIt("bases");
			} // end clearAll()


			function togglevisi(IDhere){
				if(IDhere.style.visibility == "hidden"){
					IDhere.style.visibility = "visible";
				}

				else{
					IDhere.style.visibility = "hidden";
				}
			} // end togglevisi(IDhere)


			function funcKeypress(e){
				if (document.all){
					e = window.event;
				}

				var keyNumbvalue;

				if (document.layers){
					keyNumbvalue = e.which;
				}

				if (document.all){
					keyNumbvalue = e.keyCode;
				}

				var key = String.fromCharCode(keyNumbvalue);

				if (keyNumbvalue == "13"){ // enter keypress
					calculate("all");
					return false;
				}
			} // end funcKeypress(e)


			function clearForm(x, y1, y2, y3){
				var myBlock = x;
				for (var i = 0; i < myBlock.length; i++){
					if (i != y1 && i != y2 && i != y3){
						myBlock[i].value = "";
					}
				}
			}


			function loadNumberbases(){ // Initialize global variables and clear all fields.
				BASESELEMENTS = basesArray();
			} // end loadMe()
			function loadMeLength(){ // Initialize global variables and clear all fields.
				LENGTHELEMENTS = lengthArray();
			} // end loadMeLength()
			function loadMePressure(){ // Initialize global variables and clear all fields.
				PRESSUREELEMENTS = pressureArray();
				VOLUMEELEMENTS = volumeArray();
				FORCEELEMENTS = forceArray();
			} //loadMePressure
			function loadAngle(){ // Initialize global variables and clear all fields.
				ANGLEELEMENTS = angleArray();
			} // end loadAngle()
			function loadPower(){ // Initialize global variables and clear all fields.
				POWERELEMENTS = powerArray();
			} // end loadPower()
			function loadEnergy(){ // Initialize global variables and clear all fields.
				ENERGYELEMENTS = energyArray();
			} // end loadPower()

		// -->