// JavaScript Document
<!-- //hide from older browsers.

//mnj displays enlarged photo of product
function PopImage( path, file, w, h, name ) { 
	thewindow = window.open(path + file, name, config='height=' + h + ',width=' + w + ',toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,directories=no,status=no'); 

} 

function GetPrice ( unique_cart_id, qty ) { 

	switch (unique_cart_id) {
		
		case 1:  // Pain Spray	
		case 47:  // Pain Spray Special Offer (1 Free Roll-On with min purachase)	
		case 55:  // Pain Spray & Roll-On Mix-n-Match
		case 56: { // Pain Spray Roll-On	
		
			if ((qty >= 1) && (qty <= 2)) 		{return 9.95; }
			else if ((qty >= 3) && (qty <= 5)) 	{return 9.00; }
			else if ((qty >= 6) && (qty <= 11)) {return 8.50; }
			else if ((qty >= 12) && (qty <= 23)){return 8.00; }
			else if (qty > 23) 					{return 5.75; }
			break; 
		}
		

		case 8:   // Creme De La Femme
		case 27: { // Creme De La Femme Free Gift with Purchase
		
			if ((qty >= 1) && (qty <= 2)) 			{return 14.95; }
			else if ((qty >= 3) && (qty <= 5)) 		{return 11.00; }
			else if ((qty >= 6) && (qty <= 11)) 	{return 10.00; }
			else if ((qty >= 12) && (qty <= 23)) 	{return 9.00; }
			else if (qty > 23) 						{return 8.00; }
			break; 
		}


		case 14: { //  Headache Re-leaf
			if ((qty >= 1) && (qty <= 2))		{return 8.00; }
			else if ((qty >= 3) && (qty <= 5)) 	{return 7.00; }
			else if ((qty >= 6) && (qty <= 23))	{return 6.00; }
			else if (qty > 23) 					{return 4.00; }
		
			break; 
		}
		
		case 16:  // Aroma Works Pocket Inhalers (all scents)
		case 17:  // Aroma Works Pocket Inhalers (all scents)
		case 18:  // Aroma Works Pocket Inhalers (all scents)
		case 19: { // Aroma Works Pocket Inhalers (all scents)
			if (qty == 1) 						{return 8.95; }
			else if ((qty >= 2) && (qty <= 5)) 	{return 7.95; }
			else if ((qty >= 6) && (qty <= 11)) {return 6.95; }
			else if ((qty >= 12) && (qty <= 23)){return 6.45; }
			else if (qty > 23) 					{return 5.45; }
		
			break; 
		}
		
		case 22: { // Prostate Health Cocktail
		
			if (qty == 1)						{return 59.95; }
			else if ((qty >= 2) && (qty <= 5)) 	{return 49.95; }
			else if ((qty >= 6) && (qty <= 23))	{return 44.95; }
			else if (qty > 23) 					{return 38.88; }
			break; 
		}
		
		case 24: { // Creme Travel Size

			if (qty >= 1) 							{return 3.95; }
			break; 
		}

		
		case 29: { // Prostate Health Cocktail (Buy 1 Get 2nd Half Off)
		
			return 59.95;
			break; 
			
		}
		

		case 30: { // Pain Spray 1 oz. Travel Size
		
			if (qty >= 1) 							{return 3.95; }
			break; 
		}
		

		case 32: { //  Mite-NIX Anti-Allergy System
			
			if (qty == 1) 							{return 21.95; }
			else if ((qty >= 2) && (qty <= 5)) 		{return 19.95; }
			else if (qty > 5) 						{return 14.95; }
			break; 

		}
		
		case 33: { // Aroma Works Pocket Inhaler Set
		
			if (qty == 1)							{return 29.95; }
			else if ((qty >= 2) && (qty <= 11)) 	{return 24.95; }
			else if (qty > 11) 						{return 18.95; }
			break; 
		}
		
		case 34:  // Mite-NIX Allergy 16-oz individual bottle
		case 36: { // Mite-NIX Laundry 16-oz individual bottle
			if (qty == 1) 						{return 11.95; }
			else if ((qty >= 2) && (qty <= 5)) 	{return 10.95; }
			else if (qty > 5) 					{return 8.95; }
		
			break; 
		}

		case 35:  // Mite-NIX Allergy 32-oz individual bottle
		case 37: { // Mite-NIX Laundry 32-oz individual bottle
			if (qty == 1) 						{return 19.95; }
			else if ((qty >= 2) && (qty <= 3)) 	{return 18.95; }
			else if (qty > 3) 					{return 14.95; }
		
			break; 
		}

		case 39: { //  Headache ReLeaf 3-Pack
			if (qty == 1) 						{return 21.00; }
			else if ((qty >= 2) && (qty <= 7)) 	{return 18.00; }
			else if (qty > 7) 					{return 12.00; }
		
			break; 
		}
		case 40: { //  Headache ReLeaf 6-Pack
			if ((qty >= 1) && (qty <= 3)) 		{return 36.00; }
			else if (qty > 3) 					{return 24.00; }
		
			break; 
		}
		
		case 41: { //  Creme 3-Pack
			if (qty == 1) 						{return 33.00; }
			else if ((qty >= 2) && (qty <= 3)) 	{return 30.00; }
			else if ((qty >= 4) && (qty <= 7)) 	{return 27.00; }
			else if (qty > 7) 					{return 24.00; }
		
			break; 
		}
		case 42: { //  Creme 6-Pack
			if (qty == 1) 				 		{return 60.00; }
			else if ((qty >= 2) && (qty <= 3)) 	{return 54.00; }
			else if (qty > 3) 					{return 48.00; }
		
			break; 
		}

		case 43: { //  Pain Spray 3-Pack
			if (qty == 1) 						{return 27.00; }
			else if ((qty >= 2) && (qty <= 3)) 	{return 25.50; }
			else if ((qty >= 4) && (qty <= 7)) 	{return 24.00; }
			else if (qty > 7) 					{return 17.25; }
		
			break; 
		}
		case 44: { //  Pain Spray 6-Pack
			if (qty == 1) 						{return 51.00; }
			else if ((qty >= 2) && (qty <= 3)) 	{return 48.00; }
			else if (qty > 3) 					{return 34.50; }
		
			break; 
		}

		case 45: { // Pain Spray 24-Pack
		
			if (qty >= 1) 						{return 138.00; }
			break; 
		}


		default: return 0.00;
	}
 } 
 

