var partNum = new Array(15);

var cntParts = 0;

// Removes a row/fields from the Parts table
function removeFromPartTbl(removeId) {
  cntParts--;
  partNum[removeId] = null;
  
  var getParentTbl = document.getElementById('partTbl');
  var getChildElem = document.getElementById('tbodyFile_' + removeId);
  
  getParentTbl.removeChild(getChildElem);
  
  document.getElementById('partCount').className = 'parts_' + cntParts;
}

// Adds a row/fields to the Parts table
function addToPartTbl(tblId) {
  cntParts++;
  
  for (i = 0; i < partNum.length; i++) {
    if (!partNum[i]) {
      partNum[i] = i + 1;
      break;
    }
  }
  
  var rowClass = 'raqFileTblRow';
  var getTbl = document.getElementById(tblId);

  var newBody = document.createElement('tbody');
  newBody.id = 'tbodyFile_' + i;

  // row for top table border
  var newTopTblRow = getTbl.insertRow(-1);
  var newTopTblBrdr = newTopTblRow.insertCell(-1);
  newTopTblBrdr.colSpan = '4';
  var topTblBrdrDiv = document.createElement('div');
  topTblBrdrDiv.style.margin = '20px 0 0 0';
  var topTblBrdrImg = document.createElement('img');
  topTblBrdrImg.src = 'img/bg_raq_top.gif';
  topTblBrdrImg.alt = '';

  // row for title and delete link
  var newRow1 = getTbl.insertRow(-1);
  newRow1.className = rowClass;

  var newTitle = newRow1.insertCell(-1);
  newTitle.className = 'raqTitle';
  newTitle.colSpan = '2';
  newTitle.innerHTML = 'Part Details ' + i;

  var newRemoveLink = newRow1.insertCell(-1);
  newRemoveLink.className = 'raqRemove';
  newRemoveLink.colSpan = '2';
  var aTag = document.createElement('a');
  aTag.href = 'javascript:removeFromPartTbl(' + i + ');';
  aTag.innerHTML = 'Delete Part';

  // row for divider line
  var newRow2 = getTbl.insertRow(-1);
  newRow2.className = rowClass;

  var newLine = newRow2.insertCell(-1);
  newLine.colSpan = '4';
  var line1 = document.createElement('div');
  line1.className = 'horizLine';

  //row for file upload, part name and quantity fields
  var newRow3 = getTbl.insertRow(-1);
  newRow3.className = rowClass;

  var newFileUpload = newRow3.insertCell(-1);
  newFileUpload.className = 'raqFile';
  newFileUpload.id = 'raqFile_' + i;
  newFileUpload.colSpan = '2';
  var pFUFormLabel = document.createElement('p');
  pFUFormLabel.className = 'formlabel';
  pFUFormLabel.innerHTML = 'Select a file for uploading';
  var pFUFormField = document.createElement('p');
  pFUFormField.className = 'formfield';
  var inputUploadFile = document.createElement('input');
  inputUploadFile.name = 'file' + i;
  inputUploadFile.type = 'file';
  inputUploadFile.size = '40';
  inputUploadFile.id = 'uploadfile' + i;

  var newPartName = newRow3.insertCell(-1);
  newPartName.className = 'raqPartName';
  newPartName.id = 'raqPartName_' + i;
  var pPNFormLabel = document.createElement('p');
  pPNFormLabel.className = 'formlabel';
  pPNFormLabel.innerHTML = 'Part Name';
  var pPNFormField = document.createElement('p');
  pPNFormField.className = 'formfield';
  var inputPartName = document.createElement('input');
  inputPartName.type = 'text';
  inputPartName.style.width = '200px';
  inputPartName.id = 'uploader_partname_' + i;
  inputPartName.name = 'uploader_partname_' + i;
  inputPartName.setAttribute('disabled', 'disabled');

  var newQuantity = newRow3.insertCell(-1);
  newQuantity.className = 'raqQuantity';
  newQuantity.id = 'raqQuantity_' + i;
  var pQFormLabel = document.createElement('p');
  pQFormLabel.className = 'formlabel';
  pQFormLabel.innerHTML = 'Quantity';
  var pQFormField = document.createElement('p');
  pQFormField.className = 'formfield';
  var inputQuantity = document.createElement('input');
  inputQuantity.type = 'text';
  inputQuantity.style.width = '50px';
  inputQuantity.id = 'uploader_quantity_' + i;
  inputQuantity.name = 'uploader_quantity_' + i;

  // row for divider line
  var newRow4 = getTbl.insertRow(-1);
  newRow4.className = rowClass;

  var newLine2 = newRow4.insertCell(-1);
  newLine2.colSpan = '4';
  var line2 = document.createElement('div');
  line2.className = 'horizLine';

  // row for select drop downs: process, material, and finish
  var newRow5 = getTbl.insertRow(-1);
  newRow5.className = rowClass;

  var newProcess = newRow5.insertCell(-1);
  newProcess.className = 'raqProcess';
  newProcess.id = 'raqProcess_' + i;
  var pSPFormLabel = document.createElement('p');
  pSPFormLabel.className = 'formlabel';
  pSPFormLabel.innerHTML = 'Select a Process';
  var pSPFormField = document.createElement('p');
  pSPFormField.className = 'formfield';
  var selectProcess = document.createElement('select');
  selectProcess.size = '1';
  selectProcess.style.width = '200px';
  selectProcess.id = 'uploader_process_' + i;
  selectProcess.name = 'uploader_process_' + i;
  var spOption0 = document.createElement('option');
  spOption0.setAttribute('value', '');
  spOption0.innerHTML = 'Select a process...';
  var spOption1 = document.createElement('option');
  spOption1.setAttribute('value', 'FDM');
  spOption1.innerHTML = 'FDM';
  var spOption2 = document.createElement('option');
  spOption2.setAttribute('value', 'Polyjet');
  spOption2.innerHTML = 'Polyjet';
  var spOption3 = document.createElement('option');
  spOption3.setAttribute('value', 'SLA');
  spOption3.innerHTML = 'SLA';
  var spOption4 = document.createElement('option');
  spOption4.setAttribute('value', 'SLS');
  spOption4.innerHTML = 'SLS';
  var spOption5 = document.createElement('option');
  spOption5.setAttribute('value', 'MJM');
  spOption5.innerHTML = 'MJM HR';
  var spOption6 = document.createElement('option');
  spOption6.setAttribute('value', 'Urethane');
  spOption6.innerHTML = 'Urethane Castings';
  var spOption7 = document.createElement('option');
  spOption7.setAttribute('value', 'CNC');
  spOption7.innerHTML = 'CNC (iges file required)';

  selectProcess.appendChild(spOption0);
  selectProcess.appendChild(spOption1);
  selectProcess.appendChild(spOption2);
  selectProcess.appendChild(spOption3);
  selectProcess.appendChild(spOption4);
  selectProcess.appendChild(spOption5);
  selectProcess.appendChild(spOption6);
  selectProcess.appendChild(spOption7);

  var newMaterial = newRow5.insertCell(-1);
  newMaterial.className = 'raqMaterial';
  newMaterial.id = 'raqMaterial_' + i;
  var pSMFormLabel = document.createElement('p');
  pSMFormLabel.className = 'formlabel';
  pSMFormLabel.innerHTML = 'Select a Material';
  var pSMFormField = document.createElement('p');
  pSMFormField.className = 'formfield';
  var selectMaterial = document.createElement('select');
  selectMaterial.size = '1';
  selectMaterial.style.width = '200px';
  selectMaterial.id = 'uploader_material_' + i;
  selectMaterial.name = 'uploader_material_' + i;
  var smOption1 = document.createElement('option');
  smOption1.setAttribute('value', '');
  smOption1.innerHTML = 'Select a process first...';

  selectMaterial.appendChild(smOption1);

  var newFinish = newRow5.insertCell(-1);
  newFinish.className = 'raqFinish';
  newFinish.id = 'raqFinish_' + i;
  newFinish.colSpan = '2';
  var pSFFormLabel = document.createElement('p');
  pSFFormLabel.className = 'formlabel';
  pSFFormLabel.innerHTML = 'Finish Level';
  var pSFFormField = document.createElement('p');
  pSFFormField.className = 'formfield';
  var selectFinish = document.createElement('select');
  selectFinish.size = '1';
  selectFinish.style.width = '200px';
  selectFinish.id = 'uploader_finish_' + i;
  selectFinish.name = 'uploader_finish_' + i;
  var sfOption1 = document.createElement('option');
  sfOption1.setAttribute('value', '');
  sfOption1.innerHTML = 'Select a process first...';

  selectFinish.appendChild(sfOption1);

  // row for top table border
  var newBtmTblRow = getTbl.insertRow(-1);
  var newBtmTblBrdr = newBtmTblRow.insertCell(-1);
  newBtmTblBrdr.colSpan = '4';
  var btmTblBrdrDiv = document.createElement('div');
  var btmTblBrdrImg = document.createElement('img');
  btmTblBrdrImg.src = 'img/bg_raq_btm.gif';
  btmTblBrdrImg.alt = '';


  getTbl.appendChild(newBody);
  
  newBody.appendChild(newTopTblRow);
  newBody.appendChild(newRow1);
  newBody.appendChild(newRow2);
  newBody.appendChild(newRow3);
  newBody.appendChild(newRow4);
  newBody.appendChild(newRow5);
  newBody.appendChild(newBtmTblRow);
  
  newTopTblBrdr.appendChild(topTblBrdrDiv);
  topTblBrdrDiv.appendChild(topTblBrdrImg);
  
  newBtmTblBrdr.appendChild(btmTblBrdrDiv);
  btmTblBrdrDiv.appendChild(btmTblBrdrImg);

  newRemoveLink.appendChild(aTag);
  newLine.appendChild(line1);
  newLine2.appendChild(line2);
  
  newFileUpload.appendChild(pFUFormLabel);
  newFileUpload.appendChild(pFUFormField);
  newPartName.appendChild(pPNFormLabel);
  newPartName.appendChild(pPNFormField);
  newQuantity.appendChild(pQFormLabel);
  newQuantity.appendChild(pQFormField);
  newProcess.appendChild(pSPFormLabel);
  newProcess.appendChild(pSPFormField);
  newMaterial.appendChild(pSMFormLabel);
  newMaterial.appendChild(pSMFormField);
  newFinish.appendChild(pSFFormLabel);
  newFinish.appendChild(pSFFormField);
  pFUFormField.appendChild(inputUploadFile);
  pPNFormField.appendChild(inputPartName);
  pQFormField.appendChild(inputQuantity);
  pSPFormField.appendChild(selectProcess);
  pSMFormField.appendChild(selectMaterial);
  pSFFormField.appendChild(selectFinish);
  
  document.getElementById('partCount').className = 'parts_' + cntParts;

  addListeners();
}

