// Global variables
var	B2,B5,B6,B7,B8,B10,B13,B14,B15,B16,B18,B20,B22,B24,B26
var B39,B40,B41,B42,B43,B44,B45,B46,B47,B48
var B50,B51,B52,B53,B54,B55,B56,B57,B58,B59
var B61,B62,B63,B64,B65,B66,B67,B68,B69,B70
var B72,B73,B74,B75,B76,B77,B78,B79,B80,B81
var	B83,B84,B85,B86,B87,B88,B89,B90,B91,B92
var B94,B95,B96,B97,B98,B99,B100,B101,B102,B103
var B105,B106,B107,B108,B109,B110,B111,B112,B113,B114
var frm
var fFormat
B5=0;B6=0;B7=0;B8=0;B13=0;B14=0;
B10=0;
B15=0;
B18=0;
B20=0;
B22=0;
B24=0;
B26=0;

function coi_SetValues() { // cost of inventory set values
	frm = document.form1;
	frm.B2.value = 10.00;
	frm.B5.value = 6.00;
	frm.B6.value = .50;
	frm.B8.value = 30;
	frm.B13.value = 5.00;
	frm.B14.value = 0.20;
	frm.B16.value = 90;
	frm.B20.value = 12;
	frm.B22.value = 60;
	frm.B24.value = 6;
	frm.B26.value = 0.06; 
	compute_B7_landedcost();
	compute_B15_landedcost();
	DetailAnalysis();
}

function setFocus(fld) {
	fld.focus();	
}

function compute_B7_landedcost() {
	//alert("In compute_B7_landedcost()");
	//------------------------------------------------------
	//	Bruce Geroux
	//	Date:	11/05/2003
	//	Purpose: 
	//		Compute Landed cost of the product purchased in 
	//			 traditional manner
	//		Compute Initial Gross Margin of the product purchased
	//			 in traditional manner.		
	//--------------------------------------------------------
	frm = document.form1; 
	B2 = stringFilter(frm.B2.value);	// Selling price of product
	B5 = stringFilter(frm.B5.value);	// Cost of the product
	B6 = stringFilter(frm.B6.value);	// Cost of freight per item
	B8 = frm.B8.value;
	B7 = "";
	
	// Format for currency.
	frm.B2.value = formatCurrency(B2);
	frm.B5.value = formatCurrency(B5);
	frm.B6.value = formatCurrency(B6);
	
	// Compute Landed cost of the product purchased in traditional manner
	if (B5.length > 0 && B6.length > 0)
		{
		B7 = parseFloat(B5) + parseFloat(B6);
		frm.B7.value = formatCurrency(B7);
		}
	// Compute Initial Gross Margin of the product purchased in traditional manner	
	if (B2.length > 0 && B7 > 0)
		{
		// compute the percentage
		fFormat = ((parseFloat(B2) - parseFloat(B5)) / parseFloat(B2)) * 100;
		
		// Round up to the nearest 2 decimal places
		fFormat = fFormat  //+ .005;
		B10 = fFormat;
		
		// Format the percentage to n decimal places and add the "%" sign
		frm.B10.value = FormatPercentage(fFormat,2)+ "%";	
		}
	// Skip over B7, that's a calculated field, but not before they enter data in B6
	if (B7 > 0 && B6 != 0){
		//frm.B8.focus();	
	}
	// Skip over B10, that's a calculated field, but not before they enter data in B8
	if (B8 != 0){
		//frm.B13.focus();
	}
}

function compute_B15_landedcost() {
	//alert("In compute_B15_landedcost()");
	//------------------------------------------------------
	//	Bruce Geroux
	//	Date:	11/05/2003
	//	Purpose: 
	//		Compute Landed cost of the product purchased in 
	//			 drop ship or special manner
	//		Compute Initial Gross Margin of the product purchased 
	//			 in drop ship or special manner.
	//--------------------------------------------------------
	frm = document.form1; 
	B2 = stringFilter(frm.B2.value);		// Cost of the product purchased in traditional manner
	B13 = stringFilter(frm.B13.value);		// Cost of the product purchased in drop ship or special manner
	B14 = stringFilter(frm.B14.value);   	// Cost of freight per item in drop ship manner
	B16 = frm.B16.value;
	B15 = "";
	
	// Format for currency.
	if (frm.B2.value != "") {frm.B2.value = formatCurrency(B2);}
	if (frm.B13.value != "") {frm.B13.value = formatCurrency(B13);}
	if (frm.B14.value != "") {frm.B14.value = formatCurrency(B14);}
	
	// Compute Landed cost of the product purchased in drop ship or special manner
	if (B13.length > 0 && B14.length > 0)
		{
		//frm.B15.value = parseFloat(frm.B13.value) + parseFloat(frm.B14.value);
		frm.B15.value = parseFloat(B13) + parseFloat(B14);
		frm.B15.value = formatCurrency(frm.B15.value);
		B15 = parseFloat(B13) + parseFloat(B14);
		}
	// Compute Initial Gross Margin of the product purchased in drop ship or special manner	
	if (B2.length > 0 && B15 > 0)
		{
		// compute the percentage
		fFormat = ((parseFloat(B2) - parseFloat(B13)) / parseFloat(B2)) * 100;
		
		// Round up to the nearest 2 decimal places
		fFormat = fFormat  //+ .005;
		B18 = fFormat;
		
		// Format the percentage to n decimal places and add the "%" sign
		frm.B18.value = FormatPercentage(fFormat,2)+ "%";	
		}
	// Skip over B15, that's a calculated field, but not before they enter data in B14
	if (B15 > 0 && B14 != 0){
		//frm.B16.focus();	
	}
	// Skip over B18, that's a calculated field, but not before they enter data in B16
	if (B16 != 0){
		//frm.B20.focus();	
	}
}

function DetailAnalysis(){
	frm = document.form1;
	// If it's a large number, add commas
	if (frm.B20.value!=""){B20 = stringFilter(frm.B20.value);frm.B20.value=formatnumber(frm.B20.value);} // Quanity traditionally purchased
	if (frm.B22.value!=""){B22 = stringFilter(frm.B22.value);frm.B22.value=formatnumber(frm.B22.value);} // Quantity ordered for drop ship or special manner
	if (frm.B24.value!=""){B24 = stringFilter(frm.B24.value);frm.B24.value=formatnumber(frm.B24.value);} // Average quanity sold per month
	if (frm.B26.value!=""){B26 = stringFilter(frm.B26.value);}	// Current Cost of money borrowed(Annual Interest rate)
	
	// Format the percentage to n decimal places and add the "%" sign
	if (B26 > 0) {	// It will be null until user enters a number
		frm.B26.value = FormatPercentage(B26,2)+ "%";	
	}
	
	ComputeB39();
	ComputeB40();
	ComputeB41();
	ComputeB42();
	ComputeB43();
	ComputeB44();
	ComputeB45();
	ComputeB46();
	ComputeB47();
	ComputeB48();
	ComputeB50();
	ComputeB51();
	ComputeB52();
	ComputeB53();
	ComputeB54();
	ComputeB55();
	ComputeB56();
	ComputeB57();
	ComputeB58();
	ComputeB59();
	ComputeB61();
	ComputeB62();
	ComputeB63();
	ComputeB64();
	ComputeB65();
	ComputeB66();
	ComputeB67();
	ComputeB68();
	ComputeB69();
	ComputeB70();
	ComputeB72();
	ComputeB73();
	ComputeB74();
	ComputeB75();
	ComputeB76();
	ComputeB77();
	ComputeB78();
	ComputeB79();
	ComputeB80();
	ComputeB81();
	ComputeB83();
	ComputeB84();
	ComputeB85();
	ComputeB86();
	ComputeB87();
	ComputeB88();
	ComputeB89();
	ComputeB90();
	ComputeB91();
	ComputeB92();
	ComputeB94();
	ComputeB95();
	ComputeB96();
	ComputeB97();
	ComputeB98();
	ComputeB99();
	ComputeB100();
	ComputeB101();
	ComputeB102();
	ComputeB103();
	ComputeB105();
	ComputeB106();
	ComputeB107();
	ComputeB108();
	ComputeB109();
	ComputeB110();
	ComputeB111();
	ComputeB112();
	ComputeB113();
	ComputeB114();
}