function totalPlusTax(unique_cart_id, ele)
{
	//alert('lol');
	/* User's desired quantity. */
	var qty = ele.value;
	/* check for invalid input. */
	if ( isNaN(qty) || ((qty == '') || (qty < 0) || (qty % 1 > 0)))  
	{
		alert('You must enter a numeric value between 0 and 999');
		qty = 0;
		ele.value = 0;
		ele.focus();
	} 
		/* A straight price of 59.95 all the time as of 10/23/09. */
		var price = GetPrice(unique_cart_id,qty);
		var subTotal1 = price * qty;
		/* Current CA tax is 9.25% as of 10/23/09. Subject to change. */
		var taxMultiple = 9.25 / 100;
		var subTotal2 = subTotal1 + (subTotal1 * taxMultiple);
		/* Note: shipping is provided FREE as of 10/23/09. Subject to change upon client's request. */
		/* Set the shown quantities to equal what the user entered */
		for(var c = 0; c < 1; c++)
		{
			/* Get the div that shows quantity. */
			var element = document.getElementById("showQuantity" + c);
			element.innerHTML = ("" + qty);
		}
		/* Set the shown subTotal without tax. */
		var e = document.getElementById("showSubTotal1");
		e.innerHTML = formatCurrency(subTotal1);
		/* Set the shown subTotal with tax. */
		e = document.getElementById("showSubTotal2");
		e.innerHTML = formatCurrency(subTotal2);
		/* Set the hidden field "prodsubtotal" so that the cart will know what the subtotal is. */
		
		/* mnj OLD e = document.cartform.prodsubtotal;*/
		e = document["cartform"+unique_cart_id].prodsubtotal;
		
		e.value = subTotal2;
}
 
// mnj this has threshold at 6+ for pricing every bottle the same

