<!---

///// begin netscape cookie usage

// Sets cookie values. Expiration date is optional
//
function setCookie(name, value, expire) {
    expires = new Date();
    expires.setTime(expires.getTime() + 1000*60*60*24*365*3)
    document.cookie = name + "=" + escape(value)
        + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}

function getCookie(Name) {
    var search = Name + "=";
    if (document.cookie.length > 0) { // if there are any cookies
        offset = document.cookie.indexOf(search) 
        if (offset != -1) { // if cookie exists 
            offset += search.length 
            // set index of beginning of value
            end = document.cookie.indexOf(";", offset) 
            // set index of end of cookie value
            if (end == -1) 
                end = document.cookie.length
            return unescape(document.cookie.substring(offset, end))
        } 
    }
}

///// end netscape cookie usage

/*
    Engine Design Utility
    Author: David Andrews <david_andrews112@yahoo.com.au>
    Date: Early mornings in Feb 2004
    
    All information provided here is strictly unofficial. No responsibility
    will be taken for anything result from anything to do with this program.
*/

    
function engineSelect(form, id){

    if(id == -1){
        blockSelect(form, -1);
        crankSelect(form, -1);
        headSelect(form, -1);
        rodSelect(form, -1);
        pistonSelect(form, -1);
        camSelect(form, -1);
        form.gasket_height.value = "";
        form.redline.value = "";
    }

    blockSelect(form, engines[id]['block']);
    crankSelect(form, engines[id]['crank']);
    headSelect(form, engines[id]['head']);
    rodSelect(form, engines[id]['rod']);
    pistonSelect(form, engines[id]['piston']);
    camSelect(form, engines[id]['cam']);
    form.gasket_height.value = engines[id]['gasket_height'];
    form.redline.value = engines[id]['redline'];

}
function blockSelect(form, id){
    if(id == -1){
        form.block_cylinders.value = " ";
        form.block_height.value = " ";
        form.block_bore.value = " ";
        form.block_overbore.value = " ";
        form.blocks.selectedIndex = ++id;
        return;
    }
    form.block_cylinders.value = blocks[id]['cylinders'];
    form.block_height.value = blocks[id]['height'];
    form.block_bore.value = blocks[id]['bore'];
    form.block_overbore.value = blocks[id]['overbore'];
    form.blocks.selectedIndex = ++id;
}
function pistonSelect(form, id){
    if(id == -1){
        form.piston_bore.value = " ";
        form.piston_pin_height.value = " ";
        form.piston_pin_diametre.value = " ";
        form.piston_cc.value = " ";
        form.piston_weight.value = " ";
        form.pistons.selectedIndex = ++id;
        return;
    }
    form.piston_bore.value = pistons[id]['bore'];
    form.piston_pin_height.value = pistons[id]['pin_height'];
    form.piston_pin_diametre.value = pistons[id]['pin_diametre'];
    form.piston_cc.value = pistons[id]['cc'];
    form.piston_weight.value = pistons[id]['weight'];
    form.pistons.selectedIndex = ++id;
}
function headSelect(form, id){
    if(id == -1){
        form.head_cc.value = " ";
        form.head_valves.value = " ";
        //form.head_valve_depth.value = " ";
        form.head_intake_valve_diametre.value = " ";
        form.head_exhaust_valve_diametre.value = " ";
        form.heads.selectedIndex = ++id;
        return;
    }
    form.head_cc.value = heads[id]['cc'];
    form.head_valves.value = heads[id]['valves'];
    //form.head_valve_depth.value = heads[id]['valve_depth'];
    form.head_intake_valve_diametre.value = heads[id]['intake_valve_diametre'];
    form.head_exhaust_valve_diametre.value = heads[id]['exhaust_valve_diametre'];
    form.heads.selectedIndex = ++id;
}
function rodSelect(form, id){
    if(id == -1){
        form.rod_length.value = " ";
        form.rod_piston_end_bore.value = " ";
        form.rod_piston_end_thickness.value = " ";
        form.rod_big_end_bore.value = " ";
        form.rod_big_end_thickness.value = " ";
        form.rod_weight.value = " ";
        form.rods.selectedIndex = ++id;
        return;
    }

    form.rod_length.value = rods[id]['rod_length'];
    form.rod_piston_end_bore.value = rods[id]['piston_end_bore'];
    form.rod_piston_end_thickness.value = rods[id]['piston_end_thickness'];
    form.rod_big_end_bore.value = rods[id]['big_end_bore'];
    form.rod_big_end_thickness.value = rods[id]['big_end_thickness'];
    form.rod_weight.value = rods[id]['weight'];
    form.rods.selectedIndex = ++id;
}
function crankSelect(form, id){
    if(id == -1){
        form.crank_stroke.value = " ";
        form.crank_rod_bearing_od.value = " ";
        //form.crank_rod_bearing_id.value = " ";
        form.crank_rod_width.value = " ";
        form.cranks.selectedIndex = ++id;
        return;
    }
    form.crank_stroke.value = cranks[id]['stroke'];
    form.crank_rod_bearing_od.value = cranks[id]['rod_bearing_od'];
    //form.crank_rod_bearing_id.value = cranks[id]['rod_bearing_id'];
    form.crank_rod_width.value = cranks[id]['rod_width'];
    form.cranks.selectedIndex = ++id;
}
function camSelect(form, id){
    if(id == -1){
        form.cam_intake_lift.value = " ";
        form.cam_exhaust_lift.value = " ";
        form.cam_intake_duration.value = " ";
        form.cam_exhaust_duration.value = " ";
        form.cam_intake_opens.value = " ";
        form.cam_exhaust_opens.value = " ";
        form.cams.selectedIndex = ++id;
        return;
    }
    form.cam_intake_lift.value = cams[id]['intake_lift'];
    form.cam_exhaust_lift.value = cams[id]['exhaust_lift'];
    form.cam_intake_duration.value = cams[id]['intake_duration'];
    form.cam_exhaust_duration.value = cams[id]['exhaust_duration'];
    form.cam_intake_opens.value = cams[id]['intake_opens'];
    form.cam_exhaust_opens.value = cams[id]['exhaust_opens'];
    form.cams.selectedIndex = ++id;
}

