function calculateFreight(postcode, weightPerUnit, qty) { 

	
	if (fr[postcode] == undefined) {
		return 0;
		}
	
			
	var kgRate = fr[postcode][0];
	var basicRate = fr[postcode][1];
	var minRate = fr[postcode][2];
 	var freightTotal;
	var totalWeight = (qty * weightPerUnit) / 1000;
 
 //alert(qty + " " + weightPerUnit + " " + kgRate + " " + totalWeight);
 
 freightTotal = ((totalWeight * kgRate) + basicRate) * 1.3;

 
 if(freightTotal < minRate) {
	freightTotal = minRate;
 }


 //markup the freight
 freightTotal = freightTotal * 1.3;
 
 
 if(freightTotal < 18) {
	freightTotal = 18;
	}

	return freightTotal;
}


function CalculateFreightCart(_weight, _postcode, _freightPriceField, _ObjId, _form) {

with (document) {
	
	var postcode = getElementById(_postcode).value;	
	
	if (fr[postcode] == undefined) {
		
		getElementById(_postcode).value = "Invalid Postcode";
		return null;
		}
	
			
	var kgRate = fr[postcode][0];
	var basicRate = fr[postcode][1];
	var minRate = fr[postcode][2];
 	var freightTotal;

 
 freightTotal = ((_weight * kgRate) + basicRate) * 1.3;

 
 if(freightTotal < minRate) {
	freightTotal = minRate;
 }


 //markup the freight
 freightTotal = freightTotal * 1.3;
 
 
 if(freightTotal <= 18) {
	freightTotal = 18;
	}

	getElementById(_freightPriceField).value = parseInt(freightTotal);
	getElementById("updateShippingSwitch").name = "eCart2_Update_100";
	forms[_form].submit();
	
	}

}

function clearFreight(_freightPriceField, _form) { //v9.0

with (document) {

	getElementById(_freightPriceField).value = 0;
	getElementById("updateShippingSwitch").name = "eCart2_Update_100";
	getElementById("postcode").value = "";
	forms[_form].submit();
	
	}

}