function addListeners() {
  for (i = 0; i < partNum.length; i++) {
    if (partNum[i]) {
      var el = document.getElementById('uploadfile' + i);
      var e2 = document.getElementById('uploader_process_' + i);
      if (el.addEventListener){
        var k = i;
        el.addEventListener('change', function () { getPartName(k); }, false);
        e2.addEventListener('change', function () { chgDropDowns(e2.value, k); }, false);
      } else if (el.attachEvent) {
        var k = i;
        el.attachEvent('onchange', function () { getPartName(k); });
        e2.attachEvent('onchange', function () { chgDropDowns(e2.value, k); });
      }
    }
  }
}

// Validation for Request a Quote form
function checkform() {
  var found = true;
  
  for (i = 0; i < partNum.length; i++) {
    if (partNum[i]) {
      if ($('uploadfile' + Number(partNum[i] - 1)).value.length == 0) {
        found = false;
        document.getElementById('raqFile_' + i).className = 'raqFile alert';
      }

      if ($('uploader_partname_' + Number(partNum[i] - 1)).value.length == 0) {
        found = false;
        document.getElementById('raqPartName_' + i).className = 'raqPartName alert';
      }

      if ($('uploader_quantity_' + Number(partNum[i] - 1)).value.length == 0) {
        found = false;
        document.getElementById('raqQuantity_' + i).className = 'raqQuantity alert';
      }

      if ($('uploader_process_' + Number(partNum[i] - 1)).value.length == 0) {
        found = false;
        document.getElementById('raqProcess_' + i).className = 'raqProcess alert';
      }

      if ($('uploader_material_' + Number(partNum[i] - 1)).value.length == 0) {
        found = false;
        document.getElementById('raqMaterial_' + i).className = 'raqMaterial alert';
      }

      if ($('uploader_finish_' + Number(partNum[i] - 1)).value.length == 0) {
        found = false;
        document.getElementById('raqFinish_' + i).className = 'raqFinish alert';
      }
    }
  }

  if (!found) {
    document.getElementById('errorAlert').className = 'displayBlock';
    return false;
  }

  // Get user info
  var frmEmailAdd = '';
  if ($('uploader_email').value.length >= 0) {
    frmEmailAdd = $('uploader_email').value;
  }

  var frmPhoneNum = '';
  if ($('uploader_phone').value.length >= 0) {
    frmPhoneNum = $('uploader_phone').value;
  }

  var frmShipAdd1 = '';
  if ($('cideas_shipaddress1').value.length >= 0) {
    frmShipAdd1 = $('cideas_shipaddress1').value;
  }

  var frmShipAdd2 = '';
  if ($('cideas_shipaddress2')) {
    frmShipAdd2 = $('cideas_shipaddress2').value;
  }

  var frmShipCity = '';
  if ($('cideas_shipcity').value.length >= 0) {
    frmShipCity = $('cideas_shipcity').value;
  }

  var frmShipState = '';
  if ($('cideas_shipstate').value.length >= 0) {
    frmShipState = $('cideas_shipstate').value;
  }

  var frmShipZip = '';
  if ($('cideas_shipzip').value.length >= 0) {
    frmShipZip = $('cideas_shipzip').value;
  }

  var frmBillAdd1 = '';
  if ($('cideas_billaddress1')) {
    frmBillAdd1 = $('cideas_billaddress1').value;
  } else {
    frmBillAdd1 = 'Same as Shipping Address';
  }

  var frmBillAdd2 = '';
  if ($('cideas_billaddress2')) {
    frmBillAdd2 = $('cideas_billaddress2').value;
  }

  var frmBillCity = '';
  if ($('cideas_billcity')) {
    frmBillCity = $('cideas_billcity').value;
  }

  var frmBillState = '';
  if ($('cideas_billstate')) {
    frmBillState = $('cideas_billstate').value;
  }

  var frmBillZip = '';
  if ($('cideas_billzip')) {
    frmBillZip = $('cideas_billzip').value;
  }


  // send prelim email to notify of upload attempt
  document.getElementById('uploadtarget').src = "main.taf?erube_fh=cideas&cideas.submit.notifyEarly=1&name=" + $('uploader_name').value + "&email=" + frmEmailAdd + "&companyname=" + $('uploader_company').value + "&phone=" + frmPhoneNum + "&shipaddress1=" + frmShipAdd1 + "&shipaddress2=" + frmShipAdd2 + "&shipcity=" + frmShipCity + "&shipstate=" + frmShipState + "&shipzip=" + frmShipZip + "&billaddress1=" + frmBillAdd1 + "&billaddress2=" + frmBillAdd2 + "&billcity=" + frmBillCity + "&billstate=" + frmBillState + "&billzip=" + frmBillZip;

  var highestRes = 'No';
  if (document.uploadform.uploader_highestres.checked) {
    highestRes = 'Yes';
  }
  var bestStrength = 'No';
  if (document.uploadform.uploader_beststrength.checked) {
    bestStrength = 'Yes';
  }
  var bestPrice = 'No';
  if (document.uploadform.uploader_bestprice.checked) {
    bestPrice = 'Yes';
  }

  uploadmetadata = new Array();
  uploadmetadata['name'] = $('uploader_name').value;
  uploadmetadata['company'] = $('uploader_company').value;
  
  var indInfo = "\n" + "Email Address: " + frmEmailAdd + "\n" + "Phone Number: " + frmPhoneNum + "\n" + "Shipping Info: " + "\n" + frmShipAdd1 + "\n" + frmShipAdd2 + "\n" + frmShipCity + ", " + frmShipState + " " + frmShipZip + "\n" + "Billing Info: " + "\n" + frmBillAdd1 + "\n" + frmBillAdd2 + "\n" + frmBillCity + ", " + frmBillState + " " + frmBillZip;

  var indParts = '';
  for (i = 0; i < partNum.length; i++) {
    if (partNum[i]) {
      indParts += "\n\n" + "Part Name: " + $('uploader_partname_' + i).value + "\n" + "Quantity: " + $('uploader_quantity_' + i).value + "\n" + "Process: " + $('uploader_process_' + i).value + "\n" + "Material: " + $('uploader_material_' + i).value + "\n" + "Finish Level: " + $('uploader_finish_' + i).value;
    }
  }
  var grpParts = "\n" + $('uploader_description').value + "\n" + "Quote for Highest Available Resolution: " + highestRes + "\n" + "Quote for Best Strength: " + bestStrength + "\n" + "Quote for Best Price: " + bestPrice;
  
  $('uploader_description').value = indInfo + indParts + grpParts;
  
  uploadmetadata['description'] = $('uploader_description').value;
  
  for (i = 0; i < partNum.length; i++) {
    if (partNum[i]) {
      uploadmetadata['uploadfile' + i] = $('uploadfile' + i).value;
    }
  }

  return true;
}

