var show_detail = false;
var show_quantity = false;
var save_postcard = 0;
var save_door = 0;
var save_folded = 0;
var save_flyer = 0;
var save_brochure = 0;
var save_qty = 250;
var save_mail_checked;
var current_mail_checked;
var mail_change;
var save_EDDM_checked;
var current_EDDM_checked;
var EDDM_change;
var sku = new Array();
var Dbase = 0;
var Dcolor = 0;
var Dday = 0;
var Ddiscount = 0;
var Dfold = 0;
var DUV = 0;
var DPerf = 0;
var DEDDM = 0;
var Ddms = 0;
var Dtab = 0;
var Dpostage = 0;
var Dlist = 0;
var Dvdp = 0;
var ManualQty;
var StepDown;
var qtyactual;
var save_url;

sku[0] = new Array(0,39,44,49,54,59,79,99,119,139,149,169,189,205,226,248,273,299,442,471,527,565,721,899,1317,1739,2156);//BUS Cards 4/1,15,25,30
sku[1] = new Array(0,59,64,69,74,79,99,138,169,206,236,306,352,390,416,437,448,474,626,640,689,749,1073,1338,1820,2301,2695);//6x4 Cards 4/1,15,25,30
sku[2] = new Array(0,77,83,90,97,109,139,193,236,288,331,430,495,548,585,614,629,666,880,899,968,1053,1507,1879,2556,3231,3785);//3.5x8 Cards 4/1,15,25,30
sku[3] = new Array(0,85,91,99,107,120,153,212,260,317,364,473,545,603,644,675,692,733,968,989,1065,1158,1658,2067,2812,3554,4164);//4x9 Cards or 6.2x6.2 EDDM 4/1,15,25,30
sku[4] = new Array(0,99,107,116,125,139,179,248,304,371,426,554,636,706,753,790,810,857,1133,1158,1246,1355,1941,2420,3292,4160,4874);//4x11.5 Cards mailable 4/1,25,35,45
sku[5] = new Array(0,99,107,116,125,139,179,248,304,371,426,554,636,706,753,790,810,857,1133,1158,1246,1355,1941,2420,3292,4160,4874);//4x12 Cards non-mailable or EDDM 4/1,25,35,45
sku[6] = new Array(0,99,107,116,125,139,179,248,304,371,426,554,636,706,753,790,810,857,1133,1158,1246,1355,1941,2420,3292,4160,4874);//6x8 or 5x7 Cards  4/1,25,35,45
sku[7] = new Array(0,109,119,129,139,149,199,276,338,413,474,616,707,785,837,879,919,953,1260,1288,1386,1507,2159,2691,3661,4626,5420);//6x9 Cards or 6.2x9 EDDM 4/1,25,35,45
sku[8] = new Array(0,146,156,166,176,186,239,331,406,495,568,739,848,942,1004,1054,1080,1143,1511,1544,1662,1807,2588,3227,4390,5547,6499);//6x11.5 or 6x12 EDDM Cards 4/1,25,35,45
sku[9] = new Array(0,224,238,251,265,278,358,496,608,742,852,1108,1272,1412,1506,1580,1620,1714,2266,2316,2492,2710,3882,4840,6584,8320,9748);//8.5x11 Cards 4/1,30,50,60
sku[10] = new Array(0,72,90,104,118,129,180,222,264,301,338,413,493,572,644,716,787,859,1231,1305,1454,1602,2381,3159,4716,6273,7830);//8.5x11 flyer 4/0,20,30,40
sku[11] = new Array(0,107,134,156,177,194,269,333,395,451,507,619,739,857,965,1073,1181,1288,1846,1957,2180,2403,3571,4739,7074,9410,11745);//8.5x11 flyer 4/1 (black back),30,40,50
sku[12] = new Array(0,143,179,208,236,258,359,444,527,601,676,825,985,1143,1287,1431,1574,1717,2461,2609,2907,3204,4761,6318,9432,12546,15660);//8.5x11 flyer 4/4,30,40,50
sku[13] = new Array(0,100,125,145,164,180,250,308,367,418,470,573,684,794,894,994,1093,1193,1709,1812,2019,2225,3307,4388,6550,8713,10875);//11x17 flyer 4/0,30,45,60
sku[14] = new Array(0,149,187,217,245,269,374,462,550,626,704,860,1025,1191,1341,1490,1640,1789,2564,2718,3028,3338,4960,6581,9825,13069,16313);//11x17 flyer 4/1 (black back),45,60,75
sku[15] = new Array(0,179,224,260,294,323,449,554,660,752,845,1031,1230,1429,1609,1788,1967,2147,3076,3262,3633,4005,5952,7898,11790,15683,19575);//11x17 flyer 4/4,45,60,75
sku[16] = new Array(0,159,199,231,262,287,399,493,586,668,751,917,1094,1270,1430,1590,1749,1908,2734,2899,3230,3560,5290,7020,10480,13940,17400);//8.5x11 or 8x9 brochure,30,40,50
sku[17] = new Array(0,179,224,260,294,323,449,554,660,752,845,1031,1230,1429,1609,1788,1967,2147,3076,3262,3633,4005,5952,7898,11790,15683,19575);//12x9 brochure,30,40,50
sku[18] = new Array(0,199,249,289,327,359,499,616,733,835,939,1146,1367,1588,1788,1987,2186,2385,3418,3624,4037,4450,6613,8775,13100,17425,21750);//11x17 brochure,45,60,75
sku[19] = new Array(0,110,138,160,180,198,275,339,404,460,517,630,752,873,983,1093,1202,1312,1880,1993,2221,2448,3638,4827,7205,9584,11963);//12x18 flyer 4/0 poster,30,45,60
sku[20] = new Array(0,164,206,239,270,296,411,508,605,689,774,946,1128,1310,1475,1639,1804,1968,2820,2990,3331,3672,5456,7239,10808,14376,17944);//12x18 flyer 4/1 poster,45,60,75
sku[21] = new Array(0,197,246,286,323,355,494,609,726,827,930,1134,1353,1572,1770,1967,2164,2362,3384,3588,3996,4406,6547,8688,12969,17251,21533);//12x18 flyer 4/4 poster,45,60,75
sku[22] = new Array(0,112,142,166,188,206,287,354,421,478,538,654,781,906,1019,1132,1244,1356,1942,2059,2294,2527,3758,4987,7447,9906,12366);//12x18 broch 4/0 poster,30,45,60
sku[23] = new Array(0,166,213,247,282,309,429,531,631,716,805,983,1171,1359,1529,1697,1867,2035,2913,3088,3440,3791,5636,7479,11171,14859,18549);//12x18 broch 4/1 poster,45,60,75
sku[24] = new Array(0,200,254,296,337,370,516,636,757,860,967,1178,1405,1631,1835,2037,2240,2442,3496,3706,4127,4549,6763,8976,13404,17831,22259);//12x18 broch 4/4 poster,45,60,75
sku[25] = new Array(0,154,193,224,252,277,385,475,566,644,724,882,1053,1222,1376,1530,1683,1837,2632,2790,3109,3427,5093,6758,10087,13418,16748);//12x18 card 4/0 poster,30,45,60
sku[26] = new Array(0,230,288,335,378,414,575,711,847,965,1084,1324,1579,1834,2065,2295,2526,2755,3948,4186,4663,5141,7638,10135,15131,20126,25122);//12x18 card 4/1 poster,45,60,75
sku[27] = new Array(0,276,344,400,452,497,692,853,1016,1158,1302,1588,1894,2201,2478,2754,3030,3307,4738,5023,5594,6168,9166,12163,18157,24151,30146);//12x18 card 4/4 poster,45,60,75
sku[28] = new Array(0,5,10,15,20,25,50,75,100,125,150,200,250,300,350,400,450,500,750,800,900,1000,1500,2000,3000,4000,5000);//Mailing Envelopes
sku[29] = new Array(0,0,0,199,216,233,302,359,407,453,499,578,656,733,802,870,939,1009,1367,1441,1588,1722,2385,3074,4450,5893,7334);//6x6 brochure 2-fold
sku[30] = new Array(0,0,199,224,249,269,359,429,499,558,616,733,835,939,1043,1146,1257,1367,1888,1987,2186,2385,3418,4450,6613,8775,10938);//6x6 brochure 3-fold, 6x9 brochure 2-fold
//  Material and sub values
//  0	Business Cards
//  -	0	Business Cards
//  1 Postcards
//  - 0	6x4 postcards
//  - 1	3.5x8 postcards
//  - 2	4x9 postcards
//  - 3	4x11.5 postcards mailable
//  - 4	4x12 postcards non-mailable
//  - 5	4x12 EDDM postcards
//  - 6	5x7 postcards
//  - 7	6.2x6.2 EDDM postcards
//  - 8	6x8 postcards
//  - 9	6x9 postcards
//  - 10	6.2x9 EDDM postcards
//  - 11	6x11.5 postcards
//  - 12	6x12 EDDM postcards
//  - 13	8.5x11 postcards
//  2 Door Hangers
//  - 0	3.5x8 doorhanger
//  - 1	4x9 doorhanger
//  - 2	4x12 doorhanger
//  3 FoldedCards
//  - 0	4x6 folded
//  - 1	4.5x6 folded
//  - 2	5x7 folded
//  4 Flyers
//  - 0	8.5x11 flyer
//  - 1	11x17 flyer
//  5 Brochures
//  - 0	8.5x11 or 8x9 brochure
//  - 1	12x9 brochure
//  - 2	11x17 brochure
//  - 3	6x6 2 fold brochure min 150
//  - 4	6x6 3 fold brochure min 100
//  - 5	6x9 2 fold brochure min 100
//  - 6	6x9 3 fold brochure
//  - 7	9x9 2 fold brochure
//  6 Posters
//  - 0	12x18 poster - flyer stock
//  - 1	12x18 poster - brochure stock
//  - 2	12x18 poster - postcard stock
//  7 Color Copy
//  - 0	8.5x11 copy - bright white
//  - 1	8.5x11 copy - flyer stock
//  - 2	8.5x11 copy - cover stock
//  - 2	8.5x11 copy - postcard stock
//  8	Giclee


