<%--
    Document   : Vendor EnrollmentEnquiry
    Created on : May 5, 2016, 12:31:09 PM
    Author     : 590685
--%>

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

<% try {
%>
<html>

    <head>
        <title>Vendor Enrollment/Enquiry</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>
        <script>



            function noBack()
            {
                window.history.forward();
            }
            function submitform(VendorMasterForm)
            {
                if (checkDiv(VendorMasterForm))
                {
                    document.forms[0].handle_id.value = "Create";
                    document.forms[0].action = '/PacsApplication/VendorMasterServlet';
                    VendorMasterForm.submit();
                }
            }


            function Updateform(VendorMasterForm)
            {
                if (updateDiv(VendorMasterForm))
                {

                    document.forms[0].handle_id.value = "Update";

                    document.forms[0].action = '/PacsApplication/VendorMasterServlet';

                    VendorMasterForm.submit();
                }
            }





            function checkDiv(VendorMasterForm)
            {
                if (VendorMasterForm.vendorname.value == "")
                {
                    alert("Vendor Name must be filled.");
                    VendorMasterForm.vendorname.focus();
                    return false;
                }
                if (VendorMasterForm.address.value == "")
                {
                    alert("Address must be filled.");
                    VendorMasterForm.address.focus();
                    return false;
                }
                if (VendorMasterForm.phone.value == "")
                {
                    alert("Phone Number must be filled.");
                    VendorMasterForm.phone.focus();
                    return false;
                }
                if (VendorMasterForm.contactperson.value == "")
                {
                    alert("Contact Person must be filled.");
                    VendorMasterForm.contactperson.focus();
                    return false;
                }                

                var counter = document.forms[0].rowCounter.value;



                for (var i = 1; i <= counter; i++) {
                    try{

                    var commoditytype = document.getElementById("commoditytype"+i).value;
                    var typedesc = document.getElementById("typeDesc"+i).value;
                    var commoditysubtype = document.getElementById("commoditysubtype"+i).value;
                    var subtypedesc = document.getElementById("subtypeDesc"+i).value;



                    if (commoditytype == "" || typedesc == "" || commoditysubtype == "" || subtypedesc == "" ) {

                        alert("Fill The Required Fields");
                        return false;
                    }
                    }
                    catch(e){}

                }
                return true;

            }


            function updateDiv(VendorMasterForm)
            {
                if (VendorMasterForm.vendornameAmend.value == "")
                {
                    alert("Vendor Name must be filled.");
                    VendorMasterForm.vendornameAmend.focus();
                    return false;
                }
                if (VendorMasterForm.addressAmend.value == "")
                {
                    alert("Addres must be filled.");
                    VendorMasterForm.addressAmend.focus();
                    return false;
                }
                if (VendorMasterForm.contactpersonAmend.value == "")
                {
                    alert("Contact Person must be filled.");
                    VendorMasterForm.contactpersonAmend.focus();
                    return false;
                }                

                var counter = document.forms[0].rowCounter.value;



                for (var i = 1; i <= counter; i++) {

                    try{
                        var commoditytype = document.getElementById("commoditytypeAmend"+i).value;

                        var typedesc = document.getElementById("typeDescAmend"+i).value;

                        var commoditysubtype = document.getElementById("commoditysubtypeAmend"+i).value;

                        var subtypedesc = document.getElementById("subtypeDescAmend"+i).value;



                        if (commoditytype == "" || typedesc == "" || commoditysubtype == "" || subtypedesc == "" ) {

                            alert("Fill The Required Fields");
                            return false;
                        }


                    }
                    catch(e){

                    }


                }

                return true;

            }

            function checkop()
            {
                if (document.getElementById("checkOption").value == "create")
                {
                    document.getElementById('create').style.display = 'block';
                    document.getElementById('amend').style.display = 'none';
                    document.getElementById('amend2').style.display = 'none';
                }
                if (document.getElementById("checkOption").value == "amend")
                {
                    document.getElementById('create').style.display = 'none';
                    document.getElementById('amend').style.display = 'block';

                    document.getElementById('amend2').style.display = 'none';
                }
            }

            function numbersonly(e){
                    var unicode=e.charCode? e.charCode : e.keyCode
                    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
                    }
            }


            function getDetails() {

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

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

        </script>
    </head>
    <body>

        <%          int count = 1;
                    String error_msg = "";
                    Object error = request.getAttribute("message");
                    if (error != null) {
                        error_msg = error.toString();
                    }
        %>
        <%!
            String blankNull(String s) {
                return (s == null) ? "" : s;
            }
        %>

        <%
                    Object ObjVendorMasterHeaderBean = request.getAttribute("VendorMasterHeaderBeanObj");
                    VendorMasterHeaderBean VendorMasterHeaderBeanObj = new VendorMasterHeaderBean();
                    if (ObjVendorMasterHeaderBean != null) {
                        VendorMasterHeaderBeanObj = (VendorMasterHeaderBean) request.getAttribute("VendorMasterHeaderBeanObj");
                    }
        %>

        <%
                    Object alVendorMasterDtlBeanObj = request.getAttribute("alVendorMasterDtlBean");
                    ArrayList<VendorMasterDtlBean> alVendorMasterDtlBean = new ArrayList<VendorMasterDtlBean>();
                    VendorMasterDtlBean oVendorMasterDtlBean = new VendorMasterDtlBean();
                    if (alVendorMasterDtlBeanObj != null) {
                        alVendorMasterDtlBean = (ArrayList<VendorMasterDtlBean>) request.getAttribute("alVendorMasterDtlBean");

                    }
        %>

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

        <jsp:include page="MenuHead_TRADING.jsp" flush="true" />
        <br>
        <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">Vendor Enrollment/Enquiry</legend>

            <form id="VendorMasterForm" name="VendorMasterForm" method="post" action="VendorMasterServlet">

                <%if (!error_msg.equalsIgnoreCase("")) {%>
                <center><div class="info" id="errorMessage"><center><%= error_msg%></center></div></center>
                <% }%>
                <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>
                <div id="create" style="display:none;">
                    <table>
                        <tbody>
                            <tr>
                                <td>Vendor Name<font color="red" >*</font>:</td>
                                <td><input type="text" id="vendorname" name="vendorname" />

                                </td>
                            </tr>
                            <tr>
                                <td>Address<font color="red" >*</font>:</td>
                                <td>
                                    <textarea name="address" id="address" ></textarea>
                                </td>
                            </tr>
                            <tr>
                                <td>Phone<font color="red" >*</font>:</td>
                                <td><input type="text" name="phone" maxlength="10"  id="phone" maxlength="10" onkeypress="return numbersonly(event)" value="" style="text-align:right;" /></td>
                            </tr>
                            <tr>
                                <td>Contact Person<font color="red" >*</font>:</td>
                                <td><input type="text" name="contactperson" id="contactperson" value="" /></td>
                            </tr>
                            <tr>
                                <td>GSTIN Number:</td>
                                <td><input type="text" name="gstin" id="gstin" value="" maxlength="20" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 90 && event.charCode != 64' /></td>
                            </tr>
                        </tbody>
                    </table>
                    <br>
                    <table id="order-list"  >

                        <thead  class="CSSTableGenerator" >
                            <tr>
                                <td></td>
                                <td colspan="2">Commodity Type</td>
                                <td>Type Description</td>
                                <td>Sub Type</td>
                                <td>Sub Type description</td>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td><input type="checkbox" name="chckbox<%=count%>" id="chckbox<%=count%>" onclick="checkboxTrue(<%=count%>);" /></td>
                                <td><input type="text" name="commoditytype<%=count%>" id="commoditytype<%=count%>" readonly /></td>
                                <td> <center>
                                        <input type="button" value="Search"  onclick="javascript:searchProduct(450,180,<%=count%>)">
                                    </center></td>

                                <td><input type="text" name="typeDesc<%=count%>" id="typeDesc<%=count%>" readonly /></td>

                                <td><input type="text"  name="commoditysubtype<%=count%>" id="commoditysubtype<%=count%>" readonly/></td>
                                <td><input type="text"  name="subtypeDesc<%=count%>" id="subtypeDesc<%=count%>" readonly/></td>

                                <td><input type="hidden" name="product_id<%=count%>" id="product_id<%=count%>"/></td>
                            </tr>
                        </tbody>
                    </table>

                    <br/><br/>
                    <center>
                        <input type="button" id="addRow" value="Add Row"/>
                        <input type="button" id="deleteRow" value="Delete Row"/>
                        <input type="button" value="Submit" onclick="javascript:submitform(VendorMasterForm)"/>
                        <input type="button" value="Reset" onclick="ShowParent();" />
                    </center>
                </div>
                <br>

                <div id="amend" style="display: none;">
                    <center>
                        <lable style=" font-family: Berlin Sans FB; font-weight:  normal;" >Enter Vendor Name: </lable>
                        <input type="text" name="vendornameSearch" id="vendornameSearch" />
                        <input type="button"  value="Search" onclick="javascript:SearchVendor(450, 200, document.VendorMasterForm.vendornameSearch.value)" />
                        <input type="button"  value="Submit" onclick="javascript:getDetails()" />
                    </center>
                    <br><br>
                </div>

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

                <div id="amend2" >
                    <table>
                        <tbody>
                            <tr>
                                <td>Vendor Name:</td>
                                <td><input type="text" name="vendornameAmend" readonly id="vendornameAmend" value="<%=blankNull(VendorMasterHeaderBeanObj.getVendorname())%>" /></td>
                            </tr
                            <tr>
                                <td>Address:</td>
                                <td>
                                    <textarea  name="addressAmend" id="addressAmend"><%=blankNull(VendorMasterHeaderBeanObj.getAddress())%></textarea>
                                </td>
                            </tr>
                            <tr>
                                <td>Phone:</td>
                                <td><input type="text" style="text-align:right;" name="phoneAmend"  id="phoneAmend" value="<%=blankNull(VendorMasterHeaderBeanObj.getPhone())%>" maxlength="10" /></td>
                            </tr>
                            <tr>
                                <td>Contact person:</td>
                                <td><input type="text" name="contactpersonAmend" id="contactpersonAmend" value="<%=blankNull(VendorMasterHeaderBeanObj.getContactperson())%>" /></td>
                            </tr>
                            <tr>
                                <td>GSTIN Number:</td>
                                <td><input type="text" name="gstinAmend" id="gstinAmend" value="<%=blankNull(VendorMasterHeaderBeanObj.getGstin())%>" maxlength="20" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 90 && event.charCode != 64' /></td>
                            </tr>
                        </tbody>
                    </table>
                    <br>
                    <!--For Populating Deatils-->

                    <% if (alVendorMasterDtlBean.size() > 0) { %>

                    <table id="order-list-Amend"  >

                        <thead  class="CSSTableGenerator" >
                            <tr>
                                <td></td>
                                <td colspan="2">Commodity Type</td>
                                <td>Type Description</td>
                                <td>Sub Type</td>
                                <td>Sub Type description</td>

                            </tr>
                        </thead>
                        <tbody>

                            <%
                                oVendorMasterDtlBean = new VendorMasterDtlBean();
                                count = 0;

                                for (int i = 0; i < alVendorMasterDtlBean.size(); i++) {
                                    oVendorMasterDtlBean = alVendorMasterDtlBean.get(i);

                                    count++;
                            %>

                            <tr>
                                <td><input type="checkbox" name="chckboxAmend<%=count%>" id="chckboxAmend<%=count%>" onclick="checkboxTrueAmend(<%=count%>);" value="<%=blankNull(oVendorMasterDtlBean.getDetailID())%>" /></td>
                                <td><input type="text" name="commoditytypeAmend<%=count%>" id="commoditytypeAmend<%=count%>" readonly value="<%=blankNull(oVendorMasterDtlBean.getCommoditytype())%>" /></td>
                                <td> <center>
                                        <input type="button" value="Search"  onclick="javascript:searchProduct_Amend(450,200,<%=count%>)">
                                    </center></td>

                                <td><input type="text" name="typeDescAmend<%=count%>" id="typeDescAmend<%=count%>" readonly value="<%=blankNull(oVendorMasterDtlBean.getTypeDesc())%>" /></td>

                                <td><input type="text"  name="commoditysubtypeAmend<%=count%>" id="commoditysubtypeAmend<%=count%>" readonly value="<%=blankNull(oVendorMasterDtlBean.getCommoditysubtype())%>"/></td>
                                <td><input type="text"  name="subtypeDescAmend<%=count%>" id="subtypeDescAmend<%=count%>" readonly value="<%=blankNull(oVendorMasterDtlBean.getSubtypeDesc())%>" /></td>

                                <td><input type="hidden" name="product_idAmend<%=count%>" id="product_idAmend<%=count%>" value="<%=blankNull(oVendorMasterDtlBean.getProduct_id())%>" /></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(oVendorMasterDtlBean.getDetailID())%>" /></td>
                            </tr>

                            <%}%>
                        </tbody>
                    </table>

                    <br>
                    <center>
                        <input type="button" id="addRowAmend" value="Add Row"/>
                        <input type="button" id="deleteRowAmend" value="Delete Row"/>
                        <input type="button" value="Submit" onclick="javascript:Updateform(VendorMasterForm)"/>
                        <input type="button" value="Reset" onclick="ShowParent();" />

                    </center>
                    <%}%>
                </div>
                <%}%>
                <input type="hidden" name="handle_id" value="" />
                <input type="hidden" name="rowCounter" id="rowCounter" value="<%=count%>">
                <input type="hidden" name="rowCounterDelete" id="rowCounterDelete" value="<%=count%>">
                <input type="hidden" name="rowCounterDeleteCreate" id="rowCounterDeleteCreate" value="<%=count%>">
                <input type="hidden" name="chkboxCounter" id="chkboxCounter" value="0"/>
                <input type="hidden" name="vendorID" id="vendorID" value="<%=blankNull(VendorMasterHeaderBeanObj.getVendorID())%>" />
                <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><input type="checkbox" name="chckbox' + counter + '" id="chckbox' + counter + '" onclick="checkboxTrue(' + counter + ');"/></td>  \n\
                <td align="center"><input type="text" readonly name="commoditytype' + counter + '" id="commoditytype' + counter + '" value=""/></td> \n\
                <td> <center><input type="button" value="Search"  onclick="javascript:searchProduct(220,180,' + counter + ')"></center></td>\n\
                <td><input type="text" readonly id="typeDesc' + counter + '" name="typeDesc' + counter + '" value=""/></td>\n\
                <td><input type="text" readonly name="commoditysubtype' + counter + '" id="commoditysubtype' + counter + '" value=""/></td>\n\
                \n\
                <td><input type="text" readonly name="subtypeDesc' + counter + '" id="subtypeDesc' + counter + '"/></td>\n\
                <td><input type="hidden" name="rowStatus' + counter + '" id="rowStatus' + counter + '" value="N"/></td>\n\
                <td><input type="hidden" name="product_id' + counter + '" id="product_id' + counter + '" value=""/></td>\n\\n\
                \n\
                </tr>');
                    $("#rowCounter").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);

                    }

                });




                function checkboxTrue(i){

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

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

                    else{

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

                }

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

                }

                function SearchVendor(width, height, VendorName)
                {

                    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 = "VendorEnrollmentEnquiry.jsp";
                    var lovKey = "VendorDetails";

                    popWin = open('/PacsApplication/CommonSearchInformationTradingLOV.jsp?screenName=' + screenName + '&lovKey=' + lovKey + '&VendorName=' + VendorName , 'VendorDetails', attr);
                    popWin.focus();

                }

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


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

                    var counter = $("#rowCounter").val();
                    counter++;
                    $('#order-list-Amend tr:last').after('<tr><td><input type="checkbox" name="chckboxAmend' + counter + '" id="chckboxAmend' + counter + '" onclick="checkboxTrueAmend(' + counter + ');" value="" /></td>  \n\
                <td align="center"><input type="text" readonly name="commoditytypeAmend' + counter + '" id="commoditytypeAmend' + counter + '"/></td> \n\
                <td> <center><input type="button" value="Search"  onclick="javascript:searchProduct_Amend(220,180,' + counter + ')"></center></td>\n\
                <td><input type="text" readonly id="typeDescAmend' + counter + '" name="typeDescAmend' + counter + '"/></td>\n\
                <td><input type="text" readonly name="commoditysubtypeAmend' + counter + '" id="commoditysubtypeAmend' + counter + '"/></td>\n\
                \n\
                <td><input type="text" readonly name="subtypeDescAmend' + counter + '" id="subtypeDescAmend' + counter + '"/></td>\n\
                <td><input type="hidden" name="rowStatus' + counter + '" id="rowStatus' + counter + '" value="N"/></td>\n\
                <td><input type="hidden" name="product_idAmend' + counter + '" id="product_idAmend' + counter + '" value=""/></td>\n\
                <td><input type="hidden" name="detailIDAmend' + counter + '" id="detailIDAmend' + counter + '" value="" /></td>\n\
                </tr>');
                    $("#rowCounter").val(counter);
                    $("#rowCounterDelete").val(counter);

                });


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


                    var len = ($("#order-list-Amend tr").length)-1;
                    var counter =$("#rowCounterDelete").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;
                        }

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

                        selchbox= getSelectedChbox(VendorMasterForm);
                        $("#deletedRows").val(selchbox);

                        $('input:checkbox:checked').closest('tr').remove();
                        $("#rowCounterDelete").val(counterDelete);
                        chkboxCounter=0;
                        $("#chkboxCounter").val(chkboxCounter);


                    }


                });



                function checkboxTrueAmend(i){

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

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

                    else{

                        var counter = $("#chkboxCounter").val();
                        counter--;
                        $("#chkboxCounter").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 = "VendorEnrollmentEnquiry.jsp";
                    var lovKey = "TradingProductSearchAmend"
                    popWin = open('/PacsApplication/CommonSearchInformationTradingLOV.jsp?screenName=' + screenName + '&lovKey=' + lovKey + '&textIndex=' + i, 'TrandingProductSearch', attr);
                    popWin.focus();

                }


                function getSelectedChbox(VendorMasterForm) {

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

                    // gets all the input tags in frm, and their number
                    var inpfields = VendorMasterForm.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;
                }

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