function GetInteger(n)
{
	var iReturn=parseInt(n);
	if  ( isNaN(iReturn) ){iReturn=0}
	return iReturn
}
function checkMoney(obj) {
			var message;
			message="";
			obj.value = obj.value.replace(/,/g,"");
			if (obj.value.match(/\./) == ".") {
			 	message += "This value must be represented in whole dollars, no periods.\n";
			} 
			if (obj.value.match(/\D/g) != null) {
				message += "Please only enter numbers in this field.\n";
			}
 			if (obj.value == "") {
				message += "All fields are required.\n";
			}
			if (message!=""){
				obj.style.color="#6eb53f";
				alert(message);
			} else {
				obj.style.color="#666666";
			}
		}
		
//form a
function submitform1()
{
var selection ="";
for (i=0;i<document.forms[0].q1.length;i++) 
{ 
      if (document.forms[0].q1[i].checked) 
      { 
             selection = document.forms[0].q1[i].value; 
			 document.forms[0].loanid.value=i;
      } 
} 

if (selection=="")
{
	alert("Please make a selection!");
}
	else
{	
	
	document.forms[0].submit();
}

}
///form a
///form b
function submitform2()
{
	document.forms[0].submit();
}
///form b

///form d

	function showHide(elementid){
		if (document.forms[0].q35.checked) {
			document.getElementById(elementid).style.display = '';
		} else {
			document.getElementById(elementid).style.display = 'none';
		}
	}

function submitform3()
{
	var error="";
	
	if (document.forms[0].q6.value=="") {error="6"}
	if (document.forms[0].q7.value=="") {error="7"}
	//if (document.forms[0].q8.value=="") {error="8"}
	if (document.forms[0].q9.value=="") {error="9"}
	if (document.forms[0].q10.value=="") {error="10"}
	if (document.forms[0].q11.value=="") {error="11"}
	if (document.forms[0].q12.value=="") {error="12"}
	if (document.forms[0].q13.value=="") {error="13"}
	
	if (document.forms[0].q37.value=="") {error="37"}
	if (document.forms[0].q38.value=="") {error="38"}
	if (document.forms[0].q39.value=="") {error="39"}
	if (document.forms[0].q40.value=="") {error="40"}

	if (document.forms[0].q14.value=="") {error="14"}
	if (document.forms[0].q15.value=="") {error="15"}
	if (document.forms[0].q16.value=="") {error="16"}
	if (document.forms[0].q17.value=="") {error="17"}
	if (document.forms[0].q18.value=="") {error="18"}
	if (document.forms[0].q19.value=="") {error="19"}
	if (document.forms[0].q20.value=="") {error="20"}
	if (document.forms[0].q21.value=="") {error="21"}
	if (document.forms[0].q22.value=="") {error="22"}
	if (document.forms[0].q23.value=="") {error="23"}
	if (document.forms[0].q24.value=="") {error="24"}
	if (document.forms[0].q25.value=="") {error="25"}
	if (document.forms[0].q26.value=="") {error="26"}
	if (document.forms[0].q27.value=="") {error="27"}
	if (document.forms[0].q28.value=="") {error="28"}
	if (document.forms[0].q29.value=="") {error="29"}
	if (document.forms[0].q30.value=="") {error="30"}
	if (document.forms[0].q31.value=="") {error="31"}
	if (document.forms[0].q32.value=="") {error="32"}
	if (document.forms[0].q33.value=="") {error="33"}
	if (document.forms[0].q34.value=="") {error="34"}
	
	
	if(document.forms[0].q35.checked == true)
	{
	
		if (document.forms[0].q141.value=="") {error="141"}
		if (document.forms[0].q142.value=="") {error="142"}
		//if (document.forms[0].q143.value=="") {error="143"}
		if (document.forms[0].q144.value=="") {error="144"}
		if (document.forms[0].q145.value=="") {error="145"}
		if (document.forms[0].q146.value=="") {error="146"}
		if (document.forms[0].q147.value=="") {error="147"}
		if (document.forms[0].q148.value=="") {error="148"}
		if (document.forms[0].q149.value=="") {error="149"}
		if (document.forms[0].q150.value=="") {error="150"}
		if (document.forms[0].q151.value=="") {error="151"}
		if (document.forms[0].q152.value=="") {error="152"}
		if (document.forms[0].q153.value=="") {error="153"}
		if (document.forms[0].q154.value=="") {error="154"}
		if (document.forms[0].q155.value=="") {error="155"}
		if (document.forms[0].q156.value=="") {error="156"}
		if (document.forms[0].q157.value=="") {error="157"}
		if (document.forms[0].q158.value=="") {error="158"}
		if (document.forms[0].q159.value=="") {error="159"}
		if (document.forms[0].q160.value=="") {error="160"}
		if (document.forms[0].q161.value=="") {error="161"}
		if (document.forms[0].q162.value=="") {error="162"}
		if (document.forms[0].q163.value=="") {error="163"}
		if (document.forms[0].q164.value=="") {error="164"}
		if (document.forms[0].q165.value=="") {error="165"}
		if (document.forms[0].q166.value=="") {error="166"}
		if (document.forms[0].q167.value=="") {error="167"}
		if (document.forms[0].q168.value=="") {error="168"}
		if (document.forms[0].q169.value=="") {error="169"}
		if (document.forms[0].q170.value=="") {error="170"}
		if (document.forms[0].q171.value=="") {error="171"}
		if (document.forms[0].q172.value=="") {error="172"}
		if (document.forms[0].q173.value=="") {error="173"}
		if (document.forms[0].q174.value=="") {error="174"}
		

	
	}
	
	
	
	
	if(document.forms[0].q36.checked == false)  {error="35"}
	
	if (error==""){
		document.forms[0].submit();
	}else{
		alert("Please complete all fields and agree to the terms!" )
	}
	
		
	
}
///form d
///e-1
function calcTotalLoan() {
			var total;
			var p1=GetInteger(document.forms[0].q45.value);
			var p3=GetInteger(document.forms[0].q70.value);
			var p4=GetInteger(document.forms[0].q47.value);
			
			total = p1+p3-p4; 
			document.forms[0].q48.value = total;
		}
		