giclee = new Array(6,6,6,12,12,15,15,9,12,6,6);
ResetPage();
function SelectionMade()
{
if(document.form1.RadioQty[1].checked == true)
{
	validate_numbers();
	if (!document.Ready_to_Post)return;
}
var sub = 0;
var sub1 = 0;
var sub2 = 0;
if(document.form1.RadioQty[1].checked == true)
   {
   show_quantity = true;
   if(document.getElementById('divEnterQty').style.display == 'none')
   {
   	document.getElementById('divQuantity').style.display = 'none';
   	document.getElementById('divEnterQty').style.display = 'block';
   	document.form1.QtyEntered.focus();
   	document.form1.QtyEntered.select();
   }
   ManualQty = document.form1.QtyEntered.value;
   StepDown = 0;
	while (parseInt(ManualQty) >= parseInt(document.form1.QtySelection[StepDown].value))
		{
		StepDown++;
		if (document.form1.QtySelection.options.length == StepDown)
			{
			break;
			}
		}
	StepDown--;
   }
else{
	show_quantity = false;
	document.getElementById('divQuantity').style.display = 'block';
   document.getElementById('divEnterQty').style.display = 'none';
   document.form1.QtyEntered.value = 250;
}
if (show_quantity)
	{
	var qty = StepDown;
	}
else
	{
	var qty = document.form1.QtySelection.selectedIndex;
	}
qtyactual = document.form1.QtySelection[qty].value;
var qtynext = 0;
(qty+2 > document.form1.QtySelection.options.length) ? (qtynext = qtyactual):(qtynext = document.form1.QtySelection[qty+1].value);
var qtynext2 = 0;
(qty+3 > document.form1.QtySelection.options.length) ? (qtynext2 = qtynext):(qtynext2 = document.form1.QtySelection[qty+2].value);
if (show_quantity)
	{
	qtyactual = ManualQty;
	}
var Savesub;
var Savesub1;
var Savesub2;
var CardIndex = document.form1.CardSelection.selectedIndex;
var FoldedIndex = document.form1.FoldedSelection.selectedIndex;
var DoorIndex = document.form1.DoorSelection.selectedIndex;
var FlyerIndex = document.form1.FlyerSelection.selectedIndex;
var BrochIndex = document.form1.BrochSelection.selectedIndex;
var PosterIndex = document.form1.PosterSelection.selectedIndex;
var CopyIndex = document.form1.CopySelection.selectedIndex;
var GicleeIndex = document.form1.GicleeMaterial.selectedIndex;
var qty3 = document.form1.GicleeQty.selectedIndex;
var qty4 = document.form1.GicleeQty[qty3].value;
var width1 = document.form1.GicleeWidth.selectedIndex;
var width2 = document.form1.GicleeWidth[width1].value;
var height1 = document.form1.GicleeHeight.selectedIndex;
var height2 = document.form1.GicleeHeight[height1].value;
var sku_array;
Dbase = 0;
Dcolor = 0;
DUV = 0;
DPerf = 0;
Dday = 0;
Ddiscount = 0;
Dfold = 0;
DEDDM = 0;
Ddms = 0;
Ddoor = 0;
Dtab = 0;
Dpostage = 0;
Dlist = 0;
Dvdp = 0;
// ensure that when selection changes postage goes back to standard
if (save_postcard != CardIndex || save_door != DoorIndex || save_folded != FoldedIndex
    || save_flyer != document.form1.FlyerSelection.selectedIndex || save_brochure != document.form1.BrochSelection.selectedIndex || (save_qty <= 250 && qtyactual >= 500))
   {
   document.form1.RadioClass[1].checked = true;
   }
save_postcard = CardIndex;
save_door = DoorIndex;
save_folded = FoldedIndex;
save_flyer = document.form1.FlyerSelection.selectedIndex;
save_brochure = document.form1.BrochSelection.selectedIndex;
save_qty = qtyactual;
if (document.form1.RadioMail[0].checked) current_mail_checked = 0;
if (document.form1.RadioMail[1].checked) current_mail_checked = 1;
if (document.form1.RadioEDDM[0].checked) current_EDDM_checked = 0;
if (document.form1.RadioEDDM[1].checked) current_EDDM_checked = 1;
if (document.form1.RadioEDDM[2].checked) current_EDDM_checked = 2;
if (save_mail_checked == undefined)save_mail_checked = current_mail_checked;
if (save_EDDM_checked == undefined)save_EDDM_checked = current_EDDM_checked;
mail_change = false;
EDDM_change = false;
if (save_mail_checked != current_mail_checked)
	{
		mail_change = true;
		save_mail_checked = current_mail_checked;
	}
if (save_EDDM_checked != current_EDDM_checked)
	{
		EDDM_change = true;
		save_EDDM_checked = current_EDDM_checked;
	}
// BUSINESS CARDS

if(document.form1.Material.selectedIndex == 0)
   {
   //alert('it is 0');
   document.getElementById('divDays').style.display = 'block';
   document.getElementById('divCopyDays').style.display = 'none';
   document.getElementById('divDesign').style.display = 'block';
   document.getElementById('divColor').style.display = 'block';
   document.getElementById('divStock').style.display = 'block';
   document.getElementById('divPerf').style.display = 'block';
   // if matte paper stock is selected hide UV options.
   if (document.form1.RadioStock[0].checked){
   	document.getElementById('divUV').style.display = 'block';
   }
   else{
   	document.getElementById('divUV').style.display = 'none';
   	document.form1.RadioUV[0].checked = true;
   }
   document.getElementById('divQtyInput').style.display = 'block';
   document.getElementById('divFlyerColor').style.display = 'none';
   document.getElementById('divCopyColor').style.display = 'none';
   document.getElementById('divEDDM').style.display = 'none';
   document.getElementById('divMail').style.display = 'none';
   document.getElementById('divClass').style.display = 'none';
   document.getElementById('divList').style.display = 'none';
   document.getElementById('divCard').style.display = 'none';
   document.getElementById('divDoor').style.display = 'none';
   document.getElementById('divFolded').style.display = 'none';
   document.getElementById('divFold').style.display = 'none';
   document.getElementById('divFlyer').style.display = 'none';
   document.getElementById('divBroch').style.display = 'none';
   document.getElementById('divPoster').style.display = 'none';
   document.getElementById('divCopy').style.display = 'none';
   document.getElementById('divWidthHeight').style.display = 'none';
   document.getElementById('divMaterial').style.display = 'none';
   if (!show_quantity)
   	{
   	document.getElementById('divQuantity').style.display = 'block';
   	}
   document.getElementById('divGicleeQty').style.display = 'none';
   document.getElementById('divUnit').style.display = 'block';
   document.getElementById('divVDP').style.display = 'none';
   }
if(document.form1.Material.selectedIndex == 0)
   {
   sku_array = sku[0];
   sub = sku_array[qty+1];
   (qty+2 > document.form1.QtySelection.options.length) ? (sub1 = sub):(sub1 = sku_array[qty+2]);
   (qty+3 > document.form1.QtySelection.options.length) ? (sub2 = sub1):(sub2 = sku_array[qty+3]);
	if (show_quantity && sub != sub1)
		{
		sub = Math.ceil(sub + (((sub1 - sub)/(parseInt(document.form1.QtySelection[StepDown+1].value) - parseInt(document.form1.QtySelection[StepDown].value))) * (ManualQty - parseInt(document.form1.QtySelection[StepDown].value))));
		}
   Dbase = sub;
   if (document.form1.RadioColor[1].checked)
      {
      Dcolor = Math.round(sub * .35);      
      sub = Math.round(sub * 1.35);
      sub1 = Math.round(sub1 * 1.35);
      sub2 = Math.round(sub2 * 1.35);
      }
   // add Perforation - this must after folding (if can be) since folding will null perforation charge
   if (document.form1.RadioPerf[1].checked && document.getElementById('divPerf').style.display == 'block')
      {
   	DPerf = Math.round(((qtyactual/500)*15)+50);
     	sub += Math.round(((qtyactual/500)*15)+50);
     	sub1 += Math.round(((qtynext/500)*15)+50);
     	sub2 += Math.round(((qtynext2/500)*15)+50);
     	}
   // add UV coating
   if (document.form1.RadioUV[1].checked)
      {
      DUV = Math.round(qtyactual * .02);      
      sub += DUV;
      sub1 += Math.round(qtynext * .02);
      sub2 += Math.round(qtynext2 * .02);
      }
   if (document.form1.RadioUV[2].checked)
      {
      DUV = Math.round(qtyactual * .04);      
      sub += DUV;
      sub1 += Math.round(qtynext * .04);
      sub2 += Math.round(qtynext2 * .04);
      }
   // add 25% for 1 day
   if (document.form1.RadioDelivery[1].checked)
      {
      Dday = Math.round(sub * .25);
      sub += Math.round(sub * .25);
      sub1 += Math.round(sub1 * .25);
      sub2 += Math.round(sub2 * .25);
      }
   // add 50% for same day
   if (document.form1.RadioDelivery[2].checked)
      {
      Dday = Math.round(sub * .5);
      sub += Math.round(sub * .5);
      sub1 += Math.round(sub1 * .5);
      sub2 += Math.round(sub2 * .5);
      }
   // Give discount for ready to print
   if (document.form1.RadioDesign[1].checked)
      {
      if (qtyactual<500)
         {
         sub -= 15;
         Ddiscount = -15;
         }
       else
          {
          if (qtyactual<1000)
             {
             sub -= 25;
             Ddiscount = -25;
             }
          else
             {
             sub -= 30;
             Ddiscount = -30;
             }
          }
      }
   if (document.form1.RadioDesign[1].checked)
      {
      if (qtynext<500)
         {
         sub1 -= 15;
         }
       else
          {
          if (qtynext<1000)
             {
             sub1 -= 25;
             }
          else
             {
             sub1 -= 30;
             }
          }
      }
   if (document.form1.RadioDesign[1].checked)
      {
      if (qtynext2 < 500)
         {
         sub2 -= 15;
         }
       else
          {
          if (qtynext2 < 1000)
             {
             sub2 -= 25;
             }
          else
             {
             sub2 -= 30;
             }
          }
      }
   document.form1.total.value = MakeCents(sub * 100);
   document.form1.total0.value = MakeCents(sub * 100);
   document.form1.total1.value = MakeCents(sub1 * 100);
   document.form1.total2.value = MakeCents(sub2 * 100);
   document.form1.plus0.value = qtyactual;
   document.form1.plus1.value = qtynext;
   document.form1.plus2.value = qtynext2;
   document.form1.unit0.value = format(sub / qtyactual,4);
   document.form1.unit1.value = format(sub1 / qtynext,4);
   document.form1.unit2.value = format(sub2 / qtynext2,4);
   }
   
// POSTCARDS - postcards, door hangers, folded cards
 
if(document.form1.Material.selectedIndex == 1 || document.form1.Material.selectedIndex == 2 || document.form1.Material.selectedIndex == 3)
   {
   //alert('it is 1 or 2 or 3');
   if(document.form1.Material.selectedIndex == 1)
   	{
  	 	document.getElementById('divCard').style.display = 'block';
  	 	document.getElementById('divFolded').style.display = 'none';
  	 	document.getElementById('divDoor').style.display = 'none';
   	}
   if(document.form1.Material.selectedIndex == 2)
   	{
  	 	document.getElementById('divCard').style.display = 'none';
  	 	document.getElementById('divFolded').style.display = 'none';
  	 	document.getElementById('divDoor').style.display = 'block';
   	}
    if(document.form1.Material.selectedIndex == 3)
   	{
  	 	document.getElementById('divFolded').style.display = 'block';
  	 	document.getElementById('divCard').style.display = 'none';
  	 	document.getElementById('divDoor').style.display = 'none';
   	}
   document.getElementById('divDays').style.display = 'block';
   document.getElementById('divCopyDays').style.display = 'none';
   document.getElementById('divDesign').style.display = 'block';
   document.getElementById('divColor').style.display = 'block';
   document.getElementById('divStock').style.display = 'block';
   document.getElementById('divPerf').style.display = 'block';
   // if matte paper stock is selected hide UV options.
   if (document.form1.RadioStock[0].checked){
   	document.getElementById('divUV').style.display = 'block';
   }
   else{
   	document.getElementById('divUV').style.display = 'none';
   	document.form1.RadioUV[0].checked = true;
   }
   document.getElementById('divQtyInput').style.display = 'block';
   document.getElementById('divFlyerColor').style.display = 'none';
   document.getElementById('divCopyColor').style.display = 'none';
   // turn off VDP flag if no mail is selected
   if(document.form1.RadioMail[0].checked) document.form1.RadioVDP[0].checked = true;
 	// for doorhangers and EDDM cards no mailing option
   if((document.form1.Material.selectedIndex == 1 && CardIndex != 5 && CardIndex != 7 && CardIndex != 10 && CardIndex != 12) || document.form1.Material.selectedIndex == 3)
   	{
   	document.getElementById('divMail').style.display = 'block';
   	}
   // for 4x12, 6.2x6.2, 6.2x9, 6x12 and 8.5x11 turn on EDDM
   	if(document.form1.Material.selectedIndex == 1 && (CardIndex == 5 || CardIndex == 7 || CardIndex == 10 || CardIndex == 12 || CardIndex == 13))
   		{
   			document.getElementById('divEDDM').style.display = 'block';
   		}
   	else
   		{
   			document.getElementById('divEDDM').style.display = 'none';
   		}
   // for EDDM cards turn on 'self' if 'no' selected
   if(document.form1.Material.selectedIndex == 1 && (CardIndex == 5 || CardIndex == 7 || CardIndex == 10 || CardIndex == 12) && document.form1.RadioEDDM[0].checked)
   	{
   		document.form1.RadioEDDM[1].checked = true;
   		save_EDDM_checked = 1;
   		document.form1.RadioMail[0].checked = true;
   		save_mail_checked = 2;
   	}
   // if EDDM selected then check qty, must be 200 or more
   if (document.getElementById('divEDDM').style.display == 'block')
   	{
   	if (qtyactual < 200 && (document.form1.RadioEDDM[1].checked || document.form1.RadioEDDM[2].checked))
			{
			alert('For EDDM qty must be at least 200');
			if(document.form1.RadioQty[1].checked == true)
			{
				document.form1.QtyEntered.value = 200;
			}
			else
			{
				document.form1.QtySelection.selectedIndex = 3;
			}
			SelectionMade();
			return;
			}
		// if EDDM check, turn off Mail selection and turn off fold
		if(document.form1.RadioEDDM[1].checked || document.form1.RadioEDDM[2].checked)
			{
				if(EDDM_change)
					{
					document.form1.RadioMail[0].checked = true;
					save_mail_checked = 0;
					}
				document.form1.RadioFold[0].checked = true;
			}
		}
   // for 4x12 non mailable and EDDM turn off mailing options
   if(document.form1.Material.selectedIndex == 1 && (CardIndex == 4 || CardIndex == 5 || CardIndex == 7 || CardIndex == 10 || CardIndex == 12))
   	{
   	document.getElementById('divMail').style.display = 'none';
   	}
   if(document.form1.Material.selectedIndex == 2)
   	{
   	document.getElementById('divMail').style.display = 'none';
   	document.getElementById('divEDDM').style.display = 'none';
   	}
   // turn off any selection if EDDM is not selectable
   if (document.getElementById('divEDDM').style.display == 'none')
   	{
   		document.form1.RadioEDDM[0].checked = true;
   		save_EDDM_checked = 0;
   	}
   // display mailing options if mail is selectable and turn off EDDM
   if(document.form1.RadioMail[1].checked && document.getElementById('divMail').style.display == 'block')
      {
      if (mail_change)
      	{
      	document.form1.RadioEDDM[0].checked = true;
      	save_EDDM_checked = 0;
      	}
      document.getElementById('divClass').style.display = 'block';
      document.getElementById('divList').style.display = 'block';
      document.getElementById('divVDP').style.display = 'block';
      document.getElementById('PostageIncluded').style.display = '';
      }
   else
      {
      document.getElementById('divClass').style.display = 'none';
      document.getElementById('divList').style.display = 'none';
      document.getElementById('divVDP').style.display = 'none';
      document.form1.RadioVDP[0].checked = true;
      document.getElementById('PostageIncluded').style.display = 'none';
      }
   // for foldable card display option to fold
   if(document.form1.Material.selectedIndex == 1)
   	{
   	if(CardIndex == 6 || CardIndex == 8 || CardIndex == 9 || CardIndex == 11 || CardIndex == 13)
      	{
      	document.getElementById('divFold').style.display = 'block';
      	}
   	else
      	{
      	document.getElementById('divFold').style.display = 'none';
      	}
      }
    // for folded cards and door hangers no option for folding - for folded cards it is mandatory
    if(document.form1.Material.selectedIndex == 2 || document.form1.Material.selectedIndex == 3)
    	{
    	document.getElementById('divFold').style.display = 'none';
    	}
   document.getElementById('divFlyer').style.display = 'none';
   document.getElementById('divBroch').style.display = 'none';
   document.getElementById('divPoster').style.display = 'none';
   document.getElementById('divCopy').style.display = 'none';
   document.getElementById('divWidthHeight').style.display = 'none';
   document.getElementById('divMaterial').style.display = 'none';
   if (!show_quantity)
   	{
   	document.getElementById('divQuantity').style.display = 'block';
   	}
   document.getElementById('divGicleeQty').style.display = 'none';
   document.getElementById('divUnit').style.display = 'block';
   }
if(document.form1.Material.selectedIndex == 1 || document.form1.Material.selectedIndex == 2 || document.form1.Material.selectedIndex == 3)
   {
   if(document.form1.Material.selectedIndex == 1)
   	{
   	if(CardIndex == 0) sku_array = sku[1]; // 6x4 postcards
   	if(CardIndex == 1) sku_array = sku[2]; // 3.5x8 postcards
 	   if(CardIndex == 2 || CardIndex == 7) sku_array = sku[3]; // 4x9 postcards or 6.2x6.2 EDDM
 	   if(CardIndex == 3) sku_array = sku[4]; // 4x11.5 postcards mailable
 	   if(CardIndex == 4 || CardIndex == 5) sku_array = sku[5]; // 4x12 postcards non-mailable and EDDM
 	   if(CardIndex == 6 || CardIndex == 8) sku_array = sku[6]; // 6x8 or 5x7 postcards
 	   if(CardIndex == 9 || CardIndex == 10) sku_array = sku[7]; // 6x9 postcards or 6.2x9 EDDM
 	   if(CardIndex == 11 || CardIndex == 12) sku_array = sku[8]; // 6x11.5 or 6x12 postcards
 	   if(CardIndex == 13) sku_array = sku[9]; // 8.5x11 postcards
   	}
   if(document.form1.Material.selectedIndex == 2)
   	{
   	if(DoorIndex == 0) sku_array = sku[2]; // 3.5x8 doorhanger same plus door
 	   if(DoorIndex == 1) sku_array = sku[3]; // 4x9 doorhanger same plus door
 	   if(DoorIndex == 2) sku_array = sku[5]; // 4x12 doorhanger same plus door
   	}
   if(document.form1.Material.selectedIndex == 3)
   	{
   	if(FoldedIndex == 0) sku_array = sku[6]; // 4x6 folded same as 6x8 plus fold
   	if(FoldedIndex == 1) sku_array = sku[7]; // 4.5x6 folded same as 6x9 plus fold
   	if(FoldedIndex == 2) sku_array = sku[9]; // 5x7 folded same as 8.5x11 plus fold
   	}
   
   // Base price
   sub = sku_array[qty+1];
   (qty+2 > document.form1.QtySelection.options.length) ? (sub1 = sub):(sub1 = sku_array[qty+2]);
   (qty+3 > document.form1.QtySelection.options.length) ? (sub2 = sub1):(sub2 = sku_array[qty+3]);
	if (show_quantity && sub != sub1)
		{
		sub = Math.ceil(sub + (((sub1 - sub)/(parseInt(document.form1.QtySelection[StepDown+1].value) - parseInt(document.form1.QtySelection[StepDown].value))) * (ManualQty - parseInt(document.form1.QtySelection[StepDown].value))));
		}
   Dbase = sub;
   // Add color on back
   if (document.form1.RadioColor[1].checked)
      {
      Dcolor = Math.round(sub * .35);     
      sub = Math.round(sub * 1.35);
      sub1 = Math.round(sub1 * 1.35);
      sub2 = Math.round(sub2 * 1.35);
      }
   // add UV coating
   if (document.form1.RadioUV[1].checked)
      {
      DUV = Math.round(qtyactual * .02);      
      sub += DUV;
      sub1 += Math.round(qtynext * .02);
      sub2 += Math.round(qtynext2 * .02);
      }
   if (document.form1.RadioUV[2].checked)
      {
      DUV = Math.round(qtyactual * .04);      
      sub += DUV;
      sub1 += Math.round(qtynext * .04);
      sub2 += Math.round(qtynext2 * .04);
      }
   // add door hanging
   if (document.form1.Material.selectedIndex == 2)
      {
      Ddoor = Math.round(((qtyactual/500)*15)+50);
      sub += Math.round(((qtyactual/500)*15)+50);
     	sub1 += Math.round(((qtynext/500)*15)+50);
     	sub2 += Math.round(((qtynext2/500)*15)+50);
      }
   // Add folding
   if(document.form1.Material.selectedIndex == 1)
   	{
   	if (document.form1.RadioFold[1].checked && document.getElementById('divFold').style.display == 'block')
      	{
      	Dfold = Math.round(((qtyactual/500)*15)+50);
      	sub += Math.round(((qtyactual/500)*15)+50);
      	sub1 += Math.round(((qtynext/500)*15)+50);
      	sub2 += Math.round(((qtynext2/500)*15)+50);
      	}
      }
   // add folding to folded cards - manadatory
   if(document.form1.Material.selectedIndex == 3)
   	{
   	Dfold = Math.round(((qtyactual/500)*15)+50);
      sub += Math.round(((qtyactual/500)*15)+50);
      sub1 += Math.round(((qtynext/500)*15)+50);
      sub2 += Math.round(((qtynext2/500)*15)+50);
   	}
   // add Perforation - this must after folding (if can be) since folding will null perforation charge
   if (Dfold == 0 && document.form1.RadioPerf[1].checked && document.getElementById('divPerf').style.display == 'block')
      {
   	DPerf = Math.round(((qtyactual/500)*15)+50);
     	sub += Math.round(((qtyactual/500)*15)+50);
     	sub1 += Math.round(((qtynext/500)*15)+50);
     	sub2 += Math.round(((qtynext2/500)*15)+50);
     	}
   // save sub to be used as base for rushing orders
   Savesub = sub;
   Savesub1 = sub1;
   Savesub2 = sub2;
   // Add EDDM
   if (document.form1.RadioEDDM[2].checked && document.getElementById('divEDDM').style.display == 'block')
   	{
   	document.getElementById('PostageIncluded').style.display = '';
   	DEDDM = Math.round((qtyactual/50)*.5) + Math.ceil(qtyactual/5000)*25;
   	Dpostage = Math.round(qtyactual*.145);
      sub += Math.round((qtyactual/50)*.5) + Math.ceil(qtyactual/5000)*25 + Math.round(qtyactual*.145);
      sub1 += Math.round((qtynext/50)*.5) + Math.ceil(qtynext/5000)*25 + Math.round(qtynext*.145);
      sub2 += Math.round((qtynext2/50)*.5) + Math.ceil(qtynext2/5000)*25 + Math.round(qtynext2*.145);
      // save sub here again as base for rushing orders
   	Savesub = sub - Dpostage;
   	Savesub1 = sub1 - Dpostage;
   	Savesub2 = sub2 - Dpostage;
   	}
   // Add DMS
   if (document.form1.RadioMail[1].checked && document.getElementById('divMail').style.display == 'block')
      {
      Ddms = Math.round(((qtyactual/500)*30) + 65);
      sub += Math.round(((qtyactual/500)*30) + 65);
      sub1 += Math.round(((qtynext/500)*30) + 65);
      sub2 += Math.round(((qtynext2/500)*30) + 65);
      // Add tabbing
      if ((document.form1.RadioFold[1].checked && document.getElementById('divFold').style.display == 'block') || document.form1.Material.selectedIndex == 3)
         {
         Dtab = Math.round(((qtyactual/500)*15)+5);
         sub += Math.round(((qtyactual/500)*15)+5);
         sub1 += Math.round(((qtynext/500)*15)+5);
         sub2 += Math.round(((qtynext2/500)*15)+5);
         }
      // Add mailing list
      if (document.form1.RadioList[1].checked)
         {
         if (qtyactual < 3000)
    	   	{
    	   	Dlist = 25;
    	   	sub += 25;
           }
    	 	else
    	 		{
    	 		Dlist = (qtyactual/100);
    	 	   sub += (qtyactual/100);
       	  	}
       	if (qtynext < 3000)
    	 	   {
    	 	   sub1 += 25;
            }
    	 	else
    	 	   {
    	 	   sub1 += (qtynext/100);
            }
         if (qtynext2 < 3000)
    	 	   {
    	 	   sub2 += 25;
            }
    	 	else
    	  	   {
    	   	sub2 += (qtynext2/100);
            }
         }
      // Add VDP
      if (document.form1.RadioVDP[1].checked == true)
         {
         Dvdp = Math.round(((qtyactual/500)*30) + 40);
         sub += Math.round(((qtyactual/500)*30) + 40);
         sub1 += Math.round(((qtynext/500)*30) + 40);
         sub2 += Math.round(((qtynext2/500)*30) + 40);
         }
      // save sub here again as base for rushing orders
      Savesub = sub;
      Savesub1 = sub1;
      Savesub2 = sub2;
      // Calculate postage
      // OK here are the rules
      //
      //	-------6x4 cards 									  under 200 go at postcard rate - as of 1/22/12 it is .32              - Postcard First Class
      //                                   		  200 to 499 standard presort rate - as of 1/22/12 it is .281 OR          - Presort Standard mixed AADC
      //                                  				 200 to 499 first class rate - as of 1/22/12 it is .32              - Postcard First Class
      //									 all other qty is forced FIRST class presort rate - as of 1/22/12 it is .255             - Postcard First Class presort mixed AADC
      //
      //	-----ANYTHING ELSE but 4x11.5			 under 200 go at regular postage rate - as of 1/22/12 it is .45              - First Class
      //							 						   200 to 499 at regular postage rate - as of 1/22/12 it is .45 OR           - First Class
      //							 						  200 to 499 at standard presort rate - as of 1/22/12 it is .281             - Presort standard mixed AADC
      //		 	  anything else equal to 500 or greater go at standard presort rate - as of 1/22/12 it is .281 OR          - Presort standard mixed AADC
      //															  	    first class presort rate - as of 1/22/12 it is .404             - Presort Frist Class Letter mixed AADC
      //
      //	-----4x11.5											 				all qty first class - as of 1/22/12 it is .45              - First Class
      //
      // Lets get the 4x11.5 logic out first
      if (document.form1.Material.selectedIndex == 1 && CardIndex == 3) // 4x11.5 cards
      	{
      	document.form1.RadioClass[0].checked = true;
      	Dpostage = Math.round((qtyactual * 0.45));
         sub += Math.round((qtyactual * 0.45));
         sub1 += Math.round((qtynext * 0.45));
         sub2 += Math.round((qtynext2 * 0.45));
      	}
      else
      	{
 	     if (document.form1.Material.selectedIndex == 1 && CardIndex == 0) // 6x4 cards
   	      {
   	      if (qtyactual < 200 || qtyactual > 499)
   	         {
   	         if (qtyactual < 200)
   	            {
   	            document.form1.RadioClass[0].checked = true;
   	            Dpostage = Math.round((qtyactual * 0.32));
   	            sub += Math.round((qtyactual * 0.32));
   	            }
   	         else
   	            {
   	            document.form1.RadioClass[0].checked = true;
   	            Dpostage = Math.round((qtyactual * 0.255));
   	            sub += Math.round((qtyactual * 0.255));
   	            }
   	         }
   	      else
   	         {
   	         if (document.form1.RadioClass[0].checked == true)
   	         	{
   	        		Dpostage = Math.round((qtyactual * 0.32));
   	         	sub += Math.round((qtyactual * 0.32));
   	         	}
   	         else
   	         	{
   	         	Dpostage = Math.round((qtyactual * 0.281));
   	         	sub += Math.round((qtyactual * 0.281));
   	         	}
   	         }
	         // qtynext
   	      if (qtynext < 200 || qtynext > 499)
   	         {
   	         if (qtynext < 200)
   	            {
   	            sub1 += Math.round((qtynext * 0.32));
   	            }
   	         else
   	            {
   	            sub1 += Math.round((qtynext * 0.255));
   	            }
	            }
   	      else
   	         {
   	         if (document.form1.RadioClass[0].checked == true)
   	         	{
   	         	sub1 += Math.round((qtynext * 0.32));
   	         	}
   	         else
   	         	{
   	         	sub1 += Math.round((qtynext * 0.281));
   	         	}
   	         }
   	      // qtynext2
   	      if (qtynext2 < 200 || qtynext2 > 499)
   	         {
   	         if (qtynext2 < 200)
   	            {
   	            sub2 += Math.round((qtynext2 * 0.32));
   	            }
   	         else
   	            {
   	            sub2 += Math.round((qtynext2 * 0.255));
   	            }
   	         }
   	      else
   	         {
   	         if (document.form1.RadioClass[0].checked == true)
   	         	{
   	         	sub2 += Math.round((qtynext2 * 0.32));
   	         	}
   	         else
   	         	{
   	         	sub2 += Math.round((qtynext2 * 0.281));
   	         	}
   	         }
   	      }
   	   else // not 6x4 and not 4x11.5
   	      {
   	      if (qtyactual < 200)
   	         {
   	         document.form1.RadioClass[0].checked = true;
   	         Dpostage = Math.round((qtyactual * 0.45));
   	         sub += Math.round((qtyactual * 0.45));
   	         }
   	      else
   	         {
   	         if (qtyactual < 500 )
   	            {
   	            if (document.form1.RadioClass[0].checked == true)
   	            	{
   	            	Dpostage = Math.round((qtyactual * 0.45));
   	            	sub += Math.round((qtyactual * 0.45));
   	            	}
   	            else
   	            	{
   	            	Dpostage = Math.round((qtyactual * 0.281));
   	            	sub += Math.round((qtyactual * 0.281));
   	            	}
   	            }
   	         else
   	            {
   	            if (document.form1.RadioClass[0].checked == true)
   	               {
   	               Dpostage = Math.round((qtyactual * 0.404));
   	               sub += Math.round((qtyactual * 0.404));
   	               }
   	            else
   	               {
   	               Dpostage = Math.round((qtyactual * 0.281));
   	               sub += Math.round((qtyactual * 0.281));
   	               }
   	            }
   	         }
   	      // qtynext
   	      if (qtynext < 200)
   	         {
   	         sub1 += Math.round((qtynext * 0.45));
   	         }
   	      else
   	         {
   	         if (qtynext < 500 )
   	            {
   	            if (document.form1.RadioClass[0].checked == true)
   	            	{
   	            	sub1 += Math.round((qtynext * 0.45));
   	            	}
   	            else
   	            	{
   	            	sub1 += Math.round((qtynext * 0.281));
   	            	}
   	            }
   	         else
   	            {
   	            if (document.form1.RadioClass[0].checked == true)
   	               {
   	               sub1 += Math.round((qtynext * 0.404));
   	               }
   	            else
   	               {
   	               sub1 += Math.round((qtynext * 0.281));
   	               }
   	            }
   	         }
   	      // qtynext2
   	      if (qtynext2 < 200)
   	         {
   	         sub2 += Math.round((qtynext2 * 0.45));
   	         }
   	      else
   	         {
   	         if (qtynext2 < 500 )
   	            {
   	            if (document.form1.RadioClass[0].checked == true)
   	            	{
   	            	sub2 += Math.round((qtynext2 * 0.45));
   	            	}
   	            else
   	            	{
   	            	sub2 += Math.round((qtynext2 * 0.281));
   	            	}
   	            }
   	         else
   	            {
   	            if (document.form1.RadioClass[0].checked == true)
   	               {
   	               sub2 += Math.round((qtynext2 * 0.404));
   	               }
   	            else
   	               {
   	               sub2 += Math.round((qtynext2 * 0.281));
   	               }
   	            }
   	         }
   	      }
   		}
      }    
   // add 25% for 1 day
   if (document.form1.RadioDelivery[1].checked)
      {
      Dday = Math.round(Savesub * .25);
      sub += Math.round(Savesub * .25);
      sub1 += Math.round(Savesub1 * .25);
      sub2 += Math.round(Savesub2 * .25);
      }
   // add 50% for same day
   if (document.form1.RadioDelivery[2].checked)
      {
      Dday = Math.round(Savesub * .5);
      sub += Math.round(Savesub * .5);
      sub1 += Math.round(Savesub1 * .5);
      sub2 += Math.round(Savesub2 * .5);
      }
   // For display purpose only do something special here
   Ddiscount = sub;
   // Give discount for ready to print
   if (document.form1.RadioDesign[1].checked)
      {
      if (qtyactual<500)
         {
         if (document.form1.Material.selectedIndex == 1)
         	{
         	if (CardIndex == 0 || CardIndex == 1 || CardIndex == 2) sub -= 15;
         	if (CardIndex > 2 && CardIndex < 13) sub -= 25;
         	if (CardIndex == 13) sub -= 30;
         	}
         if (document.form1.Material.selectedIndex == 2)
         	{
         	if (DoorIndex == 0 || DoorIndex == 1) sub -= 15;
         	if (DoorIndex == 2) sub -= 25;
         	}
         if (document.form1.Material.selectedIndex == 3)
         	{
         	if (FoldedIndex == 0 || FoldedIndex == 1) sub -= 25;
         	if (FoldedIndex == 2) sub -= 30;
         	}
         }
      else
         {
         if (qtyactual<1000)
           {
	        	if (document.form1.Material.selectedIndex == 1)
   	     		{
   	     		if (CardIndex == 0 || CardIndex == 1 || CardIndex == 2) sub -= 25;
   	     		if (CardIndex > 2 && CardIndex < 13) sub -= 35;
   	     		if (CardIndex == 13) sub -= 50;
   	     		}
   	     	if (document.form1.Material.selectedIndex == 2)
   	     		{
   	     		if (DoorIndex == 0 || DoorIndex == 1) sub -= 25;
   	     		if (DoorIndex == 2) sub -= 35;
   	     		}
   	     	if (document.form1.Material.selectedIndex == 3)
   	     		{
   	     		if (FoldedIndex == 0 || FoldedIndex == 1) sub -= 35;
   	     		if (FoldedIndex == 2) sub -= 50;
   	     		}
        	}
         else
            {
            if (document.form1.Material.selectedIndex == 1)
        			{
     	   		if (CardIndex == 0 || CardIndex == 1 || CardIndex == 2) sub -= 30;
      	  		if (CardIndex > 2 && CardIndex < 13) sub -= 45;
      	  		if (CardIndex == 13) sub -= 60;
      	  		}
      	  	if (document.form1.Material.selectedIndex == 2)
      	  		{
      	  		if (DoorIndex == 0 || DoorIndex == 1) sub -= 30;
      	  		if (DoorIndex == 2) sub -= 45;
      	  		}
      	  	if (document.form1.Material.selectedIndex == 3)
      	  		{
      	  		if (FoldedIndex == 0 || FoldedIndex == 1) sub -= 45;
      	  		if (FoldedIndex == 2) sub -= 60;
      	  		}
          	}
         }
      }
   if (document.form1.RadioDesign[1].checked)
      {
      if (qtynext<500)
         {
         if (document.form1.Material.selectedIndex == 1)
         	{
         	if (CardIndex == 0 || CardIndex == 1 || CardIndex == 2) sub1 -= 15;
         	if (CardIndex > 2 && CardIndex < 13) sub1 -= 25;
         	if (CardIndex == 13) sub1 -= 30;
         	}
         if (document.form1.Material.selectedIndex == 2)
         	{
         	if (DoorIndex == 0 || DoorIndex == 1) sub1 -= 15;
         	if (DoorIndex == 2) sub1 -= 25;
         	}
         if (document.form1.Material.selectedIndex == 3)
         	{
         	if (FoldedIndex == 0 || FoldedIndex == 1) sub1 -= 25;
         	if (FoldedIndex == 2) sub1 -= 30;
         	}
         }
      else
         {
         if (qtynext<1000)
           {
        	if (document.form1.Material.selectedIndex == 1)
        		{
        		if (CardIndex == 0 || CardIndex == 1 || CardIndex == 2) sub1 -= 25;
        		if (CardIndex > 2 && CardIndex < 13) sub1 -= 35;
        		if (CardIndex == 13) sub1 -= 50;
        		}
        	if (document.form1.Material.selectedIndex == 2)
        		{
        		if (DoorIndex == 0 || DoorIndex == 1) sub1 -= 25;
        		if (DoorIndex == 2) sub1 -= 35;
        		}
        	if (document.form1.Material.selectedIndex == 3)
        		{
        		if (FoldedIndex == 0 || FoldedIndex == 1) sub1 -= 35;
        		if (FoldedIndex == 2) sub1 -= 50;
        		}
        	}
         else
            {
            if (document.form1.Material.selectedIndex == 1)
        			{
     	   		if (CardIndex == 0 || CardIndex == 1 || CardIndex == 2) sub1 -= 30;
      	  		if (CardIndex > 2 && CardIndex < 13) sub1 -= 45;
      	  		if (CardIndex == 13) sub1 -= 60;
      	  		}
      	  	if (document.form1.Material.selectedIndex == 2)
      	  		{
      	  		if (DoorIndex == 0 || DoorIndex == 1) sub1 -= 30;
      	  		if (DoorIndex == 2) sub1 -= 45;
      	  		}
      	  	if (document.form1.Material.selectedIndex == 3)
      	  		{
      	  		if (FoldedIndex == 0 || FoldedIndex == 1) sub1 -= 45;
      	  		if (FoldedIndex == 2) sub1 -= 60;
      	  		}
          	}
         }
      }
   if (document.form1.RadioDesign[1].checked)
      {
      if (qtynext2<500)
         {
         if (document.form1.Material.selectedIndex == 1)
         	{
         	if (CardIndex == 0 || CardIndex == 1 || CardIndex == 2) sub2 -= 15;
         	if (CardIndex > 2 && CardIndex < 13) sub2 -= 25;
         	if (CardIndex == 13) sub2 -= 30;
         	}
         if (document.form1.Material.selectedIndex == 2)
         	{
         	if (DoorIndex == 0 || DoorIndex == 1) sub2 -= 15;
         	if (DoorIndex == 2) sub2 -= 25;
         	}
         if (document.form1.Material.selectedIndex == 3)
         	{
         	if (FoldedIndex == 0 || FoldedIndex == 1) sub2 -= 25;
         	if (FoldedIndex == 2) sub2 -= 30;
         	}
         }
      else
         {
         if (qtynext2<1000)
           {
        	if (document.form1.Material.selectedIndex == 1)
        		{
        		if (CardIndex == 0 || CardIndex == 1 || CardIndex == 2) sub2 -= 25;
        		if (CardIndex > 2 && CardIndex < 13) sub2 -= 35;
        		if (CardIndex == 13) sub2 -= 50;
        		}
        	if (document.form1.Material.selectedIndex == 2)
        		{
        		if (DoorIndex == 0 || DoorIndex == 1) sub2 -= 25;
        		if (DoorIndex == 2) sub2 -= 35;
        		}
        	if (document.form1.Material.selectedIndex == 3)
        		{
        		if (FoldedIndex == 0 || FoldedIndex == 1) sub2 -= 35;
        		if (FoldedIndex == 2) sub2 -= 50;
        		}
        	}
         else
            {
            if (document.form1.Material.selectedIndex == 1)
        			{
     	   		if (CardIndex == 0 || CardIndex == 1 || CardIndex == 2) sub2 -= 30;
      	  		if (CardIndex > 2 && CardIndex < 13) sub2 -= 45;
      	  		if (CardIndex == 13) sub2 -= 60;
      	  		}
      	  	if (document.form1.Material.selectedIndex == 2)
      	  		{
      	  		if (DoorIndex == 0 || DoorIndex == 1) sub2 -= 30;
      	  		if (DoorIndex == 2) sub2 -= 45;
      	  		}
      	  	if (document.form1.Material.selectedIndex == 3)
      	  		{
      	  		if (FoldedIndex == 0 || FoldedIndex == 1) sub2 -= 45;
      	  		if (FoldedIndex == 2) sub2 -= 60;
      	  		}
          	}
         }
      }
   // For display purpose only do something special here
   Ddiscount = sub - Ddiscount;
   document.form1.total.value = MakeCents(sub * 100);
   document.form1.total0.value = MakeCents(sub * 100);
   document.form1.total1.value = MakeCents(sub1 * 100);
   document.form1.total2.value = MakeCents(sub2 * 100);
   document.form1.plus0.value = qtyactual;
   document.form1.plus1.value = qtynext;
   document.form1.plus2.value = qtynext2;
   document.form1.unit0.value = format(sub / qtyactual,4);
   document.form1.unit1.value = format(sub1 / qtynext,4);
   document.form1.unit2.value = format(sub2 / qtynext2,4);
   }
 
   
 // FLYERS  
   
if(document.form1.Material.selectedIndex == 4)
   {
   //alert('it is 2');
   document.getElementById('divDays').style.display = 'block';
   document.getElementById('divCopyDays').style.display = 'none';
   document.getElementById('divDesign').style.display = 'block';
   document.getElementById('divColor').style.display = 'none';
   document.getElementById('divStock').style.display = 'block';
   document.getElementById('divPerf').style.display = 'block';
   // NO UV for flyers
   document.getElementById('divUV').style.display = 'none';
   document.form1.RadioUV[0].checked = true;
   document.getElementById('divFlyerColor').style.display = 'block';
   document.getElementById('divCopyColor').style.display = 'none';
   document.getElementById('divMail').style.display = 'block';
   // turn off VDP flag if no mail is selected
   if(document.form1.RadioMail[0].checked) document.form1.RadioVDP[0].checked = true;
   // for 11x17 turn on EDDM
   if(FlyerIndex == 1)
   	{
  			document.getElementById('divEDDM').style.display = 'block';
  		}
  	else
  		{
  			document.getElementById('divEDDM').style.display = 'none';
  		}
   // if EDDM selected then check qty, must be 200 or more
   if (document.getElementById('divEDDM').style.display == 'block')
   	{
   	if (qtyactual < 200 && (document.form1.RadioEDDM[1].checked || document.form1.RadioEDDM[2].checked))
			{
			alert('For EDDM qty must be at least 200');
			if(document.form1.RadioQty[1].checked == true)
			{
				document.form1.QtyEntered.value = 200;
			}
			else
			{
				document.form1.QtySelection.selectedIndex = 3;
			}
			SelectionMade();
			return;
			}
		// if EDDM check, turn off Mail selection and turn on folding
		if(document.form1.RadioEDDM[1].checked || document.form1.RadioEDDM[2].checked)
			{
				if(EDDM_change)
					{
					document.form1.RadioMail[0].checked = true;
					save_mail_checked = 0;
					}
				document.form1.RadioFold[1].checked = true;
			}
		}
   if(document.form1.RadioMail[1].checked)
      {
      if (mail_change)
      	{
      	document.form1.RadioEDDM[0].checked = true;
      	save_EDDM_checked = 0;
      	}
      document.getElementById('divClass').style.display = 'block';
      document.getElementById('divList').style.display = 'block';
      document.getElementById('divVDP').style.display = 'block';
      document.getElementById('PostageIncluded').style.display = '';
      }
   else
      {
      document.getElementById('divClass').style.display = 'none';
      document.getElementById('divList').style.display = 'none';
      document.getElementById('divVDP').style.display = 'none';
      document.form1.RadioVDP[0].checked = true;
      document.getElementById('PostageIncluded').style.display = 'none';
      }
   document.getElementById('divFold').style.display = 'block';
   document.getElementById('divQtyInput').style.display = 'block';
   document.getElementById('divCard').style.display = 'none';
   document.getElementById('divDoor').style.display = 'none';
   document.getElementById('divFolded').style.display = 'none';
   document.getElementById('divFlyer').style.display = 'block';
   document.getElementById('divBroch').style.display = 'none';
   document.getElementById('divPoster').style.display = 'none';
   document.getElementById('divCopy').style.display = 'none';
   document.getElementById('divWidthHeight').style.display = 'none';
   document.getElementById('divMaterial').style.display = 'none';
   if (!show_quantity)
   	{
   	document.getElementById('divQuantity').style.display = 'block';
   	}
   document.getElementById('divGicleeQty').style.display = 'none';
   document.getElementById('divUnit').style.display = 'block';
   }
if(document.form1.Material.selectedIndex == 4)
   {
   if (document.form1.RadioMail[1].checked || document.form1.RadioEDDM[1].checked || document.form1.RadioEDDM[2].checked)
      {
      document.form1.RadioFold[1].checked = true;
      if (document.form1.RadioFlyerColor[0].checked)
         {
         document.form1.RadioFlyerColor[1].checked = true;
         }
      }
   if (FlyerIndex == 0)
      {
      sku_array = sku[10]; // 8.5x11 4/0 flyer
      if (document.form1.RadioFlyerColor[1].checked)
         {
         sku_array = sku[11];// 8.5x11 4/1 flyer (black back)
         }
      if (document.form1.RadioFlyerColor[2].checked)
         {
         sku_array = sku[12];// 8.5x11 4/4 flyer
         }
      }
   else
      {
      sku_array = sku[13];//11x17 4/0 flyer
      if (document.form1.RadioFlyerColor[1].checked)
         {
         sku_array = sku[14];// 11x17 4/1 flyer (black back)
         }
      if (document.form1.RadioFlyerColor[2].checked)
         {
         sku_array = sku[15];// 11x17 4/4 flyer
         }
      }
   sub = sku_array[qty+1];
   (qty+2 > document.form1.QtySelection.options.length) ? (sub1 = sub):(sub1 = sku_array[qty+2]);
   (qty+3 > document.form1.QtySelection.options.length) ? (sub2 = sub1):(sub2 = sku_array[qty+3]);
	if (show_quantity && sub != sub1)
		{
		sub = Math.ceil(sub + (((sub1 - sub)/(parseInt(document.form1.QtySelection[StepDown+1].value) - parseInt(document.form1.QtySelection[StepDown].value))) * (ManualQty - parseInt(document.form1.QtySelection[StepDown].value))));
		}
   Dbase = sub;
   // Add folding
   if (document.form1.RadioFold[1].checked)
      {
      Dfold = Math.round(((qtyactual/500)*15)+50);
      sub += Math.round(((qtyactual/500)*15)+50);
      sub1 += Math.round(((qtynext/500)*15)+50);
      sub2 += Math.round(((qtynext2/500)*15)+50);
      }
   // add Perforation - this must after folding (if can be) since folding will null perforation charge
   if (Dfold == 0 && document.form1.RadioPerf[1].checked && document.getElementById('divPerf').style.display == 'block')
      {
   	DPerf = Math.round(((qtyactual/500)*15)+50);
     	sub += Math.round(((qtyactual/500)*15)+50);
     	sub1 += Math.round(((qtynext/500)*15)+50);
     	sub2 += Math.round(((qtynext2/500)*15)+50);
     	}
   Savesub = sub;
   Savesub1 = sub1;
   Savesub2 = sub2;
   // Add EDDM
   if (document.form1.RadioEDDM[2].checked && document.getElementById('divEDDM').style.display == 'block')
   	{
   	document.getElementById('PostageIncluded').style.display = '';
   	DEDDM = Math.round((qtyactual/50)*.5) + Math.ceil(qtyactual/5000)*25;
   	Dpostage = Math.round(qtyactual*.145);
      sub += Math.round((qtyactual/50)*.5) + Math.ceil(qtyactual/5000)*25 + Math.round(qtyactual*.145);
      sub1 += Math.round((qtynext/50)*.5) + Math.ceil(qtynext/5000)*25 + Math.round(qtynext*.145);
      sub2 += Math.round((qtynext2/50)*.5) + Math.ceil(qtynext2/5000)*25 + Math.round(qtynext2*.145);
      // save sub here again as base for rushing orders
   	Savesub = sub - Dpostage;
   	Savesub1 = sub1 - Dpostage;
   	Savesub2 = sub2 - Dpostage;
   	}
   // Add DMS
   if (document.form1.RadioMail[1].checked && document.getElementById('divMail').style.display == 'block')
      {
      Ddms = Math.round(((qtyactual/500)*30) + 65);
      sub += Math.round(((qtyactual/500)*30) + 65);
      sub1 += Math.round(((qtynext/500)*30) + 65);
      sub2 += Math.round(((qtynext2/500)*30) + 65);
      // Add tabbing
      Dtab = Math.round(((qtyactual/500)*15)+5);
      sub += Math.round(((qtyactual/500)*15)+5);
      sub1 += Math.round(((qtynext/500)*15)+5);
      sub2 += Math.round(((qtynext2/500)*15)+5);
      // Add mailing list
      if (document.form1.RadioList[1].checked)
         {
         if (qtyactual < 3000)
    	   	{
    	   	Dlist = 25;
    	   	sub += 25;
           	}
    	 	else
    	   	{
    	   	Dlist = (qtyactual/100);
    	   	sub += (qtyactual/100);
         	}
         if (qtynext < 3000)
    	   	{
    	   	sub1 += 25;
           	}
    	 	else
    	   	{
    	   	sub1 += (qtynext/100);
           	}
         if (qtynext2 < 3000)
    	   	{
    	   	sub2 += 25;
           	}
    	 	else
    	   	{
    	   	sub2 += (qtynext2/100);
         	}
         }
      // Add VDP
      if (document.form1.RadioVDP[1].checked == true)
         {
         Dvdp = Math.round(((qtyactual/500)*30) + 40);
         sub += Math.round(((qtyactual/500)*30) + 40);
         sub1 += Math.round(((qtynext/500)*30) + 40);
         sub2 += Math.round(((qtynext2/500)*30) + 40);
         }
      Savesub = sub;
      Savesub1 = sub1;
      Savesub2 = sub2;
      // Calculate postage
      // Force to be first class if less then 200, otherwise user's choice
      if (qtyactual < 200)
         {
         document.form1.RadioClass[0].checked = true;
         Dpostage = Math.round((qtyactual * 0.45));
         sub += Math.round((qtyactual * 0.45));
         }
      else
         {
         if (qtyactual < 500 )
            {
            if (document.form1.RadioClass[0].checked == true)
            	{
           		Dpostage = Math.round((qtyactual * 0.45));
            	sub += Math.round((qtyactual * 0.45));
            	}
            else
            	{
            	Dpostage = Math.round((qtyactual * 0.281));
            	sub += Math.round((qtyactual * 0.281));
            	}
            }
         else
            {
             if (document.form1.RadioClass[0].checked == true)
                {
                Dpostage = Math.round((qtyactual * 0.404));
                sub += Math.round((qtyactual * 0.404));
                }
             else
                {
                Dpostage = Math.round((qtyactual * 0.281));
                sub += Math.round((qtyactual * 0.281));
                }
            }
         }
      if (qtynext < 200)
         {
         sub1 += Math.round((qtynext * 0.45));
         }
      else
         {
         if (qtynext < 500 )
            {
            if (document.form1.RadioClass[0].checked == true)
            	{
            	sub1 += Math.round((qtynext * 0.281));
            	}
            else
            	{
            	sub1 += Math.round((qtynext * 0.45));
            	}
            }
         else
            {
             if (document.form1.RadioClass[0].checked == true)
                {
                sub1 += Math.round((qtynext * 0.404));
                }
             else
                {
                sub1 += Math.round((qtynext * 0.281));
                }
            }
         }
      if (qtynext2 < 200)
         {
         sub2 += Math.round((qtynext2 * 0.45));
         }
      else
         {
         if (qtynext2 < 500 )
            {
            if (document.form1.RadioClass[0].checked == true)
            	{
            	sub2 += Math.round((qtynext2 * 0.45));
            	}
            else
            	{
            	sub2 += Math.round((qtynext2 * 0.281));
            	}
            }
         else
            {
             if (document.form1.RadioClass[0].checked == true)
                {
                sub2 += Math.round((qtynext2 * 0.404));
                }
             else
                {
                sub2 += Math.round((qtynext2 * 0.281));
                }
            }
         }
      }
   // add 25% for 1 day
   if (document.form1.RadioDelivery[1].checked)
      {
      Dday = Math.round(Savesub * .25);
      sub += Math.round(Savesub * .25);
      sub1 += Math.round(Savesub1 * .25);
      sub2 += Math.round(Savesub2 * .25);
      }
   // add 50% for same day
   if (document.form1.RadioDelivery[2].checked)
      {
      Dday = Math.round(Savesub * .5);
      sub += Math.round(Savesub * .5);
      sub1 += Math.round(Savesub1 * .5);
      sub2 += Math.round(Savesub2 * .5);
      }
   // For display purpose only do something special here
   Ddiscount = sub;
   // Give discount for ready to print
   if (document.form1.RadioDesign[1].checked)
      {
      if (qtyactual<500)
         {
         if (FlyerIndex == 0 && document.form1.RadioFlyerColor[0].checked) sub -= 20;
         if (FlyerIndex == 0 && document.form1.RadioFlyerColor[1].checked) sub -= 30;
         if (FlyerIndex == 0 && document.form1.RadioFlyerColor[2].checked) sub -= 30;
         if (FlyerIndex == 1 && document.form1.RadioFlyerColor[0].checked) sub -= 30;
         if (FlyerIndex == 1 && document.form1.RadioFlyerColor[1].checked) sub -= 45;
         if (FlyerIndex == 1 && document.form1.RadioFlyerColor[2].checked) sub -= 45;
         }
      else
        {
        if (qtyactual<1000)
           {
           if (FlyerIndex == 0 && document.form1.RadioFlyerColor[0].checked) sub -= 30;
           if (FlyerIndex == 0 && document.form1.RadioFlyerColor[1].checked) sub -= 40;
           if (FlyerIndex == 0 && document.form1.RadioFlyerColor[2].checked) sub -= 40;
           if (FlyerIndex == 1 && document.form1.RadioFlyerColor[0].checked) sub -= 45;
           if (FlyerIndex == 1 && document.form1.RadioFlyerColor[1].checked) sub -= 60;
           if (FlyerIndex == 1 && document.form1.RadioFlyerColor[2].checked) sub -= 60;
           }
        else
           {
           if (FlyerIndex == 0 && document.form1.RadioFlyerColor[0].checked) sub -= 40;
           if (FlyerIndex == 0 && document.form1.RadioFlyerColor[1].checked) sub -= 50;
           if (FlyerIndex == 0 && document.form1.RadioFlyerColor[2].checked) sub -= 50;
           if (FlyerIndex == 1 && document.form1.RadioFlyerColor[0].checked) sub -= 60;
           if (FlyerIndex == 1 && document.form1.RadioFlyerColor[1].checked) sub -= 75;
           if (FlyerIndex == 1 && document.form1.RadioFlyerColor[2].checked) sub -= 75;
           }
        }
      }
   if (document.form1.RadioDesign[1].checked)
      {
      if (qtynext<500)
         {
         if (FlyerIndex == 0 && document.form1.RadioFlyerColor[0].checked) sub1 -= 20;
         if (FlyerIndex == 0 && document.form1.RadioFlyerColor[1].checked) sub1 -= 30;
         if (FlyerIndex == 0 && document.form1.RadioFlyerColor[2].checked) sub1 -= 30;
         if (FlyerIndex == 1 && document.form1.RadioFlyerColor[0].checked) sub1 -= 30;
         if (FlyerIndex == 1 && document.form1.RadioFlyerColor[1].checked) sub1 -= 45;
         if (FlyerIndex == 1 && document.form1.RadioFlyerColor[2].checked) sub1 -= 45;
         }
      else
         {
         if (qtynext<1000)
            {
            if (FlyerIndex == 0 && document.form1.RadioFlyerColor[0].checked) sub1 -= 30;
            if (FlyerIndex == 0 && document.form1.RadioFlyerColor[1].checked) sub1 -= 40;
            if (FlyerIndex == 0 && document.form1.RadioFlyerColor[2].checked) sub1 -= 40;
            if (FlyerIndex == 1 && document.form1.RadioFlyerColor[0].checked) sub1 -= 45;
            if (FlyerIndex == 1 && document.form1.RadioFlyerColor[1].checked) sub1 -= 60;
            if (FlyerIndex == 1 && document.form1.RadioFlyerColor[2].checked) sub1 -= 60;
            }
         else
            {
            if (FlyerIndex == 0 && document.form1.RadioFlyerColor[0].checked) sub1 -= 40;
            if (FlyerIndex == 0 && document.form1.RadioFlyerColor[1].checked) sub1 -= 50;
            if (FlyerIndex == 0 && document.form1.RadioFlyerColor[2].checked) sub1 -= 50;
            if (FlyerIndex == 1 && document.form1.RadioFlyerColor[0].checked) sub1 -= 60;
            if (FlyerIndex == 1 && document.form1.RadioFlyerColor[1].checked) sub1 -= 75;
            if (FlyerIndex == 1 && document.form1.RadioFlyerColor[2].checked) sub1 -= 75;
            }
         }
      }
   if (document.form1.RadioDesign[1].checked)
      {
      if (qtynext2 < 500)
         {
         if (FlyerIndex == 0 && document.form1.RadioFlyerColor[0].checked) sub2 -= 20;
         if (FlyerIndex == 0 && document.form1.RadioFlyerColor[1].checked) sub2 -= 30;
         if (FlyerIndex == 0 && document.form1.RadioFlyerColor[2].checked) sub2 -= 30;
         if (FlyerIndex == 1 && document.form1.RadioFlyerColor[0].checked) sub2 -= 30;
         if (FlyerIndex == 1 && document.form1.RadioFlyerColor[1].checked) sub2 -= 45;
         if (FlyerIndex == 1 && document.form1.RadioFlyerColor[2].checked) sub2 -= 45;
         }
      else
         {
         if (qtynext2 < 1000)
            {
            if (FlyerIndex == 0 && document.form1.RadioFlyerColor[0].checked) sub2 -= 30;
            if (FlyerIndex == 0 && document.form1.RadioFlyerColor[1].checked) sub2 -= 40;
            if (FlyerIndex == 0 && document.form1.RadioFlyerColor[2].checked) sub2 -= 40;
            if (FlyerIndex == 1 && document.form1.RadioFlyerColor[0].checked) sub2 -= 45;
            if (FlyerIndex == 1 && document.form1.RadioFlyerColor[1].checked) sub2 -= 60;
            if (FlyerIndex == 1 && document.form1.RadioFlyerColor[2].checked) sub2 -= 60;
            }
         else
            {
            if (FlyerIndex == 0 && document.form1.RadioFlyerColor[0].checked) sub2 -= 40;
            if (FlyerIndex == 0 && document.form1.RadioFlyerColor[1].checked) sub2 -= 50;
            if (FlyerIndex == 0 && document.form1.RadioFlyerColor[2].checked) sub2 -= 50;
            if (FlyerIndex == 1 && document.form1.RadioFlyerColor[0].checked) sub2 -= 60;
            if (FlyerIndex == 1 && document.form1.RadioFlyerColor[1].checked) sub2 -= 75;
            if (FlyerIndex == 1 && document.form1.RadioFlyerColor[2].checked) sub2 -= 75;
            }
         }
      }
   // For display purpose only do something special here
   Ddiscount = sub - Ddiscount;
   document.form1.total.value = MakeCents(sub * 100);
   document.form1.total0.value = MakeCents(sub * 100);
   document.form1.total1.value = MakeCents(sub1 * 100);
   document.form1.total2.value = MakeCents(sub2 * 100);
   document.form1.plus0.value = qtyactual;
   document.form1.plus1.value = qtynext;
   document.form1.plus2.value = qtynext2;
   document.form1.unit0.value = format(sub / qtyactual,4);
   document.form1.unit1.value = format(sub1 / qtynext,4);
   document.form1.unit2.value = format(sub2 / qtynext2,4);
   }

 // BROCHURES

if(document.form1.Material.selectedIndex == 5)
   {
   //alert('it is 3');
   document.getElementById('divDays').style.display = 'block';
   document.getElementById('divCopyDays').style.display = 'none';
   document.getElementById('divDesign').style.display = 'block';
   document.getElementById('divPerf').style.display = 'block';
   document.getElementById('divUV').style.display = 'block';
   document.getElementById('divColor').style.display = 'none';
   document.getElementById('divStock').style.display = 'block';
   // if matte paper stock is selected hide UV options.
   if (document.form1.RadioStock[0].checked){
   	document.getElementById('divUV').style.display = 'block';
   }
   else{
   	document.getElementById('divUV').style.display = 'none';
   	document.form1.RadioUV[0].checked = true;
   }
   document.getElementById('divQtyInput').style.display = 'block';
   document.getElementById('divFlyerColor').style.display = 'none';
   document.getElementById('divCopyColor').style.display = 'none';
   // turn off VDP flag if no mail is selected
   if(document.form1.RadioMail[0].checked) document.form1.RadioVDP[0].checked = true;
   // for 8.5x11, 12x9 and 11x17 turn on EDDM
   if(BrochIndex < 3)
   	{
  			document.getElementById('divEDDM').style.display = 'block';
  		}
  	else
  		{
  			document.getElementById('divEDDM').style.display = 'none';
  		}
   // if EDDM selected then check qty, must be 200 or more
   if (document.getElementById('divEDDM').style.display == 'block')
   	{
   	if (qtyactual < 200 && (document.form1.RadioEDDM[1].checked || document.form1.RadioEDDM[2].checked))
			{
			alert('For EDDM qty must be at least 200');
			if(document.form1.RadioQty[1].checked == true)
			{
				document.form1.QtyEntered.value = 200;
			}
			else
			{
				document.form1.QtySelection.selectedIndex = 3;
			}
			SelectionMade();
			return;
			}
		// if EDDM checked, turn off Mail selection (there is no fold option)
		if(document.form1.RadioEDDM[1].checked || document.form1.RadioEDDM[2].checked)
			{
				if(EDDM_change)
					{
					document.form1.RadioMail[0].checked = true;
					save_mail_checked = 0;
					}
			}
		}
   document.getElementById('divBroch').style.display = 'block';
   document.getElementById('divMail').style.display = 'block';
   if(document.form1.RadioMail[1].checked)
      {
      if (mail_change)
      	{
      	document.form1.RadioEDDM[0].checked = true;
      	save_EDDM_checked = 0;
      	}
      document.getElementById('divClass').style.display = 'block';
      document.getElementById('divList').style.display = 'block';
      document.getElementById('divVDP').style.display = 'block';
      document.getElementById('PostageIncluded').style.display = '';
      }
   else
      {
      document.getElementById('divClass').style.display = 'none';
      document.getElementById('divList').style.display = 'none';
      document.getElementById('divVDP').style.display = 'none';
      document.form1.RadioVDP[0].checked = true;
      document.getElementById('PostageIncluded').style.display = 'none';
      }
   document.getElementById('divFold').style.display = 'none';
   document.getElementById('divCard').style.display = 'none';
   document.getElementById('divDoor').style.display = 'none';
   document.getElementById('divFolded').style.display = 'none';
   document.getElementById('divFlyer').style.display = 'none';
   document.getElementById('divPoster').style.display = 'none';
   document.getElementById('divCopy').style.display = 'none';
   document.getElementById('divWidthHeight').style.display = 'none';
   document.getElementById('divMaterial').style.display = 'none';
   if (!show_quantity)
   	{
   	document.getElementById('divQuantity').style.display = 'block';
   	}
   document.getElementById('divGicleeQty').style.display = 'none';
   document.getElementById('divUnit').style.display = 'block';
   }
if(document.form1.Material.selectedIndex == 5)
   {
   if (!show_quantity && BrochIndex == 3 && qty < 2)
   	{
   	alert('Minimum quantity is 150');
   	qtyactual = 150;
   	document.form1.QtySelection.selectedIndex = 2;
   	qty = 2;
   	}
   if (!show_quantity && (BrochIndex == 4 || BrochIndex == 5) && qty < 1)
   	{
   	alert('Minimum quantity is 100');
   	qtyactual = 100;
   	document.form1.QtySelection.selectedIndex = 1;
   	qty = 1;
   	}
   if (show_quantity && BrochIndex == 3 && document.form1.QtyEntered.value < 150)
   	{
   	alert('Minimum quantity is 150');
   	document.form1.QtyEntered.value = 150;
   	ManualQty = 150;
   	qtyactual = ManualQty;
   	StepDown = 2;
   	qty = 2;
   	}
   if (show_quantity && (BrochIndex == 4 || BrochIndex == 5) && document.form1.QtyEntered.value < 100)
   	{
   	alert('Minimum quantity is 100');
   	document.form1.QtyEntered.value = 100;
   	ManualQty = 100;
   	qtyactual = ManualQty;
   	StepDown = 1;
   	qty = 1;
   	}
   // Recalculate qtynex and qtynext2 since we may had to change to base in order to meet minimum quantity
   (qty+2 > document.form1.QtySelection.options.length) ? (qtynext = qtyactual):(qtynext = document.form1.QtySelection[qty+1].value);
	(qty+3 > document.form1.QtySelection.options.length) ? (qtynext2 = qtynext):(qtynext2 = document.form1.QtySelection[qty+2].value);
   if (BrochIndex == 0) sku_array = sku[16];// 8.5x11 or 8x9 brochure
   if (BrochIndex == 1) sku_array = sku[17];// 12x9 brochure
   if (BrochIndex == 2 || BrochIndex == 6 || BrochIndex == 7) sku_array = sku[18];// 11x17 brochure and all the custom size brochures that is one up
	if (BrochIndex == 3) sku_array = sku[29];// All the custom size brochures that is three up
	if (BrochIndex == 4 || BrochIndex == 5) sku_array = sku[30];// All the custom size brochures that is two up
	sub = sku_array[qty+1];
   (qty+2 > document.form1.QtySelection.options.length) ? (sub1 = sub):(sub1 = sku_array[qty+2]);
   (qty+3 > document.form1.QtySelection.options.length) ? (sub2 = sub1):(sub2 = sku_array[qty+3]);
	if (show_quantity && sub != sub1)
		{
		sub = Math.ceil(sub + (((sub1 - sub)/(parseInt(document.form1.QtySelection[StepDown+1].value) - parseInt(document.form1.QtySelection[StepDown].value))) * (ManualQty - parseInt(document.form1.QtySelection[StepDown].value))));
		}
   Dbase = sub;
   Savesub = sub;
   Savesub1 = sub1;
   Savesub2 = sub2;
   // add Perforation - no charge for brochures
   // add UV coating
   if (document.form1.RadioUV[1].checked)
      {
      DUV = Math.round(qtyactual * .02);      
      sub += DUV;
      sub1 += Math.round(qtynext * .02);
      sub2 += Math.round(qtynext2 * .02);
      }
   if (document.form1.RadioUV[2].checked)
      {
      DUV = Math.round(qtyactual * .04);      
      sub += DUV;
      sub1 += Math.round(qtynext * .04);
      sub2 += Math.round(qtynext2 * .04);
      }
    // Add EDDM
   if (document.form1.RadioEDDM[2].checked && document.getElementById('divEDDM').style.display == 'block')
   	{
   	document.getElementById('PostageIncluded').style.display = '';
   	DEDDM = Math.round((qtyactual/50)*.5) + Math.ceil(qtyactual/5000)*25;
   	Dpostage = Math.round(qtyactual*.145);
      sub += Math.round((qtyactual/50)*.5) + Math.ceil(qtyactual/5000)*25 + Math.round(qtyactual*.145);
      sub1 += Math.round((qtynext/50)*.5) + Math.ceil(qtynext/5000)*25 + Math.round(qtynext*.145);
      sub2 += Math.round((qtynext2/50)*.5) + Math.ceil(qtynext2/5000)*25 + Math.round(qtynext2*.145);
      // save sub here again as base for rushing orders
   	Savesub = sub - Dpostage;
   	Savesub1 = sub1 - Dpostage;
   	Savesub2 = sub2 - Dpostage;
   	}
   // Add DMS
   if (document.form1.RadioMail[1].checked && document.getElementById('divMail').style.display == 'block')
      {
      Ddms = Math.round(((qtyactual/500)*30) + 65);
      sub += Math.round(((qtyactual/500)*30) + 65);
      sub1 += Math.round(((qtynext/500)*30) + 65);
      sub2 += Math.round(((qtynext2/500)*30) + 65);
      // Add tabbing
      Dtab = Math.round(((qtyactual/500)*15)+5);
      sub += Math.round(((qtyactual/500)*15)+5);
      sub1 += Math.round(((qtynext/500)*15)+5);
      sub2 += Math.round(((qtynext2/500)*15)+5);
      // Add mailing list
      if (document.form1.RadioList[1].checked)
         {
         if (qtyactual < 3000)
    	   	{
    	   	Dlist = 25;
    	   	sub += 25;
           	}
    	 	else
    	   	{
    	   	Dlist = (qtyactual/100);
    	   	sub += (qtyactual/100);
           	}
         if (qtynext < 3000)
    	   	{
    	   	sub1 += 25;
           	}
    	 	else
    	   	{
    	   	sub1 += (qtynext/100);
           	}
         if (qtynext2 < 3000)
    	   	{
    	   	sub2 += 25;
           	}
    	 	else
    	   	{
    	   	sub2 += (qtynext2/100);
           	}
         }
      // Add VDP
      if (document.form1.RadioVDP[1].checked == true)
         {
         Dvdp = Math.round(((qtyactual/500)*30) + 40);
         sub += Math.round(((qtyactual/500)*30) + 40);
         sub1 += Math.round(((qtynext/500)*30) + 40);
         sub2 += Math.round(((qtynext2/500)*30) + 40);
         }
      Savesub = sub;
      Savesub1 = sub1;
      Savesub2 = sub2;
      // Calculate postage
      // Force to be first class if less then 200, standard if 200 or 250 otherwise user's choice
      if (qtyactual < 200)
         {
         document.form1.RadioClass[0].checked = true;
         Dpostage = Math.round((qtyactual * 0.45));
         sub += Math.round((qtyactual * 0.45));
         }
      else
         {
         if (qtyactual < 500 )
            {
            if (document.form1.RadioClass[0].checked == true)
            	{
	            Dpostage = Math.round((qtyactual * 0.45));
   	         sub += Math.round((qtyactual * 0.45));
   	         }
   	      else
   	      	{
   	      	Dpostage = Math.round((qtyactual * 0.281));
   	         sub += Math.round((qtyactual * 0.281));
   	      	}
            }
         else
            {
             if (document.form1.RadioClass[0].checked == true)
                {
                Dpostage = Math.round((qtyactual * 0.404));
                sub += Math.round((qtyactual * 0.404));
                }
             else
                {
                Dpostage = Math.round((qtyactual * 0.281));
                sub += Math.round((qtyactual * 0.281));
                }
            }
         }
      if (qtynext < 200)
         {
         sub1 += Math.round((qtynext * 0.45));
         }
      else
         {
         if (qtynext < 500 )
            {
            if (document.form1.RadioClass[0].checked == true)
            	{
            	sub1 += Math.round((qtynext * 0.45));
            	}
            else
            	{
            	sub1 += Math.round((qtynext * 0.281));
            	}
            }
         else
            {
             if (document.form1.RadioClass[0].checked == true)
                {
                sub1 += Math.round((qtynext * 0.404));
                }
             else
                {
                sub1 += Math.round((qtynext * 0.281));
                }
            }
         }
      if (qtynext2 < 200)
         {
         sub2 += Math.round((qtynext2 * 0.45));
         }
      else
         {
         if (qtynext2 < 500 )
            {
            if (document.form1.RadioClass[0].checked == true)
            	{
            	sub2 += Math.round((qtynext2 * 0.45));
            	}
            else
            	{
            	sub2 += Math.round((qtynext2 * 0.281));
            	}
            }
         else
            {
             if (document.form1.RadioClass[0].checked == true)
                {
                sub2 += Math.round((qtynext2 * 0.404));
                }
             else
                {
                sub2 += Math.round((qtynext2 * 0.281));
                }
            }
         }
      }
   // add 25% for 1 day
   if (document.form1.RadioDelivery[1].checked)
      {
      Dday = Math.round(Savesub * .25);
      sub += Math.round(Savesub * .25);
      sub1 += Math.round(Savesub1 * .25);
      sub2 += Math.round(Savesub2 * .25);
      }
   // add 50% for same day
   if (document.form1.RadioDelivery[2].checked)
      {
      Dday = Math.round(Savesub * .5);
      sub += Math.round(Savesub * .5);
      sub1 += Math.round(Savesub1 * .5);
      sub2 += Math.round(Savesub2 * .5);
      }
   // For display purpose only do something special here
   Ddiscount = sub;
   // Give discount for ready to print
   if (document.form1.RadioDesign[1].checked)
      {
      if (qtyactual<500)
         {
         if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 0 || BrochIndex == 1 || BrochIndex == 3 || BrochIndex == 4 || BrochIndex == 5)) sub -= 30;
         if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 2 || BrochIndex == 6 || BrochIndex == 7)) sub -= 45;
         }
      else
        {
        if (qtyactual<1000)
           {
           if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 0 || BrochIndex == 1 || BrochIndex == 4 || BrochIndex == 5)) sub -= 40;
           if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 2 || BrochIndex == 6 || BrochIndex == 7)) sub -= 60;
           if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 3)) sub -= 35;
           }
        else
           {
           if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 0 || BrochIndex == 1 || BrochIndex == 4 || BrochIndex == 5)) sub -= 50;
           if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 2 || BrochIndex == 6 || BrochIndex == 7)) sub -= 75;
           if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 3)) sub -= 40;
           }
        }
      }
   if (document.form1.RadioDesign[1].checked)
      {
      if (qtynext<500)
         {
         if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 0 || BrochIndex == 1 || BrochIndex == 3 || BrochIndex == 4 || BrochIndex == 5)) sub1 -= 30;
         if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 2 || BrochIndex == 6 || BrochIndex == 7)) sub1 -= 45;
         }
      else
         {
         if (qtynext<1000)
            {
            if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 0 || BrochIndex == 1 || BrochIndex == 4 || BrochIndex == 5)) sub1 -= 40;
            if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 2 || BrochIndex == 6 || BrochIndex == 7)) sub1 -= 60;
            if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 3)) sub1 -= 35;
            }
         else
            {
            if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 0 || BrochIndex == 1 || BrochIndex == 4 || BrochIndex == 5)) sub1 -= 50;
          	if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 2 || BrochIndex == 6 || BrochIndex == 7)) sub1 -= 75;
            if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 3)) sub1 -= 40;
            }
         }
      }
   if (document.form1.RadioDesign[1].checked)
      {
      if (qtynext2 < 500)
         {
         if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 0 || BrochIndex == 1 || BrochIndex == 3 || BrochIndex == 4 || BrochIndex == 5)) sub2 -= 30;
         if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 2 || BrochIndex == 6 || BrochIndex == 7)) sub2 -= 45;
         }
      else
         {
         if (qtynext2 < 1000)
            {
            if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 0 || BrochIndex == 1 || BrochIndex == 4 || BrochIndex == 5)) sub2 -= 40;
           	if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 2 || BrochIndex == 6 || BrochIndex == 7)) sub2 -= 60;
           	if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 3)) sub2 -= 35;
            }
         else
            {
            if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 0 || BrochIndex == 1 || BrochIndex == 4 || BrochIndex == 5)) sub2 -= 50;
           	if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 2 || BrochIndex == 6 || BrochIndex == 7)) sub2 -= 75;
           	if (document.getElementById('divBroch').style.display == 'block' && (BrochIndex == 3)) sub2 -= 40;
            }
         }
      }
   // For display purpose only do something special here
   Ddiscount = sub - Ddiscount;
   document.form1.total.value = MakeCents(sub * 100);
   document.form1.total0.value = MakeCents(sub * 100);
   document.form1.total1.value = MakeCents(sub1 * 100);
   document.form1.total2.value = MakeCents(sub2 * 100);
   document.form1.plus0.value = qtyactual;
   document.form1.plus1.value = qtynext;
   document.form1.plus2.value = qtynext2;
   document.form1.unit0.value = format(sub / qtyactual,4);
   document.form1.unit1.value = format(sub1 / qtynext,4);
   document.form1.unit2.value = format(sub2 / qtynext2,4);
   }
 // POSTERS  
   
