
function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}

function calc_price_inclusive(){
	var oPriceInclusive=document.getElementById('price');
	var oPriceInclusiveSpan=document.getElementById('sp_price_inclusive');
	var oPriceExclusive=document.getElementById('price_exclusive');
	var oQuantity=document.getElementById('quantity');
	var oHalfBox=document.getElementById('Half Box');
	var oSupplierCost=document.getElementById('Supplier Carriage');
	var oCustomerCost=document.getElementById('Customer Carriage');
	var oQTYPerBox=document.getElementById('Quantity Per Box');
	var oSetupCost=document.getElementById('Setup Cost');
	var oMarkup=document.getElementById('Markup');
	var oExtraMarkup=document.getElementById('ExtraMarkup');
	
	var quantity=oQuantity.value*1;
	var extramarkup=oExtraMarkup.value*1
	var price=((oPriceExclusive.value*1)*(oMarkup.value*1));
	price=roundNumber(price,2);

	var boxes=Math.ceil(quantity/(oQTYPerBox.value*1));
	boxes=roundNumber(boxes,2);
	var carriagein=boxes*(oSupplierCost.value*1);
	carriagein=roundNumber(carriagein,2);
	price+=roundNumber((carriagein/quantity),2);


	var carriageout=boxes*(oCustomerCost.value*1);
	carriageout=roundNumber(carriageout,2);
	price+=roundNumber((carriageout/quantity),2);

	
	price+=((oSetupCost.value*1)/quantity);
	price+=extramarkup;

	oPriceInclusive.value='£'+price.toFixed(2);
	oPriceInclusiveSpan.innerHTML='£'+price.toFixed(2);
	//oPriceExclusive.value='';
}




