function keyhandler(e){
	if ( focusObject ) {
		focusObject.blur();
		focusObject.focus();
		var form = getFormObj('f1');
		calc_software_price(form);	
	} // end if
} // end key handler

if ( is_nav4only ) {
	document.captureEvents( Event.KEYUP );
	document.onkeyup = keyhandler;
} // end if

function getFormObj( formName ) {
	var form;
	if ( is_nav4only ) {
		if ( document.layers["content"] ) {
			form = document.layers["content"].document.forms[formName];
		} else {
			form = document.forms[formName];
		} // end nif
	} else {
		form = document.forms[formName];
	} /* end if */
    return form;
}

function do_decimals( number ) {
	if ( isNaN(number) ) {
		return '0.00';
	} else { 
		var myStr = new String(Math.round(number*100)/100);
		var decPos = myStr.indexOf(".");
		// test for no decimals
		if (decPos==-1) {
			myStr += ".00";
		} else if (decPos==myStr.length-2) {
		// test for one decimal
			myStr += "0";
		} // end if
	} // end if
	return myStr;
} // end do_decimals

function calc_software_price( form ) {

var totalPrice = 0;
var annualLicenseSupportPrice = 0;
var licenses = 0;
var exchangeRate;

var PriceArray = new Array();

// Products
PriceArray['Products']='10';

// Suppliers
PriceArray['Suppliers']='3000';

// Payment Prices
PriceArray['CreditAccount']='300';
PriceArray['CreditCard']='1800';
PriceArray['DigitalCheque']='1800';

// Additional Feature Prices
PriceArray['ShipmentEstimating']='3000';

PriceArray['ProductInventory']='6000';
PriceArray['MaterialInventory']='6000';
PriceArray['ProjectInventory']='6000';
PriceArray['IntegratedAccounting']='6000';
PriceArray['ProductionDataCollection']='6000';
PriceArray['EmployeeTimeTracking']='6000';

PriceArray['AutomatedScheduling']='12000';
PriceArray['ProductionEstimating']='12000';

// General Software Configuration Prices
PriceArray['SuppliedIn-houseServer']='5000';
PriceArray['ExistingIn-houseServer']='1200';
PriceArray['Print-QuotesServers']='2400';

PriceArray['CustomInterface']='2400';
PriceArray['PreDesignedTemplate']='600';

PriceArray['DomainLicense']='10000';

PriceArray['Training']='75';

if ( form.elements["CreditAccount"].checked ){totalPrice += parseFloat(PriceArray["CreditAccount"]); } // end if
if ( form.elements["CreditCard"].checked ){totalPrice += parseFloat(PriceArray["CreditCard"]); } // end if
if ( form.elements["DigitalCheque"].checked ){totalPrice += parseFloat(PriceArray["DigitalCheque"]); } // end if

if ( form.elements["ProductInventory"].checked ){totalPrice += parseFloat(PriceArray["ProductInventory"]); } // end if
if ( form.elements["MaterialInventory"].checked ){totalPrice += parseFloat(PriceArray["MaterialInventory"]); } // end if
if ( form.elements["ProjectInventory"].checked ){totalPrice += parseFloat(PriceArray["ProjectInventory"]); } // end if
if ( form.elements["IntegratedAccounting"].checked ){totalPrice += parseFloat(PriceArray["IntegratedAccounting"]); } // end if
if ( form.elements["AutomatedScheduling"].checked ){totalPrice += parseFloat(PriceArray["AutomatedScheduling"]); } // end if
if ( form.elements["ProductionDataCollection"].checked ){totalPrice += parseFloat(PriceArray["ProductionDataCollection"]); } // end if
if ( form.elements["EmployeeTimeTracking"].checked ){totalPrice += parseFloat(PriceArray["EmployeeTimeTracking"]); } // end if
if ( form.elements["ShipmentEstimating"].checked ){totalPrice += parseFloat(PriceArray["ShipmentEstimating"]); } // end if
if ( form.elements["ProductionEstimating"].checked ){totalPrice += parseFloat(PriceArray["ProductionEstimating"]); } // end if

if (form.txtProducts.value < 1001) {
	totalPrice += parseFloat(PriceArray["Products"] * form.txtProducts.value);
	} // end if
if (form.txtProducts.value > 1001 && form.txtProducts.value < 2001) {
	totalPrice += parseFloat(PriceArray["Products"] * 1000);
	totalPrice += parseFloat(PriceArray["Products"] * 0.9 * (form.txtProducts.value - 1000));
	} // end if
if (form.txtProducts.value > 2001 && form.txtProducts.value < 3001) {
	totalPrice += parseFloat(PriceArray["Products"] * 1.9 * 1000);
	totalPrice += parseFloat(PriceArray["Products"] * 0.8 * (form.txtProducts.value - 2000));
	} // end if
if (form.txtProducts.value > 3001 && form.txtProducts.value < 4001) {
	totalPrice += parseFloat(PriceArray["Products"] * 2.7 * 1000);
	totalPrice += parseFloat(PriceArray["Products"] * 0.7 * (form.txtProducts.value - 3000));
	} // end if
if (form.txtProducts.value > 4001 && form.txtProducts.value < 5001) {
	totalPrice += parseFloat(PriceArray["Products"] * 3.4 * 1000);
	totalPrice += parseFloat(PriceArray["Products"] * 0.7 * (form.txtProducts.value - 4000));
	} // end if
if (form.txtProducts.value > 5001 && form.txtProducts.value < 6001) {
	totalPrice += parseFloat(PriceArray["Products"] * 4.0 * 1000)
	totalPrice += parseFloat(PriceArray["Products"] * 0.5 * (form.txtProducts.value - 5000));
	} // end if
if (form.txtProducts.value > 6001 && form.txtProducts.value < 7001) {
	totalPrice += parseFloat(PriceArray["Products"] * 4.5 * 1000);
	totalPrice += parseFloat(PriceArray["Products"] * 0.4 * (form.txtProducts.value - 6000));
	} // end if
if (form.txtProducts.value > 7001 && form.txtProducts.value < 8001) {
	totalPrice += parseFloat(PriceArray["Products"] * 4.9 * 1000);
	totalPrice += parseFloat(PriceArray["Products"] * 0.3 * (form.txtProducts.value - 7000));
	} // end if
if (form.txtProducts.value > 8001 && form.txtProducts.value < 9001) {
	totalPrice += parseFloat(PriceArray["Products"] * 5.2 * 1000);
	totalPrice += parseFloat(PriceArray["Products"] * 0.2 * (form.txtProducts.value - 8000));
	} // end if
if (form.txtProducts.value > 9001) {
	totalPrice += parseFloat(PriceArray["Products"] * 5.4 * 1000);
	totalPrice += parseFloat(PriceArray["Products"] * 0.1 * (form.txtProducts.value - 9000));
	} // end if	

totalPrice += parseFloat(PriceArray["Suppliers"] * form.txtSuppliers.value);

if (form.rdbHosting[0].checked) {
	totalPrice += parseFloat(PriceArray["ExistingIn-houseServer"]); 
	form.hdnHosting.value = 0;
	} // end if
	
if (form.rdbHosting[1].checked) {
	totalPrice += parseFloat(PriceArray["SuppliedIn-houseServer"]); 
	form.hdnHosting.value = 0;
	} // end if
	
if (form.rdbHosting[2].checked) {
	totalPrice += parseFloat(PriceArray["Print-QuotesServers"]);
	} // end if
	
if (form.rdbHosting[2].checked && form.hdnHosting.value == 0) {
	alert ("A price for your first year of hosting has been added to your total price. Additional hosting fees will be invoiced annually.\n\nAdditional fees for bandwidth usage may apply.");
	form.hdnHosting.value = 1;
	} // end if
	
if (form.rdbInterface[0].checked) {
	totalPrice += parseFloat(PriceArray["CustomInterface"] * form.txtDomainLicense.value); 
	} // end if
	
if (form.rdbInterface[1].checked) {
	totalPrice += parseFloat(PriceArray["PreDesignedTemplate"] * form.txtDomainLicense.value); 
	} // end if

totalPrice += parseFloat(PriceArray["Training"] * form.txtTraining.value);

totalPrice += parseFloat(PriceArray["DomainLicense"] * form.txtDomainLicense.value); 
annualLicenseSupportPrice = parseFloat(totalPrice * 0.12);	

if (form.txtExchangeRate.value == "") {
	form.txtExchangeRate.value = 1.4;
	exchangeRate = form.txtExchangeRate.value;
	} // end if

exchangeRate = form.txtExchangeRate.value;

if (form.rdbCurrency[1].checked) {
	
	totalPrice = parseFloat(totalPrice / exchangeRate); 
	annualLicenseSupportPrice = parseFloat(annualLicenseSupportPrice / exchangeRate);
	
	} // end if

form.txtTotalPrice.value = do_decimals(parseFloat(totalPrice));
form.txtAnnualLicenseSupport.value = do_decimals(parseFloat(annualLicenseSupportPrice));

form.txtDesignPhase.value = do_decimals(parseFloat(totalPrice) * 0.30);
form.txtDevelopmentPhase.value = do_decimals(parseFloat(totalPrice) * 0.50);
form.txtDeliveryPhase.value = do_decimals(parseFloat(totalPrice) * 0.20);
form.txtAnnualLicenseSupport2.value = do_decimals(parseFloat(annualLicenseSupportPrice));

form.txtFinancedDesignPhase.value = do_decimals(parseFloat(totalPrice + annualLicenseSupportPrice) * 0.30 * 0.60);
form.txtFinancedDevelopmentPhase.value = do_decimals(parseFloat(totalPrice + annualLicenseSupportPrice) * 0.50 * 0.60);
form.txtFinancedDeliveryPhase.value = do_decimals(parseFloat(totalPrice + annualLicenseSupportPrice) * 0.20 * 0.60);
form.txtFinancedMonthlyPaymentPrice.value = do_decimals(parseFloat(totalPrice + annualLicenseSupportPrice) * 0.4  * 1.1  / 12);

form.txt2FinancedDesignPhase.value = do_decimals(parseFloat(totalPrice + annualLicenseSupportPrice) * 0.30 * 0.60);
form.txt2FinancedDevelopmentPhase.value = do_decimals(parseFloat(totalPrice + annualLicenseSupportPrice) * 0.50 * 0.60);
form.txt2FinancedDeliveryPhase.value = do_decimals(parseFloat(totalPrice + annualLicenseSupportPrice) * 0.20 * 0.60);
form.txt2FinancedMonthlyPaymentPrice.value = do_decimals(parseFloat((totalPrice + annualLicenseSupportPrice ) * 0.4  + annualLicenseSupportPrice) * 1.2  / 24);

form.txtPriceMonthLeaseRate12.value = do_decimals(parseFloat(totalPrice + annualLicenseSupportPrice) / 12 * 1.18);
form.txtPriceMonthLeaseRate24.value = do_decimals(parseFloat(totalPrice + (annualLicenseSupportPrice * 2)) / 24 * 1.18);
form.txtPriceMonthLeaseRate36.value = do_decimals(parseFloat(totalPrice + (annualLicenseSupportPrice * 3)) / 36 * 1.18);
form.txtPriceMonthLeaseRate48.value = do_decimals(parseFloat(totalPrice + (annualLicenseSupportPrice * 4)) / 48 * 1.18);

} // end function calc_software_price