if(document.form1.Material.selectedIndex == 6)
   {
   //alert('it is 4');
   document.getElementById('divDays').style.display = 'block';
   document.getElementById('divCopyDays').style.display = 'none';
   document.getElementById('divDesign').style.display = 'block';
   document.getElementById('divColor').style.display = 'none';
   document.getElementById('divStock').style.display = 'block';
   document.getElementById('divPerf').style.display = 'block';
   // no UV on flyer stock OR if matte paper stock is selected hide UV options.
   if (document.form1.RadioStock[0].checked && PosterIndex != 0){
   	document.getElementById('divUV').style.display = 'block';
   }
   else{
   	document.getElementById('divUV').style.display = 'none';
   	document.form1.RadioUV[0].checked = true;
   }
   document.getElementById('divQtyInput').style.display = 'block';
   document.getElementById('divFlyerColor').style.display = 'block';
   document.getElementById('divCopyColor').style.display = 'none';
   document.getElementById('divEDDM').style.display = 'none';
   document.getElementById('divMail').style.display = 'none';
   document.getElementById('divClass').style.display = 'none';
   document.getElementById('divList').style.display = 'none';
   document.getElementById('divVDP').style.display = 'none';
   // turn off VDP flag if no mail is selected
   if(document.form1.RadioMail[0].checked) document.form1.RadioVDP[0].checked = true;
   document.getElementById('divFold').style.display = 'none';
   document.getElementById('divCard').style.display = 'none';
   document.getElementById('divDoor').style.display = 'none';
   document.getElementById('divFolded').style.display = 'none';
   document.getElementById('divFlyer').style.display = 'none';
   document.getElementById('divPoster').style.display = 'block';
   document.getElementById('divCopy').style.display = 'none';
   document.getElementById('divBroch').style.display = 'none';
   document.getElementById('divWidthHeight').style.display = 'none';
   document.getElementById('divMaterial').style.display = 'none';
   if (!show_quantity)
   	{
   	document.getElementById('divQuantity').style.display = 'block';
   	}
   document.getElementById('divGicleeQty').style.display = 'none';
   document.getElementById('divUnit').style.display = 'block';
   }