// Populates part name field with file name once the file is selected selected
function getPartName(fieldNum) {
  var filePathValue = document.getElementById('uploadfile' + fieldNum).value;
  var fileName = filePathValue.substr(filePathValue.lastIndexOf('\\') + 1, filePathValue.length);
  var fieldPartName = document.getElementById('uploader_partname_' + fieldNum);

  fieldPartName.value = fileName;
}

// Populates the Material and Finish drop-downs based on the selected value of the Process dropdown
function chgDropDowns(listIndex, fieldNum) {
  var ddMaterial = document.getElementById('uploader_material_' + fieldNum);
  var ddFinish = document.getElementById('uploader_finish_' + fieldNum);

  ddMaterial.options.length = 0;
  ddFinish.options.length = 0;

  switch(listIndex) {
    case "":
    ddMaterial.options[0] = new Option("Select a process first...", "");

    ddFinish.options[0] = new Option("Select a process first...", "");

    break;

    case "FDM":
    ddMaterial.options[0] = new Option("Select a material...", "");
    ddMaterial.options[1] = new Option("ABS White (standard)", "ABS White (standard)");
    ddMaterial.options[2] = new Option("ABS Black (standard)", "ABS Black (standard)");
    ddMaterial.options[3] = new Option("ABS Steel Grey", "ABS Steel Grey");
    ddMaterial.options[4] = new Option("ABS Marigold", "ABS Marigold");
    ddMaterial.options[5] = new Option("ABS Yellow", "ABS Yellow");
    ddMaterial.options[6] = new Option("ABS Red", "ABS Red");
    ddMaterial.options[7] = new Option("ABS Blue", "ABS Blue");
    ddMaterial.options[8] = new Option("ABS Green", "ABS Green");
    ddMaterial.options[9] = new Option("ABS F1 Natural Cream", "ABS F1 Natural Cream");
    ddMaterial.options[10] = new Option("ABS F1 Black", "ABS F1 Black");
    ddMaterial.options[11] = new Option("ABS/PC Blend Black", "ABS/PC Blend Black");
    ddMaterial.options[12] = new Option("Polycarbonite White", "Polycarbonite White");
    ddMaterial.options[13] = new Option("Operators Choice", "Operators Choice");

    ddFinish.options[0] = new Option("Select a finish...", "");
    ddFinish.options[1] = new Option("Support Removed (standard)", "Support Removed (standard)");
    ddFinish.options[2] = new Option("Sanded with Primer", "Sanded with Primer");
    ddFinish.options[3] = new Option("Sanded with Paint to Match", "Sanded with Paint to Match");
    ddFinish.options[4] = new Option("Chemically Seal Surfaces", "Chemically Seal Surfaces");
    ddFinish.options[5] = new Option("Vacuum Metalized", "Vacuum Metalized");
    ddFinish.options[6] = new Option("Nickle Plated 'A' Side", "Nickle Plated 'A' Side");
    ddFinish.options[7] = new Option("Other 'see notes section'", "Other");

    break;

    case "Polyjet":
    ddMaterial.options[0] = new Option("Select a material...", "");
    ddMaterial.options[1] = new Option("Vero White (standard)", "Vero White (standard)");
    ddMaterial.options[2] = new Option("Vero Black", "Vero Black");
    ddMaterial.options[3] = new Option("Vero Blue", "Vero Blue");
    ddMaterial.options[4] = new Option("Vero Grey", "Vero Grey");
    ddMaterial.options[5] = new Option("Fullcure 720 Amber", "Fullcure 720 Amber");
    ddMaterial.options[6] = new Option("Durus Milky White", "Durus Milky White");
    ddMaterial.options[7] = new Option("Tango Plus 27A", "Tango Plus 27A");
    ddMaterial.options[8] = new Option("Tango Black 61A", "Tango Black 61A");
    ddMaterial.options[9] = new Option("Tango Grey 75A", "Tango Grey 75A");
    ddMaterial.options[10] = new Option("Operators Choice (rigid)", "Operators Choice (rigid)");
    ddMaterial.options[11] = new Option("Operators Choice (elastomer)", "Operators Choice (elastomer)");

    ddFinish.options[0] = new Option("Select a finish...", "");
    ddFinish.options[1] = new Option("Support Removed (standard)", "Support Removed (standard)");
    ddFinish.options[2] = new Option("Sanded with Primer", "Sanded with Primer");
    ddFinish.options[3] = new Option("Sanded with Paint to Match", "Sanded with Paint to Match");
    ddFinish.options[4] = new Option("Vacuum Metalized", "Vacuum Metalized");
    ddFinish.options[5] = new Option("Tango 'GT' elastomer soak", "Tango 'GT' elastomer soak");
    ddFinish.options[6] = new Option("Other 'see notes section'", "Other");

    break;

    case "SLA":
    ddMaterial.options[0] = new Option("Select a material...", "");
    ddMaterial.options[1] = new Option("Accura 60 Clear (standard)", "Accura 60 Clear (standard)");
    ddMaterial.options[2] = new Option("Accura 25 White", "Accura 25 White");
    ddMaterial.options[3] = new Option("Accura Xtreme Grey", "Accura Xtreme Grey");
    ddMaterial.options[4] = new Option("Somos 9420 White", "Somos 9420 White");
    ddMaterial.options[5] = new Option("Somos 11122 Clear", "Somos 11122 Clear");
    ddMaterial.options[6] = new Option("Somos 18420 White", "Somos 18420 White");
    ddMaterial.options[7] = new Option("Somos DMX Off-White", "Somos DMX Off-White");
    ddMaterial.options[8] = new Option("Somos Nano High Temp", "Somos Nano High Temp");
    ddMaterial.options[9] = new Option("Operators Choice (clear)", "Operators Choice (clear)");
    ddMaterial.options[10] = new Option("Operators Choice (opaque)", "Operators Choice (opaque)");

    ddFinish.options[0] = new Option("Select a finish...", "");
    ddFinish.options[1] = new Option("Lightly Sanded (standard)", "Lightly Sanded (standard)");
    ddFinish.options[2] = new Option("Support Removed Only", "Support Removed Only");
    ddFinish.options[3] = new Option("Sanded with Primer", "Sanded with Primer");
    ddFinish.options[4] = new Option("Sanded with Paint to Match", "Sanded with Paint to Match");
    ddFinish.options[5] = new Option("Vacuum Metalized", "Vacuum Metalized");
    ddFinish.options[6] = new Option("Sanded with Clear Coat", "Sanded with Clear Coat");
    ddFinish.options[7] = new Option("Polished Clear 'Lens Like'", "Polished Clear 'Lens Like'");
    ddFinish.options[8] = new Option("Quickcast", "Quickcast");
    ddFinish.options[9] = new Option("Other 'see notes section'", "Other");

    break;

    case "SLS":
    ddMaterial.options[0] = new Option("Select a material...", "");
    ddMaterial.options[1] = new Option("DuraForm Glass Filled Nylon", "DuraForm Glass Filled Nylon");
    ddMaterial.options[2] = new Option("DuraForm Nylon PA White", "DuraForm Nylon PA White");
    ddMaterial.options[3] = new Option("DuraForm EX White", "DuraForm EX White");
    ddMaterial.options[4] = new Option("DuraForm EX Black", "DuraForm EX Black");
    ddMaterial.options[5] = new Option("WINDFORM XT", "WINDFORM XT");
    ddMaterial.options[6] = new Option("Operators Choice", "Operators Choice");

    ddFinish.options[0] = new Option("Select a finish...", "");
    ddFinish.options[1] = new Option("Bead Blast (standard)", "Bead Blast (standard)");
    ddFinish.options[2] = new Option("Chemical Sealing", "Chemical Sealing");
    ddFinish.options[3] = new Option("Other 'see notes section'", "Other");

    break;

    case "MJM":
    ddMaterial.options[0] = new Option("Select a material...", "");
    ddMaterial.options[1] = new Option("HR-M100 Blue (high-res)", "HR-M100 Blue (high-res)");
    ddMaterial.options[2] = new Option("M100 Milky (low-res)", "M100 Milky (low-res)");
    ddMaterial.options[3] = new Option("Operators Choice", "Operators Choice");

    ddFinish.options[0] = new Option("Select a finish...", "");
    ddFinish.options[1] = new Option("Support Removed (standard)", "Support Removed (standard)");
    ddFinish.options[2] = new Option("Other 'see notes section'", "Other");

    break;

    case "Urethane":
    ddMaterial.options[0] = new Option("Select a material...", "");
    ddMaterial.options[1] = new Option("'ABS Like' Rigid (standard)", "'ABS Like' Rigid (standard)");
    ddMaterial.options[2] = new Option("Rigid Clear", "Rigid Clear");
    ddMaterial.options[3] = new Option("Rigid 'Polypropylene Like'", "Rigid 'Polypropylene Like'");
    ddMaterial.options[4] = new Option("Elastomer or Rubber", "Elastomer or Rubber");
    ddMaterial.options[5] = new Option("'Other' Material Not Listed", "Other");

    ddFinish.options[0] = new Option("Select a finish...", "");
    ddFinish.options[1] = new Option("Smooth Cast in Color", "Smooth Cast in Color");
    ddFinish.options[2] = new Option("Textured Cast in Color", "Textured Cast in Color");
    ddFinish.options[3] = new Option("Painted Match Metallic", "Painted Match Metallic");
    ddFinish.options[4] = new Option("Bead Blasted", "Bead Blasted");
    ddFinish.options[5] = new Option("Metalized or Nickle Plated", "Metalized or Nickle Plated");

    break;

    case "CNC":
    ddMaterial.options[0] = new Option("Select a material...", "");
    ddMaterial.options[1] = new Option("Rigid Plastic", "Rigid Plastic");
    ddMaterial.options[2] = new Option("Rigid Metal", "Rigid Metal");
    ddMaterial.options[3] = new Option("Other", "'Other' Material Not Listed");

    ddFinish.options[0] = new Option("Call for finish levels", "Call");

    break;
  }
}