function getNumberOfUnits(index) {
var i = index
var units = document.form1.elements[i].value
if (units == ""){
	units = 1
}

return (units == "") ? 0 : units;
}

function showResult(result, index) {
var i = index-1	
document.form1.elements[i].value = result;
}

function formatMessage(units, unit_price, discount, ex) {
	if (units !=0){
		//return formatPrice(unit_price-(unit_price*(discount/100)));
		return formatPrice((unit_price-(unit_price*(discount/100)))/ ex);
	}
	else{
		return formatPrice(0);
	}
}



function formatMessage2(units, unit_price, discount, ex) {
	if (units !=0){
		//return formatPrice2(unit_price-(unit_price*(discount/100)));
		return formatPrice2((unit_price-(unit_price*(discount/100)))/ ex);
	}
	else{
		return formatPrice2(0);
	}
}




function findPrice(index, desc) {
var units = getNumberOfUnits(index);


if (desc == "AllyCAD_Micro") {
	var ex = exchangeRate()
	parent.CheckCurrency()
	/////////////////////////////////////////////////////////
	//allyCAD Micro gets NO discounts therefore discount = 0
	////////////////////////////////////////////////////////
	//var discount = getDiscount(units, desc);
	var discount = 0
	var unit_price = AllyGetPrice(ex);
	var result;
	
	
	////
	var courierPrice = courier();
	
	courierPrice = (Math.floor(((courierPrice * units)/ex) * 100) / 100)
	parent.courier_p(index, courierPrice);
}

//other if statements
else if (desc =="AllyCAD_SME") {
	var ex = exchangeRate()
	parent.CheckCurrency()
	
	var discount = getDiscount(units, desc, ex);
	var unit_price = AllyGetPrice2(ex);
	var result;
	
	/////
	var courierPrice = courier();
	
	courierPrice = (Math.floor(((courierPrice * units)/ex) * 100) / 100)
	parent.courier_p(index, courierPrice);
}

else if (desc =="AllyCAD_PRO") {
	var ex = exchangeRate()
	parent.CheckCurrency()
	
	var discount = getDiscount(units, desc);
	var unit_price = AllyGetPrice3(ex);
	var result;
	
	
	
	///
	var courierPrice = courier();
	
	courierPrice = (Math.floor(((courierPrice * units)/ex) * 100) / 100)
	parent.courier_p(index, courierPrice);
}




else if (desc =="ChoiceSteel") {
	var ex = exchangeRate()
	parent.CheckCurrency()
	
	/////////////////////////////////////////////////////////
	//ChoiseSteel gets NO discounts therefore discount = 0
	////////////////////////////////////////////////////////
	//var discount = getDiscount(units, desc);
	var discount = 0
	var unit_price = ChoiceGetPrice4(ex);
	var result;
	
	
	
	////
	var courierPrice = courier();
	
	courierPrice = (Math.floor(((courierPrice * units)/ex) * 100) / 100)
	parent.courier_p(index, courierPrice);
}


result = formatMessage(units, unit_price, discount, ex); 

showResult(result, index);
}




////////////////////////////////////////////////////////////////////////////////////
//this is only used on the versions pages, choiceSteel product page AND price List
//for the product price and Knowledge Base Price List page
////////////////////////////////////////////////////////////////////////////////////

function findPrice1(index, desc, exchange) {
var units = 1;

if (desc == "AllyCAD_Micro") {
	var ex = exchangeRate(exchange)

	
	/////////////////////////////////////////////////////////
	//allyCAD Micro gets NO discounts therefore discount = 0
	////////////////////////////////////////////////////////
	//var discount = getDiscount(units, desc);
	var discount = 0
	var unit_price = AllyGetPrice(ex);
	var result;
}

//other if statements
else if (desc =="AllyCAD_SME") {
	var ex = exchangeRate(exchange)
	//parent.CheckCurrency()
	
	var discount = getDiscount(units, desc, ex);
	var unit_price = AllyGetPrice2(ex);
	var result;
}

else if (desc =="AllyCAD_PRO") {
	var ex = exchangeRate(exchange)
	//parent.CheckCurrency()
	
	var discount = getDiscount(units, desc);
	var unit_price = AllyGetPrice3(ex);
	var result;
}






else if (desc =="TrueCAD_Upgrade") {
	var ex = exchangeRate(exchange)
	//parent.CheckCurrency()
	
	var discount = getDiscount(units, desc);
	var unit_price = AllyGetPrice3(ex) * 0.35;
	var result;
}






else if (desc == "Micro_Maintenance") {
	var ex = exchangeRate(exchange)
	//parent.CheckCurrency()
	//parent.currencySymbol[1]
	
	/////////////////////////////////////////////////////////
	//allyCAD Micro gets NO discounts therefore discount = 0
	////////////////////////////////////////////////////////
	//var discount = getDiscount(units, desc);
	var discount = 0
	var unit_price = AllyGetPrice4(ex);
	var result;
}

//other if statements
else if (desc =="SME_Maintenance") {
	var ex = exchangeRate(exchange)
	//parent.CheckCurrency()
	
	var discount = getDiscount(units, desc, ex);
	var unit_price = AllyGetPrice5(ex);
	var result;
}

else if (desc =="PRO_Maintenance") {
	var ex = exchangeRate(exchange)
	//parent.CheckCurrency()
	
	var discount = getDiscount(units, desc);
	var unit_price = AllyGetPrice6(ex);
	var result;
}



else if (desc =="ChoiceSteel") {
	var ex = exchangeRate(exchange)
	//parent.CheckCurrency()
	
	/////////////////////////////////////////////////////////
	//ChoiseSteel gets NO discounts therefore discount = 0
	////////////////////////////////////////////////////////
	//var discount = getDiscount(units, desc);
	var discount = 0
	var unit_price = ChoiceGetPrice4(ex);
	var result;
}


result = formatMessage2(units, unit_price, discount, ex); 
showResult2(result, index);
}



function formatPrice(value, ex) {

	var result= ((Math.floor(value * 100)) / 100)

return result;

}


function formatPrice2(value, ex) {

	var result= ((Math.floor(value)))
	//var result= ((Math.floor(value * 100)) / 100)

return result;

}



function filterNonNumeric(field) {
var result = new String();
var numbers = "0123456789";
var chars = field.value.split(""); // create array 
for (i = 0; i < chars.length; i++) {
if (numbers.indexOf(chars[i]) != -1) result += chars[i];
}
if (field.value != result) field.value = result;
}
//  End -->