if(document.form1.Material.selectedIndex == 6)
   {
   if (PosterIndex == 0)
      {
      sku_array = sku[19];// 12x18 4/0 flyer poster
      if (document.form1.RadioFlyerColor[1].checked)
         {
         sku_array = sku[20];// 12x18 4/1 flyer poster
         }
      if (document.form1.RadioFlyerColor[2].checked)
         {
         sku_array = sku[21];// 12x18 4/4 flyer poster
         }
      }
   if (PosterIndex == 1)
      {
      sku_array = sku[22];// 12x18 4/0 broch poster
      if (document.form1.RadioFlyerColor[1].checked)
         {
         sku_array = sku[23];// 12x18 4/1 broch poster
         }
      if (document.form1.RadioFlyerColor[2].checked)
         {
         sku_array = sku[24];// 12x18 4/4 broch poster
         }
      }
   if (PosterIndex == 2)
      {
      sku_array = sku[25];// 12x18 4/0 card poster
      if (document.form1.RadioFlyerColor[1].checked)
         {
         sku_array = sku[26];// 12x18 4/1 card poster
         }
      if (document.form1.RadioFlyerColor[2].checked)
         {
         sku_array = sku[27];// 12x18 4/4 card poster
         }
      }
   sub = sku_array[qty+1];
   (qty+2 > document.form1.QtySelection.options.length) ? (sub1 = sub):(sub1 = sku_array[qty+2]);
   (qty+3 > document.form1.QtySelection.options.length) ? (sub2 = sub1):(sub2 = sku_array[qty+3]);
	if (show_quantity && sub != sub1)
		{
		sub = Math.ceil(sub + (((sub1 - sub)/(parseInt(document.form1.QtySelection[StepDown+1].value) - parseInt(document.form1.QtySelection[StepDown].value))) * (ManualQty - parseInt(document.form1.QtySelection[StepDown].value))));
		}
   Dbase = sub;

   Savesub = sub;
   Savesub1 = sub1;
   Savesub2 = sub2;
	
	// add Perforation - this must after folding (if can be) since folding will null perforation charge
   if (document.form1.RadioPerf[1].checked && document.getElementById('divPerf').style.display == 'block')
      {
   	DPerf = Math.round(((qtyactual/500)*15)+50);
     	sub += Math.round(((qtyactual/500)*15)+50);
     	sub1 += Math.round(((qtynext/500)*15)+50);
     	sub2 += Math.round(((qtynext2/500)*15)+50);
     	}
   // add UV coating
   if (document.form1.RadioUV[1].checked)
      {
      DUV = Math.round(qtyactual * .02);      
      sub += DUV;
      sub1 += Math.round(qtynext * .02);
      sub2 += Math.round(qtynext2 * .02);
      }
   if (document.form1.RadioUV[2].checked)
      {
      DUV = Math.round(qtyactual * .04);      
      sub += DUV;
      sub1 += Math.round(qtynext * .04);
      sub2 += Math.round(qtynext2 * .04);
      }
   // add 25% for 1 day
   if (document.form1.RadioDelivery[1].checked)
      {
      Dday = Math.round(Savesub * .25);
      sub += Math.round(Savesub * .25);
      sub1 += Math.round(Savesub1 * .25);
      sub2 += Math.round(Savesub2 * .25);
      }
   // add 50% for same day
   if (document.form1.RadioDelivery[2].checked)
      {
      Dday = Math.round(Savesub * .5);
      sub += Math.round(Savesub * .5);
      sub1 += Math.round(Savesub1 * .5);
      sub2 += Math.round(Savesub2 * .5);
      }
   // For display purpose only do something special here
   Ddiscount = sub;
   // Give discount for ready to print
   if (document.form1.RadioDesign[1].checked)
      {
      if (qtyactual<500)
         {
         if (document.form1.RadioFlyerColor[0].checked) sub -= 30;
         if (document.form1.RadioFlyerColor[1].checked) sub -= 45;
         if (document.form1.RadioFlyerColor[2].checked) sub -= 45;
         }
      else
        {
        if (qtyactual<1000)
           {
           if (document.form1.RadioFlyerColor[0].checked) sub -= 45;
           if (document.form1.RadioFlyerColor[1].checked) sub -= 60;
           if (document.form1.RadioFlyerColor[2].checked) sub -= 60;
           }
        else
           {
           if (document.form1.RadioFlyerColor[0].checked) sub -= 60;
           if (document.form1.RadioFlyerColor[1].checked) sub -= 75;
           if (document.form1.RadioFlyerColor[2].checked) sub -= 75;
           }
        }
      }
   if (document.form1.RadioDesign[1].checked)
      {
      if (qtynext<500)
         {
         if (document.form1.RadioFlyerColor[0].checked) sub1 -= 30;
         if (document.form1.RadioFlyerColor[1].checked) sub1 -= 45;
         if (document.form1.RadioFlyerColor[2].checked) sub1 -= 45;
         }
      else
         {
         if (qtynext<1000)
            {
            if (document.form1.RadioFlyerColor[0].checked) sub1 -= 45;
            if (document.form1.RadioFlyerColor[1].checked) sub1 -= 60;
            if (document.form1.RadioFlyerColor[2].checked) sub1 -= 60;
            }
         else
            {
            if (document.form1.RadioFlyerColor[0].checked) sub1 -= 60;
            if (document.form1.RadioFlyerColor[1].checked) sub1 -= 75;
            if (document.form1.RadioFlyerColor[2].checked) sub1 -= 75;
            }
         }
      }
   if (document.form1.RadioDesign[1].checked)
      {
      if (qtynext2 < 500)
         {
         if (document.form1.RadioFlyerColor[0].checked) sub2 -= 30;
         if (document.form1.RadioFlyerColor[1].checked) sub2 -= 45;
         if (document.form1.RadioFlyerColor[2].checked) sub2 -= 45;
         }
      else
         {
         if (qtynext2 < 1000)
            {
            if (document.form1.RadioFlyerColor[0].checked) sub2 -= 45;
            if (document.form1.RadioFlyerColor[1].checked) sub2 -= 60;
            if (document.form1.RadioFlyerColor[2].checked) sub2 -= 60;
            }
         else
            {
            if (document.form1.RadioFlyerColor[0].checked) sub2 -= 60;
            if (document.form1.RadioFlyerColor[1].checked) sub2 -= 75;
            if (document.form1.RadioFlyerColor[2].checked) sub2 -= 75;
            }
         }
      }
   // For display purpose only do something special here
   Ddiscount = sub - Ddiscount;
   document.form1.total.value = MakeCents(sub * 100);
   document.form1.total0.value = MakeCents(sub * 100);
   document.form1.total1.value = MakeCents(sub1 * 100);
   document.form1.total2.value = MakeCents(sub2 * 100);
   document.form1.plus0.value = qtyactual;
   document.form1.plus1.value = qtynext;
   document.form1.plus2.value = qtynext2;
   document.form1.unit0.value = format(sub / qtyactual,4);
   document.form1.unit1.value = format(sub1 / qtynext,4);
   document.form1.unit2.value = format(sub2 / qtynext2,4);
   }
 // COLOR COPY  
   