function prtotalPHCSpecialWebPage(unique_cart_id, ele){
  var qty=0,ttlqty=0,fee,ttlprice=0;
  var i;
  var tqty;
  var count;
  var ttlcounter;
  var arrayLength;
  
  if (isNaN(ele.value))  {
   alert('You must enter a numeric value between 0 and 999');
   ele.value = 0;
   ele.focus();
  } else {
   if (ele.value==''||ele.value<0||ele.value%1>0) {
    alert('You must enter a numeric value between 0 and 999');
    ele.value=0;
    ele.focus();
   }
 	}
  
  //mnj orig var oProds = document.cartform.quantity;
	var oProds = document["cartform"+unique_cart_id].quantity;
	//var oProds = eval( "document.cartform" + unique_cart_id + ".quantity" );
  if (!oProds.length) arrayLength = 1;
  else arrayLength = oProds.length;

  /* Calculate Matrix Variables */
  ttlqty = TotalCount( arrayLength, document["cartform"+unique_cart_id] );
  var ttlPricePerBottle = GetPrice( unique_cart_id, ttlqty );
  var ttlPriceForFirstBottle =  GetPrice( unique_cart_id, 1 );
  
  /* Index the current product. */
  if (ttlqty >= 6) { ttlcounter = 1; }
  else { ttlcounter = 0; }
 
  /* Receipt Description */
  var description = "";
    
  for (i=0; i<arrayLength; i++ ) {
      /* Get the QTY from the Array */
      if (arrayLength > 1) qty = parseInt(document["cartform"+unique_cart_id].quantity[i].value);
      if (arrayLength == 1) qty = parseInt(document["cartform"+unique_cart_id].quantity.value);
   
   /* Add the subtotals and grand */
   if ((ttlcounter == 0) && (qty > 0)) {
    /* Local Sub Total Calc */
    price = ttlPriceForFirstBottle + ((qty - 1) * ttlPricePerBottle)
 
    /* Add it to the total */    
    ttlprice += price;
    
    /* Okay.  No more of this. */
    ttlcounter = 1;
   } else {
    /* Local Sub Total Calc */
    price = (qty * ttlPricePerBottle);
   
    /* Add to total */
    ttlprice += price;
   }
    
   if ((document["cartform"+unique_cart_id].isMac.value == "True")||(document["cartform"+unique_cart_id].isNetscape6.value == "True")||(document["cartform"+unique_cart_id].isIE.value == "False")) { 
      if (arrayLength > 1) document["cartform"+unique_cart_id].prodsubtotal[i].value = formatCurrency(price);
      if (arrayLength == 1) document["cartform"+unique_cart_id].prodsubtotal.value = formatCurrency(price);
   } else {
      UpdateDivContent('divSubtotal'+ i,  '<span class=blk11>' + formatCurrency(price) + '</span>');
   }
   
   		for(var c = 0; c < 1; c++)
		{
			/* Get the div that shows quantity. */
			var element = document.getElementById("showQuantity" + c);
			element.innerHTML = ("" + qty);
		}

  }
  
}

// mnj this has threshold at 6+ for pricing every bottle the same

function prtotal(unique_cart_id, ele){
  var qty=0,ttlqty=0,fee,ttlprice=0;
  var i;
  var tqty;
  var count;
  var ttlcounter;
  var arrayLength;
  
  if (isNaN(ele.value))  {
   alert('You must enter a numeric value between 0 and 999');
   ele.value = 0;
   ele.focus();
  } else {
   if (ele.value==''||ele.value<0||ele.value%1>0) {
    alert('You must enter a numeric value between 0 and 999');
    ele.value=0;
    ele.focus();
   }
 	}
  
  //mnj orig var oProds = document.cartform.quantity;
	var oProds = document["cartform"+unique_cart_id].quantity;
	//var oProds = eval( "document.cartform" + unique_cart_id + ".quantity" );
  if (!oProds.length) arrayLength = 1;
  else arrayLength = oProds.length;

  /* Calculate Matrix Variables */
  ttlqty = TotalCount( arrayLength, document["cartform"+unique_cart_id] );
  var ttlPricePerBottle = GetPrice( unique_cart_id, ttlqty );
  var ttlPriceForFirstBottle =  GetPrice( unique_cart_id, 1 );
  
  /* Index the current product..  First bottle is always 5.95 */
  if (ttlqty >= 6) { ttlcounter = 1; }
  else { ttlcounter = 0; }
 
  /* Receipt Description */
  var description = "";
    
  for (i=0; i<arrayLength; i++ ) {
      /* Get the QTY from the Array */
      if (arrayLength > 1) qty = parseInt(document["cartform"+unique_cart_id].quantity[i].value);
      if (arrayLength == 1) qty = parseInt(document["cartform"+unique_cart_id].quantity.value);
   
   /* Add the subtotals and grand */
   if ((ttlcounter == 0) && (qty > 0)) {
    /* Local Sub Total Calc */
    price = ttlPriceForFirstBottle + ((qty - 1) * ttlPricePerBottle)
 
    /* Add it to the total */    
    ttlprice += price;
    
    /* Okay.  No more of this. */
    ttlcounter = 1;
   } else {
    /* Local Sub Total Calc */
    price = (qty * ttlPricePerBottle);
   
    /* Add to total */
    ttlprice += price;
   }
    
   if ((document["cartform"+unique_cart_id].isMac.value == "True")||(document["cartform"+unique_cart_id].isNetscape6.value == "True")||(document["cartform"+unique_cart_id].isIE.value == "False")) { 
      if (arrayLength > 1) document["cartform"+unique_cart_id].prodsubtotal[i].value = formatCurrency(price);
      if (arrayLength == 1) document["cartform"+unique_cart_id].prodsubtotal.value = formatCurrency(price);
   } else {
      UpdateDivContent('divSubtotal'+ i,  '<span class=blk11>' + formatCurrency(price) + '</span>');
   } 
  }
  
}

