(function () {
    var validateMailingList = function (e) {
        var email = $('[name="addliame"]').val();
        if (!email.match(/^[A-Z0-9._%+-]+@(?:[A-Z0-9\-]+\.)+[A-Z]{2,4}$/i)) {
            e.preventDefault();
            $('<p>Please correct your email address.</p>').dialog({
                height: 140,
                modal: true,
                title: "Ooops!"
            });
        }
    };
    
    $(document).ready(function () {
        var splashy = Global.MediaCarousel(".id-splashMedia", ".id-splashMediaUI");
        var logos = Global.MediaCarousel(".id-logosCarousel", "", {
            delay: 9000,
            useIndicators: false,
            activate: function (el) {
                el.addClass("woot");
                el.animate({
                    "opacity":1,
                    "left":"0%"
                }, { 
                    queue: false, 
                    duration: 3000
                });
            },
            deactivate: function (el) {
                el.removeClass("woot");
                el.animate({
                    "opacity":0,
                    "left":"-100%"
                }, { 
                    queue: false, 
                    duration: 3000, 
                    complete: function () {
                        el.css({"left": "100%"});
                    }
                });
            }
        });
        
        $('.id-signupForm').bind("submit", validateMailingList)
    });
})();