function calcPaymentTotal()
		{
			var total;
//	
			var p1=GetInteger(document.forms[0].q54.value);
			var p2=GetInteger(document.forms[0].q55.value);
			var p3=GetInteger(document.forms[0].q56.value);
			
			
			total = p1+p2+p3; 
			

			document.forms[0].q57.value = total;
			
		}
		
function incomeCalc() {
			var total;
			var inc1=GetInteger(document.forms[0].q51.value);
			var inc2=GetInteger(document.forms[0].q52.value);
			if  ( isNaN(inc1) ){inc1=0}
			if  ( isNaN(inc2) ){inc2=0}
			total =inc1 +	inc2;
				
			document.forms[0].q53.value = total;
			
		}
		
function PrincCalc() {
			//var total;
//			var inc1=GetInteger(document.forms[0].q51.value);
//			var inc2=GetInteger(document.forms[0].q52.value);
//			if  ( isNaN(inc1) ){inc1=0}
//			if  ( isNaN(inc2) ){inc2=0}
//			total =inc1 +	inc2;
//				
//			document.forms[0].q53.value = total;
			
		}
		
function calcDebtRatio() {
			var total;
			var inc1=GetInteger(document.forms[0].q57.value);
			var inc2=GetInteger(document.forms[0].q53.value);
			if  ( isNaN(inc1) ){inc1=0}
			if  ( isNaN(inc2) ){inc2=0}
			
			total =Math.round(inc1/inc2*100)/100
			if  ( isNaN(total) ){total=0}
			
			document.forms[0].q72.value = total+'%';
			calcTotalDebtRatio();
		}		
		
function calcTotalDebtRatio() {
			var total;
			var inc1=GetInteger(document.forms[0].q56.value);
			var inc2=GetInteger(document.forms[0].q71.value);
			var inc3=GetInteger(document.forms[0].q53.value);
			if  ( isNaN(inc1) ){inc1=0}
			if  ( isNaN(inc2) ){inc2=0}
			if  ( isNaN(inc3) ){inc3=0}
			
			total =Math.round(((inc1+inc2)/inc3)*100)/100
			if  ( isNaN(total) ){total=0}
			
			document.forms[0].q73.value = total+'%';
			
		}		
	