//function like prtotal, except for every two bottles, 1 is half off. Written by Benjamin D. Beasley on 09/12/09.
function prtotal5halfoff(unique_cart_id, ele)
{
	//alert("lol!");
	
  	var qty=0,ttlqty=0,fee,ttlprice=0;
  	var i;
  	var tqty;
  	var count;
  	var ttlcounter;
  	var arrayLength;
	var tf = true;
  	//alert("value: " + ele.value);
	if (isNaN(ele.value))  
	{
   		document.getElementById("message").innerHTML = 'You must enter a numeric value between 0 and 999';
		ele.value = 0;
   		ele.focus();
		tf = false;
  	} 
	else 
	{
   		if (ele.value==''||ele.value<0||ele.value%1>0)
		{
    		document.getElementById("message").innerHTML = 'You must enter a numeric value between 0 and 999';
    		ele.value=0;
    		ele.focus();
			tf = false;
   		}
 	}
	
  	/* Note, first bottle price is always at a big discount price. */
  	ttlqty = ele.value;
  	var ttlPricePerBottle = GetPrice( unique_cart_id, ttlqty );
		var qty = ttlqty;
		var qty_halfoff = 0;
		var qty_normal = 0;
		var amt_saved = 0;
		//Half will be @ half price, and half will be @ normal price.
		if(qty % 2 == 0)
		{
			//alert("lol6    qty: "  + qty);
			if(qty != 0)
			{
				//alert("lol7");
				qty_halfoff = qty / 2;
				qty_normal = qty / 2;
			}
		}
		else if (qty != 1)
		{
			//alert("lol8");
			qty_halfoff = ((qty - 1) / 2);
			qty_normal = ((qty - 1) / 2) + 1;
		}
		else
		{
			qty_halfoff = 0;
			qty_normal = 1;
		}
    	 /* calc the price of regular product plus the half-off prices of every other bottle.*/
		var price_halfoff = (ttlPricePerBottle / 2)  - 0.005;
    	price = (qty_normal * ttlPricePerBottle) + (qty_halfoff * price_halfoff);
 		amt_saved = (qty_halfoff) * ((ttlPricePerBottle / 2) + 0.005);
  		/* Receipt Description */
  		var description = "";
		//alert("lol3");
		if ((document.cartform.isMac.value == "True") || (document.cartform.isNetscape6.value == "True") || (document.cartform.isIE.value == "False")) 
   		{ 
			//alert("lol2");
		  	document.cartform.prodsubtotal.value = formatCurrency(price);
   		} 
   		else 
   		{
			//alert("lol4");
      		UpdateDivContent('divSubtotal'+ i,  '<span class=blk11>' + formatCurrency(price) + '</span>');
   		} 
		
		//MR. BEASLEY, EDIT THESE TO CHANGE WHAT IS SAID WHEN quantity entered is greater than  or equal to 2,  equal to one, or is equal to 0.
		if(tf)
		{
			if(qty % 2 != 0)
			{
				if(qty == 1)
				{
					document.getElementById("message").innerHTML = "Buy 2, and get the second bottle half off.";
				}
				else
				{
					var num_shouldbuy = parseInt(qty,0) + 1;
					var temp1 = (parseInt(qty,0) +1) / 2;
					var save = (temp1) * ((ttlPricePerBottle / 2) + 0.005);
					var newprice = (temp1 * price_halfoff) + (temp1 * (ttlPricePerBottle));
					//alert("lol1");
					document.getElementById("message").innerHTML = "Buy " + num_shouldbuy + " bottles for " + formatCurrency(newprice) +  " and save " + formatCurrency(save) +".";
					//alert("lol2");
				}
			}
			else 
			{
				if(qty >= 2)
				{
					document.getElementById("message").innerHTML = "You save " + formatCurrency(amt_saved);
				}
				else
				{
					document.getElementById("message").innerHTML = "Buy one, get one half off.";
				}
			}
		}
}