if(document.form1.Material.selectedIndex == 7)
   {
   //alert('it is 7');
   document.getElementById('divQtyInput').style.display = 'block';
   document.getElementById('divDays').style.display = 'none';
   document.getElementById('divCopyDays').style.display = 'block';
   document.getElementById('divDesign').style.display = 'none';
   document.getElementById('divColor').style.display = 'none';
   document.getElementById('divStock').style.display = 'none';
   document.getElementById('divPerf').style.display = 'block';
   document.getElementById('divUV').style.display = 'none';
   document.getElementById('divFlyerColor').style.display = 'none';
   document.getElementById('divCopyColor').style.display = 'block';
   document.getElementById('divEDDM').style.display = 'none';
   document.getElementById('divMail').style.display = 'none';
   document.getElementById('divClass').style.display = 'none';
   document.getElementById('divList').style.display = 'none';
   document.getElementById('divVDP').style.display = 'none';
   // turn off VDP flag if no mail is selected
   if(document.form1.RadioMail[0].checked) document.form1.RadioVDP[0].checked = true;
   document.getElementById('divFold').style.display = 'none';
   document.getElementById('divCard').style.display = 'none';
   document.getElementById('divDoor').style.display = 'none';
   document.getElementById('divFolded').style.display = 'none';
   document.getElementById('divFlyer').style.display = 'none';
   document.getElementById('divPoster').style.display = 'none';
   document.getElementById('divCopy').style.display = 'block';
   document.getElementById('divBroch').style.display = 'none';
   document.getElementById('divWidthHeight').style.display = 'none';
   document.getElementById('divMaterial').style.display = 'none';
   if (!show_quantity)
   	{
   	document.getElementById('divQuantity').style.display = 'block';
   	}
   document.getElementById('divGicleeQty').style.display = 'none';
   document.getElementById('divUnit').style.display = 'block';
   }