function ComputeB39(){
	//------------------------------------------------
	// Compute B39:
	//  - Quantity on shelf 60 days after invoice - traditional
	//  - Formula: IF(B20-B24>0,B20-B24,0)
	//-------------------------------------------------
	
	if (B20.length > 0 && B24.length > 0){ 
			if (B20 - B24 > 0){
				frm.B39.value = (B20 - B24);
			}else{
				frm.B39.value = 0;
			}	
	}
	B39 = frm.B39.value;
}

function ComputeB40(){
	//--------------------------------------------------------------------
	// Compute B40: 
	//  - 60 days after invoice, cost of product on shelf purchased traditional
	//  - Formula: IF(B39=0,0,B7+((B26/360)*IF(60>B8,60-B8,0)))
	//-------------------------------------------------------------------- 
	B40 = 0;
	var i=0;
	var ii=0;
	if (B39 == 0) {
		frm.B40.value = formatCurrency(B40);
	}else
		i = B26/360;
		if (60 > B8) {
			ii=60-B8;
		}else{
			ii = 0;
	}
	B40 = parseFloat(B7 + (i*ii));	
	frm.B40.value = formatCurrency(B40);
}

function ComputeB41(){
	//--------------------------------------------------------------------
	// Compute B41:
	//  - 60 days after invoice, new gross margin of product purchased traditional
	//  - Formula: IF(B39=0,0,(B2-B40)/B2
	//-------------------------------------------------------------------- 

	if (B39 == 0){
		B41 = 0;
		frm.B41.value = 0;
	}else{
		fFormat = ((B2-B40)/B2) * 100;
		// Round up to the nearest 2 decimal places
		fFormat = fFormat  //+ .005;
		B41 = fFormat;
		// Format the percentage to n decimal places and add the "%" sign
		frm.B41.value = FormatPercentage(fFormat,2)+ "%";	
	}
}

function ComputeB42(){
	//--------------------------------------------------------------------
	// Compute B42:
	//  - 60 days after invoice, change in gross margin on product purchased traditional
	//  - Formula: IF(B39=0,0,B41-B10
	//-------------------------------------------------------------------- 
	if (B39 == 0){
		B42 = 0;
		frm.B42.value = 0;
	}else{
		fFormat = B41 - B10;
		if (fFormat < 0){
			fFormat = fFormat + (-.005);
		}else{
			fFormat = fFormat  //+ .005;
		}	
		B42 = fFormat;
		// Format the percentage to n decimal places and add the "%" sign.  If 
		// negative, add ( ).
		if (fFormat < 0){
			frm.B42.style.color="red";
			frm.B42.value = "(" + FormatPercentage(fFormat,2) + ")%";	
		}else{
			frm.B42.value = FormatPercentage(fFormat,2)+ "%";	
		}	
	}
}

function ComputeB43(){
	//--------------------------------------------------------------------
	// Compute B43:
	//  - 60 days after invoice, lost profit on remaining product purchased traditional
	//  - Formula: IF(B39=0,0,(B39*B2*B42)/B39)
	//-------------------------------------------------------------------- 
	if (B39 == 0){
		B43 = 0;
		frm.B43.value = 0;
	}else{
		B43 = ((B39*B2*B42)/B39)/100;
	}
	if (B43	< 0){
		frm.B43.style.color="red";
		frm.B43.value = formatCurrency(B43);
	}else{
		frm.B43.value = formatCurrency(B43);
	}		
}

function ComputeB44(){
	//--------------------------------------------------------------------
	// Compute B44:
	//  - Quantity on shelf 60 days after invoice - drop ship or special manner
	//  - Formula: IF(B22-B24>0,B22-B24,0)
	//-------------------------------------------------------------------- 
	if ((B22 - B24) > 0){
		B44 = (B22 - B24);
		frm.B44.value = B44;
	}else{
		B44  = 0;
		frm.B44.value = B44;
	}
}

function ComputeB45(){
	//--------------------------------------------------------------------
	// Compute B45:
	//  - 60 days after invoice, cost of product on shelf purchased drop ship or special manner
	//  - Formula: IF(B44=0,0,B15+((B26/360)*IF(60>B16,60-B16,0)))
	//-------------------------------------------------------------------- 
	var i=0;
	var ii=0;
	B45=0;
	if (B44 == 0){
		B45 = 0;
	}else{
		i = (B26/360);
		if (60>B16){
			ii = (60-B16);
		}else{
			ii = 0;	
		}
	}
	B45 = B15 + (i*ii);
	frm.B45.value=formatCurrency(B45);
}

function ComputeB46(){
	//--------------------------------------------------------------------
	// Compute B46:
	//  - 60 days after invoice, new gross margin for product purchased drop ship or special manner
	//  - Formula: IF(B44=0,0,(B2-B45)/B2)
	//-------------------------------------------------------------------- 
	if (B44 == 0){
		B46 =0;
		frm.B46.value = 0;
	}else{
		fFormat = ((B2 - B45) / B2) * 100;
		B46 = fFormat;
		frm.B46.value = FormatPercentage(fFormat,2)+ "%";	
	}
}	

function ComputeB47(){
	//--------------------------------------------------------------------
	// Compute B47:
	//  - 60 days after invoice, change in gross margin on product purchased drop ship or special manner
	//  - Formula: IF(B44=0,0,B46-B18)
	//-------------------------------------------------------------------- 
	if (B44 == 0){
		B47 = 0;
		frm.B47.value=0;
	}else{
		fFormat = B46 - B18;
		B47 = fFormat;
		// Format the percentage to n decimal places and add the "%" sign.  If 
		// negative, add parentheses.
		if (fFormat < 0){
			frm.B47.style.color="red";
			frm.B47.value = "(" + FormatPercentage(fFormat,2) + ")%";	
		}else{
			frm.B47.value = FormatPercentage(fFormat,2)+ "%";	
		}	
	}
}

function ComputeB48(){
	//--------------------------------------------------------------------
	// Compute B48:
	//  - 60 days after invoice, lost profit on remaining product purchased 
	//  -  drop ship or special manner
	//  - Formula: IF(B44=0,0,(B44*B2*B47)/B44)
	//-------------------------------------------------------------------- 
	if (B44 == 0){
	    B48=0;
	    frm.B48.value=0;
	}else{
		B48 = ((B44*B2*B47)/B44)/100;
		//frm.B48.value = formatCurrency(B48);
	}
	if (B48	< 0){
		frm.B48.style.color="red";
		frm.B48.value = formatCurrency(B48);
	}else{
		frm.B48.value = formatCurrency(B48);
	}		
}

function ComputeB50(){
	//--------------------------------------------------------------------
	// Compute B50:
	//  - Quantity on shelf 90 days after invoice - traditional
	//  - Formula: IF(B39-B24>0,B39-B24,0)
	//-------------------------------------------------------------------- 
	if ((B39 - B24) > 0){
		B50 = (B39 - B24);
		frm.B50.value = B50;
	}else{
		B50 = 0;
		frm.B50.value = 0;
	}
}

function ComputeB51(){
	//--------------------------------------------------------------------
	// Compute B51:
	//  - 90 days after invoice, cost of product on shelf purchased traditional
	//  - Formula: IF(B50=0,0,B7+((B26/360)*IF(90>B8,90-B8,0))))
	//-------------------------------------------------------------------- 
	var i=0;
	var ii=0;
	B51=0;
	if (B50 == 0) {
		frm.B51.value = formatCurrency(B51);
		return;
	}else
		i = B26/360;
		if (90 > B8) {
			ii=90-B8;
		}else{
			ii = 0;
	}
	B51 = parseFloat(B7 + (i*ii));	
	frm.B51.value = formatCurrency(B51);
}
	
function ComputeB52(){
	//--------------------------------------------------------------------
	// Compute B52:
	//  - 90 days after invoice, new gross margin of product purchased traditional
	//  - Formula: IF(B50=0,0,(B2-B51)/B2)
	//-------------------------------------------------------------------- 

	if (B50 == 0){
		B52 = 0;
		frm.B52.value = 0;
	}else{
		fFormat = ((B2-B51)/B2) * 100;
		// Round up to the nearest 2 decimal places
		fFormat = fFormat  //+ .005;
		B52 = fFormat;
		// Format the percentage to n decimal places and add the "%" sign
		frm.B52.value = FormatPercentage(fFormat,2)+ "%";	
	}
}