function describe(form, type){

    switch(type){

        case "engine":
            array = "engines";
            list = "form.engines";
            break;

        case "block":
            array = "blocks";
            list = "form.blocks";
            break;

        case "piston":
            array = "pistons";
            list = "form.pistons";
            break;

        case "head":
            array = "heads";
            list = "form.heads";
            break;

        case "rod":
            array = "rods";
            list = "form.rods";
            break;

        case "crank":
            array = "cranks";
            list = "form.cranks";
            break;

        case "cam":
            array = "cams";
            list = "form.cams";
            break;

        default:
            return;

    }

    id = eval(list+".selectedIndex");
    id--;
    description = eval(array)[id]['description'];
    alert(description);
     

}

function save(form, type, action){

    term = new Array();
    question = new Array();
    classneeded = false;

    i = 0;

    term[i] = "description";
    question[i++] = "Description:";

    switch(type){

        case "engine":

            //engines is a special case
            array = "engines";
            list = "form.engines";

            if(action == "add"){
     
                name = prompt("What is it called?");
                description = prompt("Description:");
                arrayId= engines.length;
                engines[arrayId] = new Array();
                engines[arrayId]['who'] = "u";
                engines[arrayId]['name'] = name;
                engines[arrayId]['description'] = description;

                newOption = new Option(name, arrayId, false, false);
                newOptionId = form.engines.length
                form.engines.options[newOptionId] = newOption;
                form.engines.selectedIndex = newOptionId;
                
            } else if(action == "edit"){

                //we set the array values, only difference is we need the id
                arrayId = form.engines.selectedIndex;
                arrayId--;

                description = prompt("Description:", engines[arrayId]['description']);
                if(description != null)
                    engines[arrayId]['description'] = description;

            }

            //save all the currently selected components
            engines[arrayId]['block'] = 
                form.blocks.options[form.blocks.selectedIndex].value;
            engines[arrayId]['crank'] = 
                form.cranks.options[form.cranks.selectedIndex].value;
            engines[arrayId]['head'] = 
                form.heads.options[form.heads.selectedIndex].value;
            engines[arrayId]['rod'] = 
                form.rods.options[form.rods.selectedIndex].value;
            engines[arrayId]['piston'] = 
                form.pistons.options[form.pistons.selectedIndex].value;
            engines[arrayId]['cam'] = 
                form.cams.options[form.cams.selectedIndex].value;
            engines[arrayId]['gasket_height'] = 
                form.gasket_height.value;
            engines[arrayId]['redline'] = 
                form.redline.value;

            return;
            break;


        case "block":
            term[i] = "cylinders";
            question[i++] = "How many cylinders does it have?";
            term[i] = "height";
            question[i++] = "What is the block height? (mm)";
            term[i] = "bore";
            question[i++] = "What size is the bore? (mm)";
            term[i] = "overbore";
            question[i++] = "How much is the block overbored? (mm)";
            classneeded = true;
            array = "blocks";
            list = "form.blocks";
            break;

        case "piston":
            term[i] = "bore";
            question[i++] = "What size is the bore? (mm)";
            term[i] = "pin_height";
            question[i++] = "What is the pin height? (mm)";
            term[i] = "pin_diametre";
            question[i++] = "What is the pin diametre? (mm)";
            term[i] = "cc";
            question[i++] = "What is the volume of the dish/dome? (cc)";
            term[i] = "weight";
            question[i++] = "What is the weight? (g)";
            array = "pistons";
            list = "form.pistons";
            break;

        case "head":
            term[i] = "cc";
            question[i++] = "What is the volume of the combustion chamber? (cc)";
            term[i] = "valves";
            question[i++] = "How many valves per cylinder?";
            //term[i] = "valve_depth";
            //question[i++] = "How far from the head deck to the lowest point of the valve? (mm)";
            term[i] = "intake_valve_diametre";
            question[i++] = "What is diametre of the intake valve? (mm)";
            term[i] = "exhaust_valve_diametre";
            question[i++] = "What is diametre of the exhaust valve? (mm)";
            classneeded = true;
            array = "heads";
            list = "form.heads";
            break;

        case "rod":
            term[i] = "rod_length";
            question[i++] = "How long is the rod? (mm)";
            term[i] = "piston_end_bore";
            question[i++] = "What is the gudgeon pin diametre? (mm)";
            term[i] = "piston_end_thickness";
            question[i++] = "What is the thickness of the rod at the piston end? (mm)";
            term[i] = "big_end_bore";
            question[i++] = "What is the big end bore? (mm)";
            term[i] = "big_end_thickness";
            question[i++] = "What is the thickness of the rod at the big end? (mm)";
            term[i] = "weight";
            question[i++] = "What does the rod weight? (g)";
            array = "rods";
            list = "form.rods";
            break;

        case "crank":
            term[i] = "stroke";
            question[i++] = "What stroke distance? (mm)";
            term[i] = "rod_bearing_od";
            question[i++] = "What is the outer diametre of the conrod bearing? (mm)";
            //term[i] = "rod_bearing_id";
            //question[i++] = "What is the inner diametre of the conrod bearing? (mm)";
            term[i] = "rod_width";
            question[i++] = "What is the width for the conrod? (mm)";
            classneeded = true;
            array = "cranks";
            list = "form.cranks";
            break;

        case "cam":
            term[i] = "intake_lift";
            question[i++] = "What is the lift on the intake valve? (mm)";
            term[i] = "exhaust_lift";
            question[i++] = "What is the lift on the exhaust valve? (mm)";
            term[i] = "intake_duration";
            question[i++] = "What is the advertised intake duration? (degrees)";
            term[i] = "exhaust_duration";
            question[i++] = "What is the advertised exhaust duration? (degrees)";
            term[i] = "intake_opens";
            question[i++] = "At what degree BTDC does the intake valve open? (degrees)";
            term[i] = "exhaust_opens";
            question[i++] = "At what degree ATDC does the exhaust valve open? (degrees)";
            classneeded = true;
            array = "cams";
            list = "form.cams";
            break;


        default:
            return;

    }

    if(action == "add"){

        name = prompt("What is it called?");
        if(classneeded == true){
            itemclass = prompt("What class? (E.g 6-cylinder L-series class is `L6')");
            name = itemclass+":"+name;
        }

        if(name.search(",") != -1){
            alert("You cannot use commas in the name.");
            return;
        }

        nextId = eval(array).length; 
        newOption = new Option(name, nextId, false, false);
        values = new Array();

        eval(array)[nextId] = new Array();
        eval(array)[nextId]['id'] = nextId;
        eval(array)[nextId]['who'] = "u";
        eval(array)[nextId]['name'] = name;

        for(var i = 0; i < term.length; i++){

            values[i] = prompt(question[i]);
            if(values[i] == null){
                alert("You must enter values. Try again.");
                eval(array).pop();
                return;
            }
            if(values[i].toString().search(",") != -1){
                alert("You cannot use commas.");
                eval(array).pop();
                return;
            }
            eval(array)[nextId][term[i].toString()] = values[i];

        }

        eval(list)[eval(list).length] = newOption;

    } else if(action == "edit"){

        selectedId = eval(list+".selectedIndex");
        selectedId--;
        elementPrefix = array.slice(0,-1);

        for(var i = 0; i < term.length; i++){

            formelement = term[i].toString();
            /*if(term[i].toString() == "rod_length"){
                formelement = "length";    
            } else {
                formelement = term[i].toString();
            }*/

            //do we want to use the form input as the input?
            //newval = eval("form."+elementPrefix.toString()+"_"+formelement+".value");

            //newval = prompt(question[i], eval("form."+elementPrefix.toString()+"_"+formelement+".value"));
            newval = prompt(question[i], eval(array)[selectedId][formelement.toString()]);
            if(newval == null){
                alert("Invalid valid. Try again.");
                return;
            }
            eval(array)[selectedId][term[i].toString()] = newval;
            eval(elementPrefix+"Select")(document.forms[0], selectedId);

        }

    }

}