// mnj this has threshold at 2+ for pricing every bottle the same (3-Packs)

function prtotal2Threshold(unique_cart_id, ele){
  var qty=0,ttlqty=0,fee,ttlprice=0;
  var i;
  var tqty;
  var count;
  var ttlcounter;
  var arrayLength;
  
  if (isNaN(ele.value))  {
   alert('You must enter a numeric value between 0 and 999');
   ele.value = 0;
   ele.focus();
  } else {
   if (ele.value==''||ele.value<0||ele.value%1>0) {
    alert('You must enter a numeric value between 0 and 999');
    ele.value=0;
    ele.focus();
   }
 	}
  
  //mnj orig var oProds = document.cartform.quantity;
	var oProds = document["cartform"+unique_cart_id].quantity;
	//var oProds = eval( "document.cartform" + unique_cart_id + ".quantity" );
  if (!oProds.length) arrayLength = 1;
  else arrayLength = oProds.length;

  /* Calculate Matrix Variables */
  ttlqty = TotalCount( arrayLength, document["cartform"+unique_cart_id] );
  var ttlPricePerBottle = GetPrice( unique_cart_id, ttlqty );
  var ttlPriceForFirstBottle =  GetPrice( unique_cart_id, 1 );
  
  /* Index the current product..  First bottle is always 5.95 */
  if (ttlqty >= 2) { ttlcounter = 1; }
  else { ttlcounter = 0; }
 
  /* Receipt Description */
  var description = "";
    
  for (i=0; i<arrayLength; i++ ) {
      /* Get the QTY from the Array */
      if (arrayLength > 1) qty = parseInt(document["cartform"+unique_cart_id].quantity[i].value);
      if (arrayLength == 1) qty = parseInt(document["cartform"+unique_cart_id].quantity.value);
   
   /* Add the subtotals and grand */
   if ((ttlcounter == 0) && (qty > 0)) {
    /* Local Sub Total Calc */
    price = ttlPriceForFirstBottle + ((qty - 1) * ttlPricePerBottle)
 
    /* Add it to the total */    
    ttlprice += price;
    
    /* Okay.  No more of this. */
    ttlcounter = 1;
   } else {
    /* Local Sub Total Calc */
    price = (qty * ttlPricePerBottle);
   
    /* Add to total */
    ttlprice += price;
   }
    
   if ((document["cartform"+unique_cart_id].isMac.value == "True")||(document["cartform"+unique_cart_id].isNetscape6.value == "True")||(document["cartform"+unique_cart_id].isIE.value == "False")) { 
      if (arrayLength > 1) document["cartform"+unique_cart_id].prodsubtotal[i].value = formatCurrency(price);
      if (arrayLength == 1) document["cartform"+unique_cart_id].prodsubtotal.value = formatCurrency(price);
   } else {
      UpdateDivContent('divSubtotal'+ i,  '<span class=blk11>' + formatCurrency(price) + '</span>');
   } 
  }
  
}

// mnj duplicate of prtotal except this has threshold at 3+ (for creme de la femme) for pricing every bottle the same

function prtotal3Threshold(unique_cart_id, ele){
  var qty=0,ttlqty=0,fee,ttlprice=0;
  var i;
  var tqty;
  var count;
  var ttlcounter;
  var arrayLength;
  
  if (isNaN(ele.value))  {
   alert('You must enter a numeric value between 0 and 999');
   ele.value = 0;
   ele.focus();
  } else {
   if (ele.value==''||ele.value<0||ele.value%1>0) {
    alert('You must enter a numeric value between 0 and 999');
    ele.value=0;
    ele.focus();
   }
 	}
  
  var oProds = document["cartform"+unique_cart_id].quantity;
  
  if (!oProds.length) arrayLength = 1;
  else arrayLength = oProds.length;

  /* Calculate Matrix Variables */
  ttlqty = TotalCount( arrayLength, document["cartform"+unique_cart_id] );
  var ttlPricePerBottle = GetPrice( unique_cart_id, ttlqty );
  var ttlPriceForFirstBottle =  GetPrice( unique_cart_id, 1 );
  
  /* Index the current product. */
  if (ttlqty >= 3) { ttlcounter = 1; }
  else { ttlcounter = 0; }
 
  /* Receipt Description */
  var description = "";
    
  for (i=0; i<arrayLength; i++ ) {
      /* Get the QTY from the Array */
      if (arrayLength > 1) qty = parseInt(document["cartform"+unique_cart_id].quantity[i].value);
      if (arrayLength == 1) qty = parseInt(document["cartform"+unique_cart_id].quantity.value);
   
   /* Add the subtotals and grand */
   if ((ttlcounter == 0) && (qty > 0)) {
    /* Local Sub Total Calc */
    price = ttlPriceForFirstBottle + ((qty - 1) * ttlPricePerBottle)
 
    /* Add it to the total */    
    ttlprice += price;
    
    /* Okay.  No more of this. */
    ttlcounter = 1;
   } else {
    /* Local Sub Total Calc */
    price = (qty * ttlPricePerBottle);
   
    /* Add to total */
    ttlprice += price;
   }
    
   if ((document["cartform"+unique_cart_id].isMac.value == "True")||(document["cartform"+unique_cart_id].isNetscape6.value == "True")||(document["cartform"+unique_cart_id].isIE.value == "False")) { 
      if (arrayLength > 1) document["cartform"+unique_cart_id].prodsubtotal[i].value = formatCurrency(price);
      if (arrayLength == 1) document["cartform"+unique_cart_id].prodsubtotal.value = formatCurrency(price);
   } else {
      UpdateDivContent('divSubtotal'+ i,  '<span class=blk11>' + formatCurrency(price) + '</span>');
   } 
  }
  
}