function ComputeB53(){
	//--------------------------------------------------------------------
	// Compute B53:
	//  - 90 days after invoice, change in gross margin on product purchased traditional
	//  - Formula: IF(B50=0,0,B52-B10)
	//-------------------------------------------------------------------- 
	if (B50 == 0){
		B53 = 0;
		frm.B53.value = 0;
	}else{
		fFormat = B52 - B10;
		if (fFormat < 0){
			fFormat = fFormat + (-.005);
		}else{
			fFormat = fFormat  //+ .005;
		}	
		B53 = fFormat;
		// Format the percentage to n decimal places and add the "%" sign.  If 
		// negative, add ( ).
		if (fFormat < 0){
			frm.B53.style.color="red";
			frm.B53.value = "(" + FormatPercentage(fFormat,2) + ")%";	
		}else{
			frm.B53.value = FormatPercentage(fFormat,2)+ "%";	
		}	
	}
}

function ComputeB54(){
	//--------------------------------------------------------------------
	// Compute B54:
	//  - 90 days after invoice, lost profit on remaining product purchased traditional
	//  - Formula:  IF(B50=0,0,(B50*B2*B53)/B50) 
	//-------------------------------------------------------------------- 
	if (B50 == 0){
		B54 = 0;
		frm.B54.value = 0;
	}else{
		B54 = ((B50*B2*B53)/B50)/100;
	}
	if (B54	< 0){
		frm.B54.style.color="red";
		frm.B54.value = formatCurrency(B54);
	}else{
		frm.B54.value = formatCurrency(B54);
	}		
}

function ComputeB55(){
	//--------------------------------------------------------------------
	// Compute B55:
	//  - Quantity on shelf 90 days after invoice - drop ship or special manner
	//  - Formula:  IF(B44-B24>0,B44-B24,0)
	//-------------------------------------------------------------------- 
	if ((B44 - B24) > 0){
		B55 = (B44 - B24);
		frm.B55.value = B55;
	}else{
		B55  = 0;
		frm.B55.value = B55;
	}
}

function ComputeB56(){
	//--------------------------------------------------------------------
	// Compute B56:
	//  - 90 days after invoice, cost of product on shelf purchased drop ship or special manner
	//  - Formula:  IF(B55=0,0,B15+((B26/360)*IF(90>B16,90-B16,0)))
	//-------------------------------------------------------------------- 
	var i=0;
	var ii=0;
	B56=0;
	if (B55 == 0){
		B56 = 0;
		frm.B56.value=formatCurrency(B56);
	}else{
		i = (B26/360);
		if (90>B16){
			ii = (90-B16);
		}else{
			ii = 0;	
		}
		B56 = B15 + (i*ii);
		frm.B56.value=formatCurrency(B56);
	}
}

function ComputeB57(){
	//--------------------------------------------------------------------
	// Compute B57:
	//  - 90 days after invoice, new gross margin for product purchased drop ship or special manner
	//  - Formula:	 IF(B55=0,0,(B2-B56)/B2)
	//-------------------------------------------------------------------- 
	if (B55 == 0){
		B57 =0;
		frm.B57.value = 0;
	}else{
		fFormat = ((B2 - B56) / B2) * 100;
		B57 = fFormat;
		frm.B57.value = FormatPercentage(fFormat,2)+ "%";	
	}
}

function ComputeB58(){
	//--------------------------------------------------------------------
	// Compute B58:
	//  - 90 days after invoice, change in gross margin on product purchased drop ship or special manner
	//  - Formula:  IF(B55=0,0,B57-B18)
	//-------------------------------------------------------------------- 
	if (B55 == 0){
		B58 = 0;
		frm.B58.value=0;
	}else{
		fFormat = B57 - B18;
		B58 = fFormat;
		// Format the percentage to n decimal places and add the "%" sign.  If 
		// negative, add parentheses.
		if (fFormat < 0){
			frm.B58.style.color="red";
			frm.B58.value = "(" + FormatPercentage(fFormat,2) + ")%";	
		}else{
			frm.B58.value = FormatPercentage(fFormat,2)+ "%";	
		}	
	}
}

function ComputeB59(){
	//--------------------------------------------------------------------
	// Compute B59:
	//  - 90 days after invoice, lost profit on remaining product purchased 
	//  -  drop ship or special manner
	//  - Formula:	IF(B55=0,0,(B55*B2*B58)/B55)
	//-------------------------------------------------------------------- 
	if (B55 == 0){
	    B59=0;
	    frm.B59.value=0;
	}else{
		B59 = ((B55*B2*B58)/B55)/100;
		//frm.B59.value = formatCurrency(B59);
	}
	if (B59	< 0){
		frm.B59.style.color="red";
		frm.B59.value = formatCurrency(B59);
	}else{
		frm.B59.value = formatCurrency(B59);
	}		
}


function ComputeB61(){
	//--------------------------------------------------------------------
	// Compute B61:
	//  - Quantity on shelf 120 days after invoice - traditional
	//  - Formula:	IF(B50-B24>0,B50-B24,0)
	//-------------------------------------------------------------------- 
	if ((B50 - B24) > 0){
		B61 = (B50 - B24);
		frm.B61.value = B61;
	}else{
		B61 = 0;
		frm.B61.value = 0;
	}
}

function ComputeB62(){
	//--------------------------------------------------------------------
	// Compute B62:
	//  - 120 days after invoice, cost of product on shelf purchased traditional
	//  - Formula:	IF(B61=0,0,B7+((B26/360)*IF(120>B8,120-B8,0))) 
	//-------------------------------------------------------------------- 
	var i=0;
	var ii=0;
	B62=0;
	if (B61 == 0) {
		frm.B62.value = formatCurrency(B62);
		return;
	}else
		i = B26/360;
		if (120 > B8) {
			ii=120-B8;
		}else{
			ii = 0;
	}
	B62 = parseFloat(B7 + (i*ii));	
	frm.B62.value = formatCurrency(B62);
}
	
function ComputeB63(){
	//--------------------------------------------------------------------
	// Compute B63:
	//  - 120 days after invoice, new gross margin of product purchased traditional
	//  - Formula:	IF(B61=0,0,(B2-B62)/B2) 
	//-------------------------------------------------------------------- 

	if (B61 == 0){
		B63 = 0;
		frm.B63.value = 0;
	}else{
		fFormat = ((B2-B62)/B2) * 100;
		// Round up to the nearest 2 decimal places
		fFormat = fFormat  //+ .005;
		B63 = fFormat;
		// Format the percentage to n decimal places and add the "%" sign
		frm.B63.value = FormatPercentage(fFormat,2)+ "%";	
	}
}

function ComputeB64(){
	//--------------------------------------------------------------------
	// Compute B64:
	//  - 120 days after invoice, change in gross margin on product purchased traditional
	//  - Formula:	IF(B61=0,0,B63-B10) 
	//-------------------------------------------------------------------- 
	if (B61 == 0){
		B64 = 0;
		frm.B64.value = 0;
	}else{
		fFormat = B63 - B10;
		if (fFormat < 0){
			fFormat = fFormat + (-.005);
		}else{
			fFormat = fFormat  //+ .005;
		}	
		B64 = fFormat;
		// Format the percentage to n decimal places and add the "%" sign.  If 
		// negative, add ( ).
		if (fFormat < 0){
			frm.B64.style.color="red";
			frm.B64.value = "(" + FormatPercentage(fFormat,2) + ")%";	
		}else{
			frm.B64.value = FormatPercentage(fFormat,2)+ "%";	
		}	
	}
}

function ComputeB65(){
	//--------------------------------------------------------------------
	// Compute B65:
	//  - 120 days after invoice, lost profit on remaining product purchased traditional
	//  - Formula:	IF(B61=0,0,(B61*B2*B64)/B61)  
	//-------------------------------------------------------------------- 
	if (B61 == 0){
		B65 = 0;
		frm.B65.value = 0;
	}else{
		B65 = ((B61*B2*B64)/B61)/100;
	}
	if (B65	< 0){
		frm.B65.style.color="red";
		frm.B65.value = formatCurrency(B65);
	}else{
		frm.B65.value = formatCurrency(B65);
	}		
}

function ComputeB66(){
	//--------------------------------------------------------------------
	// Compute B66:
	//  - Quantity on shelf 120 days after invoice - drop ship or special manner
	//  - Formula:	IF(B55-B24>0,B55-B24,0)	  
	//-------------------------------------------------------------------- 
	if ((B55 - B24) > 0){
		B66 = (B55 - B24);
		frm.B66.value = B66;
	}else{
		B66  = 0;
		frm.B66.value = B66;
	}
}

