<!DOCTYPE html>
    <html>

    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="apple-mobile-web-app-capable" content="yes" />
        <title>Certificate</title>
        <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
        <link href="css/profile.css" rel="stylesheet" type="text/css" />

        <!-- <link rel="Shortcut Icon" type="image/x-icon" href="/images/Logo.png" /> -->
        <script>
            certificate = {}
            // certificate.shared = {}
            // certificate.contacts = {}
            // certificate.docs = {}
            certificate.v = {}
        </script>


        <script type="text/javascript" src="jsinclude/jquery-1.11.3.js"></script>
        <script type="text/javascript" src="jsinclude/jquery-ui.min.js"></script>

<!--
        <script type="text/javascript" src="jsinclude/modernizr.min.js"></script>
        <script type="text/javascript" src="jsinclude/jquery.md5.js"></script>
        <script type="text/javascript" src="jsinclude/jquery.cookie.js"></script>
        <script type="text/javascript" src="jsinclude/moment.min.js"></script>
        <script type="text/javascript" src="jsinclude/moment-timezone.js"></script>
-->

        <script type="text/javascript" src="js/transfer.js"></script>

        <style type="text/css">
        	
        	.certItem {
        		height: unset !important;
        		display: block !important;
        	}

        </style>

    </head>

    <body>

    <?
        $valid = false;
        $error = 'Unspecified Error';

        if (isset($_GET['id'])) {
            include('_functions2.php');
            $check = transferCheck($_GET['id']);

            if (strlen($check) > 30) {
                $valid = false;
                $error = 'This gift card has been transfered.';
                
            } else {
                $cert = certificatePrint($_GET['id']);
                if (sizeof($cert)) {
                    if ($cert[0]['used']) {
                        $valid = false;
                        $error = 'This gift card has been used.';
                    } elseif ($cert[0]['del']) {
                        $valid = false;
                        $error = 'This gift card has been deleted.';
                    } else {
                        $valid = true;
                    }

                } else {
                    $valid = false;
                    $error = 'This gift card has been deleted.';
                }
                                      
            }

        } else {
            $valid = false;
            $error = 'Missing ID';
            $check = '';
        }

    ?>


    <? if ( $valid ) { ?>

            <div id="status"><span></span></div>
                <div id="header">
                    <img src="images/logo.jpg" id="logo" alt="" />
                    <br />
                    <br />
                    <br />

                    
                    <div id="menu" onClick=""></div>

                    <!-- <div id="logout" onclick="< ? echo urlLogout(); ? >">logout</div> -->
                    <div class="title">Gift Certificate Transfer</div>
                </div>


                <br />
                <br />
                <br />
                <div id="main" style="text-align: center;">













<!-- 
<div id="selectsomething" ><div id="selectsomethinginner"><span id="selectheader" class="ui-draggable-handle">Gift Certificate Transfer

</span><hr><div class="items">

    <form id="transfer" action="processTransfer.php" method="post">
                        <input type="hidden" name="id" value="18A8B7F7-8BBC-C41A-3EF6-0BB28394368B">
                        <br>
                        <br>
                        <div id="contactBody">
                            <div id="row_0" class="certItem">
                                <div class="certItem">
                                    <div class="itemLabel first"> To First: </div>
                                    <div id="eefDegree" class="certField">
                                        <input name="first" type="text" id="cert_0_First" class="certbox" value="">
                                    </div>
                                </div>
                                <div class="certItem">
                                    <div class="itemLabel last"> To Last: </div>
                                    <div id="eefSchool" class="certField">
                                        <input name="last" type="text" id="cert_0_Last" class="certbox" value="">
                                    </div>
                                </div>
                                <div class="certItem">
                                    <div class="itemLabel email"> To Email: </div>
                                    <div class="certField">
                                        <input name="email" type="text" id="cert_0_Email" class="certbox" value="" style="border-color: crimson;">
                                    </div>
                                </div>

                                <br>
                                <div id="someSpace"></div>
                            </div>
                            <hr>
                            <div>
                                <p>
                                    <input name="from" type="text" id="cert_0_From" class="certbox" value="From Name" style="width: 250px;">
                                    <br>
                                    <textarea name="message" type="text" id="cert_0_Message" class="certbox" style="width: 250px;" maxlength="300">Message</textarea>
                                    <br>
                                    <span id="msgcnt"></span>
                                </p>

                            </div>

                        </div>
                        <br>
                        <br>
                        <br>
    <span id="processButton" class="button" onclick="certificate.transfer.process();" style="">Transfer</span>  
    </form>

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

 -->










                    <form id="transfer" action="processTransfer.php" method="post">
                        <input type="hidden" name="id" value="<? echo $_GET["id"]; ?>">
                        <br />
                        <br />
                        <div id="contactBody">
                            <div id="row_0" class="certItem">
                                <div class="certItem">
                                    <div class="itemLabel first"> To First: &nbsp;&nbsp;</div>
                                    <div id="eefDegree" class="certField">
                                        <input name="first" type="text" id="cert_0_First" class="certbox" value="">
                                    </div>
                                </div>
                                <div class="certItem">
                                    <div class="itemLabel last"> To Last: &nbsp;&nbsp;</div>
                                    <div id="eefSchool" class="certField">
                                        <input name="last" type="text" id="cert_0_Last" class="certbox" value="">
                                    </div>
                                </div>
                                <div class="certItem">
                                    <div class="itemLabel email"> To Email: </div>
                                    <div class="certField">
                                        <input name="email" type="text" id="cert_0_Email" class="certbox" value="">
                                    </div>
                                </div>

                                <br />
                                <div id="someSpace"></div>
                            </div>
                            <hr width="30%" >
                            <div>
                                <p>
                                    <input name="from" type="text" id="cert_0_From" class="certbox" value="From Name" style="width: 250px;">
                                    <br />
                                    <textarea name="message" type="text" id="cert_0_Message" class="certbox" style="width: 250px;" maxlength="300">Message</textarea>
                                    <br />
                                    <span id="msgcnt"></span>
                                </p>

                            </div>

                        </div>
                        <br />
                        <br />
                        <br />
                    </form>
                            <span id="processButton" class="button" onclick="certificate.transfer.process();" style="">Transfer</span>





                </div>

            </div>

    <br />
    <br />
    <script type="text/javascript">
        $( '#cert_0_From' ).focus(function() {
          if ($(this).val() === 'From Name') {
            $(this).val('');
          }
        });
        $( '#cert_0_From' ).blur(function() {
          if ($(this).val() === '') {
            $(this).val('From Name');
          }
        });
        $( '#cert_0_Message' ).focus(function() {
          if ($(this).val() === 'Message') {
            $(this).val('');
          } 
          $('#msgcnt').text(300-$(this).val().length)
        });
        $( '#cert_0_Message' ).blur(function() {
          if ($(this).val() === '') {
            $(this).val('Message');
            $('#msgcnt').text('');
            
            certificate.transfer.valid();
          }
        });

        $( '.certbox' ).blur(function() {
            certificate.transfer.valid();
        });

        $( '#cert_0_Message' ).keyup(function() {
                $('#msgcnt').text(300-$(this).val().length);
            
            if ($(this).val().length > 300) {
                // $('#msgcnt').text('');
                $(this).css('border-color','crimson');
                $(this).css('border-width','2px');
                $('#msgcnt').css('color','crimson');
            } else {
                $('#msgcnt').css('color','black');
            }
        });
    </script>

<? } else { ?>

    <style type="text/css">
        #header {
            display: block;
            text-align: center;
        }
        .messagearea {
            display: block;
            text-align: center;
            margin-top: 200px;
            font-size: 150%;
        }
    </style>
            <div id="header">
                <img src="images/logo.jpg" id="logo" alt="" />
            </div>
            <div class="messagearea">
                <div class="error">There is an issue with this eGift Card. 
                    <br /> 
                    <br /> 
                    If you feel that you have reached this message in error, please contact Signature&nbsp;Massage&nbsp;&amp;&nbsp;Facial&nbsp;Spa&nbsp;at&nbsp;813&#8209;925&#8209;8898 
                    <br />
                    <br />
                    Our apologies for any inconvenience.
                </div>
                    <br />
                    <br />
                <div class="specificerror">Error: <? echo $error; ?></div>
            </div>
        <? } ?>


<!--         <script type="text/javascript">
		// setTimeout(function(){}, 2000);
		// $(document).ready(function() {});
        </script> -->


    </body>

    </html>