function exportData(form, destination, msg){

    //take the data from the arrays and place it into the textarea

    enginestr = "";
    for(var i = 0; i < engines.length; i++){
        if(engines[i]['who'] == "u"){
            enginestr += "en:u,";
            enginestr += engines[i]['name']+",";
            enginestr += engines[i]['description']+",";
            enginestr += engines[i]['block']+",";
            enginestr += engines[i]['crank']+",";
            enginestr += engines[i]['head']+",";
            enginestr += engines[i]['rod']+",";
            enginestr += engines[i]['piston']+",";
            enginestr += engines[i]['cam']+",";
            enginestr += engines[i]['gasket_height']+",";
            enginestr += engines[i]['redline']+"\n";
        }
    }
    blockstr = "";
    for(var i = 0; i < blocks.length; i++){
        if(blocks[i]['who'] == "u"){
            blockstr += "bl:u,";
            blockstr += blocks[i]['name']+",";
            blockstr += blocks[i]['description']+",";
            blockstr += blocks[i]['cylinders']+",";
            blockstr += blocks[i]['height']+",";
            blockstr += blocks[i]['bore']+",";
            blockstr += blocks[i]['overbore']+"\n";
        }
    }
    pistonstr = "";
    for(var i = 0; i < pistons.length; i++){
        if(pistons[i]['who'] == "u"){
            pistonstr += "pi:u,";
            pistonstr += pistons[i]['name']+",";
            pistonstr += pistons[i]['description']+",";
            pistonstr += pistons[i]['bore']+",";
            pistonstr += pistons[i]['pin_height']+",";
            pistonstr += pistons[i]['pin_diametre']+",";
            pistonstr += pistons[i]['cc']+",";
            pistonstr += pistons[i]['weight']+"\n";
        }
    }
    headstr = "";
    for(var i = 0; i < heads.length; i++){
        if(heads[i]['who'] == "u"){
            headstr += "he:u,";
            headstr += heads[i]['name']+",";
            headstr += heads[i]['description']+",";
            headstr += heads[i]['cc']+",";
            headstr += heads[i]['valves']+",";
            //headstr += heads[i]['valve_depth']+",";
            headstr += heads[i]['intake_valve_diametre']+",";
            headstr += heads[i]['exhaust_valve_diametre']+"\n";
        }
    }
    rodstr = "";
    for(var i = 0; i < rods.length; i++){
        if(rods[i]['who'] == "u"){
            rodstr += "ro:u,";
            rodstr += rods[i]['name']+",";
            rodstr += rods[i]['description']+",";
            rodstr += rods[i]['rod_length']+",";
            rodstr += rods[i]['piston_end_bore']+",";
            rodstr += rods[i]['piston_end_thickness']+",";
            rodstr += rods[i]['big_end_bore']+",";
            rodstr += rods[i]['big_end_thickness']+",";
            rodstr += rods[i]['weight']+"\n";
        }
    }
    crankstr = "";
    for(var i = 0; i < cranks.length; i++){
        if(cranks[i]['who'] == "u"){
            crankstr += "cr:u,";
            crankstr += cranks[i]['name']+",";
            crankstr += cranks[i]['description']+",";
            crankstr += cranks[i]['stroke']+",";
            crankstr += cranks[i]['rod_bearing_od']+",";
            //crankstr += cranks[i]['rod_bearing_id']+",";
            crankstr += cranks[i]['rod_width']+"\n";
        }
    }
    camstr = "";
    for(var i = 0; i < cams.length; i++){
        if(cams[i]['who'] == "u"){
            camstr += "ca:u,";
            camstr += cams[i]['name']+",";
            camstr += cams[i]['description']+",";
            camstr += cams[i]['intake_lift']+",";
            camstr += cams[i]['exhaust_lift']+",";
            camstr += cams[i]['intake_duration']+",";
            camstr += cams[i]['exhaust_duration']+",";
            camstr += cams[i]['intake_opens']+",";
            camstr += cams[i]['exhaust_opens']+"\n";
        }
    }

    if(destination == "form"){

        form.data.value = blockstr+
                            crankstr+
                            headstr+
                            rodstr+
                            pistonstr+
                            camstr+
                            enginestr;

    } else {

        setCookie("TheHelixEDS:Blocks", blockstr.toString());
        setCookie("TheHelixEDS:Cranks", crankstr.toString());
        setCookie("TheHelixEDS:Heads", headstr.toString());
        setCookie("TheHelixEDS:Rods", rodstr.toString());
        setCookie("TheHelixEDS:Pistons", pistonstr.toString());
        setCookie("TheHelixEDS:Cams", camstr.toString());
        setCookie("TheHelixEDS:Engines", enginestr.toString());

        if(msg)
            alert("The current store of components has been saved as a Cookie. It will be automatically imported upon your next visit, unless you delete the Cookie from your machine.\n");
    }



}