function ComputeB67(){
	//--------------------------------------------------------------------
	// Compute B67:
	//  - 120 days after invoice, cost of product on shelf purchased drop ship or special manner
	//  - Formula:	IF(B66=0,0,B15+((B26/360)*IF(120>B16,120-B16,0)))  
	//-------------------------------------------------------------------- 
	if (B66 == 0){
		B67 = 0;
		frm.B67.value=formatCurrency(B67);
	}else{
		var i = (B26/360);
		if (120>B16){
			var ii = (120-B16);
		}else{
			ii = 0;	
		}
		B67 = B15 + (i*ii);
		frm.B67.value=formatCurrency(B67);
	}
}

function ComputeB68(){
	//--------------------------------------------------------------------
	// Compute B68:
	//  - 120 days after invoice, new gross margin for product purchased drop ship or special manner
	//  - Formula:	IF(B66=0,0,(B2-B67)/B2)	 
	//-------------------------------------------------------------------- 
	if (B66 == 0){
		B68 =0;
		frm.B68.value = 0;
	}else{
		fFormat = ((B2 - B67) / B2) * 100;
		B68 = fFormat;
		frm.B68.value = FormatPercentage(fFormat,2)+ "%";	
	}
}

function ComputeB69(){
	//--------------------------------------------------------------------
	// Compute B69:
	//  - 120 days after invoice, change in gross margin on product purchased drop ship or special manner
	//  - Formula:	IF(B66=0,0,B68-B18)  
	//-------------------------------------------------------------------- 
	if (B66 == 0){
		B69 = 0;
		frm.B69.value=0;
	}else{
		fFormat = B68 - B18;
		B69 = fFormat;
		// Format the percentage to n decimal places and add the "%" sign.  If 
		// negative, add parentheses.
		if (fFormat < 0){
			frm.B69.style.color="red";
			frm.B69.value = "(" + FormatPercentage(fFormat,2) + ")%";	
		}else{
			frm.B69.value = FormatPercentage(fFormat,2)+ "%";	
		}	
	}
}

function ComputeB70(){
	//--------------------------------------------------------------------
	// Compute B70:
	//  - 120 days after invoice, lost profit on remaining product purchased 
	//  -  drop ship or special manner
	//  - Formula:	IF(B66=0,0,(B66*B2*B69)/B66)	
	//-------------------------------------------------------------------- 
	if (B66 == 0){
	    B70=0;
	    frm.B70.value=0;
	}else{
		B70 = ((B66*B2*B69)/B66)/100;
		//frm.B70.value = formatCurrency(B70);
	}
	if (B70	< 0){
		frm.B70.style.color="red";
		frm.B70.value = formatCurrency(B70);
	}else{
		frm.B70.value = formatCurrency(B70);
	}		
}

//---------------	

function ComputeB72(){
	//--------------------------------------------------------------------
	// Compute B72:
	//  - Quantity on shelf 150 days after invoice - traditional
	//  - Formula:	IF(B61-B24>0,B61-B24,0)	
	//-------------------------------------------------------------------- 
	if ((B61 - B24) > 0){
		B72 = (B61 - B24);
		frm.B72.value = B72;
	}else{
		B72 = 0;
		frm.B72.value = 0;
	}
}

function ComputeB73(){
	//--------------------------------------------------------------------
	// Compute B73:
	//  - 150 days after invoice, cost of product on shelf purchased traditional
	//  - Formula:	IF(B72=0,0,B7+((B26/360)*IF(150>B8,150-B8,0)))	
	//-------------------------------------------------------------------- 
	var i=0;
	var ii=0;
	B73=0;
	if (B72 == 0) {
		frm.B73.value = formatCurrency(B73);
		return;
	}else
		i = B26/360;
		if (150 > B8) {
			ii=150-B8;
		}else{
			ii = 0;
	}
	B73 = parseFloat(B7 + (i*ii));	
	frm.B73.value = formatCurrency(B73);
}
	
function ComputeB74(){
	//--------------------------------------------------------------------
	// Compute B74:
	//  - 150 days after invoice, new gross margin of product purchased traditional
	//  - Formula:	IF(B72=0,0,(B2-B73)/B2)	
	//-------------------------------------------------------------------- 

	if (B72 == 0){
		B74 = 0;
		frm.B74.value = 0;
	}else{
		fFormat = ((B2-B73)/B2) * 100;
		// Round up to the nearest 2 decimal places
		fFormat = fFormat  //+ .005;
		B74 = fFormat;
		// Format the percentage to n decimal places and add the "%" sign
		frm.B74.value = FormatPercentage(fFormat,2)+ "%";	
	}
}

function ComputeB75(){
	//--------------------------------------------------------------------
	// Compute B75:
	//  - 150 days after invoice, change in gross margin on product purchased traditional
	//  - Formula:	IF(B72=0,0,B74-B10)	
	//-------------------------------------------------------------------- 
	if (B72 == 0){
		B75 = 0;
		frm.B75.value = 0;
	}else{
		fFormat = B74 - B10;
		if (fFormat < 0){
			fFormat = fFormat + (-.005);
		}else{
			fFormat = fFormat  //+ .005;
		}	
		B75 = fFormat;
		// Format the percentage to n decimal places and add the "%" sign.  If 
		// negative, add ( ).
		if (fFormat < 0){
			frm.B75.style.color="red";
			frm.B75.value = "(" + FormatPercentage(fFormat,2) + ")%";	
		}else{
			frm.B75.value = FormatPercentage(fFormat,2)+ "%";	
		}	
	}
}

function ComputeB76(){
	//--------------------------------------------------------------------
	// Compute B76:
	//  - 150 days after invoice, lost profit on remaining product purchased traditional
	//  - Formula:	IF(B72=0,0,(B72*B2*B75)/B72)	
	//-------------------------------------------------------------------- 
	if (B72 == 0){
		B76 = 0;
		frm.B76.value = 0;
	}else{
		B76 = ((B72*B2*B75)/B72)/100;
	}
	if (B76	< 0){
		frm.B76.style.color="red";
		frm.B76.value = formatCurrency(B76);
	}else{
		frm.B76.value = formatCurrency(B76);
	}		
}

function ComputeB77(){
	//--------------------------------------------------------------------
	// Compute B77:
	//  - Quantity on shelf 150 days after invoice - drop ship or special manner
	//  - Formula:	IF(B66-B24>0,B66-B24,0)	
	//-------------------------------------------------------------------- 
	if ((B66 - B24) > 0){
		B77 = (B66 - B24);
		frm.B77.value = B77;
	}else{
		B77  = 0;
		frm.B77.value = B77;
	}
}

function ComputeB78(){
	//--------------------------------------------------------------------
	// Compute B78:
	//  - 150 days after invoice, cost of product on shelf purchased drop ship or special manner
	//  - Formula:	IF(B77=0,0,B15+((B26/360)*IF(150>B16,150-B16,0)))	
	//-------------------------------------------------------------------- 
	var i=0;
	var ii=0;
	B786=0;
	if (B77 == 0){
		B78 = 0;
		frm.B78.value=formatCurrency(B78);
	}else{
		i = (B26/360);
		if (150>B16){
			ii = (150-B16);
		}else{
			ii = 0;	
		}
		B78 = B15 + (i*ii);
		frm.B78.value=formatCurrency(B78);
	}
}

function ComputeB79(){
	//--------------------------------------------------------------------
	// Compute B79:
	//  - 150 days after invoice, new gross margin for product purchased drop ship or special manner
	//  - Formula:	IF(B77=0,0,(B2-B78)/B2)	
	//-------------------------------------------------------------------- 
	if (B77 == 0){
		B79 =0;
		frm.B79.value = 0;
	}else{
		fFormat = ((B2 - B78) / B2) * 100;
		B79 = fFormat;
		frm.B79.value = FormatPercentage(fFormat,2)+ "%";	
	}
}

function ComputeB80(){
	//--------------------------------------------------------------------
	// Compute B80:
	//  - 150 days after invoice, change in gross margin on product purchased drop ship or special manner
	//  - Formula:	IF(B77=0,0,B79-B18)	
	//-------------------------------------------------------------------- 
	if (B77 == 0){
		B80 = 0;
		frm.B80.value=0;
	}else{
		fFormat = B79 - B18;
		B80 = fFormat;
		// Format the percentage to n decimal places and add the "%" sign.  If 
		// negative, add parentheses.
		if (fFormat < 0){
			frm.B80.style.color="red";
			frm.B80.value = "(" + FormatPercentage(fFormat,2) + ")%";	
		}else{
			frm.B80.value = FormatPercentage(fFormat,2)+ "%";	
		}	
	}
}

