// JavaScript Document

priceList = new Array();
priceList[0] = new Array (270,370,470,570,670,870,970,1070,1170,1270,1370); //4x5
priceList[1] = new Array (280,380,480,580,680,880,980,1080,1180,1280,1380); //5x7
priceList[2] = new Array (290,390,490,590,690,890,990,1090,1190,1290,1390); //4x9

stockList = new Array();
stockList[0] = new Array (10,30,50,70,90,120,140,170,190,210,230); //80#
stockList[1] = new Array (20,50,70,90,120,140,980,1080,1180,1280,1380); //100#
stockList[2] = new Array (50,90,120,140,160,180,990,1090,1190,1290,1390); //120#

foldList = new Array();
foldList[0] = new Array (10,30,50,70,90,120,140,170,190,210,230); //NoFold
foldList[1] = new Array (20,50,70,90,120,140,980,1080,1180,1280,1380); //Bifold
foldList[2] = new Array (50,90,120,140,160,180,990,1090,1190,1290,1390); //Trifold
foldList[3] = new Array (20,50,70,90,120,140,980,1080,1180,1280,1380); //Z-Fold
foldList[4] = new Array (50,90,120,140,160,180,990,1090,1190,1290,1390); //GateFold

colorList = new Array();
colorList[0] = new Array (20,50,70,90,120,140,980,1080,1180,1280,1380); //Full Color Both Sides - 4/4
colorList[1] = new Array (50,90,120,140,160,180,990,1090,1190,1290,1390); //Full Color and Black - 4/1
colorList[2] = new Array (10,30,50,70,90,120,140,170,190,210,230); //Black Both Sides - 1/1

postageList = new Array();
postageList[0] = new Array (230,460,690,920,1150,2300,3450,4600,5750,11500,23000); //Standard Postage 
postageList[1] = new Array (759,660,759,1320,2320,3320,4320,5320,7320,28320,33320); //First Class Postage
postageList[2] = new Array (130,260,490,620,950,2100,3150,4100,5150,9500,18000); //Non-Profit Postage 

designList = new Array();
designList[0] = new Array (0,0,0,0,0,0,0,0,0,0,0); //Design Supplied 
designList[1] = new Array (250,250,250,250,250,250,250,250,250,250,250); //Design Needed 



function calc(){
 var frm = document.autoSumForm;
  var product1Idx = frm.product1.selectedIndex-1;  
  var product2Idx = frm.product2.selectedIndex-1; 
  var product3Idx = frm.product3.selectedIndex-1; 
  var product4Idx = frm.product4.selectedIndex-1; 
  var product5Idx = frm.product5.selectedIndex-1; 
  var product6Idx = frm.product6.selectedIndex-1; 

  var qtyIdx = frm.qty.selectedIndex-1;

  if (product1Idx!=-1 && product2Idx!=-1 && product3Idx!=-1 && product4Idx!=-1 &&  product5Idx!=-1 && product6Idx!=-1 && qtyIdx!=-1) {
    var total = ((colorList[product1Idx][qtyIdx] + priceList[product2Idx][qtyIdx] + stockList[product3Idx][qtyIdx] + foldList[product4Idx][qtyIdx] + postageList[product5Idx][qtyIdx] + designList[product6Idx][qtyIdx]));
    frm.total.value = "$ " + total.toFixed(2);
    avg = (total/frm.qty.value);
    frm.perpiece.value = "$ " + avg.toFixed(2);
    frm.price.value =  total.toFixed(2);

  } else {
    frm.total.value = "";
    frm.price.value = "";
}
   return true;
}
 
