<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function filterNum(str) {
	re = /^\$|,/g;                 	// remove "$" and ","
	return str.replace(re, "");
}

// rounds number to X decimal places, defaults to 2
function round(number,X) {
	//X = (!X ? 2 : X);
	return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}

function checkNum(data) {      	// checks if all characters 
	var valid = "0123456789.";       // are valid 
	var ok = 1; var checktemp;

	for (var i=0; i<data.length; i++) {
		checktemp = "" + data.substring(i, i+1);
		if (valid.indexOf(checktemp) == "-1") return 0; 
	}
	return 1;
}

function dollarAmount(form, field) { // idea by David Turley
	field=filterNum(field);
	Num = "" + eval("document." + form + "." + field + ".value");

	if (Num == "") {
		return
	}

	dec = Num.indexOf(".");
	end = ((dec > -1) ? "" + Num.substring(dec,Num.length) : ".00");
	Num = filterNum(Num);
	Num = "" + parseInt(Num);

	var temp1 = "";
	var temp2 = "";

	if (checkNum(Num) == 0) {
		alert("This does not appear to be a valid number.  Please try again.");
	}
	else { 
		if (end.length == 2) end += "0";
		if (end.length == 1) end += "00";
		if (end == "") end += ".00";
		var count = 0;
		for (var k = Num.length-1; k >= 0; k--) {
		var oneChar = Num.charAt(k);
		if (count == 3) {
			temp1 += ",";
				temp1 += oneChar;
				count = 1;
				continue;
			}
			else {
				temp1 += oneChar;
				count ++;
			}	
		}		
	
		for (var k = temp1.length-1; k >= 0; k--) {
			var oneChar = temp1.charAt(k);
			temp2 += oneChar;
		}
		
		temp2 = "$" + temp2 + end;
		eval("document." + form + "." + field + ".value = '" + temp2 + "';");
	}
}



function isInRange(theNumber, minNumber, maxNumber){
	if (( theNumber>=minNumber) && (theNumber<maxNumber)) 
		return true
	else 
		return false
}

function calcOwner(form) {
	tamount=parseFloat(filterNum(form.tamount.value));

	if (tamount < 10000) {
		form.OwnerRate.value = 154;
		form.OwnerRate.focus();
	} 
	else if (isInRange(tamount,10000,50001)) {
		form.OwnerRate.value = round((tamount-10000)*.004+154,0);
		form.OwnerRate.focus();
	}
	else if (isInRange(tamount,50001,100001)) {
		form.OwnerRate.value = round((tamount-50000)*.003+314,0);
		form.OwnerRate.focus();
	} 
	else if (isInRange(tamount,100001,1000000)) {
		form.OwnerRate.value = round((tamount-100000)*.002+464,0);
		form.OwnerRate.focus();
	}
	else if (tamount >= 1000000) {
		form.OwnerRate.value = "Call";
	} 
	else {
		alert("Invialid Policy Amount");
		form.OwnerRate.value = "";
	}
}

function calcLender(form) {
	tamount=parseFloat(filterNum(form.tamount.value));

	if (tamount < 10000) {
		form.LenderRate.value = 141 ;
		form.LenderRate.focus();
	} 
	else if (isInRange(tamount,10000,50001)) {
		form.LenderRate.value = round((tamount-10000)*.003+141,0);
		form.LenderRate.focus();
	}
	else if (isInRange(tamount,50001,100001)) {
		form.LenderRate.value = round((tamount-50000)*.00225+261,0);
		form.LenderRate.focus();
	} 
	else if (isInRange(tamount,100001,1000000)) {
		form.LenderRate.value = round((tamount-100000)*.0015+373.50,0);
		form.LenderRate.focus();
	}
	else if (tamount >= 1000000) {
		form.LenderRate.value = "Call";
	} 
	else {
		alert("Invialid Policy Amount");
		form.LenderRate.value = "";
	}
}

function calcCombo(form) {
	tamount=parseFloat(filterNum(form.tamount.value));

	if (tamount < 10000) {
		form.ComboRate.value = "189";
		form.ComboRate.focus();
	} 
	else if (isInRange(tamount,10000,50001)) {
		form.ComboRate.value = round((tamount-10000)*.004+154 + 35,0);
		form.ComboRate.focus();
	}
	else if (isInRange(tamount,50001,100001)) {
		form.ComboRate.value = round((tamount-50000)*.003+314 + 35,0);
		form.ComboRate.focus();
	} 
	else if (isInRange(tamount,100001,1000000)) {
		form.ComboRate.value = round((tamount-100000)*.002+464 + 35,0);
		form.ComboRate.focus();
	}
	else if (tamount >= 1000000) {
		form.ComboRate.value = "Call";
	} 
	else {
		alert("Invialid Policy Amount");
		form.ComboRate.value = "";
	}
}

function ClearFields(form) {
	form.OwnerRate.value = "";
	form.LenderRate.value = "";
	form.ComboRate.value = "";
}
-->