﻿
// Requires that profileFormText.js be included prior to this

// Types and global data.

function Option (label, text) {
	this.label = label;
	this.text = text;
}

function machineType (label, text) {
	this.type = new Option (label, text);
	this.brand = new Array ();
	this.controller = new Array ();
	this.feature = new Array ();
	
}

//	constants created as variables because of Internet Explorer limitations
	
var none = 0;
var knife = 1;
var laser = 2;
var laserpunch = 3;
var oxyfuel = 4;
var plasma = 5;
var plasmapunch = 6;
var punch = 7;
var router = 8;
var shear = 9;
var waterjet = 10;
var other = 11;
	
var machine = new Array ();


// ------------------------------------------------------------------------------------

// Loads the machines data structures with values.

function loadMachineData () {

	machine[none] = new machineType ("none", machineNext);	
	machine[knife] = new machineType ("knife",  machineKnife);
	machine[laser] = new machineType ("laser", machineLaser);
	machine[laserpunch] = new machineType ("laserpunch", machineLaserPunch);	
	machine[oxyfuel] = new machineType ("oxyfuel", machineOxyfuel);	
	machine[plasma] = new machineType ("plasma", machinePlasma);	
	machine[plasmapunch] = new machineType ("plasmapunch", machinePlasmaPunch);	
	machine[punch] = new machineType ("punch", machinePunch);	
	machine[router] = new machineType ("router", machineRouter);
	machine[shear] = new machineType ("shear", machineShear);
	machine[waterjet] = new machineType ("waterjet", machineWaterJet);	
	machine[other] = new machineType ("other", machineOther);
	
	machine[laser].brand[0] = new Option ("amada", "Amada");
	machine[laser].brand[1] = new Option ("burny", "Burny");
	machine[laser].brand[2] = new Option ("cincinnati", "Cincinnati");
	machine[laser].brand[3] = new Option ("esab", "ESAB");
	machine[laser].brand[4] = new Option ("finnpower", "FinnPower SG");
	machine[laser].brand[5] = new Option ("haco", "Haco");
	machine[laser].brand[6] = new Option ("hankwang", "Hankwang");
	machine[laser].brand[7] = new Option ("koike", "Koike");
	machine[laser].brand[8] = new Option ("lvd", "LVD");
	machine[laser].brand[9] = new Option ("mazak", "Mazak");
	machine[laser].brand[10] = new Option ("messer", "Messer");
	machine[laser].brand[11] = new Option ("mitsubishi", "Mitsubishi");
	machine[laser].brand[12] = new Option ("multicam", "MultiCam");
	machine[laser].brand[13] = new Option ("ntc", "NTC");
	machine[laser].brand[14] = new Option ("salvagnini", "Salvagnini");
	machine[laser].brand[15] = new Option ("tanaka", "Tanaka");
	machine[laser].brand[16] = new Option ("trumpf", "Trumpf");
	machine[laser].brand[17] = new Option ("other", "Other");

	machine[plasma].brand[0] = new Option ("aks", "AKS");
	machine[plasma].brand[1] = new Option ("alltra", "Alltra");
	machine[plasma].brand[2] = new Option ("burny", "Burny");
	machine[plasma].brand[3] = new Option ("c&g", "C & G");
	machine[plasma].brand[4] = new Option ("crelectronics", "CR Electronics");
	machine[plasma].brand[5] = new Option ("cs", "Cutting Systems");
	machine[plasma].brand[6] = new Option ("esab", "ESAB");
	machine[plasma].brand[7] = new Option ("esprit", "Esprit");
	machine[plasma].brand[8] = new Option ("ficep", "Ficep");
	machine[plasma].brand[9] = new Option ("koike", "Koike");
	machine[plasma].brand[10] = new Option ("kinetic", "Kinetic");
	machine[plasma].brand[11] = new Option ("komatsu", "Komatsu");
	machine[plasma].brand[12] = new Option ("mg", "MG");
	machine[plasma].brand[13] = new Option ("multicam", "MultiCam");
	machine[plasma].brand[14] = new Option ("oxyser", "Oxyser");
	machine[plasma].brand[15] = new Option ("peddinghaus", "Peddinghaus");
	machine[plasma].brand[16] = new Option ("pierce", "Pierce");
	machine[plasma].brand[17] = new Option ("saf", "SAF");
	machine[plasma].brand[18] = new Option ("sato", "SATO");
	machine[plasma].brand[19] = new Option ("sector", "Sector");
	machine[plasma].brand[20] = new Option ("soitaab", "Soitaab");
	machine[plasma].brand[21] = new Option ("stako", "Stako");
	machine[plasma].brand[22] = new Option ("whitney", "WA Whitney");
	machine[plasma].brand[23] = new Option ("zinzer", "Zinzer");
	machine[plasma].brand[24] = new Option ("other", "Other");

	machine[oxyfuel].brand[0] = new Option ("alltra", "Alltra");
	machine[oxyfuel].brand[1] = new Option ("burny", "Burny");
	machine[oxyfuel].brand[2] = new Option ("c&g", "C & G");
	machine[oxyfuel].brand[3] = new Option ("cs", "Cutting Systems");
	machine[oxyfuel].brand[4] = new Option ("esab", "ESAB");
	machine[oxyfuel].brand[5] = new Option ("esprit", "Esprit");
	machine[oxyfuel].brand[6] = new Option ("kinetic", "Kinetic");
	machine[oxyfuel].brand[7] = new Option ("koike", "Koike");
	machine[oxyfuel].brand[8] = new Option ("mg", "MG");
	machine[oxyfuel].brand[9] = new Option ("multicam", "MultiCam");
	machine[oxyfuel].brand[10] = new Option ("oxyser", "Oxyser");
	machine[oxyfuel].brand[11] = new Option ("proarc", "ProArc");
	machine[oxyfuel].brand[12] = new Option ("retro", "Retro");
	machine[oxyfuel].brand[13] = new Option ("saf", "SAF");
	machine[oxyfuel].brand[14] = new Option ("sato", "SATO");
	machine[oxyfuel].brand[15] = new Option ("sector", "Sector");
	machine[oxyfuel].brand[16] = new Option ("soitaab", "Soitaab");
	machine[oxyfuel].brand[17] = new Option ("stako", "Stako");
	machine[oxyfuel].brand[18] = new Option ("zinzer", "Zinzer");
	machine[oxyfuel].brand[19] = new Option ("other", "Other");

	machine[waterjet].brand[0] = new Option ("burny", "Burny");
	machine[waterjet].brand[1] = new Option ("bystronic", "Bystronic");
	machine[waterjet].brand[2] = new Option ("calypso", "Calypso");
	machine[waterjet].brand[3] = new Option ("esab", "ESAB");
	machine[waterjet].brand[4] = new Option ("flow", "Flow");
	machine[waterjet].brand[5] = new Option ("ingersoll", "Ingersoll");
	machine[waterjet].brand[6] = new Option ("jetedge", "Jet Edge");
	machine[waterjet].brand[7] = new Option ("mitsubishi", "Mitsubishi");
	machine[waterjet].brand[8] = new Option ("multicam", "MultiCam");
	machine[waterjet].brand[9] = new Option ("omax", "Omax");
	machine[waterjet].brand[10] = new Option ("par", "PAR Systems");
	machine[waterjet].brand[11] = new Option ("romeo", "Romeo Engineering");
	machine[waterjet].brand[12] = new Option ("technicut", "Technicut");
	machine[waterjet].brand[13] = new Option ("wjitalia", "Waterjet Italia");
	machine[waterjet].brand[14] = new Option ("wjsweden", "Waterjet Sweden");
	machine[waterjet].brand[15] = new Option ("other", "Other");

	machine[plasmapunch].brand[0] = new Option ("amada", "Amada");
	machine[plasmapunch].brand[1] = new Option ("danobat", "Danobat");
	machine[plasmapunch].brand[2] = new Option ("lvd", "LVD");
	machine[plasmapunch].brand[3] = new Option ("murata", "Murata");
	machine[plasmapunch].brand[4] = new Option ("peddinghaus", "Peddinghaus");
	machine[plasmapunch].brand[5] = new Option ("strippit", "Strippit");
	machine[plasmapunch].brand[6] = new Option ("trumpf", "Trumpf");
	machine[plasmapunch].brand[7] = new Option ("whitney", "WA Whitney");
	machine[plasmapunch].brand[8] = new Option ("other", "Other");

	machine[laserpunch].brand[0] = new Option ("amada", "Amada");
	machine[laserpunch].brand[1] = new Option ("finnpower", "Finnpower");
	machine[laserpunch].brand[2] = new Option ("peddinghaus", "Peddinghaus");
	machine[laserpunch].brand[3] = new Option ("strippit", "Strippit");
	machine[laserpunch].brand[4] = new Option ("trumpf", "Trumpf");
	machine[laserpunch].brand[5] = new Option ("other", "Other");
	
	machine[router].brand[0] = new Option ("accurouter", "Accu-Router");
	machine[router].brand[1] = new Option ("anderson", "Anderson America Corp.");
	machine[router].brand[2] = new Option ("axyz", "AXYZ");
	machine[router].brand[3] = new Option ("biesse", "Biesse");
	machine[router].brand[4] = new Option ("busellato", "Busellato");
	machine[router].brand[5] = new Option ("cronsrud", "C.R. Onsrud");
	machine[router].brand[6] = new Option ("haas", "Haas");
	machine[router].brand[7] = new Option ("heian", "Heian");
	machine[router].brand[8] = new Option ("homag", "Homag");
	machine[router].brand[9] = new Option ("komo", "Komo");
	machine[router].brand[10] = new Option ("multicam", "MultiCam");
	machine[router].brand[11] = new Option ("northwood", "Northwood");
	machine[router].brand[12] = new Option ("routech", "ROUTECH");
	machine[router].brand[13] = new Option ("shoda", "Shoda");
	machine[router].brand[14] = new Option ("multicam", "MultiCAM");
	machine[router].brand[15] = new Option ("shopbot", "ShopBot");
	machine[router].brand[16] = new Option ("techno", "Techno Inc.");
	machine[router].brand[17] = new Option ("thermwood", "Thermwood");
	machine[router].brand[18] = new Option ("torchmate", "Torchmate");
	machine[router].brand[19] = new Option ("other", "Other");

	machine[punch].brand[0] = new Option ("amada", "Amada");
	machine[punch].brand[1] = new Option ("euromac", "EUROMAC");
	machine[punch].brand[2] = new Option ("finnpower", "Finnpower");
	machine[punch].brand[3] = new Option ("haco", "Haco");
	machine[punch].brand[4] = new Option ("murata", "Murata");
	machine[punch].brand[5] = new Option ("nishinnbo", "Nishinnbo");
	machine[punch].brand[6] = new Option ("pullmax", "Pullmax");
	machine[punch].brand[7] = new Option ("salvagnini", "Salvagnini");
	machine[punch].brand[8] = new Option ("strippit", "Strippit");
	machine[punch].brand[9] = new Option ("trumpf", "Trumpf");
	machine[punch].brand[10] = new Option ("other", "Other");

	machine[knife].brand[0] = new Option ("aeronaut", "Aeronaut Automation");
	machine[knife].brand[1] = new Option ("aristo", "Aristo");
	machine[knife].brand[2] = new Option ("assyst", "Assyst Bullmer");
	machine[knife].brand[3] = new Option ("atom", "Atom");
	machine[knife].brand[4] = new Option ("autometrix", "Autometrix");
	machine[knife].brand[5] = new Option ("blackman", "Blackman and White");
	machine[knife].brand[6] = new Option ("eastman", "Eastman");
	machine[knife].brand[7] = new Option ("exact", "Exact");
	machine[knife].brand[8] = new Option ("gerber", "Gerber");
	machine[knife].brand[9] = new Option ("gfm", "GFM");
	machine[knife].brand[10] = new Option ("kongsberg", "Kongsberg");
	machine[knife].brand[11] = new Option ("lectra", "Lectra");
	machine[knife].brand[12] = new Option ("multicam", "MultiCam");
	machine[knife].brand[13] = new Option ("oteman", "Oteman");
	machine[knife].brand[14] = new Option ("pathfinder", "Pathfinder");
	machine[knife].brand[15] = new Option ("zund", "Zund");
	machine[knife].brand[15] = new Option ("other", "Other");

	machine[shear].brand[0] = new Option ("accupress", "AccuPress");
	machine[shear].brand[1] = new Option ("amada", "Amada");
	machine[shear].brand[2] = new Option ("cincinnati", "Cincinnati");
	machine[shear].brand[3] = new Option ("finnpower", "FinnPower SG");
	machine[shear].brand[4] = new Option ("lvd", "LVD");
	machine[shear].brand[5] = new Option ("trumpf", "Trumpf");
	machine[shear].brand[6] = new Option ("other", "Other");

	machine[other].brand[0] = new Option ("koike", "Koike");
	machine[other].brand[1] = new Option ("cs", "Cutting Systems");
	machine[other].brand[2] = new Option ("whitney", "WA Whitney");
	machine[other].brand[3] = new Option ("aks", "AKS");
	machine[other].brand[4] = new Option ("stako", "Stako");
	machine[other].brand[5] = new Option ("mg", "MG");
	machine[other].brand[6] = new Option ("esab", "ESAB");
	machine[other].brand[7] = new Option ("c&g", "C & G");
	machine[other].brand[8] = new Option ("sector", "Sector");
	machine[other].brand[9] = new Option ("ultra", "Ultra");
	machine[other].brand[10] = new Option ("kinetic", "Kinetic");
	machine[other].brand[11] = new Option ("crelectronics", "CR Electronics");
	machine[other].brand[12] = new Option ("esprit", "Esprit");
	machine[other].brand[13] = new Option ("soitaab", "Soitaab");
	machine[other].brand[14] = new Option ("sato", "SATO");
	machine[other].brand[15] = new Option ("zinzer", "Zinzer");
	machine[other].brand[16] = new Option ("saf", "SAF");
	machine[other].brand[17] = new Option ("komatsu", "Komatsu");
	machine[other].brand[18] = new Option ("oxyser", "Oxyser");
	machine[other].brand[19] = new Option ("ficep", "Ficep");
	machine[other].brand[20] = new Option ("pierce", "Pierce");
	machine[other].brand[21] = new Option ("other", "Other");

	machine[laser].controller[0] = new Option ("burny", "Burny");
	machine[laser].controller[1] = new Option ("fanuc", "Fanuc");
	machine[laser].controller[2] = new Option ("hypertherm", "Hypertherm");
	machine[laser].controller[3] = new Option ("siemens", "Siemens");
	machine[laser].controller[4] = new Option ("other", "Other");

	machine[plasma].controller[0] = new Option ("burny", "Burny");
	machine[plasma].controller[1] = new Option ("fanuc", "Fanuc");
	machine[plasma].controller[2] = new Option ("hypertherm", "Hypertherm");
	machine[plasma].controller[3] = new Option ("siemens", "Siemens");
	machine[plasma].controller[4] = new Option ("other", "Other");

	machine[oxyfuel].controller[0] = new Option ("burny", "Burny");
	machine[oxyfuel].controller[1] = new Option ("fanuc", "Fanuc");
	machine[oxyfuel].controller[2] = new Option ("hypertherm", "Hypertherm");
	machine[oxyfuel].controller[3] = new Option ("siemens", "Siemens");
	machine[oxyfuel].controller[4] = new Option ("other", "Other");

	machine[waterjet].controller[0] = new Option ("burny", "Burny");
	machine[waterjet].controller[1] = new Option ("fanuc", "Fanuc");
	machine[waterjet].controller[2] = new Option ("hypertherm", "Hypertherm");
	machine[waterjet].controller[3] = new Option ("siemens", "Siemens");
	machine[waterjet].controller[4] = new Option ("other", "Other");

	machine[router].controller[0] = new Option ("burny", "Burny");
	machine[router].controller[1] = new Option ("fanuc", "Fanuc");
	machine[router].controller[2] = new Option ("hypertherm", "Hypertherm");
	machine[router].controller[3] = new Option ("siemens", "Siemens");
	machine[router].controller[4] = new Option ("other", "Other");

	machine[punch].controller[0] = new Option ("burny", "Burny");
	machine[punch].controller[1] = new Option ("fanuc", "Fanuc");
	machine[punch].controller[2] = new Option ("hypertherm", "Hypertherm");
	machine[punch].controller[3] = new Option ("siemens", "Siemens");
	machine[punch].controller[4] = new Option ("other", "Other");

	machine[plasmapunch].controller[0] = new Option ("burny", "Burny");
	machine[plasmapunch].controller[1] = new Option ("fanuc", "Fanuc");
	machine[plasmapunch].controller[2] = new Option ("hypertherm", "Hypertherm");
	machine[plasmapunch].controller[3] = new Option ("siemens", "Siemens");
	machine[plasmapunch].controller[4] = new Option ("other", "Other");

	machine[laserpunch].controller[0] = new Option ("burny", "Burny");
	machine[laserpunch].controller[1] = new Option ("fanuc", "Fanuc");
	machine[laserpunch].controller[2] = new Option ("hypertherm", "Hypertherm");
	machine[laserpunch].controller[3] = new Option ("siemens", "Siemens");
	machine[laserpunch].controller[4] = new Option ("other", "Other");

	machine[knife].controller[0] = new Option ("burny", "Burny");
	machine[knife].controller[1] = new Option ("fanuc", "Fanuc");
	machine[knife].controller[2] = new Option ("hypertherm", "Hypertherm");
	machine[knife].controller[3] = new Option ("siemens", "Siemens");
	machine[knife].controller[4] = new Option ("other", "Other");

	machine[shear].controller[0] = new Option ("burny", "Burny");
	machine[shear].controller[1] = new Option ("fanuc", "Fanuc");
	machine[shear].controller[2] = new Option ("hypertherm", "Hypertherm");
	machine[shear].controller[3] = new Option ("siemens", "Siemens");
	machine[shear].controller[4] = new Option ("other", "Other");

	machine[other].controller[0] = new Option ("burny", "Burny");
	machine[other].controller[1] = new Option ("fanuc", "Fanuc");
	machine[other].controller[2] = new Option ("hypertherm", "Hypertherm");
	machine[other].controller[3] = new Option ("siemens", "Siemens");
	machine[other].controller[4] = new Option ("other", "Other");

	machine[laser].feature[0] = new Option ("bevel", featureBevel);
	machine[laser].feature[1] = new Option ("clamps", featureClamp);
	machine[laser].feature[2] = new Option ("drill", featureDrill);
	machine[laser].feature[3] = new Option ("gantry", featureGantry);
	machine[laser].feature[4] = new Option ("hybrid", featureHybrid);
	machine[laser].feature[5] = new Option ("marker", featureMarker);
	machine[laser].feature[6] = new Option ("mill", featureMill);
	machine[laser].feature[7] = new Option ("shear", featureShear);
	machine[laser].feature[8] = new Option ("parthandler", featurePartHandler);
	machine[laser].feature[9] = new Option ("sheetloader", featureSheetLoader);
	machine[laser].feature[10] = new Option ("textmarker", featureTextMarker);
	machine[laser].feature[11] = new Option ("other", featureOther);

	machine[plasma].feature[0] = new Option ("bevel", featureBevel);
	machine[plasma].feature[1] = new Option ("clamps", featureClamp);
	machine[plasma].feature[2] = new Option ("drill", featureDrill);
	machine[plasma].feature[3] = new Option ("gantry", featureGantry);
	machine[plasma].feature[4] = new Option ("hybrid", featureHybrid);
	machine[plasma].feature[5] = new Option ("marker", featureMarker);
	machine[plasma].feature[6] = new Option ("mill", featureMill);
	machine[plasma].feature[7] = new Option ("shear", featureShear);
	machine[plasma].feature[8] = new Option ("parthandler", featurePartHandler);
	machine[plasma].feature[9] = new Option ("sheetloader", featureSheetLoader);
	machine[plasma].feature[10] = new Option ("textmarker", featureTextMarker);
	machine[plasma].feature[11] = new Option ("other", featureOther);

	machine[oxyfuel].feature[0] = new Option ("bevel", featureBevel);
	machine[oxyfuel].feature[1] = new Option ("clamps", featureClamp);
	machine[oxyfuel].feature[2] = new Option ("drill", featureDrill);
	machine[oxyfuel].feature[3] = new Option ("gantry", featureGantry);
	machine[oxyfuel].feature[4] = new Option ("hybrid", featureHybrid);
	machine[oxyfuel].feature[5] = new Option ("marker", featureMarker);
	machine[oxyfuel].feature[6] = new Option ("mill", featureMill);
	machine[oxyfuel].feature[7] = new Option ("shear", featureShear);
	machine[oxyfuel].feature[8] = new Option ("parthandler", featurePartHandler);
	machine[oxyfuel].feature[9] = new Option ("sheetloader", featureSheetLoader);
	machine[oxyfuel].feature[10] = new Option ("textmarker", featureTextMarker);
	machine[oxyfuel].feature[11] = new Option ("other", featureOther);

	machine[waterjet].feature[0] = new Option ("bevel", featureBevel);
	machine[waterjet].feature[1] = new Option ("clamps", featureClamp);
	machine[waterjet].feature[2] = new Option ("drill", featureDrill);
	machine[waterjet].feature[3] = new Option ("gantry", featureGantry);
	machine[waterjet].feature[4] = new Option ("hybrid", featureHybrid);
	machine[waterjet].feature[5] = new Option ("marker", featureMarker);
	machine[waterjet].feature[6] = new Option ("mill", featureMill);
	machine[waterjet].feature[7] = new Option ("shear", featureShear);
	machine[waterjet].feature[8] = new Option ("parthandler", featurePartHandler);
	machine[waterjet].feature[9] = new Option ("sheetloader", featureSheetLoader);
	machine[waterjet].feature[10] = new Option ("textmarker", featureTextMarker);
	machine[waterjet].feature[11] = new Option ("other", featureOther);

	machine[router].feature[0] = new Option ("bevel", featureBevel);
	machine[router].feature[1] = new Option ("clamps", featureClamp);
	machine[router].feature[2] = new Option ("drill", featureDrill);
	machine[router].feature[3] = new Option ("gantry", featureGantry);
	machine[router].feature[4] = new Option ("hybrid", featureHybrid);
	machine[router].feature[5] = new Option ("marker", featureMarker);
	machine[router].feature[6] = new Option ("mill", featureMill);
	machine[router].feature[7] = new Option ("shear", featureShear);
	machine[router].feature[8] = new Option ("parthandler", featurePartHandler);
	machine[router].feature[9] = new Option ("sheetloader", featureSheetLoader);
	machine[router].feature[10] = new Option ("textmarker", featureTextMarker);
	machine[router].feature[11] = new Option ("other", featureOther);

	machine[punch].feature[0] = new Option ("bevel", featureBevel);
	machine[punch].feature[1] = new Option ("clamps", featureClamp);
	machine[punch].feature[2] = new Option ("drill", featureDrill);
	machine[punch].feature[3] = new Option ("gantry", featureGantry);
	machine[punch].feature[4] = new Option ("hybrid", featureHybrid);
	machine[punch].feature[5] = new Option ("marker", featureMarker);
	machine[punch].feature[6] = new Option ("mill", featureMill);
	machine[punch].feature[7] = new Option ("shear", featureShear);
	machine[punch].feature[8] = new Option ("parthandler", featurePartHandler);
	machine[punch].feature[9] = new Option ("sheetloader", featureSheetLoader);
	machine[punch].feature[10] = new Option ("textmarker", featureTextMarker);
	machine[punch].feature[11] = new Option ("other", featureOther);

	machine[laserpunch].feature[0] = new Option ("bevel", featureBevel);
	machine[laserpunch].feature[1] = new Option ("clamps", featureClamp);
	machine[laserpunch].feature[2] = new Option ("drill", featureDrill);
	machine[laserpunch].feature[3] = new Option ("gantry", featureGantry);
	machine[laserpunch].feature[4] = new Option ("hybrid", featureHybrid);
	machine[laserpunch].feature[5] = new Option ("marker", featureMarker);
	machine[laserpunch].feature[6] = new Option ("mill", featureMill);
	machine[laserpunch].feature[7] = new Option ("shear", featureShear);
	machine[laserpunch].feature[8] = new Option ("parthandler", featurePartHandler);
	machine[laserpunch].feature[9] = new Option ("sheetloader", featureSheetLoader);
	machine[laserpunch].feature[10] = new Option ("textmarker", featureTextMarker);
	machine[laserpunch].feature[11] = new Option ("other", featureOther);

	machine[plasmapunch].feature[0] = new Option ("bevel", featureBevel);
	machine[plasmapunch].feature[1] = new Option ("clamps", featureClamp);
	machine[plasmapunch].feature[2] = new Option ("drill", featureDrill);
	machine[plasmapunch].feature[3] = new Option ("gantry", featureGantry);
	machine[plasmapunch].feature[4] = new Option ("hybrid", featureHybrid);
	machine[plasmapunch].feature[5] = new Option ("marker", featureMarker);
	machine[plasmapunch].feature[6] = new Option ("mill", featureMill);
	machine[plasmapunch].feature[7] = new Option ("shear", featureShear);
	machine[plasmapunch].feature[8] = new Option ("parthandler", featurePartHandler);
	machine[plasmapunch].feature[9] = new Option ("sheetloader", featureSheetLoader);
	machine[plasmapunch].feature[10] = new Option ("textmarker", featureTextMarker);
	machine[plasmapunch].feature[11] = new Option ("other", featureOther);

	machine[knife].feature[0] = new Option ("bevel", featureBevel);
	machine[knife].feature[1] = new Option ("clamps", featureClamp);
	machine[knife].feature[2] = new Option ("drill", featureDrill);
	machine[knife].feature[3] = new Option ("gantry", featureGantry);
	machine[knife].feature[4] = new Option ("hybrid", featureHybrid);
	machine[knife].feature[5] = new Option ("marker", featureMarker);
	machine[knife].feature[6] = new Option ("mill", featureMill);
	machine[knife].feature[7] = new Option ("shear", featureShear);
	machine[knife].feature[8] = new Option ("parthandler", featurePartHandler);
	machine[knife].feature[9] = new Option ("sheetloader", featureSheetLoader);
	machine[knife].feature[10] = new Option ("textmarker", featureTextMarker);
	machine[knife].feature[11] = new Option ("other", featureOther);

	machine[shear].feature[0] = new Option ("bevel", featureBevel);
	machine[shear].feature[1] = new Option ("clamps", featureClamp);
	machine[shear].feature[2] = new Option ("drill", featureDrill);
	machine[shear].feature[3] = new Option ("gantry", featureGantry);
	machine[shear].feature[4] = new Option ("hybrid", featureHybrid);
	machine[shear].feature[5] = new Option ("marker", featureMarker);
	machine[shear].feature[6] = new Option ("mill", featureMill);
	machine[shear].feature[7] = new Option ("shear", featureShear);
	machine[shear].feature[8] = new Option ("parthandler", featurePartHandler);
	machine[shear].feature[9] = new Option ("sheetloader", featureSheetLoader);
	machine[shear].feature[10] = new Option ("textmarker", featureTextMarker);
	machine[shear].feature[11] = new Option ("other", featureOther);

	machine[other].feature[0] = new Option ("bevel", featureBevel);
	machine[other].feature[1] = new Option ("clamps", featureClamp);
	machine[other].feature[2] = new Option ("drill", featureDrill);
	machine[other].feature[3] = new Option ("gantry", featureGantry);
	machine[other].feature[4] = new Option ("hybrid", featureHybrid);
	machine[other].feature[5] = new Option ("marker", featureMarker);
	machine[other].feature[6] = new Option ("mill", featureMill);
	machine[other].feature[7] = new Option ("shear", featureShear);
	machine[other].feature[8] = new Option ("parthandler", featurePartHandler);
	machine[other].feature[9] = new Option ("sheetloader", featureSheetLoader);
	machine[other].feature[10] = new Option ("textmarker", featureTextMarker);
	machine[other].feature[11] = new Option ("other", featureOther);


}

