﻿function SubmitFeedback() {
    if ($("#txtEmail").val() == "") {
        alert("E-mail is required field!");
        $("#txtEmail").focus();
        return;
    } else {
        if (!EmailValider($("#txtEmail").val())) {
            alert("E-mail format is error!");
            $("#txtEmail").focus();
            return;
        }
    }
    if ($("#txtFirstName").val() == "") {
        alert("First Name is required field!");
        $("#txtFirstName").focus();
        return;
    }
    if ($("#txtLastName").val() == "") {
        alert("Last Name is required field!");
        $("#txtLastName").focus();
        return;
    }
    if ($("#txtFeedback").val() == "") {
        alert("Feedback message is required field!");
        $("#txtFeedback").focus();
        return;
    }
    ShowBackground();
    DisableOtherSubmit();
    $.ajax({
        url: $("#HomeLink").val() + '/Ajax/ProcessFeedback.ashx',
        type: 'GET',
        data: { Email: escape($("#txtEmail").val()), FirstName: escape($("#txtFirstName").val()), LastName: escape($("#txtLastName").val()), Feedback: escape($("#txtFeedback").val()), Time: (new Date()).getTime() },
        error: function() {
            location.href = $("#HomeLink").val() + "/Error/GenericErrorpage.aspx";
        },
        success: function(data) {
            RemoveBackground();
            EnableOtherSubmit();
            if (data == "ok") {
                alert("Feedback has been successfully sent.A Customer Service Representative will be in touch with you in about 2-3 business days!");
            } else {
                location.href = $("#HomeLink").val() + "/Error/GenericErrorpage.aspx";
            }
            var form1 = document.getElementById("FeedbackForm");
            form1.reset();
        }
    });
}