function ComputeB81(){
	//--------------------------------------------------------------------
	// Compute B81:
	//  - 150 days after invoice, lost profit on remaining product purchased 
	//  -  drop ship or special manner
	//  - Formula:	IF(B77=0,0,(B77*B2*B80)/B77)	
	//-------------------------------------------------------------------- 
	if (B77 == 0){
	    B81=0;
	    frm.B81.value=0;
	}else{
		B81 = ((B77*B2*B80)/B77)/100;
		if (B81 < 0){
			frm.B81.style.color="red";
		}
		frm.B81.value = formatCurrency(B81);
	}
}

//---------------	

function ComputeB83(){
	//--------------------------------------------------------------------
	// Compute B83:
	//  - Quantity on shelf 180 days after invoice - traditional
	//  - Formula:	IF(B72-B24>0,B72-B24,0)	
	//-------------------------------------------------------------------- 
	if ((B72 - B24) > 0){
		B83 = (B72 - B24);
		frm.B83.value = B83;
	}else{
		B83 = 0;
		frm.B83.value = 0;
	}
}

function ComputeB84(){
	//--------------------------------------------------------------------
	// Compute B84:
	//  - 180 days after invoice, cost of product on shelf purchased traditional
	//  - Formula:	IF(B83=0,0,B7+((B26/360)*IF(180>B8,180-B8,0)))	
	//-------------------------------------------------------------------- 
	var i=0;
	var ii=0;
	B84=0;
	if (B83 == 0) {
		frm.B84.value = formatCurrency(B84);
		return;
	}else
		i = B26/360;
		if (180 > B8) {
			ii=180-B8;
		}else{
			ii = 0;
	}
	B84 = parseFloat(B7 + (i*ii));	
	frm.B84.value = formatCurrency(B84);
}
	
function ComputeB85(){
	//--------------------------------------------------------------------
	// Compute B85:
	//  - 180 days after invoice, new gross margin of product purchased traditional
	//  - Formula:	IF(B83=0,0,(B2-B84)/B2)	
	//-------------------------------------------------------------------- 

	if (B83 == 0){
		B85 = 0;
		frm.B85.value = 0;
	}else{
		fFormat = ((B2-B84)/B2) * 100;
		// Round up to the nearest 2 decimal places
		fFormat = fFormat  //+ .005;
		B85 = fFormat;
		// Format the percentage to n decimal places and add the "%" sign
		frm.B85.value = FormatPercentage(fFormat,2)+ "%";	
	}
}

function ComputeB86(){
	//--------------------------------------------------------------------
	// Compute B86:
	//  - 180 days after invoice, change in gross margin on product purchased traditional
	//  - Formula:	IF(B83=0,0,B85-B10)	
	//-------------------------------------------------------------------- 
	if (B83 == 0){
		B86 = 0;
		frm.B86.value = 0;
	}else{
		fFormat = B85 - B10;
		if (fFormat < 0){
			fFormat = fFormat + (-.005);
		}else{
			fFormat = fFormat  //+ .005;
		}	
		B86 = fFormat;
		// Format the percentage to n decimal places and add the "%" sign.  If 
		// negative, add ( ).
		if (fFormat < 0){
			frm.B86.style.color="red";
			frm.B86.value = "(" + FormatPercentage(fFormat,2) + ")%";	
		}else{
			frm.B86.value = FormatPercentage(fFormat,2)+ "%";	
		}	
	}
}

function ComputeB87(){
	//--------------------------------------------------------------------
	// Compute B87:
	//  - 180 days after invoice, lost profit on remaining product purchased traditional
	//  - Formula:	IF(B83=0,0,(B83*B2*B86)/B83)	
	//-------------------------------------------------------------------- 
	if (B83 == 0){
		B87 = 0;
		frm.B87.value = 0;
	}else{
		B87 = ((B83*B2*B86)/B83)/100;
	}
	if (B87	< 0){
		frm.B87.style.color="red";
		frm.B87.value = formatCurrency(B87);
	}else{
		frm.B87.value = formatCurrency(B87);
	}		
}

function ComputeB88(){
	//--------------------------------------------------------------------
	// Compute B88:
	//  - Quantity on shelf 180 days after invoice - drop ship or special manner
	//  - Formula:	IF(B77-B24>0,B77-B24,0)	
	//-------------------------------------------------------------------- 
	if ((B77 - B24) > 0){
		B88 = (B77 - B24);
		frm.B88.value = B88;
	}else{
		B88  = 0;
		frm.B88.value = B88;
	}
}

function ComputeB89(){
	//--------------------------------------------------------------------
	// Compute B89:
	//  - 180 days after invoice, cost of product on shelf purchased drop ship or special manner
	//  - Formula:	IF(B88=0,0,B15+((B26/360)*IF(180>B16,180-B16,0)))	
	//-------------------------------------------------------------------- 
	var i=0;
	var ii=0;
	B89=0;
	if (B88 == 0){
		B89 = 0;
		frm.B89.value=formatCurrency(B89);
	}else{
		i = (B26/360);
		if (180>B16){
			ii = (180-B16);
		}else{
			ii = 0;	
		}
		B89 = B15 + (i*ii);
		frm.B89.value=formatCurrency(B89);
	}
}

function ComputeB90(){
	//--------------------------------------------------------------------
	// Compute B90:
	//  - 180 days after invoice, new gross margin for product purchased drop ship or special manner
	//  - Formula:	IF(B88=0,0,(B2-B89)/B2)	
	//-------------------------------------------------------------------- 
	if (B88 == 0){
		B90 =0;
		frm.B90.value = 0;
	}else{
		fFormat = ((B2 - B89) / B2) * 100;
		B90 = fFormat;
		frm.B90.value = FormatPercentage(fFormat,2)+ "%";	
	}
}

function ComputeB91(){
	//--------------------------------------------------------------------
	// Compute B91:
	//  - 180 days after invoice, change in gross margin on product purchased drop ship or special manner
	//  - Formula:	IF(B88=0,0,B90-B18)	
	//-------------------------------------------------------------------- 
	if (B88 == 0){
		B91 = 0;
		frm.B91.value=0;
	}else{
		fFormat = B90 - B18;
		B91 = fFormat;
		// Format the percentage to n decimal places and add the "%" sign.  If 
		// negative, add parentheses.
		if (fFormat < 0){
			frm.B91.style.color="red";
			frm.B91.value = "(" + FormatPercentage(fFormat,2) + ")%";	
		}else{
			frm.B91.value = FormatPercentage(fFormat,2)+ "%";	
		}	
	}
}

function ComputeB92(){
	//--------------------------------------------------------------------
	// Compute B92:
	//  - 180 days after invoice, lost profit on remaining product purchased 
	//  -  drop ship or special manner
	//  - Formula:	IF(B88=0,0,(B88*B2*B91)/B88)	
	//-------------------------------------------------------------------- 
	if (B88 == 0){
	    B92=0;
	    frm.B92.value=0;
	}else{
		B92 = ((B88*B2*B91)/B88)/100;
		if (B92 < 0){
			frm.B92.style.color="red";
		}
		frm.B92.value = formatCurrency(B92);
	}
}

//---------------	

function ComputeB94(){
	//--------------------------------------------------------------------
	// Compute B94:
	//  - Quantity on shelf 210 days after invoice - traditional
	//  - Formula:	IF(B83-B24>0,B83-B24,0)	
	//-------------------------------------------------------------------- 
	if ((B83 - B24) > 0){
		B94 = (B83 - B24);
		frm.B94.value = B94;
	}else{
		B94 = 0;
		frm.B94.value = 0;
	}
}

function ComputeB95(){
	//--------------------------------------------------------------------
	// Compute B95:
	//  - 210 days after invoice, cost of product on shelf purchased traditional
	//  - Formula:	IF(B94=0,0,B7+((B26/360)*IF(210>B8,210-B8,0)))	
	//-------------------------------------------------------------------- 
	var i=0;
	var ii=0;
	B95=0;
	if (B94 == 0) {
		frm.B95.value = formatCurrency(B95);
		return;
	}else
		i = B26/360;
		if (210 > B8) {
			ii=210-B8;
		}else{
			ii = 0;
	}
	B95 = parseFloat(B7 + (i*ii));	
	frm.B95.value = formatCurrency(B95);
}
	