// ------------------------------------------------------------------------------------

var highestMachineNumber = 0;

function setMachineAttributes (element) {

	var 	parent = element.parentNode;
	var	 	parentId = parent.id;
	var 	machineNumber =  parseInt (parentId.substring (parentId.length - 1));
	var 	nextMachineNumber = machineNumber + 1;
	var 	sibling,
			nextSibling;
	var 	baseId;
	var 	i;
	var		elementNode = 1;
	
	
	// Refresh the dynamic lists if an existing machine is altered
	
	if (element.selectedIndex != 0 && machineNumber <= highestMachineNumber) {
		refreshDynamicFields (element.selectedIndex, machineNumber);
	}

	// Create new sibling nodes if a new machine is selected.

	if (element.selectedIndex != 0 && machineNumber > highestMachineNumber)	{
		highestMachineNumber = machineNumber;
		addBrands (parent, element.selectedIndex, machineNumber);
		addController (parent, element.selectedIndex, machineNumber);
		addFeatureCheck (parent, element.selectedIndex, machineNumber);
		$(".dynamicLabel").show();						// show column headers for dynamic fields
		if (nextMachineNumber < 7) {
			$("#machineType" + nextMachineNumber).show();
			$(".machineFeature").hide(); 						// hide existing feature panels
			if (oldMSIE)
				hideFeatures();
			$("#machineFeature" + machineNumber).show(); // show the feature panel for the current machine
			$("#machineField" + machineNumber).mouseenter(function(event) { // bind an event handler to the enclosing machine div
				var id;
				var machineNumber;
				id = event.target.id;
				machineNumber = id.substring(id.length - 1);
				$(".machineFeature").hide(); 						// hide existing feature panels
				if (oldMSIE)
					hideFeatures();
				$("#machineFeature" + machineNumber).show(); // show the feature panel for the current machine
			});
		}
	}
}


