
var partPick    = "";
var surfacePick = "";
var formatPick  = "";
var sizePick    = "";

var Data            = new Array();
var description     = "";
var descriptionOrg  = "";
var cost            = "";
var costOrg         = "";
var weight          = "";
var weightOrg       = "";

var screenAddon = "";
var quietMotor  = '<input type="checkbox" name="quietMotor" value="yes" onClick="addonSelected()">Quiet Motor';
var lowVoltage  = '<input type="checkbox" name="lowVoltage" value="yes" onClick="addonSelected()">Low Voltage Control Built-In';

var quietMotorPrice = 155.99;
var lowVoltagePrice = 199.99;

function setOptions(chosen) {
var selbox = document.myform.opttwo;
selbox.options.length = 0;
if (chosen == " ") {
selbox.options[selbox.options.length] = new Option('Please select one of the options above first',' ');
}

if (chosen == "999") {
selbox.options[selbox.options.length] = new Option('Screen Format',' ');
setOptionsTwo("99");
}
if (chosen == "Matte White") {
selbox.options[selbox.options.length] = new Option('Screen Format','99');
selbox.options[selbox.options.length] = new Option('Square','Square');
}

surfacePick = chosen;
}

function setOptionsTwo(chosen) {
var selbox = document.myform.optthree;
selbox.options.length = 0;

if (chosen == " ") {
selbox.options[selbox.options.length] = new Option('Please select one of the options above first',' ');
}
if (chosen == "99") {
selbox.options[selbox.options.length] = new Option('Screen Size','9999');
}
if (chosen == "Square" && surfacePick == "Matte White") {
selbox.options[selbox.options.length] = new Option('Screen Size','9999');
selbox.options[selbox.options.length] = new Option('10 ft6 inch x 14 ft','10 ft6 inch x 14 ft');
selbox.options[selbox.options.length] = new Option('12 ft x 16 ft','12 ft x 16 ft');
selbox.options[selbox.options.length] = new Option('13 ft6 inch x 18 ft','13 ft6 inch x 18 ft');
selbox.options[selbox.options.length] = new Option('14 ft x 14 ft','14 ft x 14 ft');
selbox.options[selbox.options.length] = new Option('15 ft x 20 ft','15 ft x 20 ft');
selbox.options[selbox.options.length] = new Option('16 ft x 16 ft','16 ft x 16 ft');
selbox.options[selbox.options.length] = new Option('18 ft x 18 ft','18 ft x 18 ft');
selbox.options[selbox.options.length] = new Option('18 ft x 24 ft','18 ft x 24 ft');
selbox.options[selbox.options.length] = new Option('20 ft x 20 ft','20 ft x 20 ft');
selbox.options[selbox.options.length] = new Option('21 ft x 28 ft','21 ft x 28 ft');
selbox.options[selbox.options.length] = new Option('22 ft6 inch x 30 ft','22 ft6 inch x 30 ft');
selbox.options[selbox.options.length] = new Option('24 ft x 24 ft','24 ft x 24 ft');
selbox.options[selbox.options.length] = new Option('28 ft x 28 ft','28 ft x 28 ft');
selbox.options[selbox.options.length] = new Option('30 ft x 30 ft','30 ft x 30 ft');
selbox.options[selbox.options.length] = new Option('6 ft x 16 ft','6 ft x 16 ft');
selbox.options[selbox.options.length] = new Option('7 ft x 18 ft','7 ft x 18 ft');
}


 formatPick = chosen; 
}
function storeSize(chosen) {
sizePick= chosen;
}

function saveValues() {
document.Prod.PartNo.value = partPick;
document.Prod.Item.value = description;
document.Prod.Price.value = cost;
document.Prod.Weight.value = weight;
}

function displayValues() {
document.getElementById('unitInfo').innerHTML = surfacePick + " " + formatPick + " " + sizePick
document.getElementById('cost').innerHTML = "Our Price $" + cost +" Including Free Shipping<br><br>"

document.getElementById('button').innerHTML = '<input type="submit" value="ADD TO CART" class="btn">';
}

function displayAddons() {
  document.getElementById('access').innerHTML = screenAddon;
}

