<%--
    Document   : RepayLoan
    Created on : Dec 21, 2016, 4:06:13 PM
    Author     : 986137
--%>

<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.util.Date"%>
<%@page import="LoginDb.DbHandler"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@page import="java.util.UUID" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%String uuid = UUID.randomUUID().toString();%>
<% try {
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Loan Repayment</title>
        <link rel="shortcut icon" href="${pageContext.request.contextPath}/img/favicon.ico" type="image/x-icon" />
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/TableCSSCode.css" />
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/styles.css?pacs=<%=((new java.util.Date()).getTime())%>"/>
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/ButtonAndText.css?pacs=<%=((new java.util.Date()).getTime())%>" />
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/info.css?pacs=<%=((new java.util.Date()).getTime())%>" />

        <script type="text/javascript" src="${pageContext.request.contextPath}/jquery-ui-1.10.4.custom/development-bundle/jquery-1.10.2.js?pacs=<%=((new java.util.Date()).getTime())%>"></script>
        <script type="text/javascript" src="/PacsApplication/chromejs/chrome.js?pacs=<%=((new java.util.Date()).getTime())%>"></script>
        <script type="text/javascript" src="/PacsApplication/js/iFrame_killer.js"></script>

        <style>

            .dialog{
                border:5px solid #666;
                padding:10px;
                background:#FFFFFF;
                position:absolute;
                left: 175px;
                top: 220px;
                z-index:1;
                display:none;
            }
            .dialog label{
                display:inline-block;
                color:#151414;
            }
            div .dialog input[type=text]{
                border:1px solid #333;
                display:inline-block;
                margin:5px;
                width: 180px;

            }

        </style>

    </head>
    <body  onload="noBack()">

        <script type="text/javascript">
            function noBack()
            {
                window.history.forward();
            }

            function ShowParent()
            {
                document.forms[0].action="${pageContext.request.contextPath}/Loan/RepayLoan.jsp";
                document.forms[0].submit();
            }
            $(document).ready(function(){
                $('#repayAmt').on("cut copy paste",function(e) {
                    e.preventDefault();
                });
               
            });

            function checkDiv(RepayLoan){
                var repayAmt = parseFloat(Math.abs(RepayLoan.repayAmt.value)).toFixed(2);
                var resTXNAmt = parseFloat(Math.abs(RepayLoan.resTXNAmt.value)).toFixed(2);
                var repAmt = document.getElementById("repayAmt").value;

                if (repAmt.indexOf('.') != -1) {
                    alert("Please do not enter any decimal value in Repayment Amount!");
                    document.getElementById("repayAmt").focus();
                    return false;
                }
                if(RepayLoan.repayType.value == ""){
                    alert("Please select Repay Type.");
                    RepayLoan.repayType.focus();
                    return false;
                }
                if(RepayLoan.loanAcc.value == ""){
                    alert("Loan Account Number field is empty.");
                    RepayLoan.loanAcc.focus();
                    return false;
                }
                if(RepayLoan.custName.value == ""){
                    alert("Please select the account number from the search button to populate the other values.");
                    RepayLoan.loanAcc.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(RepayLoan.loanAcc.value))
                {
                    alert("Account No. could only contain numbers");
                    RepayLoan.loanAcc.focus();
                    return false;
                }
                if(RepayLoan.payMode.value == ""){
                    alert("Please select the Payment mode first.");
                    RepayLoan.payMode.focus();
                    return false;
                }
                if(RepayLoan.repayAmt.value == ""){
                    alert("Please enter Repayment Amount first.");
                    RepayLoan.repayAmt.focus();
                    return false;
                }
                if (!re.test(RepayLoan.repayAmt.value))
                {
                    alert("Repayment amount could contain only numbers.");
                    RepayLoan.repayAmt.focus();
                    return false;
                }
                if (RepayLoan.intAdjAmt.value == "")
                {
                    alert("Please enter Interest adjustment amount.");
                    RepayLoan.intAdjAmt.focus();
                    return false;
                }                
                if(RepayLoan.narration.value == ""){
                    alert("Please provide narration");
                    RepayLoan.narration.focus();
                    return false;
                }
                if(RepayLoan.payMode.value == "T"){
                    if(RepayLoan.transAcc.value == ""){
                        alert("Transfer account Number field is empty.");
                        RepayLoan.transAcc.focus();
                        return false;
                    }
                    if (!re.test(RepayLoan.transAcc.value))
                    {
                        alert("Transfer account No. could only contain numbers.");
                        RepayLoan.transAcc.focus();
                        return false;
                    }
                }
                if((RepayLoan.payMode.value == "C") && (Number(resTXNAmt) != Number(repayAmt))){
                    alert("Please fill-in the cash denominations.");
                    $("#repayAmt").click();
                    return false;
                }
                if (parseFloat($("#intAdjAmt").val()) < 0)
                {
                    if(confirm("Negative Interest adjustment amount increases the interest."))
                        alert("Repay Amount: " + document.getElementById("repayAmt").value);
                    else
                        return false;

                }
                if (parseFloat($("#intAdjAmt").val()) > 0)
                {
                    var amt = parseFloat(document.getElementById("repayAmt").value);
                    //alert("Repay Amount: " + amt);
                    if(confirm("Positive Interest adjustment amount decreases the interest.")){
                        if(!confirm("Repay Amount: " + amt))
                            return false;
                        }
                    else
                        return false;

                }

                if((document.getElementById("product_code").value=="7002")&&(document.getElementById("payMode").value=="C")&&(document.getElementById("member_count").value!="0"))
                    {
                        //alert
                        if(document.getElementById("memberId").value=="")
                            {
                                alert("Member Name can not be empty.");
                                transactionForm.memberName.focus();
                                return false;
                            }
                    }
                return true;
            }

            function popup_LonAcc(width, height, loanAcc, repayType) {
                if (window.innerWidth) {
                    LeftPosition = (window.innerWidth - width) / 2;
                    TopPosition = ((window.innerHeight - height) / 2) - 20;
                }
                else {
                    LeftPosition = (parseInt(window.screen.width) - width) / 2;
                    TopPosition = ((parseInt(window.screen.height) - height) / 2) - 20;
                }
                attr = 'resizable=yes,scrollbars=yes,width=' + width + ',height=' +
                    height + ',screenX=300,screenY=200,left=' + LeftPosition + ',top=' +
                    TopPosition + '';
                var screenName = "RepayLoan.jsp";
                var  lovKey="LoanAcctSearch"
                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationLoanLOV.jsp?repayType=' + repayType + '&loanAcc=' + loanAcc + '&screenName=' + screenName+'&lovKey='+lovKey, 'LoanAcctSearch', attr);
                popWin.focus();

            }

            function popup_TransferAcc(width, height, loanAcc) {
                if (window.innerWidth) {
                    LeftPosition = (window.innerWidth - width) / 2;
                    TopPosition = ((window.innerHeight - height) / 2) - 20;
                }
                else {
                    LeftPosition = (parseInt(window.screen.width) - width) / 2;
                    TopPosition = ((parseInt(window.screen.height) - height) / 2) - 20;
                }
                attr = 'resizable=yes,scrollbars=yes,width=' + width + ',height=' +
                    height + ',screenX=300,screenY=200,left=' + LeftPosition + ',top=' +
                    TopPosition + '';
                var screenName = "RepayLoan.jsp";
                var  lovKey="transferAccSrch"
                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationLoanLOV.jsp?loanAcc=' + loanAcc + '&screenName=' + screenName+'&lovKey='+lovKey, 'LoanAcctSearch', attr);
                popWin.focus();

            }

            function popup_glAcc(width, height, glAcc) {
                if (window.innerWidth) {
                    LeftPosition = (window.innerWidth - width) / 2;
                    TopPosition = ((window.innerHeight - height) / 2) - 20;
                }
                else {
                    LeftPosition = (parseInt(window.screen.width) - width) / 2;
                    TopPosition = ((parseInt(window.screen.height) - height) / 2) - 20;
                }
                attr = 'resizable=yes,scrollbars=yes,width=' + width + ',height=' +
                    height + ',screenX=300,screenY=200,left=' + LeftPosition + ',top=' +
                    TopPosition + '';
                var screenName = "RepayLoan.jsp";
                var  lovKey="glAccSrch"
                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationLoanLOV.jsp?glAcc=' + glAcc + '&screenName=' + screenName+'&lovKey='+lovKey, 'glAcctSearch', attr);
                popWin.focus();

            }

            function submitform(RepayLoan)
            {
                if(checkDiv(RepayLoan)){
                    document.forms[0].handle_id.value = "SearchLoanAcc";
                    document.forms[0].action = '/PacsApplication/RepayLoanServlet';
                    document.forms[0].submit();
                }

            }

            function isNumberKey(evt)
            {
                //alert(event.charCode);
                var charCode = (evt.which) ? evt.which : evt.keyCode;

                if (charCode != 46 && charCode > 31 && charCode != 45
                    && (charCode < 48 || charCode > 57))
                    return false;

                //$( "#btnReset" ).click();
                /*if(document.getElementById("repayType").value == "C" && document.getElementById("intAdjAmt").value != "")
                    calcAmt();*/
                return true;
            }

            function checkAmt(){
                if(document.getElementById("repayType").value == "C" && document.getElementById("intAdjAmt").value != "")
                    calcAmt();
                else if(document.getElementById("repayType").value == "C" && document.getElementById("intAdjAmt").value == "")
                    document.getElementById("repayAmt").value = $("#closeAmt").val();
            }

            function calcAmt() {
                var closeAmt = parseFloat($("#closeAmt").val());
                //var txnamt = parseFloat($("#txnamt").val());
                //var tranType = $("#tranType").val();
                var intAdjAmt = parseFloat($("#intAdjAmt").val());
                var net = parseFloat(0);

                net = closeAmt - intAdjAmt;
                document.getElementById("repayAmt").value = net;

            }

            function showTr()
            {
                //alert(document.getElementById("product_code").value);
                //alert(document.getElementById("cust_no").value);
                if((document.getElementById("product_code").value=="7002")&&(document.getElementById("member_count").value!="0"))
                    {
                        //alert("IN");
                        document.getElementById("memberCifRow").style.display='table-row';
                    }

                else
                    {
                      document.getElementById("memberCifRow").style.display='none';
                    }
            }

            function popup_loanAccountMember(width, height, accNo) {
                if (window.innerWidth) {
                    LeftPosition = (window.innerWidth - width) / 2;
                    TopPosition = ((window.innerHeight - height) / 2) - 20;
                }
                else {
                    LeftPosition = (parseInt(window.screen.width) - width) / 2;
                    TopPosition = ((parseInt(window.screen.height) - height) / 2) - 20;
                }
                attr = 'resizable=yes,scrollbars=yes,width=' + width + ',height=' +
                    height + ',screenX=300,screenY=200,left=' + LeftPosition + ',top=' +
                    TopPosition + '';
                var screenName = "RepayLoan.jsp";
                var lovKey = "loanShgMember"
                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationLoanLOV.jsp?accNo=' + accNo + '&screenName=' + screenName + '&lovKey=' + lovKey, 'loanShgMember', attr);
                popWin.focus();
            }

            $(document).ready(function () {
                $('select#payMode').change(function () {
                    $( "#btnReset" ).click();
                    $('#transAcc').val('');
                    $('#memberCifRow').hide();
                    //$('#repayAmt').val('');
                    var shouldEnable = $(this).val();
                    $('#narration').val('');

                    if($('#product_code').val() == ""){
                        alert("Please search Account Number first before proceeding.");
                        event.preventDefault();
                        $('#payMode').val("");
                    }

                    else{
                    switch(shouldEnable)
                    {
                        case 'C':
                            $('#transferAccount').hide();
                            $('#glAccount').hide();
                            showTr();
                            break;
                        case 'T':
                            $('#transferAccount').show(500);
                            $('#glAccount').hide();
                            break;
                        case 'G':
                            $('#glAccount').show();
                            $('#transferAccount').hide();
                            break;
                        default:
                            $('#transferAccount').hide();
                    }
                }});
                $('select#repayType').change(function () {
                    var shouldEnable = $(this).val();
                    $('#lonDetails').hide();
                    $('#memberCifRow').hide();
                    $('#payMode').val("");

                    //$('#narration').val('');
                    switch(shouldEnable)
                    {
                        case 'C':
                            document.getElementById("repayAmt").readOnly = true;
                            break;
                        case 'R':
                            document.getElementById("repayAmt").readOnly = false;
                            break;
                        default:
                            document.getElementById("repayAmt").readOnly = false;
                    }
                });
            });

            $(function() {
                $("#repayAmt").click(function() {
                    if($('#loanAcc').val() == ""){
                        alert("Please select a proper loan a/c number.");
                    } else if($('#intAdjAmt').val() == ""){
                        alert("Please enter interest adjustment amount");
                    } else if($('#status').val() == "C" && $('#payMode').val() == "C"){
                        alert("Cash Drawer isn't opened yet!");
                    }else{
                        if ($('#payMode').val() == "C"){

                            $("#myform").show(500);
                        }
                        else if ($('#payMode').val() == null){

                            alert("Please select payment mode first.");
                        }
                    }
                })
            });

            function resetDetails()
            {
                document.getElementById("payMode").value="";
                document.getElementById("memberName").value="";
                 document.getElementById("memberId").value="";
                  document.getElementById("product_code").value="";
                document.getElementById("memberCifRow").style.display="none";
                document.getElementById("transferAccount").style.display="none";
                document.getElementById("glAccount").style.display="none";

            }

            // to restrict back button
            history.pushState(null, null, location.href);
            window.addEventListener('popstate', function(event) {
                history.pushState(null, null, location.href);
            });
            
        </script>



        <jsp:include page="MenuHead_Loan.jsp" flush="true" />
        <br>
        <%          String error_msg = "";
             Object error = request.getAttribute("message");
             if (error != null) {
                 error_msg = error.toString();
             }
        %>

        <%
             String displayFlag = "";
             Object display = request.getAttribute("displayFlag");
             if (display != null) {
                 displayFlag = display.toString();
             }
        %>

        <%   String odeno2000 = "";
             String odeno500 = "";
             String odeno200 = "";
             String odeno100 = "";
             String odeno50 = "";
             String odeno20 = "";
             String odeno10 = "";
             String odeno5 = "";
             String odeno2 = "";
             String odeno1 = "";
             String odeno50P = "";
             String odeno1P = "";
             String status = "C";
             String pacsid = (String) session.getAttribute("pacsId");
             String makerId = session.getAttribute("user").toString();
             Connection connection = null;
             ResultSet rs = null;
             Statement statement = null;
             connection = DbHandler.getDBConnection();
             try {
                 statement = connection.createStatement();
                 rs = statement.executeQuery("select nvl(d.deno_2000,0),nvl(d.deno_500,0),nvl(d.deno_100,0),nvl(d.deno_50,0),nvl(d.deno_20,0),nvl(d.deno_10,0),nvl(d.deno_5,0),nvl(d.deno_2,0),nvl(d.deno_1,0),nvl(d.DENO_50P,0),nvl(d.DENO_1P,0),d.status,nvl(d.deno_200,0) from cash_drawer d where d.entry_date = (select system_date from system_date) and  d.teller_id ='" + makerId + "' and d.pacs_id ='" + pacsid + "' ");

                 while (rs.next()) {
                     odeno2000 = rs.getString(1);
                     odeno500 = rs.getString(2);
                     odeno100 = rs.getString(3);
                     odeno50 = rs.getString(4);
                     odeno20 = rs.getString(5);
                     odeno10 = rs.getString(6);
                     odeno5 = rs.getString(7);
                     odeno2 = rs.getString(8);
                     odeno1 = rs.getString(9);
                     odeno50P = rs.getString(10);
                     odeno1P = rs.getString(11);
                     status = rs.getString(12);
                     odeno200 = rs.getString(13);

                 }
                // statement.close();         
                // connection.close();
             } catch (Exception e) {
                System.out.println("Error occurred during processing.");
            } finally {
                try {
                    if(statement !=null)
                        statement.close();
                    if (connection != null)
                    connection.close();

            } catch (Exception e) {               
               System.out.println("Error Occurred during connection close.");
            }

            }
        %>

        <fieldset style="border-color: black; background-image: url('/PacsApplication/img/download.jpg'); border-width: 3px">
            <legend style="padding: 8px; border-radius: 20px; background-color: #006600; color: white">Loan Repayment</legend>
            <form name="RepayLoan" id="RepayLoan" action="" method="post">

                <%if (!error_msg.equalsIgnoreCase("")) {%>
                <center><div class="info" id="errorMessage"><center><%= error_msg%></center></div></center>
                <% }%>
                <br>
                <br>
                <center>
                    <div class="dialog" id="myform" >

                        <table border="2" width="auto" cellspacing="1" cellpadding="1" style="text-align: center ;overflow-y: scroll; font-size: 15px">
                            <thead class="CSSTableGenerator">
                                <tr>
                                    <td>Denominations</td>
                                    <td>Available</td>
                                    <td>IN</td>
                                    <td>OUT</td>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td align="left"><label>2000 Note</label></td>
                                    <td><input type="text" readonly name="twothouAvail" id="twothouAvail" class="available" value="<%=odeno2000%>"></td>
                                    <td><input type="text" name="twothouIN" id="twothouIN" class="inDeno"></td>
                                    <td><input type="text" name="twothouOUT" id="twothouOUT" class="outDeno"></td>
                                </tr>
                                <tr>
                                    <td align="left"><label>500 Note</label></td>
                                    <td><input type="text" readonly name="fivehundredAvail" id="fivehundredAvail" class="available" value="<%=odeno500%>"></td>
                                    <td><input type="text" name="fivehundredIN" id="fivehundredIN" class="inDeno"></td>
                                    <td><input type="text" name="fivehundredOUT" id="fivehundredOUT" class="outDeno"></td>
                                </tr>
                                <tr>
                                    <td align="left"><label>200 Note</label></td>
                                    <td><input type="text" readonly name="twohundredAvail" id="twohundredAvail" class="available" value="<%=odeno200%>"></td>
                                    <td><input type="text" name="twohundredIN" id="twohundredIN" class="inDeno"></td>
                                    <td><input type="text" name="twohundredOUT" id="twohundredOUT" class="outDeno"></td>
                                </tr>
                                <tr>
                                    <td align="left"><label>100 Note</label></td>
                                    <td><input type="text" readonly name="hundredAvail" id="hundredAvail" class="available" value="<%=odeno100%>"></td>
                                    <td><input type="text" name="hundredIN" id="hundredIN" class="inDeno"></td>
                                    <td><input type="text" name="hundredOUT" id="hundredOUT" class="outDeno"></td>
                                </tr>
                                <tr>
                                    <td align="left"><label>50 Note</label></td>
                                    <td><input type="text" readonly name="fiftyAvail" id="fiftyAvail" class="available" value="<%=odeno50%>"></td>
                                    <td><input type="text" name="fiftyIN" id="fiftyIN" class="inDeno"></td>
                                    <td><input type="text" name="fiftyOUT" id="fiftyOUT" class="outDeno"></td>
                                </tr>
                                <tr>
                                    <td align="left"><label>20 Note</label></td>
                                    <td><input type="text" readonly name="twentyAvail" id="twentyAvail" class="available" value="<%=odeno20%>"></td>
                                    <td><input type="text" name="twentyIN" id="twentyIN" class="inDeno"></td>
                                    <td><input type="text" name="twentyOUT" id="twentyOUT" class="outDeno"></td>
                                </tr>
                                <tr>
                                    <td align="left"><label>10 Note</label></td>
                                    <td><input type="text" readonly name="tenAvail" id="tenAvail" class="available" value="<%=odeno10%>"></td>
                                    <td><input type="text" name="tenIN" id="tenIN" class="inDeno"></td>
                                    <td><input type="text" name="tenOUT" id="tenOUT" class="outDeno"></td>
                                </tr>
                                <tr>
                                    <td align="left"><label>5 Note</label></td>
                                    <td><input type="text" readonly name="fiveAvail" id="fiveAvail" class="available" value="<%=odeno5%>"></td>
                                    <td><input type="text" name="fiveIN" id="fiveIN" class="inDeno"></td>
                                    <td><input type="text" name="fiveOUT" id="fiveOUT" class="outDeno"></td>
                                </tr>
                                <tr>
                                    <td align="left"><label>2 Note</label></td>
                                    <td><input type="text" readonly name="twoAvail" id="twoAvail" class="available" value="<%=odeno2%>"></td>
                                    <td><input type="text" name="twoIN" id="twoIN" class="inDeno"></td>
                                    <td><input type="text" name="twoOUT" id="twoOUT" class="outDeno"></td>
                                </tr>
                                <tr>
                                    <td align="left"><label>1 Note</label></td>
                                    <td><input type="text" readonly name="oneAvail" id="oneAvail" class="available" value="<%=odeno1%>"></td>
                                    <td><input type="text" name="oneIN" id="oneIN" class="inDeno"></td>
                                    <td><input type="text" name="oneOUT" id="oneOUT" class="outDeno"></td>
                                </tr>
                                <tr>
                                    <td align="left"><label>50 Paisa</label></td>
                                    <td><input type="text" readonly name="fiftyPaisaAvail" id="fiftyPaisaAvail" class="available" value="<%=odeno50P%>"></td>
                                    <td><input type="text" name="fiftyPaisaIN" id="fiftyPaisaIN" class="inDeno"></td>
                                    <td><input type="text" name="fiftyPaisaOUT" id="fiftyPaisaOUT" class="outDeno"></td>
                                </tr>
                                <tr>
                                    <td align="left"><label>1 Paisa</label></td>
                                    <td><input type="text" readonly name="onePaisaAvail" id="onePaisaAvail" class="available" value="<%=odeno1P%>"></td>
                                    <td><input type="text" name="onePaisaIN" id="onePaisaIN" class="inDeno"></td>
                                    <td><input type="text" name="onePaisaOUT" id="onePaisaOUT" class="outDeno"></td>
                                </tr>
                                <tr>
                                    <td colspan="2" align="left"><label>Total IN/OUT</label></td>

                                    <td><input type="text" readonly name="totalIN" id="totalIN" ></td>
                                    <td><input type="text" readonly name="totalOUT" id="totalOUT" ></td>
                                </tr>
                                <tr>
                                    <td><label>Cash Drawer Present Balance</label></td>
                                    <td><input type="text" readonly name="cashDRWBal" id="cashDRWBal" ></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td><label>Resulted Txn Amount</label></td>
                                    <td><input type="text" readonly name="resTXNAmt" id="resTXNAmt"></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                            </tbody>
                        </table>
                        <br>
                        <div align="center">
                            <input type="button" value="Ok" id="btnOK"><input type="button" value="Reset" id="btnReset"><input type="button" value="Close" id="closePopup">
                        </div>

                    </div>
                    <table>
                        <tr><td style="text-align:right;">Repay Type<font color="red" >*</font>:</td><td></td><td><select id="repayType" name="repayType"><option value=""> --select-- </option><option value="R">Repay Loan</option><option value="C">Loan Closure</option></select></td></tr>
                        <tr><td>Enter Loan Account<font color="red" >*</font>:</td><td></td><td><input type="text" maxlength="25" name="loanAcc" id="loanAcc" onchange="resetDetails()" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57'/><input type="button" value="Search" onclick="javascript:popup_LonAcc(1250, 180, document.RepayLoan.loanAcc.value,document.RepayLoan.repayType.value);"/></td></tr>
  
                    </table>
                    <input type="text" name="handle_id" id="handle_id" value="" style="display: none">
                    <br>
                    <div id="lonDetails" style="display: none">
                        <center>
                            <table>
                                <tbody>
                                    <tr>
                                        <td style="text-align:right;">Customer Name: </td>
                                        <td><input type="text" name="custName" id="custName" readonly/></td><td></td>
                                        <td style="text-align:right;">Sanction Amount: </td>
                                        <td><input type="text" name="sancAmt" id="sancAmt" readonly style="text-align:right;"/></td>
                                    </tr>
                                    <tr></tr>
                                    <tr>
                                        <td style="text-align:right;">Sanction Date: </td>
                                        <td><input type="text" name="sancDt" id="sancDt" readonly style="text-align:center;" /></td><td></td>
                                        <td style="text-align:right;">Last Repayment Date: </td>
                                        <td><input type="text" name="lstRepayDt" id="lstRepayDt" readonly style="text-align:center;" /></td>
                                    </tr>
                                    <tr></tr>
                                    <tr>
                                        <td>Outstanding Principle: </td>
                                        <td><input type="text" name="oustPrin" id="oustPrin" readonly style="text-align:right;" /></td><td></td>
                                        <td>Total Interest Outstanding: </td>
                                        <td><input type="text" name="oustInt" id="oustInt" readonly style="text-align:right;" /></td>
                                    </tr>
                                    <tr></tr>
                                    <tr>
                                        <td>Outstanding Balance: </td>
                                        <td><input type="text" name="oustBal" id="oustBal" readonly style="text-align:right;" /></td><td></td>
                                        <td style="text-align:right;">EMI: </td>
                                        <td><input type="text" name="emi" id="emi" readonly/></td>
                                    </tr>
                                    <tr><td colspan="5"><hr></td></tr>


                                </tbody>
                            </table>

                            <table>

                                <tr><td style="text-align:right;">Payment Mode<font color="red" >*</font>:</td><td  colspan="2" align="left"><select id="payMode" name="payMode">
                                            <option value="" disabled selected style="display: none">--select---</option>
                                            <option value="C">Cash/Cheque</option>
                                            <option value="T">Transfer</option>
                                            <option value="G">GL</option>
                                        </select></td></tr>
                                <tr id="memberCifRow" style="display: none">
                                <td>Member's Name</td>
                                <td><input type="text" name ="memberName" id="memberName" readonly/></td>
                                <td><input type="button" name="memberCifNo" id="memberCifNo" value="Search" onclick="javascript:popup_loanAccountMember(1250, 300,document.RepayLoan.cust_no.value);"</td>
                                </tr>
                                <tr class="DenoCanBAdded"><td align="left">Repayment Amount<font color="red" >*</font>:</td><td  colspan="2" align="left"><input type="text" maxlength="25" name="repayAmt" id="repayAmt" style="text-align:right;" onkeypress='return event.charCode >= 45 && event.charCode <= 57 && event.charCode != 46' /></td></tr>
                                <tr><td align="left">Interest Adjustment<font color="red" >*</font>:</td><td colspan="2" align="left"><input type="text" name="intAdjAmt" id="intAdjAmt" value="0" size="15" title="Negative amount increases interest" style="text-align:right;" onkeyup="javascript:checkAmt();" onkeypress='return event.charCode >= 45 && event.charCode <= 57 && event.charCode != 46' /></td></tr>

                                <tr id="transferAccount" style="display: none"><td>Transfer Account:</td><td><input type="text" maxlength="25" readonly name="transAcc" id="transAcc" style="text-align:right;" /><input type="button" value="Search" onclick="javascript:popup_TransferAcc(420, 180, document.RepayLoan.loanAcc.value);"/></td></tr>
                                <tr id="glAccount" style="display: none"><td>GL Account:</td><td><input type="text" maxlength="25" name="glAcc" id="glAcc" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /><input type="button" value="Search" onclick="javascript:popup_glAcc(420, 180, document.RepayLoan.glAcc.value);"/></td></tr>
                                <tr><td style="text-align:right;">Narration<font color="red" >*</font>:</td><td  colspan="2" align="left"><input type="text"  name="narration" id="narration"/></td></tr>
                                <input type="hidden" maxlength="25" name="closeAmt" id="closeAmt"/>
                                <input type="hidden" name="product_code" id="product_code" />
                                <input type="hidden" name="memberId" id="memberId" />
                                <input type="hidden" name="cust_no" id="cust_no" />
                                <input type="hidden" name="member_count" id="member_count" />
                            </table>
                            <br>

                        </center>

                    </div>
                    <input type="button" value="Submit" id="Submit" onclick="javascript:submitform(RepayLoan)"/>
                    <input type="button" value="Reset" id="Reset" onclick="ShowParent();" />
                </center>

                <input type="hidden" value="RepayLoan" name="screenName" />
                <input type="hidden" value="<%=status%>" name="status" id="status" />
            </form>

        </fieldset>
        <script>
            function check(v){
                if(isNaN(v) || v == '' || v.trim().length == 0){ return parseInt(0);}
                else { return v;}
            }

            var first = $('#twothouAvail').val();
            var second = $('#fivehundredAvail').val();
            var third = $('#hundredAvail').val();
            var fourth = $('#fiftyAvail').val();
            var fifth = $('#twentyAvail').val();
            var sixth = $('#tenAvail').val();
            var seventh = $('#fiveAvail').val();
            var eighth = $('#twoAvail').val();
            var ninth = $('#oneAvail').val();
            var eleventh = $('#fiftyPaisaAvail').val();
            var twelveth = $('#onePaisaAvail').val();
            var thirtinth = $('#twohundredAvail').val();


            $(document).ready(function() {
                $('#myform').find(':input.inDeno[type="text"],#totalIN,#totalOUT,#resTXNAmt').val('0');
                $('#myform').find(':input.outDeno[type="text"]').val('0');
                $('.inDeno,.outDeno').css({"background-color": "#FFFFC1"});
                $('#totalIN,#totalOUT').css({"background-color": "#ffff93"});
                $('#cashDRWBal,#resTXNAmt').css({"background-color": "#b2d0b2"});
            });

            var AvailsumOnLoad = 0;
            var DenoINsumOnLoad = 0;

            AvailsumOnLoad = parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(parseInt(check($('#fiftyPaisaAvail').val())) * 0.50) + parseFloat(parseInt(check($('#onePaisaAvail').val())) * 0.01);
            $("#cashDRWBal").val(AvailsumOnLoad);
            var tenth = $('#cashDRWBal').val();//calculating present cash drawer value for first time

            $( "#btnReset" ).click(function() {
                $('#myform').find(':input.inDeno[type="text"],:input.outDeno[type="text"]').val('0');
                $("#totalIN").val('0');
                $("#totalOUT").val('0');
                $('#twothouAvail').val(first);
                $('#fivehundredAvail').val(second);
                $('#hundredAvail').val(third);
                $('#fiftyAvail').val(fourth);
                $('#twentyAvail').val(fifth);
                $('#tenAvail').val(sixth);
                $('#fiveAvail').val(seventh);
                $('#twoAvail').val(eighth);
                $('#oneAvail').val(ninth);
                $('#fiftyPaisaAvail').val(eleventh);
                $('#onePaisaAvail').val(twelveth);
                $("#cashDRWBal").val(tenth);
                $('#resTXNAmt').val('0');
                $('#twohundredAvail').val(thirtinth);

                if ($('.DenoCanBAdded').find('img').length > 0){
                    $('.DenoAdded').remove();
                }
            });

            //make all inputs whole numbers only
            $('.dialog').on('keydown',':input[type="text"]', function(event) {
                if (event.shiftKey == true) {
                    event.preventDefault();
                }

                if ((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105) || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 37 || event.keyCode == 39 || event.keyCode == 46) {

                } else {
                    event.preventDefault();
                }
            });

            //calculating IN & OUT Total,and Resultant final Amount
            $('#myform').on("keyup", ".inDeno,.outDeno", function() {
                var DenoINsumOnChange = 0;
                var DenoOUTsumOnChange = 0;
                DenoINsumOnChange = parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01);
                $("#totalIN").val(DenoINsumOnChange);
                DenoOUTsumOnChange = parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500  + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val()) * 0.01);
                $("#totalOUT").val(DenoOUTsumOnChange);
                $('#resTXNAmt').val(parseInt(check($('#totalIN').val())) - parseInt(check($('#totalOUT').val())));
            });

            //for Rs 2000 starts
            $('#myform').on("keyup", "#twothouOUT", function() {
                if(parseInt($("#twothouAvail").val())<= 0)
                {
                    alert("Insufficiernt Rs.2000 Notes");
                    $('#btnReset').click();
                }
                else{
                    $('#twothouAvail').val(parseInt(check(first)) + (parseInt(check($('#twothouIN').val())) - parseInt(check($('#twothouOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));
                }
            });
            $('#myform').on("change", "#twothouOUT", function() {
                if(parseInt(first)< parseInt(check($('#twothouOUT').val()))){
                    alert("Insufficient Denomination !!!");
                    $('#btnReset').click();
                }
            });
            $('#myform').on("keyup", "#twothouIN", function() {

                    $('#twothouAvail').val(parseInt(check(first)) + (parseInt(check($('#twothouIN').val())) - parseInt(check($('#twothouOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));

            });

            //for Rs 500 starts
            $('#myform').on("keyup", "#fivehundredOUT", function() {
                if(parseInt($("#fivehundredAvail").val())<= 0)
                {
                    alert("Insufficiernt Rs.500 Notes");
                    $('#btnReset').click();
                }
                else{
                    $('#fivehundredAvail').val(parseInt(check(second)) + (parseInt(check($('#fivehundredIN').val())) - parseInt(check($('#fivehundredOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));
                }
            });
            $('#myform').on("change", "#fivehundredOUT", function() {
                if(parseInt(second)< parseInt(check($('#fivehundredOUT').val()))){
                    alert("Insufficient Denomination !!!");
                    $('#btnReset').click();
                }
            });
            $('#myform').on("keyup", "#fivehundredIN", function() {

                    $('#fivehundredAvail').val(parseInt(check(second)) + (parseInt(check($('#fivehundredIN').val())) - parseInt(check($('#fivehundredOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));

            });

            //for Rs 200 starts
            $('#myform').on("keyup", "#twohundredOUT", function() {
                if(parseInt($("#twohundredAvail").val())<= 0)
                {
                    alert("Insufficiernt Rs.200 Notes");
                    $('#btnReset').click();
                }
                else{
                    $('#twohundredAvail').val(parseInt(check(thirtinth)) + (parseInt(check($('#twohundredIN').val())) - parseInt(check($('#twohundredOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));
                }
            });
            $('#myform').on("change", "#twohundredOUT", function() {
                if(parseInt(thirtinth)< parseInt(check($('#twohundredOUT').val()))){
                    alert("Insufficient Denomination !!!");
                    $('#btnReset').click();
                }
            });
            $('#myform').on("keyup", "#twohundredIN", function() {

                    $('#twohundredAvail').val(parseInt(check(thirtinth)) + (parseInt(check($('#twohundredIN').val())) - parseInt(check($('#twohundredOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));

            });

            //for Rs 100 starts
            $('#myform').on("keyup", "#hundredOUT", function() {
                if(parseInt($("#hundredAvail").val())<= 0)
                {
                    alert("Insufficiernt Rs.100 Notes");
                    $('#btnReset').click();
                }
                else{
                    $('#hundredAvail').val(parseInt(check(third)) + (parseInt(check($('#hundredIN').val())) - parseInt(check($('#hundredOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));
                }
            });
            $('#myform').on("change", "#hundredOUT", function() {
                if(parseInt(third)< parseInt(check($('#hundredOUT').val()))){
                    alert("Insufficient Denomination !!!");
                    $('#btnReset').click();
                }
            });
            $('#myform').on("keyup", "#hundredIN", function() {

                    $('#hundredAvail').val(parseInt(check(third)) + (parseInt(check($('#hundredIN').val())) - parseInt(check($('#hundredOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));

            });


            //for Rs 50 starts
            $('#myform').on("keyup", "#fiftyOUT", function() {
                if(parseInt($("#fiftyAvail").val())<= 0)
                {
                    alert("Insufficiernt Rs.50 Notes");
                    $('#btnReset').click();
                }
                else{
                    $('#fiftyAvail').val(parseInt(check(fourth)) + (parseInt(check($('#fiftyIN').val())) - parseInt(check($('#fiftyOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));
                }
            });
            $('#myform').on("change", "#fiftyOUT", function() {
                if(parseInt(fourth)< parseInt(check($('#fiftyOUT').val()))){
                    alert("Insufficient Denomination !!!");
                    $('#btnReset').click();
                }
            });
            $('#myform').on("keyup", "#fiftyIN", function() {

                    $('#fiftyAvail').val(parseInt(check(fourth)) + (parseInt(check($('#fiftyIN').val())) - parseInt(check($('#fiftyOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));

            });

            //for Rs 20 starts
            $('#myform').on("keyup", "#twentyOUT", function() {
                if(parseInt($("#twentyAvail").val())<= 0)
                {
                    alert("Insufficiernt Rs.20 Notes");
                    $('#btnReset').click();
                }
                else{
                    $('#twentyAvail').val(parseInt(check(fifth)) + (parseInt(check($('#twentyIN').val())) - parseInt(check($('#twentyOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));
                }
            });
            $('#myform').on("change", "#twentyOUT", function() {
                if(parseInt(fifth)< parseInt(check($('#twentyOUT').val()))){
                    alert("Insufficient Denomination !!!");
                    $('#btnReset').click();
                }
            });
            $('#myform').on("keyup", "#twentyIN", function() {

                    $('#twentyAvail').val(parseInt(check(fifth)) + (parseInt(check($('#twentyIN').val())) - parseInt(check($('#twentyOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));

            });

            //for Rs 10 starts
            $('#myform').on("keyup", "#tenOUT", function() {
                if(parseInt($("#tenAvail").val())<= 0)
                {
                    alert("Insufficiernt Rs.10 Notes");
                    $('#btnReset').click();
                }
                else{
                    $('#tenAvail').val(parseInt(check(sixth)) + (parseInt(check($('#tenIN').val())) - parseInt(check($('#tenOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));
                }
            });
            $('#myform').on("change", "#tenOUT", function() {
                if(parseInt(sixth)< parseInt(check($('#tenOUT').val()))){
                    alert("Insufficient Denomination !!!");
                    $('#btnReset').click();
                }
            });
            $('#myform').on("keyup", "#tenIN", function() {

                    $('#tenAvail').val(parseInt(check(sixth)) + (parseInt(check($('#tenIN').val())) - parseInt(check($('#tenOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));

            });


            //for Rs 5 starts
            $('#myform').on("keyup", "#fiveOUT", function() {
                if(parseInt($("#fiveAvail").val())<= 0)
                {
                    alert("Insufficiernt Rs.5 Notes");
                    $('#btnReset').click();
                }
                else{
                    $('#fiveAvail').val(parseInt(check(seventh)) + (parseInt(check($('#fiveIN').val())) - parseInt(check($('#fiveOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));
                }
            });
            $('#myform').on("change", "#fiveOUT", function() {
                if(parseInt(seventh)< parseInt(check($('#fiveOUT').val()))){
                    alert("Insufficient Denomination !!!");
                    $('#btnReset').click();
                }
            });
            $('#myform').on("keyup", "#fiveIN", function() {

                    $('#fiveAvail').val(parseInt(check(seventh)) + (parseInt(check($('#fiveIN').val())) - parseInt(check($('#fiveOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));

            });


            //for Rs 2 starts
            $('#myform').on("keyup", "#twoOUT", function() {
                if(parseInt($("#twoAvail").val())<= 0)
                {
                    alert("Insufficiernt Rs.2 Notes");
                    $('#btnReset').click();
                }
                else{
                    $('#twoAvail').val(parseInt(check(eighth)) + (parseInt(check($('#twoIN').val())) - parseInt(check($('#twoOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));
                }
            });
            $('#myform').on("change", "#twoOUT", function() {
                if(parseInt(eighth)< parseInt(check($('#twoOUT').val()))){
                    alert("Insufficient Denomination !!!");
                    $('#btnReset').click();
                }
            });
            $('#myform').on("keyup", "#twoIN", function() {

                    $('#twoAvail').val(parseInt(check(eighth)) + (parseInt(check($('#twoIN').val())) - parseInt(check($('#twoOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));

            });


            //for Rs 1 starts
            $('#myform').on("keyup", "#oneOUT", function() {
                if(parseInt($("#oneAvail").val())<= 0)
                {
                    alert("Insufficiernt Rs.1 Notes");
                    $('#btnReset').click();
                }
                else{
                    $('#oneAvail').val(parseInt(check(ninth)) + (parseInt(check($('#oneIN').val())) - parseInt(check($('#oneOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));
                }
            });
            $('#myform').on("change", "#oneOUT", function() {
                if(parseInt(ninth)< parseInt(check($('#oneOUT').val()))){
                    alert("Insufficient Denomination !!!");
                    $('#btnReset').click();
                }
            });
            $('#myform').on("keyup", "#oneIN", function() {

                    $('#oneAvail').val(parseInt(check(ninth)) + (parseInt(check($('#oneIN').val())) - parseInt(check($('#oneOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));

            });

            //for 50 Paisa starts
            $('#myform').on("keyup", "#fiftyPaisaOUT", function() {
                if(parseInt($("#fiftyPaisaAvail").val())<= 0)
                {
                    alert("Insufficiernt 50 Paisa");
                    $('#btnReset').click();
                }
                else{
                    $('#fiftyPaisaAvail').val(parseInt(check(eleventh)) + (parseInt(check($('#fiftyPaisaIN').val())) - parseInt(check($('#fiftyPaisaOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));
                }
            });
            $('#myform').on("change", "#fiftyPaisaOUT", function() {
                if(parseInt(eleventh)< parseInt(check($('#fiftyPaisaOUT').val()))){
                    alert("Insufficient Denomination !!!");
                    $('#btnReset').click();
                }
            });
            $('#myform').on("keyup", "#fiftyPaisaIN", function() {

                    $('#fiftyPaisaAvail').val(parseInt(check(eleventh)) + (parseInt(check($('#fiftyPaisaIN').val())) - parseInt(check($('#oneOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));

            });

            //for 1 Paisa starts
            $('#myform').on("keyup", "#onePaisaOUT", function() {
                if(parseInt($("#onePaisaAvail").val())<= 0)
                {
                    alert("Insufficiernt 1 Paisa");
                    $('#btnReset').click();
                }
                else{
                    $('#onePaisaAvail').val(parseInt(check(twelveth)) + (parseInt(check($('#onePaisaIN').val())) - parseInt(check($('#onePaisaOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));
                }
            });
            $('#myform').on("change", "#onePaisaOUT", function() {
                if(parseInt(twelveth)< parseInt(check($('#onePaisaOUT').val()))){
                    alert("Insufficient Denomination !!!");
                    $('#btnReset').click();
                }
            });
            $('#myform').on("keyup", "#onePaisaIN", function() {

                    $('#onePaisaAvail').val(parseInt(check(twelveth)) + (parseInt(check($('#onePaisaIN').val())) - parseInt(check($('#onePaisaOUT').val()))));
                    $("#totalOUT").val(parseInt(check($('#twothouOUT').val())) * 2000 + parseInt(check($('#fivehundredOUT').val())) * 500 + parseInt(check($('#twohundredOUT').val())) * 200 + parseInt(check($('#hundredOUT').val())) * 100 + parseInt(check($('#fiftyOUT').val())) * 50 + parseInt(check($('#twentyOUT').val())) * 20 + parseInt(check($('#tenOUT').val())) * 10 + parseInt(check($('#fiveOUT').val())) * 5 + parseInt(check($('#twoOUT').val())) * 2 + parseInt(check($('#oneOUT').val())) + parseFloat(check($('#fiftyPaisaOUT').val()) * 0.50) + parseFloat(check($('#onePaisaOUT').val())* 0.01));
                    $('#totalIN').val(parseInt(check($('#twothouIN').val())) * 2000 + parseInt(check($('#fivehundredIN').val())) * 500 + parseInt(check($('#twohundredIN').val())) * 200 + parseInt(check($('#hundredIN').val())) * 100 + parseInt(check($('#fiftyIN').val())) * 50 + parseInt(check($('#twentyIN').val())) * 20 + parseInt(check($('#tenIN').val())) * 10 + parseInt(check($('#fiveIN').val())) * 5 + parseInt(check($('#twoIN').val())) * 2 + parseInt(check($('#oneIN').val())) + parseFloat(check($('#fiftyPaisaIN').val()) * 0.50) + parseFloat(check($('#onePaisaIN').val()) * 0.01));
                    $("#cashDRWBal").val(parseInt(check($('#twothouAvail').val()) * 2000) + parseInt(check($('#fivehundredAvail').val()) * 500) + parseInt(check($('#twohundredAvail').val()) * 200) + parseInt(check($('#hundredAvail').val()) * 100)+ parseInt(check($('#fiftyAvail').val()) * 50)+ parseInt(check($('#twentyAvail').val()) * 20)+ parseInt(check($('#tenAvail').val()) * 10)+ parseInt(check($('#fiveAvail').val()) * 5)+ parseInt(check($('#twoAvail').val()) * 2)+ parseInt(check($('#oneAvail').val()) * 1) + parseFloat(check($('#fiftyPaisaAvail').val()) * 0.50) + parseFloat(check($('#onePaisaAvail').val()) * 0.01));
                    $('#resTXNAmt').val(Number(check($('#totalIN').val())) - Number(check($('#totalOUT').val())));

            });


            //Reset transaction amout when OK button clicks
            $('#btnOK').click(function(){
                var amount = $('#resTXNAmt').val();
                var repayAmt = $('#repayAmt').val();
                var flag = 0;

                if(Number(amount) <= 0){
                    alert("Resultant amount cannot be lesser than or equal to zero when loan repay is performed!!! ");
                    flag = 1;
                }

                /*if(Number(repayAmt) != Number(amount)) {
                    alert("Resultant amount should match the repay amount");
                    flag = 1;
                }*/

                if(parseInt(flag) == 0){

                    $("#myform").hide(400);
                    $("#repayAmt").val(amount);
                    if ($('.DenoCanBAdded').find('img').length == 0 )
                    {
                        $('.DenoCanBAdded').append('<span class="DenoAdded" style="padding-right:3px; padding-top: 3px; padding-left: 5px; display:inline-block;"><img class="manImg" src="${pageContext.request.contextPath}/img/check.png" width="15" height="20"/>Denomination added</span>');

                    }
                }
            });
            $('#closePopup').click(function(){
                $( "#btnReset" ).click();
                $("#myform").hide(400);
            });
        </script>
    </body>
</html>
<% 	} catch (Exception e) {
               
            }
%>