// ------------------------------------------------------------------------------------

function addBrands (machineDiv, machineType, machineNumber) {

	var select;
	var label;
	var option;
	var i;

	select = document.createElement ('select');
	select.setAttribute ('id', 'machineBrand' + machineNumber);
	select.setAttribute ('name', 'machineBrand' + machineNumber);
	select.setAttribute ('class', 'machineBrand');
	select.setAttribute ('tabindex', '1' + machineNumber + '2');
//	select.setAttribute ('runat', 'server');
	for (i = 0; i < machine[machineType].brand.length; i++) {
		option = document.createElement ('option');
		option.appendChild (document.createTextNode (machine[machineType].brand[i].text));
		select.appendChild (option);
	}
	machineDiv.appendChild (select);
}	


// ------------------------------------------------------------------------------------

function addController (machineDiv, machineType, machineNumber) {

	var select;
	var option;
	var i;

	select = document.createElement ('select');
	select.setAttribute ('id', 'machineController' + machineNumber);
	select.setAttribute ('name', 'machineController' + machineNumber);
	select.setAttribute ('class', 'machineController');
	select.setAttribute ('tabindex', '1' + machineNumber + '3');
//	select.setAttribute ('runat', 'server');
	for (i = 0; i < machine[machineType].controller.length; i++) {
		option = document.createElement ('option');
		option.appendChild (document.createTextNode (machine[machineType].controller[i].text));
		select.appendChild (option);
	}
	machineDiv.appendChild (select);
}