function clearData(form){

    blocks = new Array();
    pistons = new Array();
    heads = new Array();
    rods = new Array();
    cranks = new Array();
    cams = new Array();
    engines = new Array();

    for(var i = 1; i < form.blocks.options.length; i)
        form.blocks.options[1] = null;
    for(var i = 1; i < form.pistons.options.length; i)
        form.pistons.options[1] = null;
    for(var i = 1; i < form.heads.options.length; i)
        form.heads.options[1] = null;
    for(var i = 1; i < form.rods.options.length; i)
        form.rods.options[1] = null;
    for(var i = 1; i < form.cranks.options.length; i)
        form.cranks.options[1] = null;
    for(var i = 1; i < form.cams.options.length; i)
        form.cams.options[1] = null;
    for(var i = 1; i < form.engines.options.length; i)
        form.engines.options[1] = null;

}

function importData(form, source){

    clearData(form);
    doexport = false;

    str = form.defaultdata.value;

    if(source == "form"){

        str += "\n"+form.data.value;

    } else {

        blockstr = getCookie("TheHelixEDS:Blocks");
        crankstr = getCookie("TheHelixEDS:Cranks");
        headstr = getCookie("TheHelixEDS:Heads");
        rodstr = getCookie("TheHelixEDS:Rods");
        pistonstr = getCookie("TheHelixEDS:Pistons");
        camstr = getCookie("TheHelixEDS:Cams");
        enginestr = getCookie("TheHelixEDS:Engines");

        if(blockstr == null &&
            crankstr == null &&
            headstr == null &&
            rodstr == null &&
            pistonstr == null &&
            camstr == null &&
            enginestr == null){

            //alert("As this is your first time, default values will be loaded.\n\nYou can then save any changes made and they will be automatically loaded on your next visit. Enjoy!");
            str = form.defaultdata.value;
            //export at end
            doexport = true;

        } else {

            str += "\n"+blockstr.toString()+
                crankstr.toString()+
                headstr.toString()+
                rodstr.toString()+
                pistonstr.toString()+
                camstr.toString()+
                enginestr.toString();

        }

    }

    lines = str.split("\n");

    for(var i = 0; i < lines.length; i++){

        cur = lines[i];

        values = cur.slice(3);
        data = values.split(",");

        if(cur.slice(0,2) == "bl"){

            nextBlockId = blocks.length; 
            newOption = new Option(data[1], nextBlockId, false, false);

            j = 0;

            blocks[nextBlockId] = new Array();
            blocks[nextBlockId]['id'] = nextBlockId;
            blocks[nextBlockId]['who'] = data[j++];
            blocks[nextBlockId]['name'] = data[j++];
            blocks[nextBlockId]['description'] = data[j++];
            blocks[nextBlockId]['cylinders'] = data[j++];
            blocks[nextBlockId]['height'] = data[j++];
            blocks[nextBlockId]['bore'] = data[j++];
            blocks[nextBlockId]['overbore'] = data[j++];

            form.blocks.options[form.blocks.length] = newOption;

        } else if(cur.slice(0,2) == "pi"){

            nextId = pistons.length; 
            newOption = new Option(data[1], nextId, false, false);

            j = 0;

            pistons[nextId] = new Array();
            pistons[nextId]['id'] = nextId;
            pistons[nextId]['who'] = data[j++];
            pistons[nextId]['name'] = data[j++];
            pistons[nextId]['description'] = data[j++];
            pistons[nextId]['bore'] = data[j++];
            pistons[nextId]['pin_height'] = data[j++];
            pistons[nextId]['pin_diametre'] = data[j++];
            pistons[nextId]['cc'] = data[j++];
            pistons[nextId]['weight'] = data[j++];

            form.pistons.options[form.pistons.length] = newOption;

        } else if(cur.slice(0,2) == "he"){

            nextId = heads.length; 
            newOption = new Option(data[1], nextId, false, false);

            j = 0;

            heads[nextId] = new Array();
            heads[nextId]['id'] = nextId;
            heads[nextId]['who'] = data[j++];
            heads[nextId]['name'] = data[j++];
            heads[nextId]['description'] = data[j++];
            heads[nextId]['cc'] = data[j++];
            heads[nextId]['valves'] = data[j++];
            //heads[nextId]['valve_depth'] = data[j++];
            heads[nextId]['intake_valve_diametre'] = data[j++];
            heads[nextId]['exhaust_valve_diametre'] = data[j++];

            form.heads.options[form.heads.length] = newOption;

        } else if(cur.slice(0,2) == "ro"){

            nextId = rods.length; 
            newOption = new Option(data[1], nextId, false, false);

            j = 0;

            rods[nextId] = new Array();
            rods[nextId]['id'] = nextId;
            rods[nextId]['who'] = data[j++];
            rods[nextId]['name'] = data[j++];
            rods[nextId]['description'] = data[j++];
            rods[nextId]['rod_length'] = data[j++];
            rods[nextId]['piston_end_bore'] = data[j++];
            rods[nextId]['piston_end_thickness'] = data[j++];
            rods[nextId]['big_end_bore'] = data[j++];
            rods[nextId]['big_end_thickness'] = data[j++];
            rods[nextId]['weight'] = data[j++];

            form.rods.options[form.rods.length] = newOption;


        } else if(cur.slice(0,2) == "cr"){
            nextId = cranks.length; 
            newOption = new Option(data[1], nextId, false, false);

            j = 0

            cranks[nextId] = new Array();
            cranks[nextId]['id'] = nextId;
            cranks[nextId]['who'] = data[j++];
            cranks[nextId]['name'] = data[j++];
            cranks[nextId]['description'] = data[j++];
            cranks[nextId]['stroke'] = data[j++];
            cranks[nextId]['rod_bearing_od'] = data[j++];
            //cranks[nextId]['rod_bearing_id'] = data[j++];
            cranks[nextId]['rod_width'] = data[j++];

            form.cranks.options[form.cranks.length] = newOption;


        } else if(cur.slice(0,2) == "ca"){
            nextId = cams.length; 
            newOption = new Option(data[1], nextId, false, false);

            j = 0;

            cams[nextId] = new Array();
            cams[nextId]['id'] = nextId;
            cams[nextId]['who'] = data[j++];
            cams[nextId]['name'] = data[j++];
            cams[nextId]['description'] = data[j++];
            cams[nextId]['intake_lift'] = data[j++];
            cams[nextId]['exhaust_lift'] = data[j++];
            cams[nextId]['intake_duration'] = data[j++];
            cams[nextId]['exhaust_duration'] = data[j++];
            cams[nextId]['intake_opens'] = data[j++];
            cams[nextId]['exhaust_opens'] = data[j++];

            form.cams.options[form.cams.length] = newOption;

        } else if(cur.slice(0,2) == "en"){
            nextId = engines.length; 
            newOption = new Option(data[1], nextId, false, false);

            j = 0;

            engines[nextId] = new Array();
            engines[nextId]['id'] = nextId;
            engines[nextId]['who'] = data[j++];
            engines[nextId]['name'] = data[j++];
            engines[nextId]['description'] = data[j++];
            engines[nextId]['block'] = data[j++];
            engines[nextId]['crank'] = data[j++];
            engines[nextId]['head'] = data[j++];
            engines[nextId]['rod'] = data[j++];
            engines[nextId]['piston'] = data[j++];
            engines[nextId]['cam'] = data[j++];
            engines[nextId]['gasket_height'] = data[j++];
            engines[nextId]['redline'] = data[j++];

            form.engines.options[form.engines.length] = newOption;

        }


    }

    if(doexport == true){
        exportData(form, false);
    }


}
-->