function ComputeB96(){
	//--------------------------------------------------------------------
	// Compute B96:
	//  - 210 days after invoice, new gross margin of product purchased traditional
	//  - Formula:	IF(B94=0,0,(B2-B95)/B2)	
	//-------------------------------------------------------------------- 

	if (B94 == 0){
		B96 = 0;
		frm.B96.value = 0;
	}else{
		fFormat = ((B2-B95)/B2) * 100;
		// Round up to the nearest 2 decimal places
		fFormat = fFormat  //+ .005;
		B96 = fFormat;
		// Format the percentage to n decimal places and add the "%" sign
		frm.B96.value = FormatPercentage(fFormat,2)+ "%";	
	}
}

function ComputeB97(){
	//--------------------------------------------------------------------
	// Compute B97:
	//  - 210 days after invoice, change in gross margin on product purchased traditional
	//  - Formula:	IF(B94=0,0,B96-B10)	
	//-------------------------------------------------------------------- 
	if (B94 == 0){
		B97 = 0;
		frm.B97.value = 0;
	}else{
		fFormat = B96 - B10;
		if (fFormat < 0){
			fFormat = fFormat + (-.005);
		}else{
			fFormat = fFormat  //+ .005;
		}	
		B97 = fFormat;
		// Format the percentage to n decimal places and add the "%" sign.  If 
		// negative, add ( ).
		if (fFormat < 0){
			frm.B97.style.color="red";
			frm.B97.value = "(" + FormatPercentage(fFormat,2) + ")%";	
		}else{
			frm.B97.value = FormatPercentage(fFormat,2)+ "%";	
		}	
	}
}

function ComputeB98(){
	//--------------------------------------------------------------------
	// Compute B98:
	//  - 210 days after invoice, lost profit on remaining product purchased traditional
	//  - Formula:	IF(B94=0,0,(B94*B2*B97)/B94)	
	//-------------------------------------------------------------------- 
	if (B94 == 0){
		B98 = 0;
		frm.B98.value = 0;
	}else{
		B98 = ((B94*B2*B97)/B94)/100;
	}
	if (B98	< 0){
		frm.B98.style.color="red";
		frm.B98.value = formatCurrency(B98);
	}else{
		frm.B98.value = formatCurrency(B98);
	}		
}

function ComputeB99(){
	//--------------------------------------------------------------------
	// Compute B99:
	//  - Quantity on shelf 210 days after invoice - drop ship or special manner
	//  - Formula:	IF(B88-B24>0,B88-B24,0)	
	//-------------------------------------------------------------------- 
	if ((B88 - B24) > 0){
		B99 = (B88 - B24);
		frm.B99.value = B99;
	}else{
		B99  = 0;
		frm.B99.value = B99;
	}
}

function ComputeB100(){
	//--------------------------------------------------------------------
	// Compute B100:
	//  - 210 days after invoice, cost of product on shelf purchased drop ship or special manner
	//  - Formula:	IF(B99=0,0,B15+((B26/360)*IF(210>B16,210-B16,0)))	
	//-------------------------------------------------------------------- 
	var i=0;
	var ii=0;
	B100=0;
	if (B99 == 0){
		B100 = 0;
		frm.B100.value=formatCurrency(B100);
	}else{
		i = (B26/360);
		if (210>B16){
			ii = (210-B16);
		}else{
			ii = 0;	
		}
		B100 = B15 + (i*ii);
		frm.B100.value=formatCurrency(B100);
	}
}

function ComputeB101(){
	//--------------------------------------------------------------------
	// Compute B101:
	//  - 210 days after invoice, new gross margin for product purchased drop ship or special manner
	//  - Formula:	IF(B99=0,0,(B2-B100)/B2)	
	//-------------------------------------------------------------------- 
	if (B99 == 0){
		B101 =0;
		frm.B101.value = 0;
	}else{
		fFormat = ((B2 - B100) / B2) * 100;
		B101 = fFormat;
		frm.B101.value = FormatPercentage(fFormat,2)+ "%";	
	}
}

function ComputeB102(){
	//--------------------------------------------------------------------
	// Compute B102:
	//  - 210 days after invoice, change in gross margin on product purchased drop ship or special manner
	//  - Formula:	IF(B99=0,0,B101-B18)	
	//-------------------------------------------------------------------- 
	if (B99 == 0){
		B102 = 0;
		frm.B102.value=0;
	}else{
		fFormat = B101 - B18;
		B102 = fFormat;
		// Format the percentage to n decimal places and add the "%" sign.  If 
		// negative, add parentheses.
		if (fFormat < 0){
			frm.B102.style.color="red";
			frm.B102.value = "(" + FormatPercentage(fFormat,2) + ")%";	
		}else{
			frm.B102.value = FormatPercentage(fFormat,2)+ "%";	
		}	
	}
}

function ComputeB103(){
	//--------------------------------------------------------------------
	// Compute B103:
	//  - 210 days after invoice, lost profit on remaining product purchased 
	//  -  drop ship or special manner
	//  - Formula:	IF(B99=0,0,(B99*B2*B102)/B99)	
	//-------------------------------------------------------------------- 
	if (B99 == 0){
	    B103=0;
	    frm.B103.value=0;
	}else{
		B103 = ((B99*B2*B102)/B99)/100;
		if (B103 < 0){
			frm.B103.style.color="red";
		}
		frm.B103.value = formatCurrency(B103);
	}
}

//---------------	

function ComputeB105(){
	//--------------------------------------------------------------------
	// Compute B105:
	//  - Quantity on shelf 240 days after invoice - traditional
	//  - Formula:	IF(B94-B24>0,B94-B24,0)
	//				IF(B83-B24>0,B83-B24,0)	
	//-------------------------------------------------------------------- 
	if ((B94 - B24) > 0){
		B105 = (B94 - B24);
		frm.B105.value = B105;
	}else{
		B105 = 0;
		frm.B105.value = 0;
	}
}

function ComputeB106(){
	//--------------------------------------------------------------------
	// Compute B106:
	//  - 240 days after invoice, cost of product on shelf purchased traditional
	//  - Formula:	IF(B105=0,0,B7+((B26/360)*IF(240>B8,240-B8,0)))	
	//				IF(B94=0,0,B7+((B26/360)*IF(210>B8,210-B8,0)))	
	//-------------------------------------------------------------------- 
	var i=0;
	var ii=0;
	B106=0;
	if (B105 == 0) {
		frm.B106.value = formatCurrency(B106);
		return;
	}else
		i = B26/360;
		if (240 > B8) {
			ii=240-B8;
		}else{
			ii = 0;
	}
	B106 = parseFloat(B7 + (i*ii));	
	frm.B106.value = formatCurrency(B106);
}
	
function ComputeB107(){
	//--------------------------------------------------------------------
	// Compute B107:
	//  - 240 days after invoice, new gross margin of product purchased traditional
	//  - Formula:	IF(B105=0,0,(B2-B106)/B2)
	//				IF(B94=0,0,(B2-B95)/B2)	
	//-------------------------------------------------------------------- 

	if (B105 == 0){
		B107 = 0;
		frm.B107.value = 0;
	}else{
		fFormat = ((B2-B106)/B2) * 100;
		// Round up to the nearest 2 decimal places
		fFormat = fFormat  //+ .005;
		B107 = fFormat;
		// Format the percentage to n decimal places and add the "%" sign
		frm.B107.value = FormatPercentage(fFormat,2)+ "%";	
	}
}

function ComputeB108(){
	//--------------------------------------------------------------------
	// Compute B108:
	//  - 240 days after invoice, change in gross margin on product purchased traditional
	//  - Formula:	IF(B105=0,0,B107-B10)	
	//				IF(B94=0,0,B96-B10)	
	//-------------------------------------------------------------------- 
	if (B105 == 0){
		B108 = 0;
		frm.B108.value = 0;
	}else{
		fFormat = B107 - B10;
		if (fFormat < 0){
			fFormat = fFormat + (-.005);
		}else{
			fFormat = fFormat  //+ .005;
		}	
		B108 = fFormat;
		// Format the percentage to n decimal places and add the "%" sign.  If 
		// negative, add ( ).
		if (fFormat < 0){
			frm.B108.style.color="red";
			frm.B108.value = "(" + FormatPercentage(fFormat,2) + ")%";	
		}else{
			frm.B97.value = FormatPercentage(fFormat,2)+ "%";	
		}	
	}
}