// ------------------------------------------------------------------------------------
// Insert each feature panel in the parent fieldset, before the first machineField element

// The in-line styles are only needed for IE7 and earlier. When IE 7 is no longer supported
// they can be removed.

function addFeatureCheck (machineDiv, machineType, machineNumber) {

    var featurePanelDiv;
    var checkbox;
    var separator;
    var parent;	
    var label;
    var id;
    var i;
	
    parent = machineDiv.parentNode;
    featurePanelDiv = document.createElement('div');
    featurePanelDiv.setAttribute('id', 'machineFeature' + machineNumber);
    featurePanelDiv.setAttribute('class', 'machineFeature');
    featurePanelDiv.style.width = '180px';
    featurePanelDiv.style.height = '250px';
    featurePanelDiv.style.borderStyle = 'solid';
    featurePanelDiv.style.borderColor = '#DBDBDB';
	featurePanelDiv.style.borderWidth = 'thin';
	featurePanelDiv.style.cssFloat = 'right';	
	featurePanelDiv.style.styleFloat = 'right';
    //  featurePanelDiv.setAttribute('tabindex', '1' + machineNumber + '4');
    //	featurePanelDiv.setAttribute ('runat', 'server');
    for (i = 0; i < machine[machineType].feature.length; i++) {
        id = machine[machineType].feature[i].label + machineNumber;
        label = document.createElement('label');
        label.setAttribute('for', id);
        label.setAttribute('class', 'featureLabel');
        label.style.display = 'block';
		label.style.cssFloat = 'right';
		label.style.styleFloat = 'right';
		label.style.width = '140px';
		label.style.marginTop = '3px';
        label.appendChild(document.createTextNode(machine[machineType].feature[i].text));
        featurePanelDiv.appendChild(label);
        checkbox = document.createElement('input');
        checkbox.setAttribute('id', id);
        checkbox.setAttribute('type', 'checkbox');
        checkbox.setAttribute('class', 'featureCheck');
        checkbox.setAttribute('value', machine[machineType].feature[i].text);
        checkbox.style.width = 'auto';
		checkbox.style.display = 'block';
		checkbox.style.cssFloat = 'left';
		checkbox.style.styleFloat = 'left';
        featurePanelDiv.appendChild(checkbox);
        separator = document.createElement('p');
        separator.setAttribute('class', 'featureSeparator');
        separator.style.clear = 'both';
		separator.style.marginTop = '0px';
		separator.style.marginBottom = '0px';
        featurePanelDiv.appendChild(separator);
	}
     parent.insertBefore(featurePanelDiv, $('#machineField1').get(0));
}

