<%--
    Document   : memberEnrollment
    Created on : Apr 22, 2016, 8:00:44 PM
    Author     : 590685
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="DataEntryBean.memberEnrollmentHeaderBean"%>
<%@page import="DataEntryBean.memberEnrollmentDetailsBean"%>
<%@page import="java.util.ArrayList"%>
<% try {
%>
<html>
    <head>
        <title>Member Enrollment</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>
    </head>


    <script>





    </script>

    <%
         String error_msg = "";
         Object error = request.getAttribute("message");
         if (error != null) {
             error_msg = error.toString();
         }
    %>

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

    <%
         Object memberEnrollmentHeaderBeanObj = request.getAttribute("omemberEnrollmentHeaderBean");
         memberEnrollmentHeaderBean OmemberEnrollmentHeaderBean = new memberEnrollmentHeaderBean();
         if (memberEnrollmentHeaderBeanObj != null) {
             OmemberEnrollmentHeaderBean = (memberEnrollmentHeaderBean) request.getAttribute("omemberEnrollmentHeaderBean");

         }

    %>
    <%          int divFamily = 0;
         Object alMemberEnrollmentDetailsBeanApendObj = request.getAttribute("alMemberEnrollmentDetailsBeanApend");
         ArrayList<memberEnrollmentDetailsBean> alMemberEnrollmentDetailsBeanApend = new ArrayList<memberEnrollmentDetailsBean>();
         if (alMemberEnrollmentDetailsBeanApendObj != null) {
             alMemberEnrollmentDetailsBeanApend = (ArrayList<memberEnrollmentDetailsBean>) request.getAttribute("alMemberEnrollmentDetailsBeanApend");
             divFamily = alMemberEnrollmentDetailsBeanApend.size();
         }

    %>

    <jsp:include page="MenuHead_PDS.jsp" flush="true" />
    <br>
    <%!
        String blankNull(String s) {
            return (s == null) ? "" : s;
        }
    %>


    <body  onload="noBack()">
        <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">MEMBER ENROLLMENT</legend>
            <form name="memberEnrollForm" method="post" action="MemberEnrollmentServlet" >

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

                <center><label style=" font-family: Berlin Sans FB; font-weight:  normal;">Operation Selection</label>
                    <select id="checkOption" onchange="checkop()" name="checkOption" >
                        <option value="" disabled selected style="display:none;" >--select--</option>
                        <option value="create" >Create</option>
                        <option value="amend" >Amend</option>

                    </select>
                </center>
                <br>
                <br>

                <div id="create" style="display: none;">

                    <div id="create1">
                        <table>


                            <tr>
                                <td>Card No: </td>
                                <td><input type="text" name="cardNo" id="cardNo"/><!--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button"  value="Search" onclick="javascript:popup_CIF(220, 180, document.memberEnrollForm.cardNo.value,document.memberEnrollForm.custName.value);" />--></td>
                            </tr>
                            <tr>
                                <td>Card Holder Name: </td>
                                <td> <input type="text" size="30" name="custName" id="custName"/><!--<input type="button"  value="Search" onclick="javascript:popup_CIF(220, 180, document.memberEnrollForm.cardNo.value,document.memberEnrollForm.custName.value)" />--></td>
                            </tr>

                            <tr>
                                <td>S/D/W of:</td>
                                <td><input type="text" name="SDWOf" id="SDWOf" value="" /></td>
                            </tr>
                            <tr>
                                <td>Date of Birth:</td>
                                <td><input type="text" name="dateOfBirth" id="dateOfBirth"  value="" readonly/><a href="#" onclick="return getCalendar(getElementById('dateOfBirth'));"><img src="${pageContext.request.contextPath}/img/calendar.gif" name="imgr" border="0" width="15" height="20" /></a></td>
                            </tr>
                            <tr>
                                <td>House No:</td>
                                <td><input type="text"  name="houseNo" id="houseNo"  value="" /></td>
                            </tr>
                            <tr>
                                <td>Street/Road:</td>
                                <td><input type="text" name="street" id="street"  value="" /></td>
                            </tr>
                            <tr>
                                <td>Gram Panchayat:</td>
                                <td><input type="text" name="gramPanchayat" id="gramPanchayat"  value="" /></td>
                            </tr>
                            <tr>
                                <td>Revenue Block:</td>
                                <td><input type="text" name="revenueBlock" id="revenueBlock"  value="" /></td>
                            </tr>
                            <tr>
                                <td>Subdivision:</td>
                                <td><input type="text" name="subdivision" id="subdivision"  value="" /></td>
                            </tr>
                            <tr>
                                <td>District:</td>
                                <td><input type="text" name="district" id="district"  value="" /></td>
                            </tr>
                            <tr>
                                <td>State:</td>
                                <td><input type="text" name="state" id="state"  value="" /></td>
                            </tr>
                            <tr>
                                <td>Issued On:</td>
                                <td><input type="text" name="issuedOn" id="issuedOn"  value="" readonly /><a href="#" onclick="return getCalendar(getElementById('issuedOn'));"><img src="${pageContext.request.contextPath}/img/calendar.gif" name="imgr" border="0" width="15" height="20" /></a></td>
                            </tr>
                            <tr>
                                <td>Valid Upto:</td>
                                <td><input type="text" name="validUpto" id="validUpto"  value="" readonly/><a href="#" onclick="return getCalendar(document.forms[0].validUpto);"><img src="${pageContext.request.contextPath}/img/calendar.gif" name="imgr" border="0" width="15" height="20" /></a></td>
                            </tr>
                            <tr>
                                <td>Card Category:</td>
                                <td><input type="text" id="cardCategory" name="cardCategory" readonly="true" value=""/><td><input type="hidden" id="cardTypeId" name="cardTypeId" value=""/>&nbsp;&nbsp;<input type="button" id="Search" value="Search" name="Search" onclick="javascript:popup_CIF(220, 180,'','1010');" /></td>

                            </tr>
                            <tr><td><br/></td></tr>
                            <tr>
                                <td>Enter Family Details:</td>
                                <td><input type="radio" name="choice" value="Yes" onclick="displayFamilyDetails(memberEnrollForm);">Yes&nbsp;&nbsp;<input type="radio" name="choice" value="No" checked="true" onclick="displayFamilyDetails(memberEnrollForm);">No</td>

                            </tr>
                        </table>
                        <br><br>

                    </div>

                    <div style="display:none" id="create2" >

                        <table id="order-list">
                            <thead class="CSSTableGenerator">
                                <tr>
                                    <td></td>
                                    <td>
                                        Card No

                                    </td>
                                    <td>
                                        Card Holder Name

                                    </td>
                                    <td>
                                        DOB

                                    </td>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td><input type="checkbox" name="chckbox<%=count%>" id="chckbox<%=count%>" onclick="return checkboxTrue(<%=count%>)"/></td>
                                    <td><input type="text" id="cardNoFamily<%=count%>" name="cardNoFamily<%=count%>"/>  </td>
                                    <td><input type="text" id="cardHolderNameFamily<%=count%>" name="cardHolderNameFamily<%=count%>" /></td>
                                    <td><input type="text" id="DOBFamily<%=count%>" name="DOBFamily<%=count%>" readonly/><a href="#" onclick="return getCalendar(getElementById('DOBFamily'+<%=count%>));"><img src="${pageContext.request.contextPath}/img/calendar.gif" name="imgr" border="0" width="15" height="20" /></a></td>
                                    <td><input type="hidden" id="familyId<%=count%>" name="familyId<%=count%>" value=""/></td>
                                </tr>
                            </tbody>
                        </table>

                        <br/><br/>
                        <input type="button" id="addRow" value="Add Row" onclick="addRow();">
                        <input type="button" id="deleteRow" value="Delete Row">

                        <br/><br/><br/>


                    </div>

                    <div id="mandatory" >
                        <center>
                            <br/><br/>

                            <input type="button" value="Submit" onclick="javascript:submitform(memberEnrollForm)">
                            <input type="button" value="Reset" onclick="ShowParent();" />
                            <br/><br/><br/>
                        </center>
                        <table>
                            <tr><td><br></td></tr>
                            <tr><td><br></td></tr>

                            <tr><td><label style=" font-family: Berlin Sans FB; font-weight:normal; ">All fields are mandatory</label></td></tr>

                        </table>
                    </div>
                </div>

                <div id="amend" style="display: none;">
                    <center>
                        <table>
                            <tr>
                                <td>Name: </td>
                                <td> <input type="text" readonly name="custNameAmendSearch" id="custNameAmendSearch" value="<%=blankNull(OmemberEnrollmentHeaderBean.getCustName())%>"/></td>
                                <td><input type="button"  value="Search" onclick="javascript:popup_CIF(220, 180,document.memberEnrollForm.cardNoAmendSearch.value, document.memberEnrollForm.custNameAmendSearch.value)" /></td>
                            </tr>
                            <tr>
                                <td>Card No: </td>
                                <td><input type="text" readonly name="cardNoAmendSearch" id="cardNoAmendSearch" value="<%=blankNull(OmemberEnrollmentHeaderBean.getCardNo())%>"/></td>

                                <td><input type="button"  value="Search" onclick="javascript:popup_CIF(220, 180, document.memberEnrollForm.cardNoAmendSearch.value, document.memberEnrollForm.custNameAmendSearch.value);" /></td>
                            </tr>
                        </table>
                        <br>
                        <input type="button"  value="Submit" onclick="javascript:searchMember()" />
                    </center><br>
                </div>

                <%if (displayFlag.equalsIgnoreCase("Y")) {%>

                <div id="amend2" >

                    <input type="hidden" name="holderIdAmend" id="holderIdAmend" value="<%=blankNull(OmemberEnrollmentHeaderBean.getHolderId())%>"/>
                    <table>

                        <tr>
                            <td>Card No: </td>
                            <td><input type="text" name="cardNoAmend" id="cardNoAmend" readonly="true" value="<%=blankNull(OmemberEnrollmentHeaderBean.getCardNo())%>"/></td>


                        </tr>
                        <tr>
                            <td>Card Holder Name: </td>
                            <td> <input type="text" name="custNameAmend" id="custNameAmend" value="<%=blankNull(OmemberEnrollmentHeaderBean.getCustName())%>"/></td>

                        </tr>

                        <tr>
                            <td>S/D/W of:</td>
                            <td><input type="text" name="SDWOfAmend" id="SDWOfAmend" value="<%=blankNull(OmemberEnrollmentHeaderBean.getSDWOf())%>" /></td>
                        </tr>

                        <tr>
                            <td>Date of Birth:</td>
                            <td><input type="text" name="dateOfBirthAmend" id="dateOfBirthAmend"  value="<%=blankNull(OmemberEnrollmentHeaderBean.getDateOfBirth())%>" readonly><a href="#" onclick="return getCalendar(document.forms[0].dateOfBirthAmend);"><img src="${pageContext.request.contextPath}/img/calendar.gif" name="imgr" border="0" width="15" height="20" /></a></td>
                        </tr>
                        <tr>
                            <td>House No:</td>
                            <td><input type="text"  name="houseNoAmend" id="houseNoAmend" value="<%=blankNull(OmemberEnrollmentHeaderBean.getHouseNo())%>" /></td>
                        </tr>
                        <tr>
                            <td>Street/Road:</td>
                            <td><input type="text"  name="streetAmend" id="streetAmend" value="<%=blankNull(OmemberEnrollmentHeaderBean.getStreet())%>" /></td>
                        </tr>
                        <tr>
                            <td>Gram Panchayat:</td>
                            <td><input type="text"  name="gramPanchayatAmend" id="gramPanchayatAmend" value="<%=blankNull(OmemberEnrollmentHeaderBean.getGramPanchayat())%>" /></td>
                        </tr>
                        <tr>
                            <td>Revenue Block:</td>
                            <td><input type="text"  name="revenueBlockAmend" id="revenueBlockAmend" value="<%=blankNull(OmemberEnrollmentHeaderBean.getRevenueBlock())%>" /></td>
                        </tr>
                        <tr>
                            <td>Subdivision:</td>
                            <td><input type="text"  name="subdivisionAmend" id="subdivisionAmend" value="<%=blankNull(OmemberEnrollmentHeaderBean.getSubdivision())%>" /></td>
                        </tr>
                        <tr>
                            <td>District:</td>
                            <td><input type="text" name="districtAmend" id="districtAmend"  value="<%=blankNull(OmemberEnrollmentHeaderBean.getDistrict())%>" /></td>
                        </tr>
                        <tr>
                            <td>State:</td>
                            <td><input type="text"  name="stateAmend" id="stateAmend" value="<%=blankNull(OmemberEnrollmentHeaderBean.getState())%>" /></td>
                        </tr>
                        <tr>
                            <td>Issued on:</td>
                            <td><input type="text"  name="issuedOnAmend" id="issuedOnAmend" value="<%=blankNull(OmemberEnrollmentHeaderBean.getIssuedOn())%>" readonly/><a href="#" onclick="return getCalendar(document.forms[0].issuedOnAmend);"><img src="${pageContext.request.contextPath}/img/calendar.gif" name="imgr" border="0" width="15" height="20" /></a></td>
                        </tr>
                        <tr>
                            <td>Valid upto:</td>
                            <td><input type="text"  name="validUptoAmend" id="validUptoAmend" value="<%=blankNull(OmemberEnrollmentHeaderBean.getValidUpto())%>" readonly /><a href="#" onclick="return getCalendar(document.forms[0].validUptoAmend);"><img src="${pageContext.request.contextPath}/img/calendar.gif" name="imgr" border="0" width="15" height="20" /></a></td>
                        </tr>
                        <tr>
                            <td>Card category:</td>


                            <td><input type="text" id="cardCategoryAmend" name="cardCategoryAmend"  readonly="true" value="<%=blankNull(OmemberEnrollmentHeaderBean.getCardCategory())%>" /><td><input type="hidden" id="cardTypeIdAmend" name="cardTypeIdAmend" value="<%=blankNull(OmemberEnrollmentHeaderBean.getCardTypeId())%>"/>&nbsp;&nbsp;<input type="button" id="Search" value="Search" name="Search" onclick="javascript:popup_CIF(220, 180,'','2010');" />
                            </td>




                        </tr>




                    </table>

                    <br>
                    <%
                        if (alMemberEnrollmentDetailsBeanApend.size() > 0) {
                    %>
                    <!--<div id="newFamilyDiv1" style="display:none">
                    <table id="newFamily1">
                        <tr>
                            <td>Enter Family Details:</td>
                            <td><input type="radio" name="choiceAmend1" value="Yes" onclick="displayFamilyDetails1(memberEnrollForm);">Yes&nbsp;&nbsp;<input type="radio" name="choiceAmend" value="No" checked="true" onclick="displayFamilyDetails1(memberEnrollForm);">No</td>

                        </tr>
                    </table>
                    </div>-->
                    <table id="order_list_Amend">
                        <thead class="CSSTableGenerator">
                            <tr>
                                <td></td>
                                <td>
                                    Card No

                                </td>
                                <td>
                                    Card Holder Name

                                </td>
                                <td>
                                    DOB

                                </td>
                            </tr>
                        </thead>
                        <tbody>
                            <%
                                                        count = 0;
                                                        memberEnrollmentDetailsBean omemberEnrollmentDetailsBeanApend = new memberEnrollmentDetailsBean();
                                                        int i;
                                                        for (i = 0; i < alMemberEnrollmentDetailsBeanApend.size(); i++) {
                                                            omemberEnrollmentDetailsBeanApend = alMemberEnrollmentDetailsBeanApend.get(i);
                                                            count++;
                            %>
                            <tr>
                                <td><input type="checkbox" name="chckboxAmend<%=count%>" id="chckboxAmend<%=count%>" onclick="return checkboxTrueAmend(<%=count%>)" value="<%=blankNull(omemberEnrollmentDetailsBeanApend.getDetailIdAmend())%>" /></td>
                                <td><input type="text" id="cardNoFamilyAmend<%=count%>" name="cardNoFamilyAmend<%=count%>" value="<%=blankNull(omemberEnrollmentDetailsBeanApend.getCardNoFamily())%>" /></td>
                                <td><input type="text" id="cardHolderNameFamilyAmend<%=count%>" name="cardHolderNameFamilyAmend<%=count%>" value="<%=blankNull(omemberEnrollmentDetailsBeanApend.getCardHolderNameFamily())%>" /></td>
                                <td><input type="text" id="DOBFamilyAmend<%=count%>" name="DOBFamilyAmend<%=count%>" value="<%=blankNull(omemberEnrollmentDetailsBeanApend.getDOBFamily())%>" readonly/><a href="#" onclick="return getCalendar(getElementById('DOBFamilyAmend'+<%=count%>));"><img src="${pageContext.request.contextPath}/img/calendar.gif" name="imgr" border="0" width="15" height="20" /></a></td>
                                <td><input type="hidden" id="familyIdAmend<%=count%>" name="familyIdAmend<%=count%>" value="<%=blankNull(omemberEnrollmentDetailsBeanApend.getFamilyId())%>"/></td>

                                <td><input type="hidden" name="rowStatus<%=count%>" id="rowStatus<%=count%>" value="A"/></td>
                                <td><input type="hidden" name="detailIDAmend<%=count%>" id="detailIDAmend<%=count%>" value="<%=blankNull(omemberEnrollmentDetailsBeanApend.getDetailIdAmend())%>" /></td>

                            </tr>







                            <%}%>
                        </tbody>
                    </table>
                    <br/><br/>
                    <input type="button" id="addRowAmend" value="Add Row"/>
                    <input type="button" id="deleteRowAmend" value="Delete Row"/>
                    <br/><br/>

                    <%} else {%>




                    <table id="newFamily">
                        <tr>
                            <td>Enter Family Details:</td>
                            <td><input type="radio" name="choiceAmend" value="Yes" onclick="displayFamilyDetails1(memberEnrollForm);">Yes&nbsp;&nbsp;<input type="radio" name="choiceAmend" value="No" checked="true" onclick="displayFamilyDetails1(memberEnrollForm);">No</td>

                        </tr>
                    </table>


                    <!--new div for add row-->
                    <div style="display:none" id="amend3" >
                        <table id="order-list-amend3">
                            <thead class="CSSTableGenerator">
                                <tr>
                                    <td></td>
                                    <td>
                                        Card No

                                    </td>
                                    <td>
                                        Card Holder Name

                                    </td>
                                    <td>
                                        DOB

                                    </td>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td><input type="checkbox" name="chckboxAmend3<%=count%>" id="chckboxAmend3<%=count%>" onclick="return checkboxTrueAmend3(<%=count%>)"/></td>
                                    <td><input type="text" id="cardNoFamilyAmend3<%=count%>" name="cardNoFamilyAmend3<%=count%>"/>  </td>
                                    <td><input type="text" id="cardHolderNameFamilyAmend3<%=count%>" name="cardHolderNameFamilyAmend3<%=count%>" /></td>
                                    <td><input type="text" id="DOBFamilyAmend3<%=count%>" name="DOBFamilyAmend3<%=count%>" readonly="true"/><a href="#" onclick="return getCalendar(getElementById('DOBFamilyAmend3'+<%=count%>));"><img src="${pageContext.request.contextPath}/img/calendar.gif" name="imgr" border="0" width="15" height="20" /></a></td>
                                    <td><input type="hidden" id="familyIdAmend3<%=count%>" name="familyIdAmend3<%=count%>" value=""/></td>
                                    <td><input type="hidden" name="rowStatus2<%=count%>" id="rowStatus2<%=count%>" value="N"/></td>
                                </tr>
                            </tbody>
                        </table>

                        <br/><br/>
                        <input type="button" id="addRowAmend3" value="Add Row" onclick="addRow();">
                        <input type="button" id="deleteRowAmend3" value="Delete Row">

                        <br/><br/><br/>


                    </div>




                    <%}%>


                    <center>

                        <input type="button" value="Update" onclick="javascript:updateform(memberEnrollForm)">
                        <input type="button" value="Reset" onclick="ShowParent()" />

                    </center>
                    <table>
                        <tr><td><label>All Fields are mandatory</label></td></tr>
                        </tbody>
                    </table>
                    <%}%>
                </div>

                <input type="hidden" name="rowCounterAmend" id="rowCounterAmend" value="<%=alMemberEnrollmentDetailsBeanApend.size()%>">
                <input type="hidden" name="rowCounterAmend3" id="rowCounterAmend3" value="0" >
                <input type="hidden" name="holderId" id="holderId" value=""/>

                <input type="hidden" name="handle_id" id="handle_id" value="" />
                <input type="hidden" name="rowCounter" id="rowCounter" value="0">

                <input type="hidden" name="rowCounterDeleteAmend" id="rowCounterDeleteAmend" value="<%=alMemberEnrollmentDetailsBeanApend.size()%>">
                <input type="hidden" name="rowCounterDeleteAmendAmend3" id="rowCounterDeleteAmendAmend3" value="0">
                <input type="hidden" name="chkboxCounter" id="chkboxCounter" value="0"/>
                <input type="hidden" name="chkboxCounterAmend" id="chkboxCounterAmend" value="0"/>
                <input type="hidden" name="chkboxCounterAmend3" id="chkboxCounterAmend3" value="0"/>
                <input type="hidden" name="deletedRows" id="deletedRows" value=""/>

            </form>
            <script>

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

                   // var counter = $("#rowCounter").val();
                    counter++;
                    $('#order-list tr:last').after('<tr><td align="center"><input type="checkbox" name="chckbox'+counter+'" id="chckbox'+counter+'" onclick="return checkboxTrue('+counter+')"/></td>\n\
<td><input type="text" id="cardNoFamily'+counter+'" name="cardNoFamily'+counter+'"/></td>\n\
<td><input type="text" id="cardHolderNameFamily'+counter+'" name="cardHolderNameFamily'+counter+'"/></td>\n\
<td><input type="text" name="DOBFamily'+counter+'" id="DOBFamily'+counter+'" readonly/>\n\
<a href="#" onclick="ShowCalender('+counter+');"><img src="${pageContext.request.contextPath}/img/calendar.gif" name="imgr" border="0" width="15" height="20" /></a></td><td><input type="hidden" name="rowStatus' + counter + '" id="rowStatus' + counter + '" value="N"/></td></tr>');
                    $("#rowCounter").val(counter);

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

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

                    if (counter==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();
                        $("#rowCounter").val(counter);
                        chkboxCounter=0;
                        $("#chkboxCounter").val(chkboxCounter);

                    }

                });

                function checkboxTrue(i){
                    //alert("counter");
                    if(document.getElementById("chckbox"+i).checked==true){

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

                    else{

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

                }
                $("#addRowAmend").click(function () {

                   // var counter = $("#rowCounterAmend").val();
                    // alert(counter);
                    counter++;
                    $('#order_list_Amend tr:last').after('<tr><td align="center"><input type="checkbox" name="chckboxAmend'+counter+'" id="chckboxAmend'+counter+'" onclick="return checkboxTrueAmend('+counter+')" value="" /></td>\n\
<td><input type="text" id="cardNoFamilyAmend'+counter+'" name="cardNoFamilyAmend'+counter+'"/></td>\n\
<td><input type="text" id="cardHolderNameFamilyAmend'+counter+'" name="cardHolderNameFamilyAmend'+counter+'"/></td>\n\
<td><input type="text" name="DOBFamilyAmend'+counter+'" id="DOBFamilyAmend'+counter+'" readonly/>\n\
<a href="#" onclick="ShowCalenderAmend('+counter+');"><img src="${pageContext.request.contextPath}/img/calendar.gif" name="imgr" border="0" width="15" height="20" /></a></td>\n\
<td><input type="hidden" name="rowStatus' + counter + '" id="rowStatus' + counter + '" value="N"/></td>\n\
<td><input type="hidden" name="familyIdAmend' + counter + '" id="familyIdAmend' + counter + '" value=""/></td>\n\
            <td><input type="hidden" name="detailIDAmend' + counter + '" id="detailIDAmend' + counter + '" value="" /></td></tr>');


                    $("#rowCounterAmend").val(counter);
                    $("#rowCounterDeleteAmend").val(counter);

                });


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

                    var len = ($("#order_list_Amend tr").length)-1;
                    var counter =$("#rowCounterDeleteAmend").val();
                    // alert(counter);
                    var chkboxCounterAmend=$("#chkboxCounterAmend").val();
                    //alert(chkboxCounterAmend);
                    var counterDelete=counter-chkboxCounterAmend;
                    //alert(counterDelete);
                    if (counterDelete==0){

                        alert("At least one family member must be present");
                    }
                    else{

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


                        var selchbox = [];        // array that will store the value of selected checkboxes

                        selchbox= getSelectedChbox(memberEnrollForm);
                        $("#deletedRows").val(selchbox);
                        $('input:checkbox:checked').closest('tr').remove();
                        $("#rowCounterDeleteAmend").val(counterDelete);
                        chkboxCounterAmend=0;
                        $("#chkboxCounterAmend").val(chkboxCounterAmend);


                    }


                });



                function checkboxTrueAmend(i){
                    //alert(i);
                    if(document.getElementById("chckboxAmend"+i).checked==true){

                        var counter = $("#chkboxCounterAmend").val();

                        counter++;
                        //alert(counter);
                        $("#chkboxCounterAmend").val(counter);
                    }

                    else{

                        var counter = $("#chkboxCounterAmend").val();
                        counter--;
                        //alert(counter);
                        $("#chkboxCounterAmend").val(counter);
                    }

                }

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

                   // var counter = $("#rowCounterAmend3").val();
                    counter++;
                    $('#order-list-amend3 tr:last').after('<tr><td align="center"><input type="checkbox" name="chckboxAmend3'+counter+'" id="chckboxAmend3'+counter+'" onclick="return checkboxTrueAmend3('+counter+')"/></td>\n\
<td><input type="text" id="cardNoFamilyAmend3'+counter+'" name="cardNoFamilyAmend3'+counter+'"/></td>\n\
<td><input type="text" id="cardHolderNameFamilyAmend3'+counter+'" name="cardHolderNameFamilyAmend3'+counter+'"/></td>\n\
<td><input type="text" name="DOBFamilyAmend3'+counter+'" id="DOBFamilyAmend3'+counter+'" readonly="true"/>\n\
<a href="#" onclick="ShowCalenderAmend3('+counter+');"><img src="${pageContext.request.contextPath}/img/calendar.gif" name="imgr" border="0" width="15" height="20" /></a></td>\n\
<td><input type="hidden" name="rowStatus2' + counter + '" id="rowStatus2' + counter + '" value="N"/></td></tr>');
                    $("#rowCounterAmend3").val(counter);
                    $("#rowCounterDeleteAmendAmend3").val(counter);

                });
                $( "#deleteRowAmend3" ).click(function() {

                    var len = ($("#order-list-amend3 tr").length)-1;
                    var counter = $("#rowCounterDeleteAmendAmend3").val();
                    var chkboxCounter=$("#chkboxCounterDeleteAmend3").val();

                    counter=counter-chkboxCounter;

                    if (counter==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();
                        $("#rowCounterDeleteAmendAmend3").val(counter);
                        chkboxCounter=0;
                        $("#chkboxCounterAmend3").val(chkboxCounter);

                    }

                });

                function checkboxTrueAmend3(i){
                    //alert("counter");
                    if(document.getElementById("chckboxAmend3"+i).checked==true){

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

                    else{

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

                }
                function searchProduct_Amend(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 = "memberEnrollment.jsp";
                    var lovKey = "TradingProductSearchAmend"
                    popWin = open('/PacsApplication/CommonSearchInformationTradingLOV.jsp?screenName=' + screenName + '&lovKey=' + lovKey + '&textIndex=' + i, 'TrandingProductSearch', attr);
                    popWin.focus();

                }


                function getSelectedChbox(memberEnrollForm) {

                    var selchbox = [];        // array that will store the value of selected checkboxes

                    // gets all the input tags in frm, and their number
                    var inpfields = memberEnrollForm.getElementsByTagName('input');
                    var nr_inpfields = inpfields.length;

                    // traverse the inpfields elements, and adds the value of selected (checked) checkbox in selchbox
                    for(var i=0; i<nr_inpfields; i++) {
                        if(inpfields[i].type == 'checkbox' && inpfields[i].checked == true){
                            if  (inpfields[i].value!=null || inpfields[i].value!="" ){

                                selchbox.push(inpfields[i].value);

                            }

                        }

                    }

                    return selchbox;
                }

                function noBack()
                {
                    window.history.forward();
                }

                function submitform(memberEnrollForm)
                {

                    if (checkCreateDiv(memberEnrollForm))
                    {

                        document.forms[0].handle_id.value = "Create";
                        document.forms[0].action='/PacsApplication/MemberEnrollmentServlet';
                        document.forms[0].submit();
                    }

                }
                function checkCreateDiv(memberEnrollForm)
                {
                    var cnt=document.forms[0].rowCounter.value;

                    var i=1;

                    if (memberEnrollForm.custName.value == ""||memberEnrollForm.cardNo.value == ""||memberEnrollForm.district.value == ""||memberEnrollForm.dateOfBirth.value == ""||memberEnrollForm.SDWOf.value == ""||memberEnrollForm.houseNo.value == ""||memberEnrollForm.street.value == ""||memberEnrollForm.gramPanchayat.value == ""||memberEnrollForm.revenueBlock.value == ""||memberEnrollForm.subdivision.value == ""||memberEnrollForm.state.value == ""||memberEnrollForm.issuedOn.value == ""||memberEnrollForm.validUpto.value == ""||memberEnrollForm.revenueBlock.value == ""||memberEnrollForm.cardCategory.value == "")
                    {
                        alert("!! All fields must be filled !!");
                        //||
                        return false;
                        // memberEnrollForm.custName.focus();

                    }
                    
                    var radios = document.getElementsByName("choice");
                    if ( radios[0].checked ) { // radio checked?
                        val = radios[0].value; // if so, hold its value in val

                    }
                    else{
                        val = radios[1].value; // if so, hold its value in val
                    }
                    //alert(val);
                    if (val=="Yes"){
                        for (i=1;i<=cnt;i++){
                            if (document.getElementById("cardNoFamily"+i).value == ""||document.getElementById("cardHolderNameFamily"+i).value == ""||document.getElementById("DOBFamily"+i).value == ""){
                                alert("!! All fields must be filled !!");
                                return false;
                            }
                        }
                    }

                    var chkdate = document.getElementById("dateOfBirth").value;
                    var edate = chkdate.split("/");
                    var spdate = new Date();
                    var sdd = spdate.getDate();
                    var smm = spdate.getMonth();
                    var syyyy = spdate.getFullYear()-0;
                    var today = new Date(syyyy,smm,sdd).getTime();
                    var e_date = new Date(edate[2],edate[1]-1,edate[0]).getTime();
                    if(e_date > today)
                    {
                        alert("Birth Date is not valid");
                        return false;
                    }
                    

                    var chkdate = document.getElementById("issuedOn").value;
                    var edate = chkdate.split("/");
                    var spdate = new Date();
                    var sdd = spdate.getDate();
                    var smm = spdate.getMonth();
                    var syyyy = spdate.getFullYear()-0;
                    var today = new Date(syyyy,smm,sdd).getTime();
                    var e_date = new Date(edate[2],edate[1]-1,edate[0]).getTime();
                    if(e_date > today)
                    {
                        alert("Issued Date is not valid");
                        return false;
                    }
                   
                    var chkdate = document.getElementById("validUpto").value;
                    var edate = chkdate.split("/");
                    var spdate = new Date();
                    var sdd = spdate.getDate();
                    var smm = spdate.getMonth();
                    var syyyy = spdate.getFullYear()-0;
                    var today = new Date(syyyy,smm,sdd).getTime();
                    var e_date = new Date(edate[2],edate[1]-1,edate[0]).getTime();
                    if(e_date < today)
                    {
                        alert("Valid upto Date is not valid");
                        return false;
                    }
                    


                    return true;
                }
                function updateform(memberEnrollForm)
                {

                    // if (checkUpdateDiv(memberEnrollForm))
                    //  {
                    //alert("Hi");
                    document.forms[0].handle_id.value = "Update";
                    document.forms[0].action='/PacsApplication/MemberEnrollmentServlet';
                    memberEnrollForm.submit();

                    //  }
                }


                function checkUpdateDiv(memberEnrollForm)
                {


                    var cnt=document.forms[0].rowCounterAmend3.value;
                    var i=1;

                    if (memberEnrollForm.custNameAmend.value == ""||memberEnrollForm.districtAmend.value == ""||memberEnrollForm.dateOfBirthAmend.value == ""||memberEnrollForm.SDWOfAmend.value == ""||memberEnrollForm.houseNoAmend.value == ""||memberEnrollForm.streetAmend.value == ""||memberEnrollForm.gramPanchayatAmend.value == ""||memberEnrollForm.revenueBlockAmend.value == ""||memberEnrollForm.subdivisionAmend.value == ""||memberEnrollForm.stateAmend.value == ""||memberEnrollForm.issuedOnAmend.value == ""||memberEnrollForm.validUptoAmend.value == "")
                    {

                        alert("!! All fields must be filled !!");
                        return false;


                    }

                    var radios = document.getElementsByName("choiceAmend");
                    if ( radios[0].checked ) { // radio checked?
                        val = radios[0].value; // if so, hold its value in val

                    }
                    else{
                        val = radios[1].value; // if so, hold its value in val
                    }
                    //alert(val);
                    if (val=="Yes"){
                        for (i=1;i<=cnt;i++){
                            if (document.getElementById("cardNoFamilyAmend"+i).value == ""||document.getElementById("cardHolderNameFamilyAmend"+i).value == ""||document.getElementById("DOBFamilyAmend"+i).value == ""){
                                alert("!! All fields must be filled !!");
                                return false;
                            }
                        }
                    }
                     var chkdate = document.getElementById("dateOfBirthAmend").value;
                    var edate = chkdate.split("/");
                    var spdate = new Date();
                    var sdd = spdate.getDate();
                    var smm = spdate.getMonth();
                    var syyyy = spdate.getFullYear()-0;
                    var today = new Date(syyyy,smm,sdd).getTime();
                    var e_date = new Date(edate[2],edate[1]-1,edate[0]).getTime();
                    if(e_date > today)
                    {
                        alert("Birth Date is not valid");
                        return false;
                    }
                    var chkdate = document.getElementById("issuedOnAmend").value;
                    var edate = chkdate.split("/");
                    var spdate = new Date();
                    var sdd = spdate.getDate();
                    var smm = spdate.getMonth();
                    var syyyy = spdate.getFullYear()-0;
                    var today = new Date(syyyy,smm,sdd).getTime();
                    var e_date = new Date(edate[2],edate[1]-1,edate[0]).getTime();
                    if(e_date > today)
                    {
                        alert("Issued Date is not valid");
                        return false;
                    }
                    var chkdate = document.getElementById("validUptoAmend").value;
                    var edate = chkdate.split("/");
                    var spdate = new Date();
                    var sdd = spdate.getDate();
                    var smm = spdate.getMonth();
                    var syyyy = spdate.getFullYear()-0;
                    var today = new Date(syyyy,smm,sdd).getTime();
                    var e_date = new Date(edate[2],edate[1]-1,edate[0]).getTime();
                    if(e_date < today)
                    {
                        alert("Valid upto Date is not valid");
                        return false;
                    }


                    return true;


                }
                //LOV
                function popup_CIF(width, height, cifNumber,cifName) {
                    // cifNumber=cifNumber+'';
                    //  cifName=cifName+'';
                    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 = "memberEnrollment.jsp";
                    var  lovKey="";
                    if (cifName=='1010')
                        lovKey="cardTypeSearch";
                    else if (cifName=='2010')
                        lovKey="cardTypeSearchAmend";
                    else
                        lovKey="memberDetails";

                    popWin = open('/PacsApplication/CommonSearchInformationPdsLOV.jsp?cifNumber=' + cifNumber + '&cifName=' + cifName +'&screenName=' + screenName+'&lovKey='+lovKey, 'memberDetails', attr);
                    popWin.focus();

                }
                function checkop()
                {

                    if (document.getElementById("checkOption").value == "create")
                    {
                        //  document.getElementById('chckboxCounter').value=0;
                        //  document.forms[0].rowCounter.value = 1;
                        document.getElementById('create').style.display = 'block';
                        // document.getElementById('mandatory').style.display = 'block';
                        document.getElementById('amend').style.display = 'none';
                        document.getElementById('amend2').style.display = 'none';
                        // document.getElementById('create2').style.display = 'block';


                    }
                    if (document.getElementById("checkOption").value == "amend")
                    {
                        //  document.getElementById('chckboxCounter').value=0;
                        //  document.forms[0].rowCounter.value = 1;

                        document.getElementById('amend').style.display = 'block';
                        //  document.getElementById('mandatory').style.display = 'none';
                        document.getElementById('create').style.display = 'none';

                        //alert("before");
                        //   document.getElementById('create2').style.display = 'none';
                        document.getElementById('amend2').style.display = 'none';

                        //alert("after");
                    }


                }


                function searchMember() {

                    document.forms[0].handle_id.value = "Search";
                    document.forms[0].action = '/PacsApplication/MemberEnrollmentServlet';
                    document.forms[0].submit();

                }
                function displayFamilyDetails1(memberEnrollForm){
                    var val;
                    // get list of radio buttons with specified name
                    var radios = document.getElementsByName("choiceAmend");
                    if ( radios[0].checked ) { // radio checked?
                        val = radios[0].value; // if so, hold its value in val

                    }
                    else{
                        val = radios[1].value; // if so, hold its value in val
                    }
                    //alert(val);
                    if (val=="Yes"){

                        $("#rowCounterAmend3").val(1);
                        document.getElementById('amend3').style.display = 'block';


                    }
                    else{
                        $("#rowCounterAmend3").val(0);
                        document.getElementById('amend3').style.display = 'none';

                    }
                }
                function displayFamilyDetails() {
                    var val;
                    // get list of radio buttons with specified name

                    var radios = document.getElementsByName("choice");
                    if ( radios[0].checked ) { // radio checked?
                        val = radios[0].value; // if so, hold its value in val

                    }
                    else{
                        val = radios[1].value; // if so, hold its value in val
                    }
                    //alert(val);
                    if (val=="Yes"){
                        $("#rowCounter").val(1);
                        document.getElementById('create2').style.display = 'block';

                    }
                    else{
                        $("#rowCounter").val(0);
                        document.getElementById('create2').style.display = 'none';

                    }
                    /*
            // loop through list of radio buttons
            for (var i=0, len=radios.length; i<len; i++) {
                if ( radios[i].checked ) { // radio checked?
                    val = radios[i].value; // if so, hold its value in val
                    break; // and break out of for loop
                }
            }

            return val; // return value of checked radio or undefined if none checked
                     */
                }
                function ShowCalender(i){

                    getCalendar(document.getElementById("DOBFamily"+i));
                }
                function ShowCalenderAmend(i){

                    getCalendar(document.getElementById("DOBFamilyAmend"+i));
                }
                function ShowCalenderAmend3(i){

                    getCalendar(document.getElementById("DOBFamilyAmend3"+i));
                }


                function ShowParent()
                {
                    document.forms[0].action = "/PacsApplication/Pds_JSP/memberEnrollment.jsp";
                    document.forms[0].submit();
                }

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