function ChooseProd() {

Data[0] = new Array("40302","Matte White","Square","10 ft6 inch x 14 ft","","","","Scenic Roller, 10 ft6 inch x 14 ft, Square, Matte White","1560.6","148");
Data[1] = new Array("40308","Matte White","Square","12 ft x 16 ft","","","","Scenic Roller, 12 ft x 16 ft, Square, Matte White","1642.95","161");
Data[2] = new Array("40314","Matte White","Square","13 ft6 inch x 18 ft","","","","Scenic Roller, 13 ft6 inch x 18 ft, Square, Matte White","1753.65","245");
Data[3] = new Array("40305","Matte White","Square","14 ft x 14 ft","","","","Scenic Roller, 14 ft x 14 ft, Square, Matte White","1667.25","164");
Data[4] = new Array("40320","Matte White","Square","15 ft x 20 ft","","","","Scenic Roller, 15 ft x 20 ft, Square, Matte White","1968.3","562");
Data[5] = new Array("40311","Matte White","Square","16 ft x 16 ft","","","","Scenic Roller, 16 ft x 16 ft, Square, Matte White","1800.9","215");
Data[6] = new Array("40317","Matte White","Square","18 ft x 18 ft","","","","Scenic Roller, 18 ft x 18 ft, Square, Matte White","1996.65","416");
Data[7] = new Array("40380","Matte White","Square","18 ft x 24 ft","","","","Scenic Roller, 18 ft x 24 ft, Square, Matte White","2085.75","674");
Data[8] = new Array("40323","Matte White","Square","20 ft x 20 ft","","","","Scenic Roller, 20 ft x 20 ft, Square, Matte White","2019.6","575");
Data[9] = new Array("40368","Matte White","Square","21 ft x 28 ft","","","","Scenic Roller, 21 ft x 28 ft, Square, Matte White","2664.9","787");
Data[10] = new Array("40356","Matte White","Square","22 ft6 inch x 30 ft","","","","Scenic Roller, 22 ft6 inch x 30 ft, Square, Matte White","2889","850");
Data[11] = new Array("40377","Matte White","Square","24 ft x 24 ft","","","","Scenic Roller, 24 ft x 24 ft, Square, Matte White","2411.1","690");
Data[12] = new Array("40365","Matte White","Square","28 ft x 28 ft","","","","Scenic Roller, 28 ft x 28 ft, Square, Matte White","3092.85","800");
Data[13] = new Array("40353","Matte White","Square","30 ft x 30 ft","","","","Scenic Roller, 30 ft x 30 ft, Square, Matte White","3576.15","880");
Data[14] = new Array("40329","Matte White","Square","6 ft x 16 ft","","","","Scenic Roller, 6 ft x 16 ft, Square, Matte White","1426.95","145");
Data[15] = new Array("40332","Matte White","Square","7 ft x 18 ft","","","","Scenic Roller, 7 ft x 18 ft, Square, Matte White","1498.5","160");


   for (i = 0; i < Data.length; i++) {
        if (surfacePick == Data[i][1] && formatPick == Data[i][2] && sizePick == Data[i][3])
        partPick = Data[i][0];
   }

    for (i = 0; i < Data.length; i++) {
        if (partPick == Data[i][0]) {
            if (Data[i][5] == "ql")     screenAddon = quietMotor + "<br>" + lowVoltage;
        else if (Data[i][4] == "q" ) {
            screenAddon = quietMotor;
            if (Data[i][6] == "l")  screenAddon = quietMotor + "<br>" + lowVoltage;
        }
        else if (Data[i][6] == "l") screenAddon = lowVoltage;
        else screenAddon = "";

            description = Data[i][7];
            descriptionOrg = description;
            cost = parseFloat(Data[i][8]);
            costOrg = cost;
            weight = Data[i][9];
            weightOrg = weight;
        }
   }

   saveValues();
    displayValues();
}



function CheckBox() {
partPick = partPick.substring(0,6);
cost = costOrg;
description = descriptionOrg;

if (document.Prod.quietMotor) {
    if (document.Prod.quietMotor.checked) {
        document.Prod.quietMotor.setAttribute("checked","checked");
        partPick = partPick + "Q";
        cost = cost + quietMotorPrice;
        description = description + ", With Quiet Motor";

    } else {
        document.Prod.quietMotor.removeAttribute("checked");
        partPick = partPick.replace("Q","");

    }

}

    if (document.Prod.lowVoltage) {
        if (document.Prod.lowVoltage.checked) {
        document.Prod.lowVoltage.setAttribute("checked","checked");
        partPick = partPick + "L";
        cost = cost + lowVoltagePrice;
        description = description + ", With Low Voltage Controller";

    } else {
        document.Prod.lowVoltage.removeAttribute("checked");
        partPick = partPick.replace("L","");

    }

}
   if (document.Prod.quietMotor && document.Prod.lowVoltage) {
        if (document.Prod.quietMotor.checked && document.Prod.lowVoltage.checked) {
            partPick = partPick.substring(0,6) + "QL";
            cost = costOrg + quietMotorPrice + lowVoltagePrice;
            description = descriptionOrg + ", With Quiet Motor & Low Voltage Controller";
    }
}

cost = cost.toFixed(2);
}

function addonSelected() {
     CheckBox();
     saveValues();
     displayValues();
}

function resetCost() {
     if (sizePick != 9999 && formatPick != 99)
         displayAddons()
     else {
          document.getElementById('access').innerHTML = "";
          document.getElementById('unitInfo').innerHTML = "";
          document.getElementById('cost').innerHTML = "Select a Material, Format and Screen Size below<br><br>";
          document.getElementById('button').innerHTML = '<input disabled type="submit"value="ADD TO CART" class="btn">';
     }
}

