﻿function numbval(value) {for (var i=0; i < value.length; i++) {a = parseInt(value.charAt(i));if (isNaN(a)) {return false;break;}}return true;}function decval(value) {for (var i=0; i < value.length; i++) {a = parseInt(value.charAt(i));if (isNaN(a)){if (value.charAt(i) != '$' && value.charAt(i) != '.'){return false;break;}}}return true;}function func(id){return document.geleid(id);}	function kalk(REOcalculator){var err = true;var errorMsg='';if(document.REOcalculator.propertyvalue.value == ''){document.REOcalculator.propertyvalue.style.backgroundColor = '#3B4E87';errorMsg+='Please enter property value';err = false;}else{if(isNaN(document.REOcalculator.propertyvalue.value)){errorMsg+='Invalid/Unrecognized format \n';document.REOcalculator.propertyvalue.style.backgroundColor = '#3B4E87';err = false;}else{document.REOcalculator.propertyvalue.style.backgroundColor = '#FFFFFF';}}if(document.REOcalculator.loanvalue.value == ''){document.REOcalculator.loanvalue.style.backgroundColor = '#3B4E87';errorMsg+='Please enter loan value \n';err = false;}else{if(isNaN(document.REOcalculator.loanvalue.value)){errorMsg+='Invalid/Unrecognized format - Loan value \n';document.REOcalculator.loanvalue.style.backgroundColor = '#3B4E87';err = false;}else{document.REOcalculator.loanvalue.style.backgroundColor = '#FFFFFF';}}if(document.REOcalculator.inerestrate.value == ''){document.REOcalculator.inerestrate.style.backgroundColor = '#3B4E87';errorMsg+='Please enter interest rate \n';err = false;}else{if(isNaN(document.REOcalculator.loanvalue.value)){errorMsg+='Invalid/Unrecognized format - interest rate \n';document.REOcalculator.inerestrate.style.backgroundColor = '#3B4E87';err = false;}else{document.REOcalculator.inerestrate.style.backgroundColor = '#FFFFFF';}}if(document.REOcalculator.propertyvalue_cur.value == ''){document.REOcalculator.propertyvalue_cur.style.backgroundColor = '#3B4E87';errorMsg+='Please enter current property value \n';err = false;}else{if(isNaN(document.REOcalculator.propertyvalue_cur.value)){errorMsg+='Invalid/Unrecognized format - property value \n';document.REOcalculator.propertyvalue_cur.style.backgroundColor = '#3B4E87';err = false;}else if(document.REOcalculator.propertyvalue_cur.value==0){errorMsg+='Division by zero not allowed \n';document.REOcalculator.propertyvalue_cur.style.backgroundColor = '#3B4E87';err = false;}else{document.REOcalculator.propertyvalue_cur.style.backgroundColor = '#FFFFFF';}}if(document.REOcalculator.sales_cost.value == ''){document.REOcalculator.sales_cost.style.backgroundColor = '#3B4E87';errorMsg+='Please enter sales cost \n';err = false;}else{if(isNaN(document.REOcalculator.sales_cost.value)){errorMsg+='Invalid/Unrecognized format - sales cost \n';document.REOcalculator.sales_cost.style.backgroundColor = '#3B4E87';err = false;}else{document.REOcalculator.sales_cost.style.backgroundColor = '#FFFFFF';}}if(document.REOcalculator.interestdue.value == ''){document.REOcalculator.interestdue.style.backgroundColor = '#3B4E87';errorMsg+='Please enter interest due months (#) \n';err = false;}else{if(isNaN(document.REOcalculator.interestdue.value)){errorMsg+='Invalid/Unrecognized format - interest due \n';document.REOcalculator.interestdue.style.backgroundColor = '#3B4E87';err = false;}else{document.REOcalculator.interestdue.style.backgroundColor = '#FFFFFF';}}if(document.REOcalculator.cleanupcost.value == ''){document.REOcalculator.cleanupcost.style.backgroundColor = '#3B4E87';errorMsg+='Please enter cleanup cost \n';err = false;}else{if(isNaN(document.REOcalculator.cleanupcost.value)){errorMsg+='Invalid/Unrecognized format - clean up cost\n';document.REOcalculator.cleanupcost.style.backgroundColor = '#3B4E87';err = false;}else{document.REOcalculator.cleanupcost.style.backgroundColor = '#FFFFFF';}}if(document.REOcalculator.legalcost.value == ''){document.REOcalculator.legalcost.style.backgroundColor = '#3B4E87';errorMsg+='Please enter legal cost \n';err = false;}else{if(isNaN(document.REOcalculator.legalcost.value)){errorMsg+='Invalid/Unrecognized format\n'; document.REOcalculator.legalcost.style.backgroundColor = '#3B4E87';err = false;}else {document.REOcalculator.legalcost.style.backgroundColor = '#FFFFFF';}}if(document.REOcalculator.propertytax.value == ''){document.REOcalculator.propertytax.style.backgroundColor = '#3B4E87';errorMsg+='Please enter property tax \n';err = false;}else{if(isNaN(document.REOcalculator.propertytax.value)){errorMsg+='Invalid/Unrecognized format - property tax\n';document.REOcalculator.propertytax.style.backgroundColor = '#3B4E87';err = false;}else{document.REOcalculator.propertytax.style.backgroundColor = '#FFFFFF';}}if(document.REOcalculator.insurnotpd.value == ''){document.REOcalculator.insurnotpd.style.backgroundColor = '#3B4E87';errorMsg+='Please enter pending/not paid insurance amount \n';err = false;}else{if(isNaN(document.REOcalculator.insurnotpd.value)){errorMsg+='Invalid/Unrecognized format - insurnotpd\n';document.REOcalculator.insurnotpd.style.backgroundColor = '#3B4E87';err = false;}else{document.REOcalculator.insurnotpd.style.backgroundColor = '#FFFFFF';}}if(!err){if(errorMsg!=''){alert(errorMsg);return false;}return false;}else{ var propsval=document.REOcalculator.propertyvalue.value;var loansval=document.REOcalculator.loanvalue.value;var intrval=document.REOcalculator.inerestrate.value;var curpropsval=document.REOcalculator.propertyvalue_cur.value;var salesval=document.REOcalculator.sales_cost.value;var intdval=document.REOcalculator.interestdue.value;var cleanupCost=document.REOcalculator.cleanupcost.value;var legcos=document.REOcalculator.legalcost.value;var proptaxbil=document.REOcalculator.propertytax.value;var insurnotpd=document.REOcalculator.insurnotpd.value;var losgain = Math.round((((curpropsval-propsval)/propsval)*100)*1000)/1000;var intimo = loansval*intrval/12;var inttot	= intimo*intdval;var asaleint	= (curpropsval*salesval)/100; var asalenet = (curpropsval-asaleint);var monintamt = Math.round(((loansval*intrval)/100)/12*1000)/1000;var loanlifint = Math.round((monintamt*intdval)*1000)/1000;var liabtot =	parseFloat(loansval)+parseFloat(loanlifint)+parseFloat(cleanupCost)+parseFloat(legcos)+parseFloat(proptaxbil)+parseFloat(insurnotpd);var liabtotyr = Math.round(liabtot*1000)/1000;var lossgaintot = Math.round((parseFloat(asalenet)- parseFloat(liabtotyr))*1000)/1000;document.REOcalculator.lossorgain.value=losgain;document.REOcalculator.netaftersales.value=asalenet;document.REOcalculator.rate_month.value=monintamt;document.REOcalculator.totintdues.value=loanlifint;document.REOcalculator.total_liability.value=liabtotyr;document.REOcalculator.gainorloss.value=lossgaintot;return false;}}function calculatorcost(){var err = true;var errorMsg='';if(document.REOcalculator.propertyvalue.value == ''){document.REOcalculator.propertyvalue.style.backgroundColor = '#3B4E87';errorMsg+='Please enter property value';err = false;}else{if(isNaN(document.REOcalculator.propertyvalue.value)){errorMsg+='Invalid/Unrecognized format \n';document.REOcalculator.propertyvalue.style.backgroundColor = '#3B4E87';err = false;}else{document.REOcalculator.propertyvalue.style.backgroundColor = '#FFFFFF';}}if(document.REOcalculator.loanvalue.value == ''){document.REOcalculator.loanvalue.style.backgroundColor = '#3B4E87';errorMsg+='Please enter loan value \n';err = false;}else{if(isNaN(document.REOcalculator.loanvalue.value)){errorMsg+='Invalid/Unrecognized format - Loan value \n';document.REOcalculator.loanvalue.style.backgroundColor = '#3B4E87';err = false;}else{document.REOcalculator.loanvalue.style.backgroundColor = '#FFFFFF';}}if(document.REOcalculator.inerestrate.value == ''){document.REOcalculator.inerestrate.style.backgroundColor = '#3B4E87';errorMsg+='Please enter interest rate \n';err = false;}else{if(isNaN(document.REOcalculator.loanvalue.value)){errorMsg+='Invalid/Unrecognized format - interest rate \n';document.REOcalculator.inerestrate.style.backgroundColor = '#3B4E87';err = false;}else{document.REOcalculator.inerestrate.style.backgroundColor = '#FFFFFF';}}if(document.REOcalculator.propertyvalue_cur.value == ''){document.REOcalculator.propertyvalue_cur.style.backgroundColor = '#3B4E87';errorMsg+='Please enter current property value \n';err = false;}else{if(isNaN(document.REOcalculator.propertyvalue_cur.value)){errorMsg+='Invalid/Unrecognized format - property value \n';document.REOcalculator.propertyvalue_cur.style.backgroundColor = '#3B4E87';err = false;}else if(document.REOcalculator.propertyvalue_cur.value==0){errorMsg+='Division by zero not allowed \n';document.REOcalculator.propertyvalue_cur.style.backgroundColor = '#3B4E87';err = false;}else{document.REOcalculator.propertyvalue_cur.style.backgroundColor = '#FFFFFF';}}if(document.REOcalculator.sales_cost.value == ''){document.REOcalculator.sales_cost.style.backgroundColor = '#3B4E87';errorMsg+='Please enter sales cost \n';err = false;}else{if(isNaN(document.REOcalculator.sales_cost.value)){errorMsg+='Invalid/Unrecognized format - sales cost \n';document.REOcalculator.sales_cost.style.backgroundColor = '#3B4E87';err = false;}else{document.REOcalculator.sales_cost.style.backgroundColor = '#FFFFFF';}}if(document.REOcalculator.interestdue.value == ''){document.REOcalculator.interestdue.style.backgroundColor = '#3B4E87';errorMsg+='Please enter interest due months (#) \n';err = false;}else{if(isNaN(document.REOcalculator.interestdue.value)){errorMsg+='Invalid/Unrecognized format - interest due \n';document.REOcalculator.interestdue.style.backgroundColor = '#3B4E87';err = false;}else{document.REOcalculator.interestdue.style.backgroundColor = '#FFFFFF';}}if(document.REOcalculator.cleanupcost.value == ''){document.REOcalculator.cleanupcost.style.backgroundColor = '#3B4E87';errorMsg+='Please enter cleanup cost \n';err = false;}else{if(isNaN(document.REOcalculator.cleanupcost.value)){errorMsg+='Invalid/Unrecognized format - clean up cost\n';document.REOcalculator.cleanupcost.style.backgroundColor = '#3B4E87';err = false;}else{document.REOcalculator.cleanupcost.style.backgroundColor = '#FFFFFF';}}if(document.REOcalculator.legalcost.value == ''){document.REOcalculator.legalcost.style.backgroundColor = '#3B4E87';errorMsg+='Please enter legal cost \n';err = false;}else{if(isNaN(document.REOcalculator.legalcost.value)){errorMsg+='Invalid/Unrecognized format\n'; document.REOcalculator.legalcost.style.backgroundColor = '#3B4E87';err = false;}else {document.REOcalculator.legalcost.style.backgroundColor = '#FFFFFF';}}if(document.REOcalculator.propertytax.value == ''){document.REOcalculator.propertytax.style.backgroundColor = '#3B4E87';errorMsg+='Please enter property tax \n';err = false;}else{if(isNaN(document.REOcalculator.propertytax.value)){errorMsg+='Invalid/Unrecognized format - property tax\n';document.REOcalculator.propertytax.style.backgroundColor = '#3B4E87';err = false;}else{document.REOcalculator.propertytax.style.backgroundColor = '#FFFFFF';}}if(document.REOcalculator.insurnotpd.value == ''){document.REOcalculator.insurnotpd.style.backgroundColor = '#3B4E87';errorMsg+='Please enter pending/not paid insurance amount \n';err = false;}else{if(isNaN(document.REOcalculator.insurnotpd.value)){errorMsg+='Invalid/Unrecognized format - insurnotpd\n';document.REOcalculator.insurnotpd.style.backgroundColor = '#3B4E87';err = false;}else{document.REOcalculator.insurnotpd.style.backgroundColor = '#FFFFFF';}}if(!err){if(errorMsg!=''){alert(errorMsg);return false;}return false;}else{var propsval=document.REOcalculator.propertyvalue.value;var loansval=document.REOcalculator.loanvalue.value;var intrval=document.REOcalculator.inerestrate.value;var curpropsval=document.REOcalculator.propertyvalue_cur.value ;var salesval=document.REOcalculator.sales_cost.value;var intdval=document.REOcalculator.interestdue.value;var cleanupCost=document.REOcalculator.cleanupcost.value;var legcos=document.REOcalculator.legalcost.value;var proptaxbil=document.REOcalculator.propertytax.value;var insurnotpd=document.REOcalculator.insurnotpd.value;var losgain = Math.round((((curpropsval-propsval)/propsval)*100)*1000)/1000;var intimo = loansval*intrval/12;var inttot	= intimo*intdval;var asaleint = (curpropsval*salesval)/100;	var asalenet = (curpropsval-asaleint);var monintamt = Math.round(((loansval*intrval)/100)/12*1000)/1000;var loanlifint = Math.round((monintamt*intdval)*1000)/1000;var liabtot = parseFloat(loansval)+parseFloat(loanlifint)+parseFloat(cleanupCost)+parseFloat(legcos)+parseFloat(proptaxbil)+parseFloat(insurnotpd);var liabtotyr =	Math.round(liabtot*1000)/1000;var lossgaintot = Math.round((parseFloat(asalenet)- parseFloat(liabtotyr))*1000)/1000;document.REOcalculator.lossorgain.value=losgain;document.REOcalculator.netaftersales.value=asalenet;document.REOcalculator.rate_month.value=monintamt;document.REOcalculator.totintdues.value=loanlifint;document.REOcalculator.total_liability.value=liabtotyr;document.REOcalculator.gainorloss.value=lossgaintot;return false;}}function alertMe(currentstate){	var stropt=currentstate.split(",");	window.location=stropt['0'];} 