$(document).ready(function () {
    $('#name').watermark('Your Name', { className: 'txtInactive' });
    $('#e-mail').watermark('Your Email Address', { className: 'txtInactive' });
    $('#subscribeBtn').click(function (event) {
        event.preventDefault();
        var $mssg = $('#subscribeMessage');
        var name = $('#name').val();
        var email = $('#e-mail').val();
        var emailValidation = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
        $mssg.html('');

        if (jQuery.trim(name) == "" || name == 'Your Name' ||
            jQuery.trim(email) == "" || email == 'Your Email Address' ||
            !emailValidation.exec(email)) {
            $mssg.html('You have to enter your name and valid email address');
            return;
        }

        $.ajax({
            type: "POST",
            traditional: true,
            url: "/ec-dForm/jsonformhelper.asmx/EmailSubscribe",
            data: "{ 'name' : '" + $('#name').val() + "','email' : '" + $('#e-mail').val() + "'}",
            contentType: 'application/json; charset=utf-8',
            dataType: "json",
            success: function (msg) {
                $mssg.html('Email subscribed');
                $('#name').val('');
                $('#e-mail').val('');
            }
        });
    });
});


$(function () {
    $('#tabs').tabs({ fx: { opacity: 'toggle', duration: 'fast'} });
    $("#dialog-modal").dialog("destroy");
    $("#FindSchool,.bodyCTA").click(function (event) {
        $("body").animate({ scrollTop: 0 }, 'fast', function () {
            $("#dialog-modal").dialog({
                height: 1,
                maxHeight: 1,
                modal: true,
                show: "fade",
                hide: "explode",
                width: 1,
                maxWidth: 1,
                position: [1, 150],
                resizable: false,
                closeOnEscape: true,
                zIndex: 750,
                close: function (event, ui) { $('#modalArrow').attr('style', 'display: none;'); }
            });
            $('.ui-dialog').attr('style', 'display: none;');
            $('#modalArrow').attr('style', '');

            $('.ui-widget-overlay').click(function () {
                $("#dialog-modal").dialog("destroy");
                $('#modalArrow').attr('style', 'display: none;');
            });
        });

    });

    $('#closeArrow').click(function () {
        $("#dialog-modal").dialog("destroy");
        $('#modalArrow').attr('style', 'display: none;');
    });

});



