﻿//hook up events

$(document).ready(function() {

    $("#anchContactUs").click(function() {
        $.facebox.settings.opacity = 0.35;
        $.facebox({ elementName: 'divContactUs' });
    });



    $("#frmContactUs").submit(function() {
        var isValid = true;

        if (GetIfBlankAndAttachErrorMessage('txtEmail', 'Please input your email address.'))
            isValid = false;
        if (!IsValidEmail($.trim($("#txtEmail").val()))) {

            AttachErrorMessage('txtEmail', 'Email does not appear to be a valid email address.');
            isValid = false;
        }
        if (GetIfBlankAndAttachErrorMessage('txtSubject', 'Please input your subject.'))
            isValid = false;
        if (GetIfBlankAndAttachErrorMessage('txtMessage', 'Please input your Message.'))
            isValid = false;

        if (isValid) {

            $.post($(this).attr("action"), $(this).serialize(), function(response) { //post using ajax
                if (response == "confirm") {
                    $("#spanfrom1").hide();
                    $("#spanUpdated1").show();
                    setTimeout("CloseFacebox()", 4000);
                }
            });
        };
        return false;
    });



});
