function startCalc(){
  interval = setInterval("calc()",1);
}
function calc(){
  A = document.autoSumForm.Almond_Brittle.value;
  B = document.autoSumForm.Cashew_Brittle.value;  
  C = document.autoSumForm.Coconut_Brittle.value; 
  D = document.autoSumForm.Jalapeno_Brittle.value; 
  E = document.autoSumForm.Macadamia_Brittle.value; 
  F = document.autoSumForm.Maple_Cashew_Brittle.value; 
  G = document.autoSumForm.Maple_Peanut_Brittle.value; 
  H = document.autoSumForm.Mixed_Nut_Brittle.value; 
  I = document.autoSumForm.No_Nut_Brittle.value; 
  J = document.autoSumForm.Peanut_Brittle.value; 
  K = document.autoSumForm.Pecan_Brittle.value; 
  L = document.autoSumForm.Sesame_Seed_Brittle.value; 
  M = document.autoSumForm.Sunflower_Brittle.value; 
  N = document.autoSumForm.Trail_Mix_Brittle.value; 
  O = document.autoSumForm.No_Sugar_Cashew_Brittle.value; 
  P = document.autoSumForm.No_Sugar_Mixed_Nut_Brittle.value; 
  Q = document.autoSumForm.No_Sugar_Peanut_Brittle.value; 
  R = document.autoSumForm.No_Sugar_Almond_Brittle.value; 

  
  document.autoSumForm.BrittlesTotalPRICE.value = ((A * 1) + (B * 1) + (C * 1) + (D * 1) + (E * 1) + (F * 1) + (G * 1) + (H * 1) + (I * 1) + (J * 1) + (K * 1) + (L * 1) + (M * 1) + (N * 1) + (O * 1) + (P * 1) + (Q * 1) + (R * 1)).toFixed(2);
}

function stopCalc(){
  startCalc6();
  clearInterval(interval);
}

function startCalc2(){
  interval2 = setInterval("calc2()",1);
}
function calc2(){
  A = document.autoSumForm.Almond_Beer_Nuts.value;
  B = document.autoSumForm.Cashew_Beer_Nuts.value;  
  C = document.autoSumForm.Jalapeno_Beer_Nuts.value; 
  D = document.autoSumForm.Maple_Peanut_Beer_Nuts.value; 
  E = document.autoSumForm.Mixed_Nut_Beer_Nuts.value; 
  F = document.autoSumForm.Peanut_Beer_Nuts.value; 
  G = document.autoSumForm.Pecan_Beer_Nuts.value; 

  
  document.autoSumForm.BeerNutTotalPRICE.value = ((A * 1) + (B * 1) + (C * 1) + (D * 1) + (E * 1) + (F * 1) + (G * 1)).toFixed(2);
}
function stopCalc2(){
  startCalc6();
  clearInterval(interval2);
}


