// JavaScript Document

function MM_findObj(n, d) { //v4.01
   var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
     d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
   if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
   for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
   if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
// end validation from unified site

function dm(amount)
{
string = "" + amount;
dec = string.length - string.indexOf('.');
if (string.indexOf('.') == -1)
return string + '.00';
if (dec == 1)
return string + '00';
if (dec == 2)
return string + '0';
if (dec > 3)
return string.substring(0,string.length-dec+3);
return string;
}
function calculate()
{
	QtyA = 0; QtyB = 0; QtyC = 0; QtyD = 0; QtyE = 0; QtyF = 0; QtyG = 0; QtyH = 0; QtyI = 0; QtyJ = 0; QtyK = 0; QtyL = 0; QtyM = 0; QtyN = 0; QtyO = 0; QtyP = 0; QtyQ = 0; QtyR = 0; QtyS = 0; QtyT = 0; QtyU = 0; QtyV = 0; QtyW = 0; QtyX = 0; QtyY = 0; QtyZ = 0; QtyAA = 0; QtyBB = 0; QtyCC = 0; QtyDD = 0;
	TotA = 0; TotB = 0; TotC = 0; TotD = 0; TotE = 0; TotF = 0; TotG = 0; TotH = 0; TotI = 0; TotJ = 0; TotK = 0; TotL = 0; TotM = 0; TotN = 0; TotO = 0; TotP = 0; TotQ = 0; TotR = 0; TotS = 0; TotT = 0; TotU = 0; TotV = 0; TotW = 0; TotX = 0; TotY = 0; TotZ = 0; TotAA = 0; TotBB = 0; TotCC = 0; TotDD = 0;
	PrcA = 30.00; PrcB = 30.00; PrcC = 20.00; PrcD = 15.00; PrcE = 15.00; PrcF = 10.00; PrcG = 20.00; PrcH = 5.00; PrcI = 10.00; PrcJ = 20.00; PrcK = 10.00; PrcL = 20.00; PrcM = 20.00; PrcN = 10.00; PrcO = 10.00; PrcP = 50.00; PrcQ = 20.00; PrcR = 5.00; PrcS = 20.00; PrcT = 25.00; PrcU = 10.00; PrcV = 2.00; PrcW = 50.00; PrcX = 40.00; PrcY = 30.00; PrcZ = 30.00; PrcAA = 20.00; PrcBB = 15.00; PrcCC = 15.00; PrcDD = 10.00;

   if (document.ofrm.qtyA.value > "")
      { QtyA = document.ofrm.qtyA.value };
   document.ofrm.qtyA.value = eval(QtyA);

   if (document.ofrm.qtyB.value > "")
      { QtyB = document.ofrm.qtyB.value };
   document.ofrm.qtyB.value = eval(QtyB);

   if (document.ofrm.qtyC.value > "")
      { QtyC = document.ofrm.qtyC.value };
   document.ofrm.qtyC.value = eval(QtyC);

    if (document.ofrm.qtyD.value > "")
      { QtyD = document.ofrm.qtyD.value };
   document.ofrm.qtyD.value = eval(QtyD);

   if (document.ofrm.qtyE.value > "")
      { QtyE = document.ofrm.qtyE.value };
   document.ofrm.qtyE.value = eval(QtyE);

   if (document.ofrm.qtyF.value > "")
      { QtyF = document.ofrm.qtyF.value };
   document.ofrm.qtyF.value = eval(QtyF);

   if (document.ofrm.qtyG.value > "")
      { QtyG = document.ofrm.qtyG.value };
   document.ofrm.qtyG.value = eval(QtyG);

   if (document.ofrm.qtyH.value > "")
      { QtyH = document.ofrm.qtyH.value };
   document.ofrm.qtyH.value = eval(QtyH);

   if (document.ofrm.qtyI.value > "")
      { QtyI = document.ofrm.qtyI.value };
   document.ofrm.qtyI.value = eval(QtyI);

   if (document.ofrm.qtyJ.value > "")
      { QtyJ = document.ofrm.qtyJ.value };
   document.ofrm.qtyJ.value = eval(QtyJ);

   if (document.ofrm.qtyK.value > "")
      { QtyK = document.ofrm.qtyK.value };
   document.ofrm.qtyK.value = eval(QtyK);

   if (document.ofrm.qtyL.value > "")
      { QtyL = document.ofrm.qtyL.value };
   document.ofrm.qtyL.value = eval(QtyL);

   if (document.ofrm.qtyM.value > "")
      { QtyM = document.ofrm.qtyM.value };
   document.ofrm.qtyM.value = eval(QtyM);

   if (document.ofrm.qtyN.value > "")
      { QtyN = document.ofrm.qtyN.value };
   document.ofrm.qtyN.value = eval(QtyN);

   if (document.ofrm.qtyO.value > "")
      { QtyO = document.ofrm.qtyO.value };
   document.ofrm.qtyO.value = eval(QtyO);

   if (document.ofrm.qtyP.value > "")
      { QtyP = document.ofrm.qtyP.value };
   document.ofrm.qtyP.value = eval(QtyP);

   if (document.ofrm.qtyQ.value > "")
      { QtyQ = document.ofrm.qtyQ.value };
   document.ofrm.qtyQ.value = eval(QtyQ);

   if (document.ofrm.qtyR.value > "")
      { QtyR = document.ofrm.qtyR.value };
   document.ofrm.qtyR.value = eval(QtyR);

   if (document.ofrm.qtyS.value > "")
      { QtyS = document.ofrm.qtyS.value };
   document.ofrm.qtyS.value = eval(QtyS);

   if (document.ofrm.qtyT.value > "")
      { QtyT = document.ofrm.qtyT.value };
   document.ofrm.qtyT.value = eval(QtyT);

   if (document.ofrm.qtyU.value > "")
      { QtyU = document.ofrm.qtyU.value };
   document.ofrm.qtyU.value = eval(QtyU);

   if (document.ofrm.qtyV.value > "")
      { QtyV = document.ofrm.qtyV.value };
   document.ofrm.qtyV.value = eval(QtyV);

   if (document.ofrm.qtyW.value > "")
      { QtyW = document.ofrm.qtyW.value };
   document.ofrm.qtyW.value = eval(QtyW);

   if (document.ofrm.qtyX.value > "")
      { QtyX = document.ofrm.qtyX.value };
   document.ofrm.qtyX.value = eval(QtyX);

   if (document.ofrm.qtyY.value > "")
      { QtyY = document.ofrm.qtyY.value };
   document.ofrm.qtyY.value = eval(QtyY);

   if (document.ofrm.qtyZ.value > "")
      { QtyZ = document.ofrm.qtyZ.value };
   document.ofrm.qtyZ.value = eval(QtyZ);

   if (document.ofrm.qtyAA.value > "")
      { QtyAA = document.ofrm.qtyAA.value };
   document.ofrm.qtyAA.value = eval(QtyAA);

   if (document.ofrm.qtyBB.value > "")
      { QtyBB = document.ofrm.qtyBB.value };
   document.ofrm.qtyBB.value = eval(QtyBB);

   if (document.ofrm.qtyCC.value > "")
      { QtyCC = document.ofrm.qtyCC.value };
   document.ofrm.qtyCC.value = eval(QtyCC);

   if (document.ofrm.qtyDD.value > "")
      { QtyDD = document.ofrm.qtyDD.value };
   document.ofrm.qtyDD.value = eval(QtyDD);

   TotA = QtyA * PrcA;
   document.ofrm.totalA.value = dm(eval(TotA));

   TotB = QtyB * PrcB;
   document.ofrm.totalB.value = dm(eval(TotB));

   TotC = QtyC * PrcC;
   document.ofrm.totalC.value = dm(eval(TotC));

   TotD = QtyD * PrcD;
   document.ofrm.totalD.value = dm(eval(TotD));

   TotE = QtyE * PrcE;
   document.ofrm.totalE.value = dm(eval(TotE));

   TotF = QtyF * PrcF;
   document.ofrm.totalF.value = dm(eval(TotF));

   TotG = QtyG * PrcG;
   document.ofrm.totalG.value = dm(eval(TotG));

   TotH = QtyH * PrcH;
   document.ofrm.totalH.value = dm(eval(TotH));

   TotI = QtyI * PrcI;
   document.ofrm.totalI.value = dm(eval(TotI));

   TotJ = QtyJ * PrcJ;
   document.ofrm.totalJ.value = dm(eval(TotJ));

   TotK = QtyK * PrcK;
   document.ofrm.totalK.value = dm(eval(TotK));

   TotL = QtyL * PrcL;
   document.ofrm.totalL.value = dm(eval(TotL));

   TotM = QtyM * PrcM;
   document.ofrm.totalM.value = dm(eval(TotM));

   TotN = QtyN * PrcN;
   document.ofrm.totalN.value = dm(eval(TotN));

   TotO = QtyO * PrcO;
   document.ofrm.totalO.value = dm(eval(TotO));

   TotP = QtyP * PrcP;
   document.ofrm.totalP.value = dm(eval(TotP));

   TotQ = QtyQ * PrcQ;
   document.ofrm.totalQ.value = dm(eval(TotQ));

   TotR = QtyR * PrcR;
   document.ofrm.totalR.value = dm(eval(TotR));

   TotS = QtyS * PrcS;
   document.ofrm.totalS.value = dm(eval(TotS));

   TotT = QtyT * PrcT;
   document.ofrm.totalT.value = dm(eval(TotT));

   TotU = QtyU * PrcU;
   document.ofrm.totalU.value = dm(eval(TotU));

   TotV = QtyV * PrcV;
   document.ofrm.totalV.value = dm(eval(TotV));

   TotW = QtyW * PrcW;
   document.ofrm.totalW.value = dm(eval(TotW));

   TotX = QtyX * PrcX;
   document.ofrm.totalX.value = dm(eval(TotX));

   TotY = QtyY * PrcY;
   document.ofrm.totalY.value = dm(eval(TotY));

   TotZ = QtyZ * PrcZ;
   document.ofrm.totalZ.value = dm(eval(TotZ));

   TotAA = QtyAA * PrcAA;
   document.ofrm.totalAA.value = dm(eval(TotAA));

   TotBB = QtyBB * PrcBB;
   document.ofrm.totalBB.value = dm(eval(TotBB));

   TotCC = QtyCC * PrcCC;
   document.ofrm.totalCC.value = dm(eval(TotCC));

   TotDD = QtyDD * PrcDD;
   document.ofrm.totalDD.value = dm(eval(TotDD));

   IPSub =
      eval(TotX) +
      eval(TotY) +
      eval(TotZ) +
      eval(TotAA) +
      eval(TotBB) +
      eval(TotCC) +
      eval(TotDD) ;
	 
   document.ofrm.IPTotal.value = dm(eval(IPSub));

   DigSub =
      eval(TotA) +
      eval(TotB) +
      eval(TotC) +
      eval(TotD) +
      eval(TotE) +
      eval(TotF) ;
	 
   document.ofrm.DigitalTotal.value = dm(eval(DigSub));

	CCSub =
      eval(TotG) +
      eval(TotH) +
      eval(TotI) +
      eval(TotJ) +
      eval(TotK) ;
	 
   document.ofrm.CCDesignTotal.value = dm(eval(CCSub));

	UCBSub =
      eval(TotL) +
      eval(TotM) +
      eval(TotN) +
      eval(TotO) +
      eval(TotP) +
      eval(TotQ) +
      eval(TotR) ;
	 
   document.ofrm.UCBTotal.value = dm(eval(UCBSub));

	UMSub =
      eval(TotS) +
      eval(TotT) +
      eval(TotU) ;
	 
   document.ofrm.UMTotal.value = dm(eval(UMSub));

	UCESub =
      eval(TotV) +
      eval(TotW) ;
	 
   document.ofrm.UCETotal.value = dm(eval(UCESub));

	FinalRebate =
      eval(IPSub) +
      eval(DigSub) +
      eval(CCSub) +
      eval(UCBSub) +
      eval(UMSub) +
      eval(UCESub) ;
	 
   document.ofrm.GrandTotal.value = dm(eval(FinalRebate));

}