﻿$(function() {

    if ($(".title").text() == "Contact Us") {

        $("input#submit").click(function() {

            var flag = true;

            var name = $("input#q1").val();
            if (name == "") {

                $("input#q1").focus();
                flag = false;
                return false;
            }

            var email = $("input#q2").val();

            if (email == "") {

                $("input#q2").focus();
                flag = false;
                return false;
            }


            var message = $("textarea#q7").val();

            if (message == "") {
                $("textarea#q7").focus();
                flag = false;
                return false;
            }

            
            if (flag) {

                $.post("ProcessMail", { type: "contact", name: name, email: email, message: message },

                function(data) {

                    //alert("Data Loaded: " + data);

                })

                $(".tblcontact").ajaxSuccess(function(evt, request, settings) {
                    $(this).hide();

                    $(".supportsendcomplete").show();
                    $(".supportsendcomplete").html("<h6>Thank you for contacting us. We will contact you shortly.</h6>");
                });

            }
            
            return false;

        });

    }

    if ($(".title").text() == "Support") {

        $("input#submit").click(function() {

            var flag = true;

            var name = $("input#q1").val();

            if (name == "") {

                $("input#q1").focus();
                flag = false;
                return false;
            }

            var company = $("input#q4").val();



            var email = $("input#q2").val();

            if (email == "") {

                $("input#q2").focus();
                flag = false;
                return false;
            }

            var phone = $("input#q9").val();

            if (phone == "") {
                $("input#q9").focus();
                flag = false;
                return false;
            }



            var issue = $("textarea#q7").val();

            if (issue == "") {
                $("textarea#q7").focus();
                flag = false;
                return false;
            }



            if (flag) {

                $.post("ProcessMail", { type: "support", name: name, company: company, email: email, phone: phone, issue: issue },

                function(data) {
                    //alert("Data Loaded: " + data);
                })

                $(".tblsupport").ajaxSuccess(function(evt, request, settings) {
                    $(this).hide();

                    $(".supportsendcomplete").show();
                    $(".supportsendcomplete").html("<h6>Thank you for contacting us. We will contact you shortly.</h6>");
                });



            }

            return false;

        });

    }

    if ($(".title").text() == "Forgot Password") {

        $("input#submit").click(function() {

            var username = $("input#username").val();



            $.get("http://209.139.209.216/STO/redirect/forgot_password.html", { username: username },

                function(data) {

                    alert("Data Loaded: " + data);

                });

            return false;

        });

    }



});