function startCalc3(){
  interval3 = setInterval("calc3()",1);
}
function calc3(){
  A = document.autoSumForm.Butter_Pecan_Fudge.value;
  B = document.autoSumForm.Butterscotch_Fudge.value;  
  C = document.autoSumForm.Belgian_Chocolate_Fudge.value; 
  D = document.autoSumForm.Choc_Amaretto_Fudge.value; 
  E = document.autoSumForm.Choc_Macaroon_Fudge.value; 
  F = document.autoSumForm.Choc_Mint_Fudge.value; 
  G = document.autoSumForm.Choc_Walnut_Fudge.value; 
  H = document.autoSumForm.Choc_Orange_Fudge.value; 
  I = document.autoSumForm.Choc_Peanut_Butter_Fudge.value; 
  J = document.autoSumForm.Coffee_Mocha_Fudge.value; 
  K = document.autoSumForm.Choc_Caramel_Fudge.value; 
  L = document.autoSumForm.Double_Dark_Decadent_Fudge.value; 
  M = document.autoSumForm.Irish_Cream_Fudge.value; 
  N = document.autoSumForm.Kahlua_Fudge.value; 
  O = document.autoSumForm.Skornado_Fudge.value; 
  P = document.autoSumForm.Maple_Walnut_Fudge.value; 
  Q = document.autoSumForm.Marble_Fudge.value; 
  R = document.autoSumForm.Cookies_n_Cream_Fudge.value; 
  S = document.autoSumForm.Peanut_Butter_Fudge.value; 
  T = document.autoSumForm.Rocky_Road_Fudge.value; 
  U = document.autoSumForm.Rum_Raisin_Fudge.value; 
  V = document.autoSumForm.Madagascar_Vanilla_Fudge.value; 
  W = document.autoSumForm.Vanilla_Walnut_Fudge.value; 
  X = document.autoSumForm.Reezes_Pieces_Fudge.value; 
  Y = document.autoSumForm.Cranberry_Raspberry_Fudge.value; 
  Z = document.autoSumForm.Turttle_Fudge.value; 
  AA = document.autoSumForm.Belgian_All_White_Dream_Fudge.value; 
  BB = document.autoSumForm.Belgian_Triple_Chocolate_Fudge.value; 
  CC = document.autoSumForm.Black_Forest_Fudge.value; 
  DD = document.autoSumForm.Candy_Cane_Fudge.value; 
  EE = document.autoSumForm.Smarttees_Fudge.value; 
  FF = document.autoSumForm.Choc_Peanut_Butter_Crunch_Fudge.value; 
  GG = document.autoSumForm.Cremesicle_Fudge.value; 
  HH = document.autoSumForm.Heavenly_Hash_Fudge.value; 
  II = document.autoSumForm.Jalapeno_Fudge.value; 
  JJ = document.autoSumForm.Nerd_Explosion_Fudge.value; 
  KK = document.autoSumForm.Pralines_n_Cream_Fudge.value; 
  LL = document.autoSumForm.Pumpkin_Pie_Fudge.value; 
  MM = document.autoSumForm.Pure_Cdn_Maple_Fudge.value; 
  NN = document.autoSumForm.Sambucca_Fudge.value; 
  OO = document.autoSumForm.Strawberry_Cheesecake_Fudge.value; 
  PP = document.autoSumForm.Penuche_Fudge.value; 

  
  document.autoSumForm.FudgeTotalPRICE.value = (((A * 1) + (B * 1) + (C * 1) + (D * 1) + (E * 1) + (F * 1) + (G * 1) + (H * 1) + (I * 1) + (J * 1) + (K * 1) + (L * 1) + (M * 1) + (N * 1) + (O * 1) + (P * 1) + (Q * 1) + (R * 1) + (S * 1) + (T * 1) + (U * 1) + (V * 1) + (W * 1) + (X * 1) + (Y * 1) + (Z * 1) + (AA * 1) + (BB * 1) + (CC * 1) + (DD * 1) + (EE * 1) + (FF * 1) + (GG * 1) + (HH * 1) + (II * 1) + (JJ * 1) + (KK * 1) + (LL * 1) + (MM * 1) + (NN * 1) + (OO * 1) + (PP * 1)) * 4).toFixed(2);
}
function stopCalc3(){
  startCalc6();
  clearInterval(interval3);
}

function startCalc4(){
  interval4 = setInterval("calc4()",1);
}
function calc4(){
  A = document.autoSumForm.Reg_Caramel_Bars.value;
  B = document.autoSumForm.Licorice_Caramel_Bars.value;  
  C = document.autoSumForm.Mint_Caramel_Bars.value; 
  D = document.autoSumForm.Jalapeno_Caramel_Bars.value; 
  E = document.autoSumForm.Maple_Caramel_Bars.value; 

  document.autoSumForm.CaramelTotalPRICE.value = ((A * 1) + (B * 1) + (C * 1) + (D * 1) + (E * 1)).toFixed(2);
}
function stopCalc4(){
	startCalc6();
  clearInterval(interval4);
}

function startCalc5(){
  interval5 = setInterval("calc5()",1);
}
function calc5(){
  A = document.autoSumForm.Milk_Choc_Sponge_Toffee.value;

  document.autoSumForm.SpongeTotalPRICE.value = ((A * 1)).toFixed(2);
}
function stopCalc5(){
	startCalc6();
  clearInterval(interval5);
}

function startCalc7(){
  interval7 = setInterval("calc7()",1);
}
function calc7(){
  A = document.autoSumForm.All_Skores_Pizza.value;
  B = document.autoSumForm.MMandMMs_Pizza.value;  
  C = document.autoSumForm.Nerdy_Slice_Pizza.value; 
  D = document.autoSumForm.Reezes_Pieces_Pizza.value; 
  E = document.autoSumForm.Smarttees_Pizza.value; 
  F = document.autoSumForm.Holiday_Delight_Pizza.value; 

  document.autoSumForm.PizzaTotalPRICE.value = (((A * 1) + (B * 1) + (C * 1) + (D * 1) + (E * 1) + (F * 1))* 5).toFixed(2);
}
function stopCalc7(){
  startCalc6();
  clearInterval(interval7);
}

function startCalc6(){
  interval6 = setInterval("calc6()",1);
}
function calc6(){
  A = document.autoSumForm.BrittlesTotalPRICE.value;
  B = document.autoSumForm.BeerNutTotalPRICE.value;  
  C = document.autoSumForm.FudgeTotalPRICE.value; 
  D = document.autoSumForm.CaramelTotalPRICE.value; 
  E = document.autoSumForm.SpongeTotalPRICE.value;
  F = document.autoSumForm.PizzaTotalPRICE.value;
  G = document.autoSumForm.SubTotal.value; 
  H = document.autoSumForm.GST.value; 
  I = document.autoSumForm.PST.value; 
  
  document.autoSumForm.SubTotal.value = ((A * 1) + (B * 1) + (C * 1) + (D * 1) + (E * 1) + (F * 1)).toFixed(2);
  document.autoSumForm.GST.value = ((G * 1) * .05).toFixed(2);
  if (document.autoSumForm.Province_State.value == 'CA-ON') {
	  document.autoSumForm.PST.value = ((G * 1) * .08).toFixed(2);
  } else {
	  document.autoSumForm.PST.value = (A * 0).toFixed(2);
  }
  document.autoSumForm.GrandTotal.value = ((G * 1) + (H * 1) + (I * 1)).toFixed(2);
  
}