// ------------------------------------------------------------------------------------
// This rubbish needs to be here, because IE 7 does not apply styles to dynamically added elemets
// and once inline styles have been applied dynamically, they seem to need to be changed in the same way.

function hideFeatures() {

	var feature;

	feature = document.getElementById('machineFeature1');
	if (feature)
		feature.style.display = 'none';
	feature = document.getElementById('machineFeature2');
	if (feature)
		feature.style.display = 'none';
	feature = document.getElementById('machineFeature3');
	if (feature)
		feature.style.display = 'none';
	feature = document.getElementById('machineFeature4');
	if (feature)
		feature.style.display = 'none';
	feature = document.getElementById('machineFeature5');
	if (feature)
		feature.style.display = 'none';
	feature = document.getElementById('machineFeature6');
	if (feature)
		feature.style.display = 'none';
}


// ------------------------------------------------------------------------------------
//	Refresh the specified, present Brand, Controller and Feture fields

function refreshDynamicFields (machineType, machineNumber) {

	var select;
	var option;
    var featurePanelDiv;
    var checkbox;
    var separator;
    var label;
    var id;
	var i;
	
	select = $('#machineBrand' + machineNumber).get (0);
	$('#machineBrand' + machineNumber).empty ();
	for (i = 0; i < machine[machineType].brand.length; i++) {
		option = document.createElement ('option');
		option.appendChild (document.createTextNode (machine[machineType].brand[i].text));
		select.appendChild (option);
	}
	
	select = $('#machineController' + machineNumber).get (0);
	$('#machineController' + machineNumber).empty ();
	for (i = 0; i < machine[machineType].controller.length; i++) {
		option = document.createElement ('option');
		option.appendChild (document.createTextNode (machine[machineType].controller[i].text));
		select.appendChild (option);
	}

	featurePanelDiv = $('#machineFeature' + machineNumber).get (0);
	$('#machineFeature' + machineNumber).empty ();
    for (i = 0; i < machine[machineType].feature.length; i++) {
        id = machine[machineType].feature[i].label + machineNumber;
        label = document.createElement('label');
        label.setAttribute('for', id);
        label.setAttribute('class', 'featureLabel');
        label.style.display = 'block';
		label.style.cssFloat = 'right';
		label.style.styleFloat = 'right';
		label.style.width = '140px';
		label.style.marginTop = '3px';
        label.appendChild(document.createTextNode(machine[machineType].feature[i].text));
        featurePanelDiv.appendChild(label);
        checkbox = document.createElement('input');
        checkbox.setAttribute('id', id);
        checkbox.setAttribute('type', 'checkbox');
        checkbox.setAttribute('class', 'featureCheck');
        checkbox.setAttribute('value', machine[machineType].feature[i].text);
        checkbox.style.width = 'auto';
		checkbox.style.display = 'block';
		checkbox.style.cssFloat = 'left';
		checkbox.style.styleFloat = 'left';
        featurePanelDiv.appendChild(checkbox);
        separator = document.createElement('p');
        separator.setAttribute('class', 'featureSeparator');
        separator.style.clear = 'both';
		separator.style.marginTop = '0px';
		separator.style.marginBottom = '0px';
        featurePanelDiv.appendChild(separator);
	}
}