// mnj duplicate of prtotal except this has threshold at 4+ (for Mite-Nix) for pricing every bottle the same

function prtotal4Threshold(unique_cart_id, ele){
  var qty=0,ttlqty=0,fee,ttlprice=0;
  var i;
  var tqty;
  var count;
  var ttlcounter;
  var arrayLength;
  
  if (isNaN(ele.value))  {
   alert('You must enter a numeric value between 0 and 999');
   ele.value = 0;
   ele.focus();
  } else {
   if (ele.value==''||ele.value<0||ele.value%1>0) {
    alert('You must enter a numeric value between 0 and 999');
    ele.value=0;
    ele.focus();
   }
 	}
  
  var oProds = document["cartform"+unique_cart_id].quantity;
  
  if (!oProds.length) arrayLength = 1;
  else arrayLength = oProds.length;

  /* Calculate Matrix Variables */
  ttlqty = TotalCount( arrayLength, document["cartform"+unique_cart_id] );
  var ttlPricePerBottle = GetPrice( unique_cart_id, ttlqty );
  var ttlPriceForFirstBottle =  GetPrice( unique_cart_id, 1 );
  
  /* Index the current product. */
  if (ttlqty >= 4) { ttlcounter = 1; }
  else { ttlcounter = 0; }
 
  /* Receipt Description */
  var description = "";
    
  for (i=0; i<arrayLength; i++ ) {
      /* Get the QTY from the Array */
      if (arrayLength > 1) qty = parseInt(document["cartform"+unique_cart_id].quantity[i].value);
      if (arrayLength == 1) qty = parseInt(document["cartform"+unique_cart_id].quantity.value);
   
   /* Add the subtotals and grand */
   if ((ttlcounter == 0) && (qty > 0)) {
    /* Local Sub Total Calc */
    price = ttlPriceForFirstBottle + ((qty - 1) * ttlPricePerBottle)
 
    /* Add it to the total */    
    ttlprice += price;
    
    /* Okay.  No more of this. */
    ttlcounter = 1;
   } else {
    /* Local Sub Total Calc */
    price = (qty * ttlPricePerBottle);
   
    /* Add to total */
    ttlprice += price;
   }
    
   if ((document["cartform"+unique_cart_id].isMac.value == "True")||(document["cartform"+unique_cart_id].isNetscape6.value == "True")||(document["cartform"+unique_cart_id].isIE.value == "False")) { 
      if (arrayLength > 1) document["cartform"+unique_cart_id].prodsubtotal[i].value = formatCurrency(price);
      if (arrayLength == 1) document["cartform"+unique_cart_id].prodsubtotal.value = formatCurrency(price);
   } else {
      UpdateDivContent('divSubtotal'+ i,  '<span class=blk11>' + formatCurrency(price) + '</span>');
   } 
  }
  
}



// mnj duplicate of prtotal except this has threshold at 6+ (for Mite-NIX Singles) for pricing every set the same

