<%--
    Document   : borrowing_creation
    Created on : Dec 13, 2017, 4:43:29 PM
    Author     : 1027350
--%>


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


<%@page import="java.util.UUID" %>
<%String uuid = UUID.randomUUID().toString();%>
<% try {
%>


<html>
    <head>

        <title>Borrowing Creation</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script src="${pageContext.request.contextPath}/js/Calendar.js?pacs=<%=((new java.util.Date()).getTime())%>"></script>
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/TableCSSCode.css?pacs=<%=((new java.util.Date()).getTime())%>" />
        <link rel="shortcut icon" href="${pageContext.request.contextPath}/img/favicon.ico?pacs=<%=((new java.util.Date()).getTime())%>" type="image/x-icon" />
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <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>
            #image-holder{
                position: absolute;
                top:265;
                right: 425;
                left: 550;
                bottom:376;
                width: auto;

            }

        </style>
        <script type="text/javascript">
            (function($) {
                $.fn.ajaxfileupload = function(options) {
                    var settings = {
                        params: {},
                        action: '',
                        onStart: function() { },
                        onComplete: function(response) { },
                        onCancel: function() { },
                        validate_extensions : true,
                        valid_extensions : ['jpg'],
                        submit_button : null
                    };

                    var uploading_file = false;

                    if ( options ) {
                        $.extend( settings, options );
                    }


                    // 'this' is a jQuery collection of one or more (hopefully)
                    //  file elements, but doesn't check for this yet
                    return this.each(function() {
                        var $element = $(this);

                        // Skip elements that are already setup. May replace this
                        //  with uninit() later, to allow updating that settings
                        if($element.data('ajaxUploader-setup') === true) return;

                        $element.change(function()
                        {
                            // since a new image was selected, reset the marker
                            uploading_file = false;

                            // only update the file from here if we haven't assigned a submit button
                            if (settings.submit_button == null)
                            {
                                upload_file();
                            }
                        });

                        if (settings.submit_button == null)
                        {
                            // do nothing
                        } else
                        {
                            settings.submit_button.click(function(e)
                            {
                                // Prevent non-AJAXy submit
                                e.preventDefault();

                                // only attempt to upload file if we're not uploading
                                if (!uploading_file)
                                {
                                    upload_file();
                                }
                            });
                        }

                        var upload_file = function()
                        {
                            if($element.val() == '') return settings.onCancel.apply($element, [settings.params]);

                            // make sure extension is valid
                            var ext = $element.val().split('.').pop().toLowerCase();
                            if(true === settings.validate_extensions && $.inArray(ext, settings.valid_extensions) == -1)
                            {
                                // Pass back to the user
                                settings.onComplete.apply($element, [{status: false, message: 'The select file type is invalid. File must be ' + settings.valid_extensions.join(', ') + '.'}, settings.params]);
                            } else
                            {
                                uploading_file = true;

                                // Creates the form, extra inputs and iframe used to
                                //  submit / upload the file
                                wrapElement($element);

                                // Call user-supplied (or default) onStart(), setting
                                //  it's this context to the file DOM element
                                var ret = settings.onStart.apply($element, [settings.params]);

                                // let onStart have the option to cancel the upload
                                if(ret !== false)
                                {
                                    $element.parent('form').submit(function(e) { e.stopPropagation(); }).submit();
                                } else {
                                    uploading_file = false;
                                }
                            }
                        };

                        // Mark this element as setup
                        $element.data('ajaxUploader-setup', true);

                        /*
          // Internal handler that tries to parse the response
          //  and clean up after ourselves.
                         */
                        var handleResponse = function(loadedFrame, element) {
                            var response, responseStr = $(loadedFrame).contents().text();
                            try {
                                //response = $.parseJSON($.trim(responseStr));
                                response = JSON.parse(responseStr);
                            } catch(e) {
                                response = responseStr;
                            }

                            // Tear-down the wrapper form
                            element.siblings().remove();
                            element.unwrap();

                            uploading_file = false;

                            // Pass back to the user
                            settings.onComplete.apply(element, [ {
                                    status : true,
                                    message : 'Your file has been uploaded!'
                                }, settings.params ]);
                        };

                        /*
          // Wraps element in a <form> tag, and inserts hidden inputs for each
          //  key:value pair in settings.params so they can be sent along with
          //  the upload. Then, creates an iframe that the whole thing is
          //  uploaded through.
                         */
                        var wrapElement = function(element) {
                            // Create an iframe to submit through, using a semi-unique ID
                            var frame_id = 'ajaxUploader-iframe-' + Math.round(new Date().getTime() / 1000)
                            $('body').after('<iframe width="0" height="0" style="display:none;" name="'+frame_id+'" id="'+frame_id+'"/>');
                            $('#'+frame_id).get(0).onload = function() {
                                handleResponse(this, element);
                            };

                            // Wrap it in a form
                            element.wrap(function() {
                                return '<form action="' + settings.action + '" method="POST" enctype="multipart/form-data" target="'+frame_id+'" />'
                            })
                            // Insert <input type='hidden'>'s for each param
                            .before(function() {
                                var key, html = '';
                                for(key in settings.params) {
                                    var paramVal = settings.params[key];
                                    if (typeof paramVal === 'function') {
                                        paramVal = paramVal();
                                    }
                                    html += '<input type="hidden" name="' + key + '" value="' + paramVal + '" />';
                                }
                                return html;
                            });
                        }
                    });
                }
            })( jQuery )
        </script>
        <script lang="Javascript">
            $(document).ready(function() {
                $('#file').ajaxfileupload({
                    'action' : '/PacsApplication/UploadFile',
                    'onComplete' : function(response) {
                        $('#upload').hide();
                        $('#message').show();

                        var statusVal = JSON.stringify(response.status);

                        if(statusVal == "false")
                        {
                            $("#message").html("<font color='red'>"+JSON.stringify(response.message)+"</font>");
                        }
                        if(statusVal == "true")
                        {
                            $("#message").html("<font color='green'>"+JSON.stringify(response.message)+"</font>");
                        }
                    },
                    'onStart' : function() {
                        $('#upload').show();
                        $('#message').hide();
                    }
                });
                $('#sigUpld').ajaxfileupload({
                    'action' : '/PacsApplication/SigUploadFile',
                    'onComplete' : function(response) {
                        $('#sigupload').hide();
                        $('#sigmessage').show();

                        var statusVal = JSON.stringify(response.status);

                        if(statusVal == "false")
                        {
                            $("#sigmessage").html("<font color='red'>"+JSON.stringify(response.message)+"</font>");
                        }
                        if(statusVal == "true")
                        {
                            $("#sigmessage").html("<font color='green'>"+JSON.stringify(response.message)+"</font>");
                        }
                    },
                    'onStart' : function() {
                        $('#sigupload').show();
                        $('#sigmessage').hide();
                    }
                });
            });
        </script>
    </head>
    <body  onload="noBack()">
        <script type="text/javascript">
            function noBack()
            {
                window.history.forward();
            }

            function checkDuplicateID(){
                var arr = [];
                $("#order-list tbody tr").each(function(){
                    arr.push($(this).find("td:nth-child(5) input").val());

                });

                for (var i = 0; i < arr.length; i++)
                {
                    for (var j = 0; j < arr.length; j++)
                    {
                        if (i != j)
                        {
                            if (arr[i] == arr[j])
                            {
                                alert("Please do not repeat ID Number.");
                                return false;
                            }
                        }
                    }
                }

                arr = [];
                return true;
            }

            function checkOp()
            {

                //alert("IN");
                if(document.getElementById("opt").value=="create")
                {
                    document.getElementById("create").style.display='block';
                    document.getElementById("amend").style.display='none';
                }
                else
                {
                    document.getElementById("create").style.display='none';
                    document.getElementById("amend").style.display='block';
                    document.getElementById("amendSearch").style.display='table-row';

                }
            }

            function searchGL(width, height,x)
            {
                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 = "Borrowing_Creation.jsp";
                var  lovKey=    "searchGl";
                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey+'&acNo='+x , 'GLSearch', attr);
                popWin.focus();
            }


            function searchGLAmend(width, height,x)
            {
                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 = "borrowing_Creation.jsp";
                var  lovKey=    "searchGlAmend";
                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey+'&acNo='+x , 'GLSearch', attr);
                popWin.focus();
            }

            function searchBank(width, height,i,rowval)
            {
                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 = "Borrowing_Creation.jsp";
                var  lovKey=    "searchBank";
                var b = document.getElementById("bankName"+rowval).value;
                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey+'&index='+i+'&bank='+b, 'GLSearch', attr);
                popWin.focus();
            }

            function searchBankAmend(width, height,i,rowval)
            {
                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 = "Borrowing_Creation.jsp";
                var  lovKey=    "searchBankAmend";
                var b = document.getElementById("bankNameAmend"+rowval).value;
                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey+'&index='+i+'&bank='+b, 'GLSearch', attr);
                popWin.focus();
            }

            function numbersonly(txt,e){

                    var unicode=e.charCode? e.charCode : e.keyCode
                if(unicode==46)
                {if (txt.value.indexOf('.') === -1) {
                        return true;
                    } else {
                        return false;
                    }
                } else if(unicode!=8){
                    //if the key isn't the backspace key (which we should allow)
                            if (unicode<48||unicode>57) //if not a number
                                    return false ;//disable key press
                    }
            }

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

        </script>


        <%
             String ModuleName = new String();

             ModuleName = (String) session.getAttribute("moduleName");
        %>

        <%if (ModuleName.equalsIgnoreCase("Deposit")) {%>
        <jsp:include page="/Deposit/MenuHead_Deposit.jsp" flush="true" />
        <%} else if (ModuleName.equalsIgnoreCase("Loan")) {%>
        <jsp:include page="/Loan/MenuHead_Loan.jsp" flush="true" />
        <%}else if (ModuleName.equalsIgnoreCase("SpecialBothKcc")) {%>
        <jsp:include page="/MenuHead.jsp" flush="true" />
        <%}else if (ModuleName.equalsIgnoreCase("SpecialBothDep")) {%>
        <jsp:include page="/Deposit/MenuHead_Deposit.jsp" flush="true" />
        <%}else if (ModuleName.equalsIgnoreCase("SpecialBoth")) {%>
        <jsp:include page="/Deposit/MenuHead_Deposit.jsp" flush="true" />
        <%}%>
        <br>

        <%
             int count = 1;
             String error_msg = "";
             Object error = request.getAttribute("message");
             if (error != null) {
                 error_msg = error.toString();
             }
             String sysDt = new String();
             Connection connection = null;
             ResultSet rs = null;
             Statement statement = null;
             connection = DbHandler.getDBConnection();
             try {
                 statement = connection.createStatement();
                 rs = statement.executeQuery("select to_char(SYSTEM_DATE,'DD/MM/YYYY') from system_date");
                 while (rs.next()) {
                     sysDt = rs.getString(1);
                 }
                // 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.");
            }

            }
        %>

        <%
             String displayFlag = "";
             Object display = request.getAttribute("displayFlag");
             if (display != null) {
                 displayFlag = display.toString();
             }
        %>
        <%!
            String blankNull(String s) {
                return (s == null) ? "" : s;
            }
        %>
        <%
             String gl_number = "";
             String bal = "";
             String op = "";
             Object alInvestmentCreationBeanObj = request.getAttribute("oborrowingCreationBeanObj");
             ArrayList<BorrowingCreationBean> alBorrowingCreationDetailBean2 = new ArrayList<BorrowingCreationBean>();
             if (alInvestmentCreationBeanObj != null) {
                 alBorrowingCreationDetailBean2 = (ArrayList<BorrowingCreationBean>) request.getAttribute("alBorrowingCreationDetailBean2");
                 gl_number = request.getAttribute("GL_Account").toString();
                 bal = request.getAttribute("balance").toString();
                 op = request.getAttribute("Option").toString();

             }
        %>



        <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">Borrowing Creation</legend>
            <form action="" method="post" name="borrowingCreateForm">

                <br>

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

                <div>
                    <center>
                        <table>
                            <tr>
                                <td>Select Option: </td>
                                <td><select id="opt" name="opt" onchange="checkOp()">
                                        <option value="Not" selected disabled> --Select-- </option>
                                        <option value="create">Create</option>
                                        <option value="amend"<%if (displayFlag == "Y") {
                                                 if (op.equalsIgnoreCase("Amend")) {%>selected<%}
                                                      }%>>Amend</option>
                                    </select></td>

                            </tr>
                        </table>
                    </center>
                </div>

                <div id="create" align="left" style="display: none">
                    <center>
                        <table>
                            <tbody>
                                <tr>
                                    <td>GL Account<font color="red" >*</font>: </td>
                                    <td><input type="text" name="glName" id="glName" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /></td>
                                    <td><input type="button" id="gl_btn" name="gl_btn" value="Search" onclick="javascript:searchGL(220,180,document.getElementById('glName').value)"/></td>
                                </tr>
                                <tr>
                                    <td>Balance: </td>
                                    <td><input type="text" name="glBal" id="glBal" readonly style="text-align:right;" /></td>
                                </tr>

                            </tbody>
                        </table>
                    </center>
                    <center>
                        <table id="order-list" border="2" width="auto" cellspacing="1" cellpadding="1" style="text-align: center ;overflow-y: scroll; font-size: 15px">
                            <thead class="CSSTableGenerator" >
                                <tr>
                                    <td></td>
                                    <td colspan="2">Bank Name</td>
                                    <td>Branch Name</td>
                                    <td>A/c Number</td>
                                    <td>Amount</td>
                                    <td>Interest Rate</td>
                                    <td>OD Interest Rate</td>
                                    <td colspan="2">A/c Open Date</td>
                                    <td colspan="2">Overdue Date</td>
                                    <td>Active</td>

                                </tr>
                            </thead>
                            <tbody>
                                <tr class="tRow">
                                    <td><input type="checkbox" name="chckbox<%=count%>" id="chckbox<%=count%>" name="chckbox<%=count%>" onclick="checkboxTrue(<%=count%>);" /></td>
                                    <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" name="bankName<%=count%>" id="bankName<%=count%>"/></td>
                                    <td><input  type="button" name="bankNameBtn<%=count%>" id="bankNameBtn<%=count%>" value="Search" onclick="javascript:searchBank(220,180,<%=count%>,<%=count%>)"/></td>
                                    <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" name="branchName<%=count%>" id="branchName<%=count%>" readonly/></td>
                                    <td><input  type="text"  style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" name="accountNo<%=count%>" id="accountNo<%=count%>" onKeyPress="return numbersonly(this, event)"/></td>
                                    <td><input  type="text"  style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" name="amount<%=count%>" id="amount<%=count%>" onKeyPress="return numbersonly(this, event)"/></td>
                                    <td><input  type="text"  style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" name="interestRate<%=count%>" id="interestRate<%=count%>" onKeyPress="return numbersonly(this, event)"/></td>
                                    <td><input  type="text"  style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" name="odInterestRate<%=count%>" id="odInterestRate<%=count%>" onKeyPress="return numbersonly(this, event)"/></td>
                                    <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" name="acOpenDate<%=count%>" id="acOpenDate<%=count%>" size="8" readonly/></td>
                                    <td><a href="#" onclick="return getCalendar(document.forms[0].acOpenDate<%=count%>);"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" style="display:block;"  height="100%" width="20" /></a></td>
                                    <td><input type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" size="8" id="acOvdDate<%=count%>" name="acOvdDate<%=count%>" readonly="true"></td>
                                    <td><a href="#" onclick="return getCalendar(document.forms[0].acOvdDate<%=count%>);"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" style="display:block;"  height="100%" width="20" /></a></td>
                                    <td><select id="active<%=count%>" name="active<%=count%>"><option value="" selected disabled>--Select--</option><option value="Yes">Yes</option><option value="No">No</option></select></td>
                                    <td style="display:none;"><input type="hidden"  name="document_mst_id<%=count%>" id="document_mst_id<%=count%>"/></td>

                                </tr>
                            </tbody>
                        </table>
                    </center>
                    <center>
                        <table >
                            <tr><td></td></tr>
                            <tr><td></td></tr>
                            <tr><td></td></tr>
                            <tr><td></td></tr>
                        </table></center>
                    <br><br><br>
                    <center>
                        <table>
                            <tr>
                                <td><input type="button" id="addRow" value="Add Row"/></td>
                                <td><input type="button" id="deleteRow" value="Delete Row"/></td>
                                <td><input type="button" value="Submit" onclick="javascript:submitform(borrowingCreateForm)"></td>
                                <td><input type="button" value="Reset" onclick="ShowParent();" /></td>
                            </tr>
                        </table>
                    </center>
                    <br>

                </div>

                <div id="amend" align="left" style="display: none">
                    <center>
                        <table>
                            <tbody>
                                <tr>
                                    <td>GL Account<font color="red" >*</font>: </td>
                                    <td><input type="text" name="glNameAmend" id="glNameAmend" <%if (displayFlag == "Y") {%>value="<%=blankNull(gl_number)%>"<%}%> style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /></td>
                                    <td><input type="button" id="gl_btnAmend" name="gl_btnAmend" value="Search" onclick="javascript:searchGLAmend(220,180,document.getElementById('glNameAmend').value)"/></td>
                                </tr>
                                <tr>
                                    <td>Balance: </td>
                                    <td><input type="text" name="glBalAmend" id="glBalAmend"  <%if (displayFlag == "Y") {%>value="<%=blankNull(bal)%>"<%}%> readonly style="text-align:right;" /></td>
                                </tr>

                                <%if (displayFlag == "") {%>
                                <tr id="amendSearch" style="display: none">
                                    <td></td>
                                    <td>
                                        <input type="button" id="searchAmend" name="searchAmend" value="Submit" onclick="javascript:fetchform(borrowingCreateForm)" />
                                    </td>
                                </tr>
                                <%}%>

                            </tbody>
                        </table>
                    </center>
                    <center>

                        <%if (displayFlag == "Y") {%>
                        <table id="order-list2" border="2" width="auto" cellspacing="1" cellpadding="1" style="text-align: center ;overflow-y: scroll; font-size: 15px">
                            <thead class="CSSTableGenerator" >
                                <tr>
                                    <td></td>
                                    <td colspan="2">Bank Name</td>
                                    <td>Branch Name</td>
                                    <td>A/c Number</td>
                                    <td>Amount</td>
                                    <td>Interest Rate</td>
                                    <td>OD Interest Rate</td>
                                    <td colspan="2">A/c Open Date</td>
                                    <td colspan="2">Overdue Date</td>
                                    <td>Active</td>

                                </tr>
                            </thead>

                            <%
                                BorrowingCreationBean oborrowingCreationBean = new BorrowingCreationBean();
                                count = 0;

                                for (int i = 0; i < alBorrowingCreationDetailBean2.size(); i++) {
                                    oborrowingCreationBean = alBorrowingCreationDetailBean2.get(i);
                                    count++;
                            %>

                            <tbody>
                                <tr class="tRow">
                                    <td><input type="checkbox" name="chckboxAmend<%=count%>" id="chckboxAmend<%=count%>" onclick="checkboxAmendTrue(<%=count%>);"  /></td>
                                    <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" name="bankNameAmend<%=count%>" id="bankNameAmend<%=count%>" value="<%=blankNull(oborrowingCreationBean.getBank_name())%>" readonly /></td>
                                    <td><input  type="button" name="bankNameAmendBtn<%=count%>" id="bankNameAmendBtn<%=count%>" value="Search" onclick="javascript:searchBankAmend(220,180,<%=count%>,<%=count%>)" disabled/></td>
                                    <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" name="branchNameAmend<%=count%>" id="branchNameAmend<%=count%>" value="<%=blankNull(oborrowingCreationBean.getBranch_name())%>" readonly /></td>
                                    <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" name="accountNoAmend<%=count%>" id="accountNoAmend<%=count%>" onKeyPress="return numbersonly(this, event)" value="<%=blankNull(oborrowingCreationBean.getAcno())%>" readonly/></td>
                                    <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" name="amountAmend<%=count%>" id="amountAmend<%=count%>" onKeyPress="return numbersonly(this, event)" value="<%=blankNull(oborrowingCreationBean.getAmt())%>"/></td>
                                    <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" name="interestRateAmend<%=count%>" id="interestRateAmend<%=count%>" onKeyPress="return numbersonly(this, event)" value="<%=blankNull(oborrowingCreationBean.getInt_rate())%>"/></td>
                                    <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" name="odInterestRateAmend<%=count%>" id="odInterestRateAmend<%=count%>" onKeyPress="return numbersonly(this, event)" value="<%=blankNull(oborrowingCreationBean.getOd_int_rate())%>"/></td>
                                    <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" name="acOpenDateAmend<%=count%>" id="acOpenDateAmend<%=count%>" size="8" readonly value="<%=blankNull((oborrowingCreationBean.getAc_opn_dt()))%>"/></td>
                                    <td><a href="#" onclick="return getCalendar(document.forms[0].acOpenDateAmend<%=count%>);"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" style="display:block;"  height="100%" width="20" /></a></td>
                                    <td><input type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" size="8" id="acMatDateAmend<%=count%>" name="acMatDateAmend<%=count%>" readonly="true" value="<%=blankNull(oborrowingCreationBean.getOvd_dt())%>"></td>
                                    <td><a href="#" onclick="return getCalendar(document.forms[0].acMatDateAmend<%=count%>);"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" style="display:block;"  height="100%" width="20" /></a></td>
                                    <td><select id="activeAmend<%=count%>" name="activeAmend<%=count%>"><option value="" selected disabled>--- Select ---</option><option value="Yes" <%if (oborrowingCreationBean.getActive_flag().equalsIgnoreCase("Yes")) {%> selected <%}%> >Yes</option><option value="No" <%if (oborrowingCreationBean.getActive_flag().equalsIgnoreCase("No")) {%> selected <%}%> >No</option></select></td>
                                    <td style="display:none;"><input type="hidden"  name="document_mst_idAmend<%=count%>" id="document_mst_idAmend<%=count%>"/></td>

                                </tr>
                            </tbody>
                            <%}%>
                        </table>
                        <%}%>
                    </center>
                    <center>
                        <table >
                            <tr><td></td></tr>
                            <tr><td></td></tr>
                            <tr><td></td></tr>
                            <tr><td></td></tr>
                        </table></center>
                    <br><br><br>
                    <center>
                        <table>
                            <tr>
                                <td><input type="button" id="addRowAmend" value="Add Row"/></td>
                                <td><input type="button" id="deleteRowAmend" value="Delete Row"/></td>
                                <td><input type="button" value="Update" onclick="javascript:updateform(borrowingCreateForm)"></td>
                                <td><input type="button" value="Reset" onclick="ShowParent();" /></td>
                            </tr>
                        </table>
                    </center>
                    <br>

                </div>



                <input type="hidden" name="handle_id" value="" />
                <input type="hidden" name="rowCounterDeleteCreate" id="rowCounterDeleteCreate" value="<%=count%>">
                <input type="hidden" name="AddrowCounterClickedCreate" id="AddrowCounterClickedCreate" value="<%=count%>">
                <input type="hidden" name="rowCounter" id="rowCounter" value="<%=count%>">
                <input type="hidden" name="chkboxCounter" id="chkboxCounter" value="0"/>
                <input type="hidden" name="all_rowsAdded" id="all_rowsAdded" value="1">

                <input type="hidden" name="rowCounterDeleteCreateAmend" id="rowCounterDeleteCreateAmend" value="<%=count%>">
                <input type="hidden" name="rowCounterAmend" id="rowCounterAmend" value="<%=count%>">
                <input type="hidden" name="chkboxCounterAmend" id="chkboxCounterAmend" value="0"/>
                <input type="hidden" name="all_rowsAddedAmend" id="all_rowsAddedAmend" value="1">
                <input type="hidden" name="searchindex" id="searchindex" >
                <input type="hidden" name="searchindex" id="searchindexAmmend" value="0">
                <input type="hidden" name="hidden_gl_no" id="hidden_gl_no" <%if (displayFlag == "Y") {%>value="<%=blankNull(gl_number)%>"<%}%> />
                <input type="hidden" name="hidden_gl_amt" id="hidden_gl_amt" <%if (displayFlag == "Y") {%>value="<%=blankNull(bal)%>"<%}%> />
            </form>

            <%
                 if (op.equalsIgnoreCase("Amend")) {%>
            <script>
                //alert("OK");
                document.getElementById("opt").value='amend';
                document.getElementById("amend").style.display='block';
            </script>
            <%}
            %>

            <script>
                var x=1;
                var y=1;
                function checkboxTrue(i){

                    if(document.getElementById("chckbox"+i).checked==true){

                        var counter = $("#chkboxCounter").val();
                        counter++;
                        $("#chkboxCounter").val(counter);

                    }
                    else{

                        var counter = $("#chkboxCounter").val();
                        counter--;
                        $("#chkboxCounter").val(counter);
                    }
                }

                $("#addRow").click(function () {
                    x=x+1;
                    $("#all_rowsAdded").val(x);
                    var counter = $("#rowCounter").val();
                    counter++;
                    $('#order-list tr:last').after('<tr class="tRow"><td><input type="checkbox" name="chckbox'+ x +'" id="chckbox'+ x +'" onclick="checkboxTrue('+ x +');" /></td>\n\
                                    <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" name="bankName'+ x +'" id="bankName'+ x +'" /></td>\n\\n\
                                    <td><input  type="button" name="bankNameBtn'+ x +'" id="bankNameBtn'+ x +'" value="Search" onclick="javascript:searchBank(220,180,'+ x +','+ x +')"/></td>\n\\n\
                                    <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" name="branchName'+ x +'" id="branchName'+ x +'" readonly/></td>\n\
                                    <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" onKeyPress="return numbersonly(this, event)" name="accountNo'+ x +'" id="accountNo'+ x +'"/></td>\n\
                                    <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" onKeyPress="return numbersonly(this, event)" name="amount'+ x +'" id="amount'+ x +'"/></td>\n\
                                    <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" onKeyPress="return numbersonly(this, event)" name="interestRate'+ x +'" id="interestRate'+ x +'"/></td>\n\
                                    <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" onKeyPress="return numbersonly(this, event)" name="odInterestRate'+ x +'" id="odInterestRate'+ x +'"/></td>\n\
                                    <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" name="acOpenDate'+ x +'" id="acOpenDate'+ x +'" size="8" readonly/></td>\n\
                                    <td><a href="#" onclick="return getCalendar(document.forms[0].acOpenDate'+ x +');"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" style="display:block;"  height="100%" width="20" /></a></td>\n\
                                    <td><input type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" size="8" id="acOvdDate'+ x +'" name="acOvdDate'+ x +'" readonly="true"></td>\n\
                                    <td><a href="#" onclick="return getCalendar(document.forms[0].acOvdDate'+ x +');"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" style="display:block;"  height="100%" width="20" /></a></td>\n\
                                    <td><select id="active'+ x +'" name="active'+ x +'"><option value="" selected disabled>--- Select ---</option><option value="Yes">Yes</option><option value="No">No</option></select></td>\n\
                                    <td style="display:none;"><input type="hidden"  name="document_mst_id'+ x +'" id="document_mst_id'+ x +'"/></td>               </tr>');

                    $("#rowCounter").val(counter);
                    $("#AddrowCounterClickedCreate").val(counter);
                    counter = $("#rowCounterDeleteCreate").val();
                    counter++;
                    $("#rowCounterDeleteCreate").val(counter);

                });

                $( "#deleteRow" ).click(function() {

                    var len = ($("#order-list tr").length)-1;
                    var counter = $("#rowCounterDeleteCreate").val();

                    var chkboxCounter=$("#chkboxCounter").val();

                    var counterDelete=counter-chkboxCounter;

                    if (counterDelete==0){

                        alert("All rows cannot be deleted");
                    }
                    else{

                        if (len ==chkboxCounter) {
                            alert("All rows can not be deleted.");
                            return false;
                        }

                        $('input:checkbox:checked').closest('tr').remove();
                        $("#rowCounterDeleteCreate").val(counterDelete);

                        chkboxCounter=0;
                        $("#chkboxCounter").val(chkboxCounter);
                        var total = 0;
                        var test;

                    }
                });
                
                function checkboxAmendTrue(i){

                    if(document.getElementById("chckboxAmend"+i).checked==true){

                        var counterAmend = $("#chkboxCounterAmend").val();
                        counterAmend++;
                        $("#chkboxCounterAmend").val(counterAmend);

                    }
                    else{

                        var counterAmend = $("#chkboxCounterAmend").val();
                        counterAmend--;
                        $("#chkboxCounterAmend").val(counterAmend);
                    }
                    //alert("ChkBoxCounterAmend="+counterAmend);
                }

                $("#addRowAmend").click(function () {
                    //x=x+1;
                    x=parseInt($("#rowCounterDeleteCreateAmend").val());
                    x=x+1;
                    $("#all_rowsAddedAmend").val(x);
                    var counterAmend = $("#rowCounterAmend").val();
                    counterAmend++;
                    $('#order-list2 tr:last').after('<tr class="tRow"><td><input type="checkbox" name="chckboxAmend'+ x +'" id="chckboxAmend'+ x +'" onclick="checkboxAmendTrue('+ x +');" /></td>\n\
                                    <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" name="bankNameAmend'+ x +'" id="bankNameAmend'+ x +'" /></td>\n\\n\
                                    <td><input  type="button" name="bankNameAmendBtn'+ x +'" id="bankNameAmendBtn'+ x +'" value="Search" onclick="javascript:searchBankAmend(220,180,'+ x +','+ x +')"/></td>\n\\n\
                                    <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" name="branchNameAmend'+ x +'" id="branchNameAmend'+ x +'" readonly/></td>\n\
                                    <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" onKeyPress="return numbersonly(this, event)" name="accountNoAmend'+ x +'" id="accountNoAmend'+ x +'"/></td>\n\
                                    <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" onKeyPress="return numbersonly(this, event)" name="amountAmend'+ x +'" id="amountAmend'+ x +'"/></td>\n\
                                    <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" onKeyPress="return numbersonly(this, event)" name="interestRateAmend'+ x +'" id="interestRateAmend'+ x +'"/></td>\n\
\n\                                 <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" onKeyPress="return numbersonly(this, event)" name="odInterestRateAmend'+ x +'" id="odInterestRateAmend'+ x +'"/></td>\n\
                                    <td><input  type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" name="acOpenDateAmend'+ x +'" id="acOpenDateAmend'+ x +'" size="8" readonly/></td>\n\
                                    <td><a href="#" onclick="return getCalendar(document.forms[0].acOpenDateAmend'+ x +');"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" style="display:block;"  height="100%" width="20" /></a></td>\n\
                                    <td><input type="text" style="width: 100%;padding: 5px;margin: 0px;border: 1px solid #CCC;" size="8" id="acMatDateAmend'+ x +'" name="acMatDateAmend'+ x +'" readonly="true"></td>\n\
                                    <td><a href="#" onclick="return getCalendar(document.forms[0].acMatDateAmend'+ x +');"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" style="display:block;"  height="100%" width="20" /></a></td>\n\
                                    <td><select id="activeAmend'+ x +'" name="activeAmend'+ x +'"><option value="" selected disabled>--- Select ---</option><option value="Yes" >Yes</option><option value="No" >No</option></select></td>\n\
                                    <td style="display:none;"><input type="hidden"  name="document_mst_idAmend'+ x +'" id="document_mst_idAmend'+ x +'"/></td>                </tr>');

                    //alert(x);
                    $("#rowCounterAmend").val(counterAmend);
                    $("#AddrowCounterClickedCreate").val(counterAmend);
                    counterAmend = $("#rowCounterDeleteCreateAmend").val();
                    counterAmend++;
                    $("#rowCounterDeleteCreateAmend").val(counterAmend);

                });

                $( "#deleteRowAmend" ).click(function() {

                    var len = ($("#order-list2 tr").length)-1;
                    var counterAmend = $("#rowCounterDeleteCreateAmend").val();
                    //alert("CounterAmend="+counterAmend);
                    var chkboxCounterAmend=$("#chkboxCounterAmend").val();
                    //alert("chkboxCounterAmend="+chkboxCounterAmend);
                    var counterDeleteAmend=counterAmend-chkboxCounterAmend;
                    //alert("counterDeleteAmend=" + counterDeleteAmend);
                    if (counterDeleteAmend==0){

                        alert("All rows cannot be deleted");
                    }
                    else{

                        if (len ==chkboxCounterAmend) {
                            alert("All rows can not be deleted");
                            return false;
                        }

                        $('input:checkbox:checked').closest('tr').remove();
                        $("#rowCounterDeleteCreateAmend").val(counterDeleteAmend);

                        chkboxCounterAmend=0;
                        $("#chkboxCounterAmend").val(chkboxCounterAmend);
                        var total = 0;
                        var test;

                    }
                });

                function SearchAsset(width, height,i)
                {

                    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 = "DepositKYCCreation.jsp";
                    var  lovKey=    "IDTypeScoreSearch"
                    popWin = open('${pageContext.request.contextPath}/CommonSearchInformationDepositLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey+'&textIndex='+i , 'IDTypeScoreSearch', attr);
                    popWin.focus();
                }

                jQuery('#order-list').on('change','.IDScore',
                function(){
                    var counter = document.forms[0].all_rowsAdded.value;
                    var total = 0;
                    var test;
                    for (var i = 1; i <= counter; i++) {
                        try{
                            var k = document.getElementById("Score" + i);
                            if(k !== null && k.value === ""){
                                test =0;
                            }
                            else
                                test=parseInt(document.getElementById("Score" + i).value);
                        }catch(err){
                            test=0;
                        }
                        total = parseInt(total) + test;
                        document.getElementById("grandTotal").value = total;
                    }
                    if(isNaN(document.getElementById("grandTotal").value)){
                        document.getElementById("grandTotal").value = 0;
                    }
                });

                $( "body" ).click(function() {
                    $( ".IDScore" ).change();
                });
                $('#order-list').on('click',':input.changeTotalScoreButton[type="button"]', function() {

                    var counter = document.forms[0].all_rowsAdded.value;
                    var total = 0;
                    var test;
                    for (var i = 1; i <= counter; i++) {
                        try{
                            var k = document.getElementById("Score" + i);
                            if(k !== null && k.value === ""){
                                test =0;
                            }
                            else
                                test=parseInt(document.getElementById("Score" + i).value);
                        }catch(err){
                            test=0;
                        }
                        total = parseInt(total) + test;
                        document.getElementById("grandTotal").value = total;
                    }
                    if(isNaN(document.getElementById("grandTotal").value)){
                        document.getElementById("grandTotal").value = 0;
                    }
                });


                function checkDiv(borrowingCreateForm)
                {
                    var row_no=parseInt(document.getElementById("rowCounterDeleteCreate").value);
                    var add_row_no_clicked=parseInt(document.getElementById("AddrowCounterClickedCreate").value);
                    var tot_amt=0;
                    if (document.getElementById("searchindex").value == "")
                    {
                        alert("Search Is Mandatory.");
                        borrowingCreateForm.glName.focus();
                        return false;
                    }

                    var i=0;

                    for (i=1;i<=add_row_no_clicked;i++)
                    {
                        try {
                            if (document.getElementById("bankName"+i).value == "")
                            {
                                alert("Bank Name must be filled.");
                                document.getElementById("bankName"+i).focus();
                                return false;
                            }

                            if (document.getElementById("branchName"+i).value == "")
                            {
                                alert("Branch Name must be filled.");
                                document.getElementById("branchName"+i).focus();
                                return false;
                            }

                            if (document.getElementById("accountNo"+i).value == "")
                            {
                                alert("Account Number must be filled.");
                                document.getElementById("accountNo"+i).focus();
                                return false;
                            }

                            if (document.getElementById("amount"+i).value == "")
                            {
                                alert("Amount must be filled.");
                                document.getElementById("amount"+i).focus();
                                return false;
                            }

                            if (document.getElementById("interestRate"+i).value == "")
                            {
                                alert("Interest Rate must be filled.");
                                document.getElementById("interestRate"+i).focus();
                                return false;
                            }
                            
                            if (document.getElementById("odInterestRate"+i).value == "")
                            {
                                alert("OD Interest Rate must be filled.");
                                document.getElementById("odInterestRate"+i).focus();
                                return false;
                            }

                            if (document.getElementById("acOpenDate"+i).value == "")
                            {
                                alert("Account Open Date must be filled.");
                                document.getElementById("acOpenDate"+i).focus();
                                return false;
                            }

                            if (document.getElementById("acOvdDate"+i).value == "")
                            {
                                alert("Account Maturity Date must be filled.");
                                document.getElementById("acOvdDate"+i).focus();
                                return false;
                            }

                            if (document.getElementById("active"+i).value == "")
                            {
                                alert("Active Flag must be filled.");
                                document.getElementById("active"+i).focus();
                                return false;
                            }
                            if (document.getElementById("active"+i).value == "Yes")
                                {
                                    tot_amt=tot_amt+parseFloat(document.getElementById("amount"+i).value);
                                }
                        }
                        catch(err){
                           // alert("IN CATCH");
                        }
                    }
//                var gl_amt=parseFloat(document.getElementById("glBal").value);
//                //alert("GL "+gl_amt);
//                if(tot_amt!=gl_amt)
//                {
//                    alert("GL Amount and sum of Bank accounts must be equal.");
//                    return false;
//                }
                return true;
            };

            function checkDivAmend(borrowingCreateForm)
            {
                var row_no=parseFloat(document.getElementById("rowCounterDeleteCreateAmend").value);
                var tot_amt=0;
                var add_row_no_clicked=parseInt(document.getElementById("AddrowCounterClickedCreate").value);
                //alert(add_row_no_clicked);

                /*if (document.getElementById("searchindexAmmend").value == "0")
                    {
                        alert("!! Search Is Mandatory !!");
                    } */

                //alert("ROW NO"+row_no);
                var i=0;

                for (i=1;i<=add_row_no_clicked;i++)
                {

                    try {
                    if (document.getElementById("bankNameAmend"+i).value == "")
                    {
                        alert("Bank Name must be filled.");
                        document.getElementById("bankNameAmend"+i).focus();
                        return false;
                    }

                    if (document.getElementById("branchNameAmend"+i).value == "")
                    {
                        alert("Branch Name must be filled.");
                        document.getElementById("branchNameAmend"+i).focus();
                        return false;
                    }

                    if (document.getElementById("accountNoAmend"+i).value == "")
                    {
                        alert("Account Number must be filled.");
                        document.getElementById("accountNoAmend"+i).focus();
                        return false;
                    }

                    if (document.getElementById("amountAmend"+i).value == "")
                    {
                        alert("Amount must be filled.");
                        document.getElementById("amountAmend"+i).focus();
                        return false;
                    }

                    if (document.getElementById("interestRateAmend"+i).value == "")
                    {
                        alert("Interest Rate must be filled.");
                        document.getElementById("interestRateAmend"+i).focus();
                        return false;
                    }
                    
                    if (document.getElementById("odInterestRateAmend"+i).value == "")
                    {
                        alert("OD Interest Rate must be filled.");
                        document.getElementById("odInterestRateAmend"+i).focus();
                        return false;
                    }

                    if (document.getElementById("acOpenDateAmend"+i).value == "")
                    {
                        alert("Account Open Date must be filled.");
                        document.getElementById("acOpenDateAmend"+i).focus();
                        return false;
                    }

                    if (document.getElementById("acMatDateAmend"+i).value == "")
                    {
                        alert("Account Maturity Date must be filled.");
                        document.getElementById("acMatDateAmend"+i).focus();
                        return false;
                    }

                    if (document.getElementById("activeAmend"+i).value == "")
                    {
                        alert("Active Flag must be filled.");
                        document.getElementById("activeAmend"+i).focus();
                        return false;
                    }
                    if (document.getElementById("activeAmend"+i).value == "Yes")
                        {
                            tot_amt=tot_amt+parseFloat(document.getElementById("amountAmend"+i).value);
                        }
                    //alert(tot_amt);

                    }
                    catch(err){

                    }

                }
//                var gl_amt=parseFloat(document.getElementById("hidden_gl_amt").value);
//                //alert("GL "+gl_amt);
//                if(tot_amt!=gl_amt)
//                {
//                    alert("GL Amount and sum of Bank accounts must be equal.");
//                    return false;
//                }
                return true;

            };

            function fetchform(borrowingCreateForm)
            {
                var gl_no=document.getElementById("glNameAmend").value;;

                if(gl_no!="")
                {
                    document.borrowingCreateForm.handle_id.value = "Search";
                    document.borrowingCreateForm.action = '/PacsApplication/BorrowingCreationServlet';
                    document.borrowingCreateForm.submit();
                }
                else
                {
                    alert("Please Search the GL Account first before proceeding.");
                    borrowingCreateForm.gl_no.focus();
                }
            }

            function updateform(borrowingCreateForm)
            {
                var gl_no=document.getElementById("hidden_gl_no").value;

                if(gl_no!="")
                {
                    if(checkDivAmend(borrowingCreateForm))
                    {
                        document.borrowingCreateForm.handle_id.value = "Update";
                        document.borrowingCreateForm.action = '/PacsApplication/BorrowingCreationServlet';
                        document.borrowingCreateForm.submit();
                    }
                }
                else
                {
                    alert(" Please Search the GL Account first before proceeding.");
                    borrowingCreateForm.gl_no.focus();
                }
            }

            function submitform(borrowingCreateForm)
            {
                //if (kycCreateForm.file.value == "" || !$('#file').val()){
                //   alert("Please select Photograph to proceed!");
                //  return false;
                // }
                if(checkDiv(borrowingCreateForm))
                {

                    document.borrowingCreateForm.handle_id.value = "Create";
                    document.borrowingCreateForm.action = '/PacsApplication/BorrowingCreationServlet';
                    document.borrowingCreateForm.submit();
                }
            }

            function ShowParent(    )
            {
                document.forms[0].action="${pageContext.request.contextPath}/borrowing_creation.jsp";
                document.forms[0].submit();
            }

            function checkIDScore(){
                $( ".IDScore" ).change();
                /*alert("ID Score checked");*/
            }

            $('div#create').on('keydown',':input.mobile[type="text"]', function() {

                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();
                }
            });

            function readURL(input) {
                if (input.files && input.files[0]) {
                    var reader = new FileReader();

                    reader.onload = function (e) {
                        $('#blah').attr('src', e.target.result);
                    }

                    reader.readAsDataURL(input.files[0]);
                }
            }

            function sigreadURL(input) {
                if (input.files && input.files[0]) {
                    var reader = new FileReader();

                    reader.onload = function (e) {
                        $('#blahsig').attr('src', e.target.result);
                    }

                    reader.readAsDataURL(input.files[0]);
                }
            }

            $(document).ready(function() {
                $("#file").change(function(){
                    readURL(this);
                    $('#blah').show();
                    $('#image-holder').show();
                });
                $("#sigUpld").change(function(){
                    sigreadURL(this);
                    $('#blahsig').show();
                    $('#image-holder').show();
                });
            });

            function hasExtension(inputID, exts) {
                var fileName = document.getElementById(inputID).value;
                return (new RegExp('(' + exts.join('|').replace(/\./g, '\\.') + ')$')).test(fileName);
            }

            </script>
        </fieldset>
    </body>
</html>
<% 	} catch (Exception e) {
              
            }
%>