// ------------------------------------------------------------------------------------
// First attempt: Adds a feature drop down list, but is not very useful, because one
// really needs to be able to select multiple features

function addFeature (machineDiv, machineType, machineNumber) {

	var select;
	var option;
	var i;

	select = document.createElement ('select');
//	select.setAttribute ('multiple', '');
	select.setAttribute ('id', 'machineFeature' + machineNumber);
	select.setAttribute ('name', 'machineFeature' + machineNumber);
	select.setAttribute ('class', 'machineFeature');
	select.setAttribute ('tabindex', '1' + machineNumber + '4');
//	select.setAttribute ('runat', 'server');
	for (i = 0; i < machine[machineType].feature.length; i++) {
		option = document.createElement ('option');
		option.appendChild (document.createTextNode (machine[machineType].feature[i].text));
		select.appendChild (option);
	}
	machineDiv.appendChild (select);
}


// ------------------------------------------------------------------------------------

function addYears (machineDiv, machineNumber) {
	
	var select;
	var option;
	var year;
	var currentYear = new Date().getFullYear();
	var	startYear = currentYear - 14;
	
	select = document.createElement ('select');
	select.setAttribute ('id', 'machineYears' + machineNumber);
	select.setAttribute ('name', 'machineYears' + machineNumber);
	select.setAttribute ('class', 'machineYears');
	select.setAttribute ('tabindex', '1' + machineNumber + '6');
	for (year = startYear; year <= currentYear; year++) {
		option = document.createElement ('option');
		option.appendChild (document.createTextNode (year.toString()));
		select.appendChild (option);
	}
	machineDiv.appendChild (select);
}