if(document.form1.Material.selectedIndex == 7)
   {
   if (CopyIndex == 0 || CopyIndex == 1)
      {
      sku_array = sku[19];// 12x18 4/0 flyer poster
      if (document.form1.RadioCopyColor[1].checked)
         {
         sku_array = sku[21];// 12x18 4/4 flyer poster
         }
      }
   if (CopyIndex == 2)
      {
      sku_array = sku[22];// 12x18 4/0 broch poster
      if (document.form1.RadioCopyColor[1].checked)
         {
         sku_array = sku[24];// 12x18 4/4 broch poster
         }
      }
   if (CopyIndex == 3)
      {
      sku_array = sku[25];// 12x18 4/0 card poster
      if (document.form1.RadioCopyColor[1].checked)
         {
         sku_array = sku[27];// 12x18 4/4 card poster
         }
      }
   sub = sku_array[qty+1];
   (qty+2 > document.form1.QtySelection.options.length) ? (sub1 = sub):(sub1 = sku_array[qty+2]);
   (qty+3 > document.form1.QtySelection.options.length) ? (sub2 = sub1):(sub2 = sku_array[qty+3]);
	if (show_quantity && sub != sub1)
		{
		sub = Math.ceil(sub + (((sub1 - sub)/(parseInt(document.form1.QtySelection[StepDown+1].value) - parseInt(document.form1.QtySelection[StepDown].value))) * (ManualQty - parseInt(document.form1.QtySelection[StepDown].value))));
		}
   Ddiscount = sub;
   // Give discount for copy JUST A DUMMY IF UNDER
   document.form1.RadioDesign[1].checked = true;
   if (document.form1.RadioDesign[1].checked)
      {
      if (qtyactual<500)
         {
         if (document.form1.RadioCopyColor[0].checked) sub -= 30;
         if (document.form1.RadioCopyColor[1].checked) sub -= 45;
         }
      else
        {
        if (qtyactual<1000)
           {
           if (document.form1.RadioCopyColor[0].checked) sub -= 45;
           if (document.form1.RadioCopyColor[1].checked) sub -= 60;
           }
        else
           {
           if (document.form1.RadioCopyColor[0].checked) sub -= 60;
           if (document.form1.RadioCopyColor[1].checked) sub -= 75;
           }
        }
      }
   if (document.form1.RadioDesign[1].checked)
      {
      if (qtynext<500)
         {
         if (document.form1.RadioCopyColor[0].checked) sub1 -= 30;
         if (document.form1.RadioCopyColor[1].checked) sub1 -= 45;
         }
      else
         {
         if (qtynext<1000)
            {
            if (document.form1.RadioCopyColor[0].checked) sub1 -= 45;
            if (document.form1.RadioCopyColor[1].checked) sub1 -= 60;
            }
         else
            {
            if (document.form1.RadioCopyColor[0].checked) sub1 -= 60;
            if (document.form1.RadioCopyColor[1].checked) sub1 -= 75;
            }
         }
      }
   if (document.form1.RadioDesign[1].checked)
      {
      if (qtynext2 < 500)
         {
         if (document.form1.RadioCopyColor[0].checked) sub2 -= 30;
         if (document.form1.RadioCopyColor[1].checked) sub2 -= 45;
         }
      else
         {
         if (qtynext2 < 1000)
            {
            if (document.form1.RadioCopyColor[0].checked) sub2 -= 45;
            if (document.form1.RadioCopyColor[1].checked) sub2 -= 60;
            }
         else
            {
            if (document.form1.RadioCopyColor[0].checked) sub2 -= 60;
            if (document.form1.RadioCopyColor[1].checked) sub2 -= 75;
            }
         }
      }
   // For display purpose only do something special here
   Dbase = Math.ceil(sub * .6);
   // there is really no discount here, it is part of the calculation
   Ddiscount = 0;
   // The actual is 60% of posters
   sub = Math.ceil(sub * .6);
   sub1 = Math.ceil(sub1 * .6);
   sub2 = Math.ceil(sub2 * .6);
   // add Perforation - this must after folding (if can be) since folding will null perforation charge
   // keep this here after calculating 60% of the above otherwise it will be discounted to 60%
   if (document.form1.RadioPerf[1].checked && document.getElementById('divPerf').style.display == 'block')
      {
   	DPerf = Math.round(((qtyactual/500)*15)+50);
     	sub += Math.round(((qtyactual/500)*15)+50);
     	sub1 += Math.round(((qtynext/500)*15)+50);
     	sub2 += Math.round(((qtynext2/500)*15)+50);
     	}
   document.form1.total.value = MakeCents(sub * 100);
   document.form1.total0.value = MakeCents(sub * 100);
   document.form1.total1.value = MakeCents(sub1 * 100);
   document.form1.total2.value = MakeCents(sub2 * 100);
   document.form1.plus0.value = qtyactual;
   document.form1.plus1.value = qtynext;
   document.form1.plus2.value = qtynext2;
   document.form1.unit0.value = format(sub / qtyactual,4);
   document.form1.unit1.value = format(sub1 / qtynext,4);
   document.form1.unit2.value = format(sub2 / qtynext2,4);
   }