function prtotal6Threshold(unique_cart_id, ele){
  var qty=0,ttlqty=0,fee,ttlprice=0;
  var i;
  var tqty;
  var count;
  var ttlcounter;
  var arrayLength;
  
  if (isNaN(ele.value))  {
   alert('You must enter a numeric value between 0 and 999');
   ele.value = 0;
   ele.focus();
  } else {
   if (ele.value==''||ele.value<0||ele.value%1>0) {
    alert('You must enter a numeric value between 0 and 999');
    ele.value=0;
    ele.focus();
   }
 	}
  
  var oProds = document["cartform"+unique_cart_id].quantity;
  
  if (!oProds.length) arrayLength = 1;
  else arrayLength = oProds.length;

  /* Calculate Matrix Variables */
  ttlqty = TotalCount( arrayLength, document["cartform"+unique_cart_id] );
  var ttlPricePerBottle = GetPrice( unique_cart_id, ttlqty );
  var ttlPriceForFirstBottle =  GetPrice( unique_cart_id, 1 );
  
  /* Index the current product. */
  if (ttlqty >= 6) { ttlcounter = 1; }
  else { ttlcounter = 0; }
 
  /* Receipt Description */
  var description = "";
    
  for (i=0; i<arrayLength; i++ ) {
      /* Get the QTY from the Array */
      if (arrayLength > 1) qty = parseInt(document["cartform"+unique_cart_id].quantity[i].value);
      if (arrayLength == 1) qty = parseInt(document["cartform"+unique_cart_id].quantity.value);
   
   /* Add the subtotals and grand */
   if ((ttlcounter == 0) && (qty > 0)) {
    /* Local Sub Total Calc */
    price = ttlPriceForFirstBottle + ((qty - 1) * ttlPricePerBottle)
 
    /* Add it to the total */    
    ttlprice += price;
    
    /* Okay.  No more of this. */
    ttlcounter = 1;
   } else {
    /* Local Sub Total Calc */
    price = (qty * ttlPricePerBottle);
   
    /* Add to total */
    ttlprice += price;
   }
    
   if ((document["cartform"+unique_cart_id].isMac.value == "True")||(document["cartform"+unique_cart_id].isNetscape6.value == "True")||(document["cartform"+unique_cart_id].isIE.value == "False")) { 
      if (arrayLength > 1) document["cartform"+unique_cart_id].prodsubtotal[i].value = formatCurrency(price);
      if (arrayLength == 1) document["cartform"+unique_cart_id].prodsubtotal.value = formatCurrency(price);
   } else {
      UpdateDivContent('divSubtotal'+ i,  '<span class=blk11>' + formatCurrency(price) + '</span>');
   } 
  }
  
}

// mnj duplicate of prtotal except this has threshold at 12+ (for AromaWorks SET) for pricing every set the same

function prtotal12Threshold(unique_cart_id, ele){
  var qty=0,ttlqty=0,fee,ttlprice=0;
  var i;
  var tqty;
  var count;
  var ttlcounter;
  var arrayLength;
  
  if (isNaN(ele.value))  {
   alert('You must enter a numeric value between 0 and 999');
   ele.value = 0;
   ele.focus();
  } else {
   if (ele.value==''||ele.value<0||ele.value%1>0) {
    alert('You must enter a numeric value between 0 and 999');
    ele.value=0;
    ele.focus();
   }
 	}
  
  var oProds = document["cartform"+unique_cart_id].quantity;
  
  if (!oProds.length) arrayLength = 1;
  else arrayLength = oProds.length;

  /* Calculate Matrix Variables */
  ttlqty = TotalCount( arrayLength, document["cartform"+unique_cart_id] );
  var ttlPricePerBottle = GetPrice( unique_cart_id, ttlqty );
  var ttlPriceForFirstBottle =  GetPrice( unique_cart_id, 1 );
  
  /* Index the current product. */
  if (ttlqty >= 12) { ttlcounter = 1; }
  else { ttlcounter = 0; }
 
  /* Receipt Description */
  var description = "";
    
  for (i=0; i<arrayLength; i++ ) {
      /* Get the QTY from the Array */
      if (arrayLength > 1) qty = parseInt(document["cartform"+unique_cart_id].quantity[i].value);
      if (arrayLength == 1) qty = parseInt(document["cartform"+unique_cart_id].quantity.value);
   
   /* Add the subtotals and grand */
   if ((ttlcounter == 0) && (qty > 0)) {
    /* Local Sub Total Calc */
    price = ttlPriceForFirstBottle + ((qty - 1) * ttlPricePerBottle)
 
    /* Add it to the total */    
    ttlprice += price;
    
    /* Okay.  No more of this. */
    ttlcounter = 1;
   } else {
    /* Local Sub Total Calc */
    price = (qty * ttlPricePerBottle);
   
    /* Add to total */
    ttlprice += price;
   }
    
   if ((document["cartform"+unique_cart_id].isMac.value == "True")||(document["cartform"+unique_cart_id].isNetscape6.value == "True")||(document["cartform"+unique_cart_id].isIE.value == "False")) { 
      if (arrayLength > 1) document["cartform"+unique_cart_id].prodsubtotal[i].value = formatCurrency(price);
      if (arrayLength == 1) document["cartform"+unique_cart_id].prodsubtotal.value = formatCurrency(price);
   } else {
      UpdateDivContent('divSubtotal'+ i,  '<span class=blk11>' + formatCurrency(price) + '</span>');
   } 
  }
  
}
 
