﻿
function loan()
{
    document.getElementById("txtEMI").readOnly=false;;
    var varRate = $('#txtRateofInterest').val();	
    var varYear = $('#ddlYears').val();	
    var varLoanAmount = $('#txtLoanAmount').val();	
    
    var numberofyears = varYear * 12;
    var rateofinterest = varRate/(12*100);
    
    var varEMI = (varLoanAmount * rateofinterest *Math.pow((1+rateofinterest),numberofyears))/(Math.pow((1+rateofinterest),numberofyears)-1);
    var roundedEMI = Math.round(varEMI*100)/100;
	var emi=Math.ceil(roundedEMI);
	
    document.getElementById("txtEMI").value=emi;
    document.getElementById("txtEMI").readOnly=true;
}

function stampduty()
{
    var varPropertyValue=document.getElementById("txtPropertyValue").value;
    var varPercent=0;
    var varBaseLimit;
    var varStampDuty;
    document.getElementById("txtStampDuty").readOnly=false;
    

        if(varPropertyValue<=500000)
        {
            document.getElementById("txtStampDuty").value=7500;
        }
        
        else if(varPropertyValue>500000)
        {
            varPropertyValue=varPropertyValue-500000;
            varPercent=(5/100)*varPropertyValue;
            var varStampDuty=varPercent+7500;
            document.getElementById("txtStampDuty").value=varStampDuty;
            document.getElementById("txtStampDuty").readOnly=true;
        }

    
}

function ClearEMIFields()
{
    $('[id$=txtRateofInterest]').val("");
    $("#ddlYears option[value='Select']").attr("selected", "selected");
    $('[id$=txtLoanAmount]').val("");
    $('[id$=txtEMI]').val("");
    
}

function ClearStampDutyFields()
{
    $('[id$=txtPropertyValue]').val("");  
    $('[id$=txtStampDuty]').val('');
}
