
<!--
var LPAmount;
var OPAmount;
var ROPAmount;
var amt1, amt2, amt3, amt5, amt6, amt7, amt8;

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);
				fnOPPremium();
				fnLPPremium();
				fnReissueCredit();
				fnFormNine();
				fnNavServ();
				fnEndPremiums();
				fnEndorsements();
				fnTotalPremium();
			}
		}
	}
}
function fnTotalPremium(){
var temp;
	temp = parseFloat(amt1) + parseFloat(amt2) + parseFloat(amt3) + parseFloat(amt5);
	temp = RoundOff(temp);
	document.theform.TotalPremium.value = MakeDollar(temp);
}
function fnEndorsements(){
var temp;
	temp = parseFloat(amt6) + parseFloat(amt7) + parseFloat(amt8);
	amt5 = RoundOff(temp);
	document.theform.EndorsementPremium.value = MakeDollar(amt5);
}
function fnEndPremiums(){
var counter;
var yesno;
	counter = 0;
	// Endorsement4
	for (sctr = 0; sctr < document.theform.Endorsement4.length; sctr++){
		if (document.theform.Endorsement4[sctr].selected == true){
	        yesno = document.theform.Endorsement4[sctr].value;
		}
 	}
	if ( yesno == 'Y' ){counter ++;}
	// Endorsement5
	for (sctr = 0; sctr < document.theform.Endorsement5.length; sctr++){
		if (document.theform.Endorsement5[sctr].selected == true){
	        yesno = document.theform.Endorsement5[sctr].value;
		}
 	}
	if ( yesno == 'Y' ){counter ++;}
	// Endorsement6
	for (sctr = 0; sctr < document.theform.Endorsement6.length; sctr++){
		if (document.theform.Endorsement6[sctr].selected == true){
	        yesno = document.theform.Endorsement6[sctr].value;
		}
 	}
	if ( yesno == 'Y' ){counter ++;}
	// Endorsement61
	for (sctr = 0; sctr < document.theform.Endorsement61.length; sctr++){
		if (document.theform.Endorsement61[sctr].selected == true){
	        yesno = document.theform.Endorsement61[sctr].value;
		}
 	}
	if ( yesno == 'Y' ){counter ++;}
	// Endorsement62
	for (sctr = 0; sctr < document.theform.Endorsement62.length; sctr++){
		if (document.theform.Endorsement62[sctr].selected == true){
	        yesno = document.theform.Endorsement62[sctr].value;
		}
 	}
	if ( yesno == 'Y' ){counter ++;}
	// Endorsement7
	for (sctr = 0; sctr < document.theform.Endorsement7.length; sctr++){
		if (document.theform.Endorsement7[sctr].selected == true){
	        yesno = document.theform.Endorsement7[sctr].value;
		}
 	}
	if ( yesno == 'Y' ){counter ++;}
	// Endorsement81
	for (sctr = 0; sctr < document.theform.Endorsement81.length; sctr++){
		if (document.theform.Endorsement81[sctr].selected == true){
	        yesno = document.theform.Endorsement81[sctr].value;
		}
 	}
	if ( yesno == 'Y' ){counter ++;}
	
	// is it a family?
	for (sctr = 0; sctr < document.theform.OneToFourFamily.length; sctr++){
		if (document.theform.OneToFourFamily[sctr].selected == true){
	        yesno = document.theform.OneToFourFamily[sctr].value;
		}
 	}
	if ( yesno == 'Y' ){
		temp = counter * 25;
		amt6 = RoundOff(temp);
	}
	else{
		temp = counter * 100;
		amt6 = RoundOff(temp);
	}	
}
function fnNavServ(){
var yesno;
var temp;
	for (sctr = 0; sctr < document.theform.NavigationalServitude.length; sctr++){
		if (document.theform.NavigationalServitude[sctr].selected == true){
	        yesno = document.theform.NavigationalServitude[sctr].value;
		}
 	}
	if ( yesno == 'Y' ){
		temp = (parseFloat(amt1) + parseFloat(amt2) - parseFloat(amt3));
		temp = (temp * 0.1);
		amt8 = RoundOff(temp);
	}
	else{
		amt8 = 0;
	}
}
function fnFormNine(){
var yesno;
var temp;
	for (sctr = 0; sctr < document.theform.Form9Endorsement.length; sctr++){
		if (document.theform.Form9Endorsement[sctr].selected == true){
	        yesno = document.theform.Form9Endorsement[sctr].value;
		}
 	}
	if ( yesno == 'Y' ){
		temp = (parseFloat(amt1) + parseFloat(amt2) + parseFloat(amt3));
		temp = (temp * 0.1);
		amt7 = RoundOff(temp);
	}
	else{
		amt7 = 0;
	}
}
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 < 17391){
					temp = 100 * -2.45;
					amt3 = RoundOff(temp);
					document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt3);
				}
				else{
					if (ROPAmount < 100000){
						temp = ROPAmount / 1000 * -2.45;
						amt3 = RoundOff(temp);
						document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt3);
					}
					else{
						if (ROPAmount < 1000000){
							temp = (((ROPAmount - 100000) / 1000 * -2) - 245);
							amt3 = RoundOff(temp);
							document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt3);
						}
						else{
							if (ROPAmount < 5000000){
								temp = (((ROPAmount - 1000000) / 1000 * -0.5) - 2045);
								amt3 = RoundOff(temp);
								document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt3);
							}
							else{
								temp = (((ROPAmount - 5000000) / 1000 * -0.25) - 4045);
								amt3 = RoundOff(temp);
								document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt3);
							}
						}
					}
				}
			}
			else {
				if (ROPAmount < 17391){
					temp = 100 * -2.45;
					amt3 = RoundOff(temp);
					document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt3);
				}
				else{
					if (ROPAmount < 100000){
						temp = ROPAmount / 1000 * -2.45;
						amt3 = RoundOff(temp);
						document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt3);
					}
					else{
						if (ROPAmount < 1000000){
							temp = (((ROPAmount - 100000) / 1000 * -2) - 245);
							amt3 = RoundOff(temp);
							document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt3);
						}
						else{
							if (ROPAmount < 5000000){
								temp = (((ROPAmount - 1000000) / 1000 * -0.5) - 2045);
								amt3 = RoundOff(temp);
								document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt3);
							}
							else{
								temp = (((ROPAmount - 5000000) / 1000 * -0.25) - 4045);
								amt3 = RoundOff(temp);
								document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt3);
							}
						}
					}
				}
			}
		}
		else{
			amt3 = 0;
			document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt3);
		}
	}
	else{
		amt3 = 0;
		document.theform.OwnersReissueCreditPremium.value = MakeDollar(amt3);
	}
}
function fnOPPremium(){
var temp;
	if (OPAmount == 0) {
		amt2 = 0;
		document.theform.OwnersPolicyPremiumAmount.value = MakeDollar(amt2);
	}
	else {
		if (OPAmount > LPAmount){
			if (OPAmount < 17391){
				amt2 = 100;
				document.theform.OwnersPolicyPremiumAmount.value = MakeDollar(amt2);
			}
			else{
				if (OPAmount < 100000){
					temp = OPAmount / 1000 * 5.75;
					amt2 = RoundOff(temp);
					document.theform.OwnersPolicyPremiumAmount.value = MakeDollar(amt2);
				}
				else{
					if (OPAmount < 1000000){
						temp = ((OPAmount - 100000) / 1000 * 5) + 575;
						amt2 = RoundOff(temp);
						document.theform.OwnersPolicyPremiumAmount.value = MakeDollar(amt2);
					}
					else{
						temp = ((OPAmount - 1000000) / 1000 * 2.5) + 5075;
						amt2 = RoundOff(temp);
						document.theform.OwnersPolicyPremiumAmount.value = MakeDollar(amt2);
					}
				}
			}
		}
		else{
			if (OPAmount < 17391){
				amt2 = 100;
				document.theform.OwnersPolicyPremiumAmount.value = MakeDollar(amt2);
			}
			else{
				if (OPAmount < 100000){
					temp = OPAmount / 1000 * 5.75;
					amt2 = RoundOff(temp);
					document.theform.OwnersPolicyPremiumAmount.value = MakeDollar(amt2);
				}
				else{
					if (OPAmount < 1000000){
						temp = ((OPAmount - 100000) / 1000 * 5) + 575;
						amt2 = RoundOff(temp);
						document.theform.OwnersPolicyPremiumAmount.value = MakeDollar(amt2);
					}
					else{
						temp = ((OPAmount - 1000000) / 1000 * 2.5) + 5075;
						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 (LPAmount > 0 && OPAmount > 0){
				amt1 = 25;
				document.theform.LendersPolicyPremium.value = MakeDollar(amt1);
			}
			else{
				amt1 = 0;
				document.theform.LendersPolicyPremium.value = MakeDollar(amt1);
			}
		}
		else {
			if (LPAmount >= OPAmount){
				if (OPAmount == 0) {
					if (LPAmount < 17391){
						amt1 = 100;
						document.theform.LendersPolicyPremium.value = MakeDollar(amt1);
					}
					else{
						if (LPAmount < 100000){
				 			temp = LPAmount / 1000 * 5.75;
				 			amt1 = RoundOff(temp);
				 			document.theform.LendersPolicyPremium.value = MakeDollar(amt1);
						}
						else{
							if (LPAmount < 1000000){
								temp = ((LPAmount - 100000) / 1000 * 5) + 575;
								amt1 = RoundOff(temp);
								document.theform.LendersPolicyPremium.value = MakeDollar(amt1);
							}
							else{
								temp = ((LPAmount - 1000000) / 1000 * 2.5) + 5075;
								amt1 = RoundOff(temp);
								document.theform.LendersPolicyPremium.value = MakeDollar(amt1);
							}
						}
					}
				}
				else {
					if (LPAmount < 17391 ) {
						if (LPAmount > 0 && OPAmount > 0){
							temp2 = 25;
						}
						else{
							temp2 = 0;
						}						
						temp = 100 - amt2 + temp2;
						amt1 = RoundOff(temp);
						document.theform.LendersPolicyPremium.value = MakeDollar(amt1);
					}
					else {
						if (LPAmount < 100000) {
							if (LPAmount > 0 && OPAmount > 0){
								temp2 = 25;
							}
							else{
								temp2 = 0;
							}
							temp = (LPAmount / 1000 * 5.75) - amt2 + temp2;
							amt1 = RoundOff(temp);
							document.theform.LendersPolicyPremium.value = MakeDollar(amt1);
						}
						else {
							if (LPAmount < 1000000) {
								if (LPAmount > 0 && OPAmount > 0){
									temp2 = 25;
								}
								else{
									temp2 = 0;
								}
								temp = (((LPAmount - 100000) / 1000 * 5) + 575) - amt2 + temp2;
								amt1 = RoundOff(temp);
								document.theform.LendersPolicyPremium.value = MakeDollar(amt1);
							}
							else {
								temp = ((LPAmount - 1000000)  / 1000 * 2.5) + 5075 - amt2;
								amt1 = RoundOff(temp);
								document.theform.LendersPolicyPremium.value = MakeDollar(amt1);
							}
						}
					}
				}
			}
			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.EndorsementPremium.value = '';
	document.theform.TotalPremium.value = '';
}
//-->

