
<!--
var LPAmount;
var OPAmount;
var ROPAmount;
var amt1, amt2, amt4;

function isBlank(val){
	if(val==null){return true;}
	for(var i=0;i<val.length;i++) {
		if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}
		}
	return true;
}
function fnCalculate(){
	if (isNaN(document.theform.LendersPolicyAmount.value) || isBlank(document.theform.LendersPolicyAmount.value)){
		alert('Please enter a number in the Lender\'s Policy Amount field.');
		document.theform.LendersPolicyAmount.focus();
		return;
	}
	else{
		if (isNaN(document.theform.OwnersPolicyAmount.value) || isBlank(document.theform.OwnersPolicyAmount.value)){
			alert('Please enter a number in the Owner\'s Policy Amount field.');
			document.theform.OwnersPolicyAmount.focus();
			return;
		}
		else{
			if (isNaN(document.theform.ReissueOwnersPolicyAmount.value) || isBlank(document.theform.ReissueOwnersPolicyAmount.value)){
				alert('Please enter a number in the Reissue Owner\'s Policy Amount field.');
				document.theform.ReissueOwnersPolicyAmount.focus();
				return;
			}
			else{
				LPAmount = parseFloat(document.theform.LendersPolicyAmount.value);
				OPAmount = parseFloat(document.theform.OwnersPolicyAmount.value);
				ROPAmount = parseFloat(document.theform.ReissueOwnersPolicyAmount.value);
				fnLPPremium();
				fnOPPremium();
				fnReissueCredit();
				fnTotalPremium();
			}
		}
	}
}
function fnTotalPremium(){
var temp;
	temp = parseFloat(amt1) + parseFloat(amt2) + parseFloat(amt4);
	temp = RoundOff(temp);
	document.theform.TotalPremium.value = MakeDollar(temp);
}
function fnReissueCredit(){
var yesno;
var temp;
	for (sctr = 0; sctr < document.theform.ReissueCreditGiven.length; sctr++){
		if (document.theform.ReissueCreditGiven[sctr].selected == true){
	        yesno = document.theform.ReissueCreditGiven[sctr].value;
		}
 	}
	if ( yesno == 'Y' ){
		if (ROPAmount > 0){
			if ( ROPAmount < LPAmount) {
				if (ROPAmount < 45455){
					temp =  125 * -0.4;
					amt4 = RoundOff(temp);
					document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt4);
				}
				else{
					if (ROPAmount < 100000){
						temp = (ROPAmount / 1000 * 2.75) * -0.4;
						amt4 = RoundOff(temp);
						document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt4);
					}
					else{
						if (ROPAmount < 200000){
							temp = (((ROPAmount - 100000) / 1000 * 2.5) + 275) * -0.4;
							amt4 = RoundOff(temp);
							document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt4);
						}
						else{
							if (ROPAmount < 500000){
								temp = (((ROPAmount - 200000) / 1000 * 2) + 525) * -0.4;
								amt4 = RoundOff(temp);
								document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt4);
							}
							else{
								temp = (((ROPAmount - 5000000) / 1000 * 1.75) + 1125) * -0.4;
								amt4 = RoundOff(temp);
								document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt4);
							}
						}
					}
				}
			}
			else {
				if (LPAmount < 14285){
					temp =  125 * -0.4;
					amt4 = RoundOff(temp);
					document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt4);
				}
				else{
					if (LPAmount < 100000){
						temp = (LPAmount / 1000 * 2.75) * -0.4;
						amt4 = RoundOff(temp);
						document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt4);
					}
					else{
						if (LPAmount < 200000){
							temp = (((LPAmount - 100000) / 1000 * 2.5) + 275) * -0.4;
							amt4 = RoundOff(temp);
							document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt4);
						}
						else{
							if (LPAmount < 500000){
								temp = (((LPAmount - 100000) / 1000 * 2) + 525) * -0.4;
								amt4 = RoundOff(temp);
								document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt4);
							}
							else{
								temp = (((LPAmount - 500000) / 1000 * 1.75) + 1125) * -0.4;
								amt4 = RoundOff(temp);
								document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt4);
							}
						}
					}
				}
			}
		}
		else{
			amt4 = 0;
			document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt4);
		}
	}
	else{
		amt4 = 0;
		document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt4);
	}
}
function fnOPPremium(){
var temp;
	if (OPAmount == 0){
		amt2 = 0;
		document.theform.OwnersPolicyPremiumAmount.value = MakeDollar(amt2);
	}
	else{
		if (OPAmount >= LPAmount){
			if (OPAmount < 35714){
				amt2 = 125;
				document.theform.OwnersPolicyPremiumAmount.value = MakeDollar(amt2);
			}
			else{
				if (OPAmount < 100000){
					temp = OPAmount / 1000 * 3.5;
					amt2 = RoundOff(temp);
					document.theform.OwnersPolicyPremiumAmount.value = MakeDollar(amt2);
				}
				else{
					if (OPAmount < 200000){
						temp = ((OPAmount - 100000) / 1000 * 2.5) + 350;
						amt2 = RoundOff(temp);
						document.theform.OwnersPolicyPremiumAmount.value = MakeDollar(amt2);
					}
					else{
						if (OPAmount < 1000000){
							temp = ((OPAmount - 200000) / 1000 * 2) + 600;
							amt2 = RoundOff(temp);
							document.theform.OwnersPolicyPremiumAmount.value = MakeDollar(amt2);
						}
						else{
							temp = ((OPAmount - 1000000) / 1000 * 1.75) + 2200;
							amt2 = RoundOff(temp);
							document.theform.OwnersPolicyPremiumAmount.value = MakeDollar(amt2);
						}
					}
				}
			}
		}
		else {
			if (LPAmount > OPAmount){
				if (OPAmount < 35714){
					amt2 = 125;
					document.theform.OwnersPolicyPremiumAmount.value = MakeDollar(amt2);
				}
				else{
					if (OPAmount < 100000){
						temp = OPAmount / 1000 * 3.5;
						amt2 = RoundOff(temp);
						document.theform.OwnersPolicyPremiumAmount.value = MakeDollar(amt2);
					}
					else{
						if (OPAmount < 200000){
							temp = ((OPAmount - 100000) / 1000 * 2.5) + 350;
							amt2 = RoundOff(temp);
							document.theform.OwnersPolicyPremiumAmount.value = MakeDollar(amt2);
						}
						else{
							if (OPAmount < 1000000){
								temp = ((OPAmount - 200000) / 1000 * 2) + 600;
								amt2 = RoundOff(temp);
								document.theform.OwnersPolicyPremiumAmount.value = MakeDollar(amt2);
							}
							else{
								temp = ((OPAmount - 1000000) / 1000 * 1.75) + 2200;
								amt2 = RoundOff(temp);
								document.theform.OwnersPolicyPremiumAmount.value = MakeDollar(amt2);
							}
						}
					}
				}
			}
			else {
				if (LPAmount > 0 && OPAmount > 0){
					temp = 50;
				}
				else {
					temp = 0;
				}
				amt2 = RoundOff(temp);
				document.theform.OwnersPolicyPremiumAmount.value = MakeDollar(amt2);
			}
		}
	}
}
function fnLPPremium(){
var temp;
var temp2;
	if (LPAmount == 0) {
		amt1 = 0;
		document.theform.LendersPolicyPremium.value = MakeDollar(amt1);
	}
	else {
		if (LPAmount > OPAmount){
			if (OPAmount == 0) {
				if (LPAmount < 45455){
					amt1 = 125;
					document.theform.LendersPolicyPremium.value = MakeDollar(amt1);
				}
				else{
					if (LPAmount < 100000){
					 temp = LPAmount / 1000 * 2.75;
					 amt1 = RoundOff(temp);
					 document.theform.LendersPolicyPremium.value = MakeDollar(amt1);
					}
					else{
						if (LPAmount < 200000){
						temp = ((LPAmount - 100000) / 1000 * 2.5) + 275;
						amt1 = RoundOff(temp);
						document.theform.LendersPolicyPremium.value = MakeDollar(amt1);
						}
						else{
							if (LPAmount < 500000){
								temp = ((LPAmount - 200000) / 1000 * 2) + 525;
								amt1 = RoundOff(temp);
								document.theform.LendersPolicyPremium.value = MakeDollar(amt1);
							}
							else{
								temp = ((LPAmount - 500000) / 1000 * 1.75) + 1125;
								amt1 = RoundOff(temp);
								document.theform.LendersPolicyPremium.value = MakeDollar(amt1);
							}
						}
					}
				}
			}
			else {
				if (LPAmount < 45455){
					if (LPAmount > 0 && OPAmount > 0){
						temp2 = 50;
					}
					else {
						temp2 = 0;
					}
					temp = 125 + temp2;
					amt1 = RoundOff(temp);
					document.theform.LendersPolicyPremium.value = MakeDollar(amt1);
				}
				else{
					if (LPAmount < 100000){
						if (LPAmount > 0 && OPAmount > 0){
							temp2 = 50;
						}
						else {
							temp2 = 0;
						}
					 temp = ((LPAmount - OPAmount)/ 1000 * 2.75) + temp2;
					 amt1 = RoundOff(temp);
					 document.theform.LendersPolicyPremium.value = MakeDollar(amt1);
					}
					else{
						if (LPAmount < 200000){
							if (LPAmount > 0 && OPAmount > 0){
								temp2 = 50;
							}
							else {
								temp2 = 0;
							}
						temp = ((LPAmount - OPAmount) / 1000 * 2.5) + temp2;
						amt1 = RoundOff(temp);
						document.theform.LendersPolicyPremium.value = MakeDollar(amt1);
						}
						else{
							if (LPAmount < 500000){
								if (LPAmount > 0 && OPAmount > 0){
									temp2 = 50;
								}
								else {
									temp2 = 0;
								}
								temp = ((LPAmount - OPAmount) / 1000 * 2) + temp2;
								amt1 = RoundOff(temp);
								document.theform.LendersPolicyPremium.value = MakeDollar(amt1);
							}
							else{
								if (LPAmount > 0 && OPAmount > 0){
									temp2 = 50;
								}
								else {
									temp2 = 0;
								}
								temp = ((LPAmount - OPAmount) / 1000 * 1.75) + temp2;
								amt1 = RoundOff(temp);
								document.theform.LendersPolicyPremium.value = MakeDollar(amt1);
							}
						}
					}
				}
			}
		}
		else{
			if (LPAmount > 0 && OPAmount > 0){
				amt1 = 50;
			}
			else{
				amt1 = 0;
			}
			document.theform.LendersPolicyPremium.value = MakeDollar(amt1);
		}
	}
}
function RoundOff(input) {
	input = '' + input;
	place = 2;
	var thenumber = '' + Math.round(input * Math.pow(10, place));
	var thepoint = thenumber.length - place;
	if(thepoint != 0) {
		rounded = thenumber.substring(0, thepoint);
		rounded += '.';
		rounded += thenumber.substring(thepoint, thenumber.length);
	}
	else {
		rounded = thenumber; 
	}
	return rounded;
}
function MakeDollar(input) {
	myNumber = Math.abs((Math.round(input * 100) / 100));

	myString = '' + myNumber;
	if (myString.indexOf('.') == -1){
		myString += '.00';
	}
	tempString = myString.substr(0,myString.indexOf('.'));
	tempNumber = tempString - 0;
	tempPos = myString.substr(myString.indexOf('.'));
	while (tempPos.length < 3){
		tempPos += '0';
	}
	if (tempNumber >= 1000){
		tempLength = tempString.length;
		tempString = parseInt('' + (tempNumber / 1000)) + ',' + tempString.substring(tempLength - 3, tempLength);
	}
	if (tempNumber >= 1000000){
		tempLength = tempString.length;
		tempString = parseInt('' + (tempNumber / 1000000)) + ',' + tempString.substring(tempLength - 7, tempLength);
	}
	returnDollarfmt = tempString + tempPos;
	if (input < 0){
		return '($' + returnDollarfmt + ')';
	}
	else{
  		return '$' + returnDollarfmt;
	}
}
function fnResetVals(){
	document.theform.LendersPolicyPremium.value = '';
	document.theform.OwnersPolicyPremiumAmount.value = '';
	document.theform.OwnersReissueCreditPremium.value = '';
	document.theform.TotalPremium.value = '';
}
//-->