// GICLEE

if(document.form1.Material.selectedIndex == 8)
   {
   //alert('it is 5');
   document.getElementById('divQtyInput').style.display = 'none';
   document.getElementById('divDays').style.display = 'none';
   document.getElementById('divCopyDays').style.display = 'none';
   document.getElementById('divDesign').style.display = 'none';
   document.getElementById('divColor').style.display = 'none';
   document.getElementById('divStock').style.display = 'none';
   document.getElementById('divPerf').style.display = 'none';
   document.getElementById('divUV').style.display = 'none';
   document.getElementById('divFlyerColor').style.display = 'none';
   document.getElementById('divCopyColor').style.display = 'none';
   document.getElementById('divEDDM').style.display = 'none';
   document.getElementById('divMail').style.display = 'none';
   document.getElementById('divClass').style.display = 'none';
   document.getElementById('divList').style.display = 'none';
   document.getElementById('divCard').style.display = 'none';
   document.getElementById('divDoor').style.display = 'none';
   document.getElementById('divFolded').style.display = 'none';
   document.getElementById('divFold').style.display = 'none';
   document.getElementById('divFlyer').style.display = 'none';
   document.getElementById('divBroch').style.display = 'none';
   document.getElementById('divPoster').style.display = 'none';
   document.getElementById('divCopy').style.display = 'none';
   document.getElementById('divWidthHeight').style.display = 'block';
   document.getElementById('divMaterial').style.display = 'block';
   document.getElementById('divQuantity').style.display = 'none';
   document.getElementById('divGicleeQty').style.display = 'block';
   document.getElementById('divUnit').style.display = 'none';
   document.getElementById('divVDP').style.display = 'none';
   }
