<%@ page language="C#" autoeventwireup="true" inherits="WebcamCapture, App_Web_5gjsljb5" masterpagefile="~/Pages/Common/MasterPages/PlainDialogMasterPage.master" enableEventValidation="false" viewStateEncryptionMode="Never" %>



<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">


    <table border="0" cellpadding="0" cellspacing="0" class="border0">

        <tr align="center">
            <td align="center" colspan="2">Student Id :
            </td>
            <td></td>
            <td align="center">
                <u>
                    <asp:TextBox ID="StudentIdNoTextBox" AutoPostBack="true" OnTextChanged="StudentIdNoTextBox_TextChanged" SkinID="CustomWidthTextBox" Width="150px" runat="server" MaxLength="200"> </asp:TextBox>
                </u>
            </td>
        </tr>



        <tr>
            <td>&nbsp
            </td>
        </tr>

        <tr align="center" class="newheadtitle">
            <td align="center" colspan="2" width="300px">

                <b><u>Live Camera  :</u> </b>
            </td>
            <td class="newheadtitle">&nbsp &nbsp &nbsp &nbsp &nbsp <u></u>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp 
  <%--          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp 
             &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp--%>
            

            </td>
            <td class="newheadtitle">&nbsp &nbsp &nbsp &nbsp &nbsp <u></u>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp <b><u>Captured Picture</u> </b>
                &nbsp &nbsp &nbsp &nbsp &nbsp <u></u>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp 
            
            
            </td>
        </tr>

    </table>


    <table border="1">

        <tr>
            <td>&nbsp &nbsp &nbsp &nbsp &nbsp <u></u>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp  
            &nbsp &nbsp &nbsp &nbsp &nbsp <u></u>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp 
            &nbsp &nbsp &nbsp &nbsp &nbsp <u></u>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp 
            &nbsp &nbsp &nbsp &nbsp &nbsp <u></u>&nbsp &nbsp &nbsp &nbsp

            
            <div id="webcam">
            </div>
            </td>
            <td>&nbsp;
            </td>
            <td>
                <asp:Image ID="imgCapture" runat="server" Style="visibility: hidden; width: 480px; height: 480px" />
            </td>
        </tr>
    </table>




    <table border="0">
        <tr>
            <td>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp  &nbsp &nbsp &nbsp &nbsp
            
                <asp:Button ID="btnCapture" Text="Capture" runat="server" OnClientClick="return Capture();" SkinID="CustomWidthButton,0" Width="130px" CssClass="PrimaryButton" />

                &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp 
                
            </td>
            <td align="center">&nbsp &nbsp
            <asp:Button ID="ClearButton" runat="Server" OnClick="ClearButton_Click" Text="Clear" />
                &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp 
        
            </td>
            <td align="center">&nbsp &nbsp &nbsp &nbsp
           <u>
               <asp:Button ID="UploadButton" runat="server" Text="Upload" OnClick="UploadButton_Click" OnClientClick="return validate();" /></u>
                &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp 
            </td>
        </tr>
    </table>

    <br />
    <span id="camStatus"></span>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script src='<%=ResolveUrl("~/JavaScript/Webcam_Plugin/jquery.webcam.js") %>' type="text/javascript"></script>
    <script type="text/javascript">
        var pageUrl = '<%=ResolveUrl("~/Pages/BaseFramework/Utilities/WebcamCapture.aspx") %>';
        $(function () {

            jQuery("#webcam").webcam({
                width: 480,
                height: 480,
                mode: "save",
                swffile: '<%=ResolveUrl("~/Javascript/Webcam_Plugin/jscam.swf") %>',
                debug: function (type, status) {
                    $('#camStatus').append(type + ": " + status + '<br /><br />');
                },
                onSave: function (data) {
                    $.ajax({
                        type: "POST",
                        url: pageUrl + "/GetCapturedImage",
                        data: '',
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (r) {
                            $("[id*=imgCapture]").css("visibility", "visible");
                            $("[id*=imgCapture]").attr("src", r.d);
                        },
                        failure: function (response) {
                            alert(response.d);
                        }
                    });
                },
                onCapture: function () {
                    webcam.save(pageUrl);
                }
            });
        });



  <%--  function GetMasterValue() {
        var hy = (document.getElementById('<%=Master.FindControl("DialogHeaderLabel").ClientID %>').innerHTML);
        
        return false;
    }--%>

        function Capture() {

            var StudIdNo = document.getElementById('<%=StudentIdNoTextBox.ClientID %>').value;
            if (StudIdNo == "") {
                alert("Enter Student Id No.");
                document.getElementById('<%=StudentIdNoTextBox.ClientID %>').focus();
            return false;
        }

        webcam.capture();
        return false;
    }

    function validate() {
        var StudIdNo = document.getElementById('<%=StudentIdNoTextBox.ClientID %>').value;

        if (StudIdNo == "") {
            alert("Enter Student Id No.");
            document.getElementById('<%=StudentIdNoTextBox.ClientID %>').focus();
            return false;
        }
    }





    </script>
</asp:Content>
