﻿function calculate(){//Calculate in USD or CDN?DollarValue = GetSelectedItem();if (DollarValue > 1){xRate = CDN}else{xRate = USD}// What's the amount entered?TheAmount = document.d.Amount.value;  // Get the amount from the input fieldAmountEntered = TheAmount * 1;        // turn the amount into a numberFeeCharged = getFee();                // Get the Fee charged for the amount enteredCostPlusFee = AmountEntered + FeeCharged;SubTotal = TheAmount / xRateSubTotal=Math.round(SubTotal*100)/100TotalAmount=SubTotal.toFixed(2)// Wite it all to the PageAmtEnt = document.getElementById("EnteredAmount"); AmtEnt.value = AmountEntered.toFixed(2) ;FeeChgd = document.getElementById("Fee");FeeChgd.value = FeeCharged.toFixed(2) ;TheCost = document.getElementById("YourCost");TheCost.value = CostPlusFee.toFixed(2) ;ExchangeRate = document.getElementById("Xchange");ExchangeRate.value = xRate ;RealTotal = document.getElementById("RealTot");RealTotal.value = TotalAmount ;}// In US or Canadian Dollars?function GetSelectedItem() {chosen = ""len = document.d.Dex.lengthfor (i = 0; i <len; i++) {if (document.d.Dex[i].checked) {chosen = document.d.Dex[i].value}}if (chosen == "") {alert("Choose the funds to calculate in")}else {DollarValue = chosen;return DollarValue;}}// Calculate the fee charged for the amount enteredfunction getFee()  {if (AmountEntered >= 1 && AmountEntered <= 50.99 ) {FeeCharged = 10.00return FeeCharged}if (AmountEntered >= 51 && AmountEntered <= 250.99 ) {FeeCharged = 13.90return FeeCharged}if (AmountEntered >= 251 && AmountEntered <= 500.99 ) {FeeCharged = 19.90return FeeCharged}if (AmountEntered >= 501 && AmountEntered <= 999.99 ) {FeeCharged = 39.90return FeeCharged}else {alert ("Please call us for amounts $1000.00 or larger")return false}}