function ComputeB109(){
	//--------------------------------------------------------------------
	// Compute B109:
	//  - 240 days after invoice, lost profit on remaining product purchased traditional
	//  - Formula:	IF(B105=0,0,(B105*B2*B108)/B105)	
	//				IF(B94=0,0,(B94*B2*B97)/B94)	
	//-------------------------------------------------------------------- 
	if (B105 == 0){
		B109 = 0;
		frm.B109.value = 0;
	}else{
		B109 = ((B105*B2*B108)/B105)/100;
	}
	if (B109	< 0){
		frm.B109.style.color="red";
		frm.B109.value = formatCurrency(B109);
	}else{
		frm.B109.value = formatCurrency(B109);
	}		
}

function ComputeB110(){
	//--------------------------------------------------------------------
	// Compute B110:
	//  - Quantity on shelf 240 days after invoice - drop ship or special manner
	//  - Formula:	IF(B99-B24>0,B99-B24,0)	
	//				IF(B88-B24>0,B88-B24,0)	
	//-------------------------------------------------------------------- 
	if ((B99 - B24) > 0){
		B110 = (B99 - B24);
		frm.B110.value = B110;
	}else{
		B110  = 0;
		frm.B110.value = B110;
	}
}

function ComputeB111(){
	//--------------------------------------------------------------------
	// Compute B111:
	//  - 240 days after invoice, cost of product on shelf purchased drop ship or special manner
	//  - Formula:	IF(B110=0,0,B15+((B26/360)*IF(240>B16,240-B16,0)))	
	//				IF(B99=0,0,B15+((B26/360)*IF(210>B16,210-B16,0)))	
	//-------------------------------------------------------------------- 
	var i=0;
	var ii=0;
	B111=0;
	if (B110 == 0){
		B111 = 0;
		frm.B111.value=formatCurrency(B111);
	}else{
		i = (B26/360);
		if (240>B16){
			ii = (240-B16);
		}else{
			ii = 0;	
		}
		B111 = B15 + (i*ii);
		frm.B111.value=formatCurrency(B111);
	}
}

function ComputeB112(){
	//--------------------------------------------------------------------
	// Compute B112:
	//  - 240 days after invoice, new gross margin for product purchased drop ship or special manner
	//  - Formula:	IF(B110=0,0,(B2-B111)/B2)	
	//				IF(B99=0,0,(B2-B100)/B2)	
	//-------------------------------------------------------------------- 
	if (B110 == 0){
		B112 =0;
		frm.B112.value = 0;
	}else{
		fFormat = ((B2 - B111) / B2) * 100;
		B112 = fFormat;
		frm.B112.value = FormatPercentage(fFormat,2)+ "%";	
	}
}

function ComputeB113(){
	//--------------------------------------------------------------------
	// Compute B113:
	//  - 240 days after invoice, change in gross margin on product purchased drop ship or special manner
	//  - Formula:	IF(B110=0,0,B112-B18)	
	//				IF(B99=0,0,B101-B18)	
	//-------------------------------------------------------------------- 
	if (B110 == 0){
		B113 = 0;
		frm.B113.value=0;
	}else{
		fFormat = B112 - B18;
		B113 = fFormat;
		// Format the percentage to n decimal places and add the "%" sign.  If 
		// negative, add parentheses.
		if (fFormat < 0){
			frm.B113.style.color="red";
			frm.B113.value = "(" + FormatPercentage(fFormat,2) + ")%";	
		}else{
			frm.B113.value = FormatPercentage(fFormat,2)+ "%";	
		}	
	}
}

function ComputeB114(){
	//--------------------------------------------------------------------
	// Compute B114:
	//  - 240 days after invoice, lost profit on remaining product purchased 
	//  -  drop ship or special manner
	//  - Formula:	IF(B110=0,0,(B110*B2*B113)/B110)	
	//				IF(B99=0,0,(B99*B2*B102)/B99)	
	//-------------------------------------------------------------------- 
	if (B110 == 0){
	    B114=0;
	    frm.B114.value=0;
	}else{
		B114 = ((B110*B2*B113)/B110)/100;
		if (B114 < 0){
			frm.B114.style.color="red";
		}
		frm.B114.value = formatCurrency(B114);
	}
}

//---- Treat the enter key like the tab key NEW ON 11/2008 AND NOT TESTED YET.
//function fn(event,number) 
//{ 
//if( event.keyCode == 13 ) 
//{ 
//	var wow = document.getElementById(number); 
//	wow.focus(); 
//}         
//} 



//---- Treat the enter key like the tab key
function fn(e,form,field)
{
var next=0, found=false
var f=form
if(e.keyCode!=13) return;
//for(var i=0;i<f.length;i++)
//	{
//	if(field.name==f.item(i).name) 
//	{
//		next=i+1;
//		found=true
//		break;
//	}
//	}
//while(found)  //Infinite loop 
//	{
//	if( f.item(next).disabled==false &&  f.item(next).type!='hidden')
//		{
//		f.item(next).focus();
//		break;
//		}
//	else
//		{
//		if(next<f.length-1)
//			next=next+1;
//		else
//			break;
//			
//		}
//	}
}


function stringFilter (input) {
	var s = input;
	var filteredValues = "$,";     // Characters stripped out
	var i;
	var returnString = "";
	for (i = 0; i < s.length; i++) {  // Search through string and append to unfiltered values to returnString.
		var c = s.charAt(i);
		if (filteredValues.indexOf(c) == -1) returnString += c;
	}
	//input.value = returnString;
	return returnString;
}

function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
	if(cents<10)
		//cents = "0" + cents + "00";		// Bruce added the 00 to get it out to 4 pos.
		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 (((sign)?'':'-') + '$' + num + '.' + cents);
}

function FormatClean(num)
{
     var sVal='';
     var nVal = num.length;
     var sChar='';
     
   try
   {
       for(i=0;i<nVal;i++)
      {
         sChar = num.charAt(i);
         nChar = sChar.charCodeAt(0);
         if ((nChar >=48) && (nChar <=57))  { sVal += num.charAt(i);   }
      }
   }
    catch (exception) { AlertError("Format Clean",e); }
    return sVal;
}
function formatnumber(num)
{       
        var sVal='';
        var minus='';
        var CommaDelimiter=',';
		
		// Make sure it's a string first
		num = num.toString();

        if (num.lastIndexOf("-") == 0) { minus='-'; }

           num = FormatClean(num);

           num = parseInt(num);

           var samount = new String(num);
             
           for (var i = 0; i < Math.floor((samount.length-(1+i))/3); i++)
          {
             samount = samount.substring(0,samount.length-(4*i+3)) + CommaDelimiter + samount.substring(samount.length-(4*i+3));
           }

        return minus + samount;
}

function FormatPercentage(floatNbr, decPlaces) {
	//------------------------------------------------------
	//	Bruce Geroux
	//	Date:	11/05/2003
	//	Parms: text string and decimal places
	//	Returns: percentage with nDecimal Places.
	//	Remarks: The string is zero based, therefore need to add +1
	//--------------------------------------------------------
	var decimalPos;
	var answer;
	var str=floatNbr.toString();	// Convert to string
	decimalPos = str.indexOf(".");	// Where is the decimal point
	answer = str.substr(0,decimalPos+decPlaces+1); // Parse it out
	return answer;	// Return the result
}