// ------------------------------------------------------------------------------------

//	Adds a machine selection list to the "machines" field division
//	This function is not used because IE 6 ignores the onchange event on a dynamically added element.
//	It is retained in case IE is subsequently fixed. The data structure that this function
//	uses must be synchronised with the fixed elements on the page in order for the remaining
//	functions to continue to operate correctly.

function addMachine () {

	var element;
	var div;
	var select;
	
	if (context.machines != null) {
		div = document.createElement ('div');
		div.setAttribute ('class', 'formInput');
		div.setAttribute ('id', 'machine' + ++context.machine);
		select = document.createElement ('select');
		select.setAttribute ('id', 'machineType' + context.machine);
		select.setAttribute ('name', 'machineType' + context.machine);
		select.setAttribute ('onchange', 'addMachineAttributes (this);');
		
		setMachineTypeOptions (select);
		
		div.appendChild (select);
		context.machines.appendChild (div);
	}
}


// ------------------------------------------------------------------------------------

function setMachineTypeOptions (select) {

	var option;
	var i;
	
	for (i = 0; i < machine.length; i++) {
		option = document.createElement ('option');
		option.appendChild (document.createTextNode (machine[i].type.text));
		select.appendChild (option);
	}	
}

// ------------------------------------------------------------------------------------
