<!DOCTYPE html>
<html>
<head>
    <title>Login</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <style type="text/css">
        body { margin: 0; }
        form {
            border: 1px solid #D1D1D1;
        }
        fieldset {
            border: 0px;
        }
        legend {
            padding-top: 15px;
        }
        label {
            width: 100px;
            display: block;
            float: left;
        }
        p {
            margin-top: 0px;
        }
        textarea, select, input {
            border: 1px solid #D1D1D1;
            padding: 5px;
            -webkit-border-radius: 2px;
            -moz-border-radius: 2px;
            border-radius: 2px;
            background-color: white;
            width: 240px;
        }
    </style>
</head>

<body>
    <form method="post" action="" id="public-ticket-create">
        <input type="hidden" name="CSRFToken" value="{{ CSRFToken }}"/>
        <fieldset>
            <p>
                <label>{{ 'Name'|trans }}: </label>
                <input type="text" name="name" value="{{ request.name }}" required="required">
            </p>

            <p>
                <label>{{ 'Email'|trans }}: </label>
                <input type="email" name="email" value="{{ request.email }}" required="required">
            </p>

            <p>
                <label>{{ 'Subject'|trans }}: </label>
                <input type="text" name="subject" value="{{ request.subject }}" required="required">
            </p>

            <p>
                <label>{{ 'Message'|trans }}: </label>
                <textarea name="message" cols="5" rows="5" required="required">{{ request.message }}</textarea>
            </p>

            {% if guest.extension_is_on({ "mod": "spamchecker" }) %}
            {% set rc = guest.spamchecker_recaptcha %}
                {% if rc.enabled %}
                    {% if rc.version == 2 %}
                        <script src='https://www.google.com/recaptcha/api.js' async defer></script>
                        <div class="g-recaptcha" data-sitekey="{{ rc.publickey }}"></div>
                    {% else %}
                        {% set server = "https://www.google.com/recaptcha/api" %}
                        <script type="text/javascript">
                            var RecaptchaOptions = {
                            theme : 'custom',
                            custom_theme_widget: 'recaptcha_widget'
                         };
                        </script>

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

                           <div id="recaptcha_image"></div>
                           <div class="recaptcha_only_if_incorrect_sol" style="color:red">{{ 'Incorrect please try again'|trans }}</div>

                           <p>
                                <label>{{ 'Enter the words above'|trans }}</label>
                                <br/>
                                <input type="text" id="recaptcha_response_field" name="recaptcha_response_field" style="width: 245px"/>
                                <a class="btn btn-primary" href="javascript:Recaptcha.reload()" style="float: right">
                                    <span class="dark-icon i-reload"></span>
                                </a>
                           </p>
                         </div>

                        <script type="text/javascript" src="{{ server }}/challenge?k={{ rc.publickey }}"></script>

                        <noscript>
                            <iframe src="{{ server }}/noscript?k={{ rc.publickey }}" height="300" width="500" frameborder="0"></iframe><br/>
                            <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
                            <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
                        </noscript>
                    {% endif %}
                {% endif %}
            {% endif %}

            <input class="btn btn-primary" type="submit" value="{{ 'Send'|trans }}" style="width: auto;"/>
        </fieldset>

        <input type="hidden" name="anti-spam" value="1" id="anti-spam" required="required"/>
    </form>

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$(function() {
    $('#anti-spam').remove();

    $('#public-ticket-create').on('submit', function(event) {
        $.post("{{ constant('SYSTEM_URL') }}api/guest/support/ticket_create",
        $(this).serialize(),
        function(json) {
            if(json.error) {
                alert(json.error.message);
            } else {
                parent.window.location = "{{ 'support/contact-us/conversation'|link }}" + '/' + json.result;
            }
        }, 'json');

        return false;
    });
});
</script>
</body>
</html>