function calcOthers() {
			var total;
			var inc1=GetInteger(document.forms[0].q58.value);
			var inc2=GetInteger(document.forms[0].q60.value);
			var inc3=GetInteger(document.forms[0].q62.value);
			var inc4=GetInteger(document.forms[0].q64.value);
			var inc5=GetInteger(document.forms[0].q66.value);
			var inc6=GetInteger(document.forms[0].q68.value);
			
			var inc7=GetInteger(document.forms[0].q57.value);
			
			if  ( isNaN(inc1) ){inc1=0}
			if  ( isNaN(inc2) ){inc2=0}
			if  ( isNaN(inc3) ){inc3=0}
			if  ( isNaN(inc4) ){inc4=0}
			if  ( isNaN(inc5) ){inc5=0}
			if  ( isNaN(inc6) ){inc6=0}
			if  ( isNaN(inc7) ){inc7=0}
			
			total =inc1+inc2+inc3+inc4+inc5+inc6+inc7;
			
			
			document.forms[0].q71.value = total;
			calcDebtRatio();
		}		
		
	
		
		
function submitform4()
{
	var error="";
	
	if (document.forms[0].q41.value=="") {error="41"}
	if (document.forms[0].q42.value=="") {error="42"}
	if (document.forms[0].q43.value=="") {error="43"}
	if (document.forms[0].q44.value=="") {error="44"}
	if (document.forms[0].q45.value=="") {error="45"}
	//if (document.forms[0].q46.value=="") {error="46"}
	if (document.forms[0].q47.value=="") {error="47"}
	if (document.forms[0].q48.value=="") {error="48"}
	if (document.forms[0].q49.value=="") {error="49"}
	if (document.forms[0].q50.value=="") {error="50"}
	if (document.forms[0].q51.value=="") {error="51"}
	if (document.forms[0].q52.value=="") {error="52"}
	if (document.forms[0].q53.value=="") {error="53"}
	if (document.forms[0].q54.value=="") {error="54"}
	if (document.forms[0].q55.value=="") {error="55"}
	if (document.forms[0].q56.value=="") {error="56"}
	if (document.forms[0].q57.value=="") {error="57"}
	if (document.forms[0].q58.value=="") {error="58"}
	if (document.forms[0].q59.value=="") {error="59"}
	if (document.forms[0].q60.value=="") {error="60"}
	if (document.forms[0].q61.value=="") {error="61"}
	if (document.forms[0].q62.value=="") {error="62"}
	if (document.forms[0].q63.value=="") {error="63"}
	if (document.forms[0].q64.value=="") {error="64"}
	if (document.forms[0].q65.value=="") {error="65"}
	if (document.forms[0].q66.value=="") {error="66"}
	if (document.forms[0].q67.value=="") {error="67"}
	if (document.forms[0].q68.value=="") {error="68"}
	if (document.forms[0].q69.value=="") {error="69"}
	if (document.forms[0].q70.value=="") {error="70"}
	if (document.forms[0].q71.value=="") {error="71"}
	if (document.forms[0].q72.value=="") {error="72"}
	if (document.forms[0].q73.value=="") {error="73"}
	if (document.forms[0].q175.value=="") {error="175"}

	
	
	
	if (error==""){
		document.forms[0].submit();
	}else{
		alert("Please complete all fields!" )
	}
	
		
	
}
///e-1
////e-2
		function calcTotalLoan2() {
			var total;
			var p1=GetInteger(document.forms[0].q78.value);
			var p3=GetInteger(document.forms[0].q80.value);
			
			
			total = p1+p3; 
			document.forms[0].q81.value = total;
		}
		
		function incomeCalc2() {
			var total;
			var inc1=GetInteger(document.forms[0].q84.value);
			var inc2=GetInteger(document.forms[0].q85.value);
			if  ( isNaN(inc1) ){inc1=0}
			if  ( isNaN(inc2) ){inc2=0}
			total =inc1 +	inc2;
				
			document.forms[0].q86.value = total;
			
		}
		function calcOthers2() {
			var total;
			var inc1=GetInteger(document.forms[0].q91.value);
			var inc2=GetInteger(document.forms[0].q93.value);
			var inc3=GetInteger(document.forms[0].q95.value);
			var inc4=GetInteger(document.forms[0].q97.value);
			var inc5=GetInteger(document.forms[0].q99.value);
			var inc6=GetInteger(document.forms[0].q101.value);
			
			var inc7=GetInteger(document.forms[0].q90.value);
			
			if  ( isNaN(inc1) ){inc1=0}
			if  ( isNaN(inc2) ){inc2=0}
			if  ( isNaN(inc3) ){inc3=0}
			if  ( isNaN(inc4) ){inc4=0}
			if  ( isNaN(inc5) ){inc5=0}
			if  ( isNaN(inc6) ){inc6=0}
			if  ( isNaN(inc7) ){inc7=0}
			
			total =inc1+inc2+inc3+inc4+inc5+inc6+inc7;
			
			
			document.forms[0].q103.value = total;
			calcDebtRatio2();
			
			
		}

	function calcDebtRatio2() {
			var total;
			var inc1=GetInteger(document.forms[0].q90.value);
			var inc2=GetInteger(document.forms[0].q86.value);
			if  ( isNaN(inc1) ){inc1=0}
			if  ( isNaN(inc2) ){inc2=0}
			
			total =Math.round(inc1/inc2*100)/100
			if  ( isNaN(total) ){total=0}
			
			document.forms[0].q104.value = total+'%';
			calcTotalDebtRatio2();
		}		
		
	function calcTotalDebtRatio2() {
			var total;
			var inc1=GetInteger(document.forms[0].q89.value);
			var inc2=GetInteger(document.forms[0].q103.value);
			var inc3=GetInteger(document.forms[0].q86.value);
			if  ( isNaN(inc1) ){inc1=0}
			if  ( isNaN(inc2) ){inc2=0}
			if  ( isNaN(inc3) ){inc3=0}
			
			total =Math.round(((inc1+inc2)/inc3)*100)/100
			if  ( isNaN(total) ){total=0}
			
			document.forms[0].q105.value = total+'%';
			
		}	
		
	
	function calcPaymentTotal2()
		{
			var total;
	
			var p1=GetInteger(document.forms[0].q87.value);
			var p2=GetInteger(document.forms[0].q88.value);
			var p3=GetInteger(document.forms[0].q89.value);
			
			
			total = p1+p2+p3; 
			

			document.forms[0].q90.value = total;
			
		}
		
		
		
		
		function calcTotalLoan3() {
			var total;
			var p1=GetInteger(document.forms[0].q110.value);
			var p3=GetInteger(document.forms[0].q112.value);
			
			
			total = p1+p3; 
			document.forms[0].q113.value = total;
			
		}
		
		function incomeCalc3() {
			var total;
			var inc1=GetInteger(document.forms[0].q116.value);
			var inc2=GetInteger(document.forms[0].q117.value);
			if  ( isNaN(inc1) ){inc1=0}
			if  ( isNaN(inc2) ){inc2=0}
			total =inc1 +	inc2;
				
			document.forms[0].q118.value = total;
			calcTotalDebtRatio3();
		}
		
		
		function calcOthers3() {
				var total;
			var inc1=GetInteger(document.forms[0].q123.value);
			var inc2=GetInteger(document.forms[0].q125.value);
			var inc3=GetInteger(document.forms[0].q127.value);
			var inc4=GetInteger(document.forms[0].q129.value);
			var inc5=GetInteger(document.forms[0].q131.value);
			var inc6=GetInteger(document.forms[0].q133.value);
			
			var inc7=GetInteger(document.forms[0].q138.value);
			
			if  ( isNaN(inc1) ){inc1=0}
			if  ( isNaN(inc2) ){inc2=0}
			if  ( isNaN(inc3) ){inc3=0}
			if  ( isNaN(inc4) ){inc4=0}
			if  ( isNaN(inc5) ){inc5=0}
			if  ( isNaN(inc6) ){inc6=0}
			if  ( isNaN(inc7) ){inc7=0}
			
			total =inc1+inc2+inc3+inc4+inc5+inc6+inc7;
			
			
			document.forms[0].q135.value = total;
			calcTotalDebtRatio3();
			
		}
		
		
		
	function calcTotalDebtRatio3() {
			var total;
			
			var inc2=GetInteger(document.forms[0].q135.value);
			var inc3=GetInteger(document.forms[0].q118.value);
			
			if  ( isNaN(inc2) ){inc2=0}
			if  ( isNaN(inc3) ){inc3=0}
			
			total =Math.round((inc2/inc3)*100)/100
			if  ( isNaN(total) ){total=0}
			
			document.forms[0].q137.value = total+'%';
			
		}	
		
		
		
		