if(document.form1.Material.selectedIndex == 8)
   {
   var GicleeSize = width2 * height2 * qty4;
   GicleeSize = Math.ceil(GicleeSize/144);
   sub = GicleeSize*giclee[GicleeIndex];
   document.form1.total.value = MakeCents(sub * 100);
   }
}
function ResetPage()
{
//alert('reset');
document.form1.RadioDelivery[0].checked = true;
document.form1.RadioDesign[0].checked = true;
document.form1.RadioColor[0].checked = true;
document.form1.RadioStock[0].checked = true;
document.form1.RadioFlyerColor[0].checked = true;
document.form1.RadioCopyColor[0].checked = true;
document.form1.CardSelection.selectedIndex = 0;
document.form1.FoldedSelection.selectedIndex = 0;
document.form1.FlyerSelection.selectedIndex = 0;
document.form1.PosterSelection.selectedIndex = 0;
document.form1.CopySelection.selectedIndex = 0;
document.form1.RadioFold[0].checked = true;
document.form1.BrochSelection.selectedIndex = 0;
document.form1.RadioEDDM[0].checked = true;
document.form1.RadioMail[0].checked = true;
document.getElementById('PostageIncluded').style.display = 'none';
document.form1.RadioClass[1].checked = true;
document.form1.RadioList[0].checked = true;
document.form1.RadioVDP[0].checked = true;
document.form1.RadioPerf[0].checked = true;
document.form1.RadioUV[0].checked = true;
document.form1.QtySelection.selectedIndex = 4;
document.form1.RadioQty[0].checked = true
document.getElementById('divEnterQty').style.display = 'none';
document.form1.QtyEntered.value = 250;
document.form1.GicleeWidth.selectedIndex = 11;
document.form1.GicleeHeight.selectedIndex = 11;
document.form1.GicleeMaterial.selectedIndex = 0;
document.form1.GicleeQty.selectedIndex = 0;
if (save_url != document.URL && document.URL.indexOf('giclee.html')!=-1){
	document.form1.Material.selectedIndex = 8;
	save_url = document.URL;
}
var query = window.location.search;
if (query.substring(0, 4) == '?123') show_detail = true;
SelectionMade()
}
function MakeCents (expr)
{
	expr = expr /100;
	//return "$" + format(expr,2);
	return format(expr,2);
}
function format (expr, decplaces)
{
	var str = "" + Math.round (eval(expr) * Math.pow(10,decplaces))
	// pad small value strings with zeros to the left of rounded number
	while (str.length <= decplaces)
	{
		str = "0" + str
	}
	// establish location of decimal point
	var decpoint = str.length - decplaces
	// assemble final result from: (a) the string up to the position of
	// the decimal point; (b) the decimal point; and (c) the balance
	// of the string. Return finished product.
	return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
}
function GoToOrderForms()
{
if(document.form1.RadioQty[1].checked == true)
{
	validate_numbers();
	if (!document.Ready_to_Post)return;
}
if (show_detail)
	{
	var browser=navigator.appName;
	if (browser=="Microsoft Internet Explorer")
		{
		alert('Pricing Breakdown - Internal use only!\n\nBase:\t\t\t'+Dbase+'\nColor:\t\t\t'+Dcolor+'\nPerf:\t\t\t'+DPerf+'\nUV:\t\t\t'+DUV+'\nFold:\t\t\t'+Dfold+'\nDoor:\t\t\t'+Ddoor+'\nEDDM:\t\t\t'+DEDDM+'\nDMS:\t\t\t'+Ddms+'\nTab:\t\t\t'+Dtab+'\nPostage:\t\t\t'+Dpostage+'\nList:\t\t\t'+Dlist+'\nVDP:\t\t\t'+Dvdp+'\nDays:\t\t\t'+Dday+'\nDiscount:\t\t\t'+Ddiscount);
		}
	else
		{
		alert('Pricing Breakdown - Internal use only!\n\nBase:\t\t\t\t'+Dbase+'\nColor:\t\t\t'+Dcolor+'\nPerf:\t\t\t\t'+DPerf+'\nUV:\t\t\t\t'+DUV+'\nFold:\t\t\t\t'+Dfold+'\nDoor:\t\t\t'+Ddoor+'\nEDDM:\t\t\t'+DEDDM+'\nDMS:\t\t\t\t'+Ddms+'\nTab:\t\t\t\t'+Dtab+'\nPostage:\t\t\t'+Dpostage+'\nList:\t\t\t\t'+Dlist+'\nVDP:\t\t\t\t'+Dvdp+'\nDays:\t\t\t'+Dday+'\nDiscount:\t\t\t'+Ddiscount);
		}
	return;
	}
var passdata = new Array();
passdata[0] = 0; // item selector
passdata[1] = 0; // color on back - cards
passdata[2] = 0; // color on back - flyers
passdata[3] = 0; // fold
passdata[4] = 0; // DMS
passdata[5] = 0; // mail class
passdata[6] = 0; // mailing list
passdata[7] = 0; // qty
passdata[8] = 0; // delivery
passdata[9] = 0; // design needed
passdata[10] = 0; // VDP
passdata[11] = 0; // UV
passdata[12] = 0; // color on back - copies
passdata[13] = 0; // stock glossy or matte - cards only
passdata[14] = 0; // quantity entered
passdata[15] = 0; // manually entered quantity
passdata[16] = 0; // Perforation
passdata[17] = 0; // EDDM

if(document.form1.Material.selectedIndex == 0) passdata[0] = 1; // Bus cards
if(document.form1.Material.selectedIndex == 1 && document.form1.CardSelection.selectedIndex == 0) passdata[0] = 2; // 6x4 postcards
if(document.form1.Material.selectedIndex == 1 && document.form1.CardSelection.selectedIndex == 1) passdata[0] = 3; // 3.5x8 postcards
if(document.form1.Material.selectedIndex == 1 && document.form1.CardSelection.selectedIndex == 2) passdata[0] = 5; // 4x9 postcards
if(document.form1.Material.selectedIndex == 1 && document.form1.CardSelection.selectedIndex == 3) passdata[0] = 7; // 4x11.5 postcards mailable
if(document.form1.Material.selectedIndex == 1 && document.form1.CardSelection.selectedIndex == 4) passdata[0] = 8; // 4x12 postcards non-mailable
if(document.form1.Material.selectedIndex == 1 && document.form1.CardSelection.selectedIndex == 5) passdata[0] = 10; // 4x12 EDDM postcards
if(document.form1.Material.selectedIndex == 1 && document.form1.CardSelection.selectedIndex == 6) passdata[0] = 11; // 5x7 postcards
if(document.form1.Material.selectedIndex == 1 && document.form1.CardSelection.selectedIndex == 7) passdata[0] = 12; // 6.2x6.2 EDDM postcards
if(document.form1.Material.selectedIndex == 1 && document.form1.CardSelection.selectedIndex == 8) passdata[0] = 13; // 6x8 postcards
if(document.form1.Material.selectedIndex == 1 && document.form1.CardSelection.selectedIndex == 9) passdata[0] = 14; // 6x9 postcards
if(document.form1.Material.selectedIndex == 1 && document.form1.CardSelection.selectedIndex == 10) passdata[0] = 15; // 6.2x9 EDDM postcards
if(document.form1.Material.selectedIndex == 1 && document.form1.CardSelection.selectedIndex == 11) passdata[0] = 16; // 6x11.5 postcards
if(document.form1.Material.selectedIndex == 1 && document.form1.CardSelection.selectedIndex == 12) passdata[0] = 17; // 6x12 EDDM postcards
if(document.form1.Material.selectedIndex == 1 && document.form1.CardSelection.selectedIndex == 13) passdata[0] = 18; // 8.5x11 postcards

if(document.form1.Material.selectedIndex == 2 && document.form1.DoorSelection.selectedIndex == 0) passdata[0] = 4; // 3.5x8 doorhanger
if(document.form1.Material.selectedIndex == 2 && document.form1.DoorSelection.selectedIndex == 1) passdata[0] = 6; // 4x9 doorhanger
if(document.form1.Material.selectedIndex == 2 && document.form1.DoorSelection.selectedIndex == 2) passdata[0] = 9; // 4x12 doorhanger

if(document.form1.Material.selectedIndex == 3) passdata[0] = document.form1.FoldedSelection.selectedIndex + 20; // folded
if(document.form1.Material.selectedIndex == 4) passdata[0] = document.form1.FlyerSelection.selectedIndex + 24; // flyers
if(document.form1.Material.selectedIndex == 5) passdata[0] = document.form1.BrochSelection.selectedIndex + 27; // brochures
if(document.form1.Material.selectedIndex == 6) passdata[0] = document.form1.PosterSelection.selectedIndex + 36; // posters
if(document.form1.Material.selectedIndex == 7) passdata[0] = document.form1.CopySelection.selectedIndex + 40; // copies

if(document.form1.Material.selectedIndex < 4 && document.form1.RadioColor[1].checked) passdata[1] = 1; // color back on bus and postcards
if(document.getElementById('divStock').style.display == 'block' && document.form1.RadioStock[1].checked) passdata[13] = 1; // matte finish on card stock
if(document.form1.Material.selectedIndex == 4 && document.form1.RadioFlyerColor[1].checked) passdata[2] = 1; // flyer back color
if(document.form1.Material.selectedIndex == 4 && document.form1.RadioFlyerColor[2].checked) passdata[2] = 2; // flyer back color
if(document.form1.Material.selectedIndex == 6 && document.form1.RadioFlyerColor[1].checked) passdata[2] = 1; // poster back color
if(document.form1.Material.selectedIndex == 6 && document.form1.RadioFlyerColor[2].checked) passdata[2] = 2; // poster back color
if(document.form1.Material.selectedIndex == 7 && document.form1.RadioCopyColor[1].checked) passdata[12] = 1; // copy back color
if ((document.form1.Material.selectedIndex == 1 || document.form1.Material.selectedIndex == 4) && document.form1.RadioFold[1].checked) passdata[3] = 1;
if (document.form1.Material.selectedIndex == 3) passdata[3] = 1;
if (document.form1.RadioMail[1].checked) passdata[4] = 1;
if (document.form1.RadioClass[0].checked) passdata[5] = 1;
if (document.form1.RadioList[1].checked) passdata[6] = 1;
passdata[7] = document.form1.QtySelection.selectedIndex;
if (document.form1.RadioDelivery[1].checked) passdata[8] = 1;
if (document.form1.RadioDelivery[2].checked) passdata[8] = 2;
if (document.form1.RadioDesign[1].checked) passdata[9] = 1;
if (document.form1.RadioVDP[1].checked) passdata[10] = 1;
if (document.form1.RadioUV[1].checked) passdata[11] = 1;
if (document.form1.RadioUV[2].checked) passdata[11] = 2;
if (document.form1.RadioPerf[1].checked) passdata[16] = 1;
if (document.form1.RadioEDDM[1].checked) passdata[17] = 1;
if (document.form1.RadioEDDM[2].checked) passdata[17] = 2;
if (show_quantity){
	passdata[14] = 1;
	passdata[15] = ManualQty;
}
var packed = "";
if(document.form1.Material.selectedIndex != 8)
   {
   for (i = 0; (i < passdata.length); i++)
      {
      if (i > 0) packed += ",";
      packed += escape(passdata[i]);
      }
   window.location = "order.html?" + packed;
   }
else
   {
   passdata[0] = document.form1.GicleeWidth[document.form1.GicleeWidth.selectedIndex].value;
   passdata[1] = document.form1.GicleeHeight[document.form1.GicleeHeight.selectedIndex].value;
   passdata[2] = document.form1.GicleeQty[document.form1.GicleeQty.selectedIndex].value;;
   passdata[3] = document.form1.GicleeMaterial.selectedIndex;
   for (i = 0; (i < passdata.length-4); i++)
      {
      if (i > 0) packed += ",";
      packed += escape(passdata[i]);
      }
   window.location = "large.html?" + packed;
   }
}
function validate_numbers ()
{
	document.Ready_to_Post = false;
	validate_form('QtyEntered','','RinRange50:50000','Quantity Entered');
}