function verify() {
var themessage = "Fudge must be purchased in multiples of 3. Please correct your order. ";
if (document.autoSumForm.FudgeTotalPRICE.value != 0.00) 
if (document.autoSumForm.FudgeTotalPRICE.value != 12.00)
if (document.autoSumForm.FudgeTotalPRICE.value != 24.00)
if (document.autoSumForm.FudgeTotalPRICE.value != 36.00)
if (document.autoSumForm.FudgeTotalPRICE.value != 48.00)
if (document.autoSumForm.FudgeTotalPRICE.value != 60.00)
if (document.autoSumForm.FudgeTotalPRICE.value != 72.00)
if (document.autoSumForm.FudgeTotalPRICE.value != 84.00)
if (document.autoSumForm.FudgeTotalPRICE.value != 96.00)
if (document.autoSumForm.FudgeTotalPRICE.value != 108.00)
if (document.autoSumForm.FudgeTotalPRICE.value != 120.00)
if (document.autoSumForm.FudgeTotalPRICE.value != 132.00)
if (document.autoSumForm.FudgeTotalPRICE.value != 144.00)
if (document.autoSumForm.FudgeTotalPRICE.value != 156.00)
if (document.autoSumForm.FudgeTotalPRICE.value != 168.00)
if (document.autoSumForm.FudgeTotalPRICE.value != 180.00)
if (document.autoSumForm.FudgeTotalPRICE.value != 192.00)
if (document.autoSumForm.FudgeTotalPRICE.value != 204.00)
if (document.autoSumForm.FudgeTotalPRICE.value != 216.00)
if (document.autoSumForm.FudgeTotalPRICE.value != 228.00)
if (document.autoSumForm.FudgeTotalPRICE.value != 240.00)
if (document.autoSumForm.FudgeTotalPRICE.value != 252.00)
if (document.autoSumForm.FudgeTotalPRICE.value != 264.00)

{
alert(themessage);
}
}

function CheckEmail(email) {
	AtPos = email.indexOf("@")
	StopPos = email.lastIndexOf(".")
	Message = ""

	if (email == "") {
		Message = "Not a valid Email address" + "\n"
	}

	if (AtPos == -1 || StopPos == -1) {
		Message = "Not a valid email address"
	}

	if (StopPos < AtPos) {
		Message = "Not a valid email address"
	}

	if (StopPos - AtPos == 1) {
		Message = "Not a valid email address"
	}

	if (Message != "")
	{
		return false;
	} else {
		return true;
	}
}

function validate(){
	if (document.autoSumForm.Name.value=="")
	{
		alert ("You must fill in the Name field.");
		document.autoSumForm.Name.focus();
		return false;
	}
	if (document.autoSumForm.Address.value=="")
	{
		alert ("You must fill in the Address field.");
		document.autoSumForm.Address.focus();
		return false;
	}
	if (document.autoSumForm.City.value=="")
	{
		alert ("You must fill in the City field.");
		document.autoSumForm.City.focus();
		return false;
	}
	if (document.autoSumForm.Province_State.value=="")
	{
		alert ("You must select a Province.");
		document.autoSumForm.Province_State.focus();
		return false;
	}
	if (document.autoSumForm.Country.value=="")
	{
		alert ("You must fill in the Country field.");
		document.autoSumForm.Country.focus();
		return false;
	}
	if (document.autoSumForm.Zip_Postal_Code.value=="")
	{
		alert ("You must fill in the Postal Code field.");
		document.autoSumForm.Zip_Postal_Code.focus();
		return false;
	}
	if (document.autoSumForm.Email.value=="")
	{
		alert ("You must fill in the Email field.");
		document.autoSumForm.Email.focus();
		return false;
	} else if (CheckEmail(document.autoSumForm.Email.value) == false)
	{
		alert ("Not a valid email address.");
		document.autoSumForm.Email.focus();
		return false;
	}
	if (document.autoSumForm.Phone_number.value=="")
	{
		alert ("You must fill in the Phone field.");
		document.autoSumForm.Phone_number.focus();
		return false;
	}
	if (document.autoSumForm.hdcaptcha.value == "")
	{
		alert ("You must fill in the Security Code field.");
		document.autoSumForm.hdcaptcha.focus();
		return false;
	}
	return true;
}