function submitform5()
{
	var error="";
	
	if (document.forms[0].q74.value=="") {error="75"}
	if (document.forms[0].q75.value=="") {error="76"}
	if (document.forms[0].q76.value=="") {error="77"}
	if (document.forms[0].q77.value=="") {error="78"}
	if (document.forms[0].q78.value=="") {error="79"}
	if (document.forms[0].q79.value=="") {error="80"}
	if (document.forms[0].q80.value=="") {error="81"}
	if (document.forms[0].q81.value=="") {error="82"}
	if (document.forms[0].q82.value=="") {error="83"}
	if (document.forms[0].q83.value=="") {error="84"}
	if (document.forms[0].q84.value=="") {error="85"}
	if (document.forms[0].q85.value=="") {error="86"}
	if (document.forms[0].q86.value=="") {error="87"}
	if (document.forms[0].q87.value=="") {error="88"}
	if (document.forms[0].q88.value=="") {error="89"}
	if (document.forms[0].q89.value=="") {error="90"}
	if (document.forms[0].q90.value=="") {error="91"}
	if (document.forms[0].q91.value=="") {error="92"}
	if (document.forms[0].q92.value=="") {error="93"}
	if (document.forms[0].q93.value=="") {error="94"}
	if (document.forms[0].q94.value=="") {error="95"}
	if (document.forms[0].q95.value=="") {error="96"}
	if (document.forms[0].q96.value=="") {error="97"}
	if (document.forms[0].q97.value=="") {error="98"}
	if (document.forms[0].q98.value=="") {error="99"}
	if (document.forms[0].q99.value=="") {error="100"}
	if (document.forms[0].q100.value=="") {error="101"}
	if (document.forms[0].q101.value=="") {error="102"}
	if (document.forms[0].q102.value=="") {error="103"}
	if (document.forms[0].q103.value=="") {error="104"}
	if (document.forms[0].q175.value=="") {error="175"}


	
	
	
	if (error==""){
		document.forms[0].submit();
	}else{
		alert("Please complete all fields!")
	}
	
		
	
}			
/////e-2
function submitform6()
{
	var error="";
	
	if (document.forms[0].q106.value=="") {error="q106"}
	if (document.forms[0].q107.value=="") {error="q107"}
	if (document.forms[0].q108.value=="") {error="q108"}
	if (document.forms[0].q109.value=="") {error="q109"}
	if (document.forms[0].q110.value=="") {error="q110"}
	if (document.forms[0].q111.value=="") {error="q111"}
	if (document.forms[0].q112.value=="") {error="q112"}
	if (document.forms[0].q113.value=="") {error="q113"}
	if (document.forms[0].q114.value=="") {error="q114"}
	if (document.forms[0].q115.value=="") {error="q115"}
	if (document.forms[0].q116.value=="") {error="q116"}
	if (document.forms[0].q117.value=="") {error="q117"}
	if (document.forms[0].q118.value=="") {error="q118"}
	if (document.forms[0].q122.value=="") {error="q122"}
	if (document.forms[0].q138.value=="") {error="q138"}
	if (document.forms[0].q123.value=="") {error="q123"}
	if (document.forms[0].q125.value=="") {error="q125"}
	if (document.forms[0].q127.value=="") {error="q127"}
	if (document.forms[0].q129.value=="") {error="q129"}
	if (document.forms[0].q131.value=="") {error="q131"}
	if (document.forms[0].q133.value=="") {error="q133"}
	if (document.forms[0].q135.value=="") {error="q135"}
	if (document.forms[0].q137.value=="") {error="q137"}

	if (document.forms[0].q175.value=="") {error="175"}


	
	
	
	if (error==""){
		document.forms[0].submit();
	}else{
		alert("Please complete all fields!")
	}
	
		
	
}