// mnj duplicate of prtotal except this has threshold at 99 (for Mite-Nix Anti-Allergy System) for pricing every bottle the same: 99=will never happen

function prtotal99Threshold(unique_cart_id, ele){
  var qty=0,ttlqty=0,fee,ttlprice=0;
  var i;
  var tqty;
  var count;
  var ttlcounter;
  var arrayLength;
  
  if (isNaN(ele.value))  {
   alert('You must enter a numeric value between 0 and 999');
   ele.value = 0;
   ele.focus();
  } else {
   if (ele.value==''||ele.value<0||ele.value%1>0) {
    alert('You must enter a numeric value between 0 and 999');
    ele.value=0;
    ele.focus();
   }
 	}
  
  var oProds = document["cartform"+unique_cart_id].quantity;
  
  if (!oProds.length) arrayLength = 1;
  else arrayLength = oProds.length;

  /* Calculate Matrix Variables */
  ttlqty = TotalCount( arrayLength, document["cartform"+unique_cart_id] );
  var ttlPricePerBottle = GetPrice( unique_cart_id, ttlqty );
  var ttlPriceForFirstBottle =  GetPrice( unique_cart_id, 1 );
  
  /* Index the current product. */
  if (ttlqty >= 99) { ttlcounter = 1; }
  else { ttlcounter = 0; }
 
  /* Receipt Description */
  var description = "";
    
  for (i=0; i<arrayLength; i++ ) {
      /* Get the QTY from the Array */
      if (arrayLength > 1) qty = parseInt(document["cartform"+unique_cart_id].quantity[i].value);
      if (arrayLength == 1) qty = parseInt(document["cartform"+unique_cart_id].quantity.value);
   
   /* Add the subtotals and grand */
   if ((ttlcounter == 0) && (qty > 0)) {
    /* Local Sub Total Calc */
    price = ttlPriceForFirstBottle + ((qty - 1) * ttlPricePerBottle)
 
    /* Add it to the total */    
    ttlprice += price;
    
    /* Okay.  No more of this. */
    ttlcounter = 1;
   } else {
    /* Local Sub Total Calc */
    price = (qty * ttlPricePerBottle);
   
    /* Add to total */
    ttlprice += price;
   }
    
   if ((document["cartform"+unique_cart_id].isMac.value == "True")||(document["cartform"+unique_cart_id].isNetscape6.value == "True")||(document["cartform"+unique_cart_id].isIE.value == "False")) { 
      if (arrayLength > 1) document["cartform"+unique_cart_id].prodsubtotal[i].value = formatCurrency(price);
      if (arrayLength == 1) document["cartform"+unique_cart_id].prodsubtotal.value = formatCurrency(price);
   } else {
      UpdateDivContent('divSubtotal'+ i,  '<span class=blk11>' + formatCurrency(price) + '</span>');
   } 
  }
  
}
 
 function TotalCount( totalproducts, cartingform ) {
  var l=0;
  var total=0;
  var val=0;
  
  /* Loop through all text boxes and  */
  for (l = 0; l < totalproducts; l++ ) {
      if (totalproducts > 1) val = cartingform.quantity[l].value;
      if (totalproducts == 1) val = cartingform.quantity.value; 

      total += parseInt( val );
  }
  
  return total;   
 }
 
 function formatCurrency(num) {
  num = num.toString().replace(/\$|\,/g,'');
  if (isNaN(num)) num = "0";
  cents = Math.floor((num*100+0.5)%100);
  num = Math.floor((num*100+0.5)/100).toString();
  if (cents < 10) cents = "0" + cents;
  for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
  num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
  return ('$' + num + '.' + cents);
 }
 
 
 function UpdateDivContent(divid, newcontent) {
    
  if (document.layers){ //ns4+
    with (document.layers[divid].document) {
      write(newcontent);
      close();
    }
   }
  
 }
 
// -->