function GraphIt(){
	//----------------------------------------------------------
	// Line Graph
	//----------------------------------------------------------
	
	document.write('<applet code="LineGraphApplet.class" archive="LineGraph.jar" width="500" height="420">');

	//<!-- Start Up Parameters -->
	  document.write('<PARAM name="LOADINGMESSAGE" value="Line Graph Loading - Please Wait.">');    //<!-- Message to be displayed on Startup -->
	  document.write('<PARAM name="STEXTCOLOR" value="0,0,100">');                                  //<!-- Message Text Color-->
	  document.write('<PARAM name="STARTUPCOLOR" value="255,255,255">');                            //<!-- Applet Background color -->

	//<!-- Chart Switches -->
	  document.write('<PARAM name="3D" value="false">');       //<!-- 3D mode On/Off -->
	  document.write('<PARAM name="grid" value="true">'); 	   //<!-- Grid On/Off -->
	  document.write('<PARAM name="axis" value="true">');      //<!-- Axis On/Off -->
	  document.write('<PARAM name="ylabels" value="true">');   //<!-- y Labels On/Off -->
	  document.write('<PARAM name="outline" value="true">');   //<!-- Outline On/Off -->
	  document.write('<PARAM name="legend" value="true">');    //<!-- Legend On/Off -->

	//<!-- Chart Characteristics -->
	  document.write('<PARAM name="nPoints" value="7">');           //<!-- Max Number of Points per series-->
	  document.write('<PARAM name="nRows" value="7">');              //<!-- Number of Rows for the grid -->
	  document.write('<PARAM name="vSpace" value="30">');            //<!-- Vertical spacing, number of Pixels -->
	  document.write('<PARAM name="nSeries" value="2">');            //<!-- Number of Series -->
	  document.write('<PARAM name="hSpace" value="60">');            //<!-- Horizontal spacing, Pixels-->
	  document.write('<PARAM name="gridxpos" value="75">');          //<!-- X position to start grid -->
	  document.write('<PARAM name="gridypos" value="350">');         //<!-- Y position to start grid -->
	  document.write('<PARAM name="gridstyle" value="3">');          //<!-- grid line style -->
	  document.write('<PARAM name="depth3D" value="15">');           //<!-- Depth of 3D effect, number of Pixels -->
	  document.write('<PARAM name="ndecplaces" value="4">');         //<!-- Number of Decimal places to display values -->
	  document.write('<PARAM name="labelOrientation" value="5">');   //<!-- x axis label orientation -->
	  document.write('<PARAM name="labelsY" value="360">');          //<!-- Y position of x axis labels-->
	  document.write('<PARAM name="chartScale" value=".2000">');      //<!-- Chart Scale -->
	  document.write('<PARAM name="chartStartY" value="0.0000">');        //<!-- Starting Y value -->

	//<!-- x axis Labels -->
	  document.write('<PARAM name="label1" value="60|-10">');
	  document.write('<PARAM name="label2" value="90|-10">');
	  document.write('<PARAM name="label3" value="120|-10">');
	  document.write('<PARAM name="label4" value="150|-10">');
	  document.write('<PARAM name="label5" value="180|-10">');
	  document.write('<PARAM name="label6" value="210|-10">');
	  document.write('<PARAM name="label7" value="240|-10">');

	//<!-- Additional font information -->
	  document.write('<PARAM name="font14" value="Verdana,N,10">');  //<!-- Y labels Font -->
	  document.write('<PARAM name="font15" value="Verdana,N,10">');  //<!-- X labels Font -->

	//<!-- Additional color information -->
	  document.write('<PARAM name="color14" value="170,170,170">');     //<!-- gridcolor         -->
	  document.write('<PARAM name="color15" value="0,0,255">');         //<!-- axiscolor         -->
	  document.write('<PARAM name="color16" value="0,100,170">');       //<!-- floorcolor        -->
	  document.write('<PARAM name="color17" value="0,0,0">');           //<!-- outline color     -->
	  document.write('<PARAM name="color18" value="50,50,50">');        //<!-- label color       -->
	  document.write('<PARAM name="color19" value="50,50,50">');        //<!-- Y color           -->

	//<!-- Legend Information -->
	  document.write('<PARAM name="legendfont" value="Verdana,N,10">');       //<!-- Legend Font        -->
	  document.write('<PARAM name="legendposition" value="345,15">');        //<!-- Legend Position    -->
	  document.write('<PARAM name="legendtitle" value="Cost of Product">');        //<!-- Legend Title       -->
	  document.write('<PARAM name="LegendBackground"value="166,210,255">');
	  document.write('<PARAM name="LegendBorder"value="0,50,175">');
	  document.write('<PARAM name="LegendtextColor"value="50,50,50">');

	//<!-- Titles - Main, x and y -->
	//<!-- title" value="text,xpos,ypos,font-type,font-style,font-size,Rcolor,Gcolor,Bcolor"> -->
		document.write('<PARAM name="title"  value="Cost of Inventory|80,60|Verdana,BI,18|100,100,200">');
		document.write('<PARAM name="xtitle" value="Days after Invoice|200,400|Verdana,B,16|100,100,200">');
		document.write('<PARAM name="ytitle" value="Product Cost|10,375|Verdana,B,16|100,100,200">');

	//<!-- Free Form Text -->
	//<!-- <PARAM name="textn" value="text,xpos,ypos,font-type,font-style,font-size,Rcolor,Gcolor,Bcolor"> -->
		 //document.write('<PARAM name="text1" value="Note :|80,85|Arial,N,10|100,100,200">');
		 //document.write('<PARAM name="text2" value="Cost of merchandise purchased traditional|85,100|Arial,N,10|50,50,50">');
		 //document.write('<PARAM name="text3" value="Cost of merchandise purchased drop ship or special manner|85,115|Arial,N,10|50,50,50">');

	//<!-- Series Data -->
	//<!-- <PARAM name="seriesN" value="series color|point style|Point Size|fill|legend label"> -->
		 document.write('<PARAM name="series1" value="99,99,156|5|8|false|Traditional">');
		 document.write('<PARAM name="series2" value="185,53,8|3|8|true|Drop Ship">');

	//<!-- Trend Lines -->
	//<!-- color|start point|end point|start value|end value|label|font -->
		 //document.write('<PARAM name="trend1" value="0,0,0|7|12|2200|3300|Upper trend|Arial,B,12">');	
		 //document.write('<PARAM name="trend2" value="0,0,0|8|12|900|1550|Lower trend|Arial,B,12">');
	
	//<!-- Target Lines -->
	//<!-- color|style|start point|end point|value|label|font -->
		 //document.write('<PARAM name="target1" value="0,125,0|4|1|12|5500|Target|Arial,N,10">');
		 //document.write('<PARAM name="target2" value="125,0,0|4|1|12|1500|Break Even|Arial,N,10">');


	//<!-- Point Data -->
	//<!-- <PARAM name="dataNseriesN" value="value|URL|Target Frame"> -->
	
	//---------------------------------------------------------------------------------
	// Global variables to use for series 1 are: B40, B51, B62, B73, B84, B95, B106 
	//---------------------------------------------------------------------------------
	
		 if(isNaN(B40))
			B40 = 0;
		 if(isNaN(B51))
			B51 = 0;
		 if(isNaN(B62))
			B62 = 0;
		 if(isNaN(B73))
			B73 = 0;
		 if(isNaN(B84))
			B84 = 0;
		 if(isNaN(B95))
			B95 = 0;
		 if(isNaN(B106))
			B106 = 0;
			
		 document.write('<PARAM name="data1series1" value="'+ B40 + '">');
		 document.write('<PARAM name="data2series1" value="'+ B51 + '">');
		 document.write('<PARAM name="data3series1" value="'+ B62 + '">');
		 document.write('<PARAM name="data4series1" value="'+ B73 + '">');
		 document.write('<PARAM name="data5series1" value="'+ B84 + '">');
		 document.write('<PARAM name="data6series1" value="'+ B95 + '">');
		 document.write('<PARAM name="data7series1" value="'+ B106 + '">');

		 
	//---------------------------------------------------------------------------------
	// Global variables to use for series 2 are: B45, B56, B67, B78, B89, B100, B111 
	//---------------------------------------------------------------------------------
		 if(isNaN(B45))
			B45 = 0;
		 if(isNaN(B56))
			B56 = 0;
		 if(isNaN(B67))
			B67 = 0;
		 if(isNaN(B78))
			B78 = 0;
		 if(isNaN(B89))
			B89 = 0;
		 if(isNaN(B100))
			B100 = 0;
		 if(isNaN(B111))
			B111 = 0;

		 document.write('<PARAM name="data1series2" value="'+ B45 + '">');
		 document.write('<PARAM name="data2series2" value="'+ B56 + '">');
		 document.write('<PARAM name="data3series2" value="'+ B67 + '">');
		 document.write('<PARAM name="data4series2" value="'+ B78 + '">');
		 document.write('<PARAM name="data5series2" value="'+ B89 + '">');
		 document.write('<PARAM name="data6series2" value="'+ B100 + '">');
		 document.write('<PARAM name="data7series2" value="'+ B111 + '">');
		 
	document.write('</applet>');

}