﻿$(document).ready(function() {
    $(".contentBox").each(function(i) {
        if ($(this).attr("id") != "contentBox3") {
            $(this).css("cursor", "pointer");
        }
    });

    $(".contentBox").hover(function() {
        if ($(this).attr("id") != "contentBox3") {
            window.status = $(this).find("a:first").attr("href");
            return false;
        }
    },
            function() {
                if ($(this).attr("id") != "contentBox3") {
                    window.status = "";
                    return false;
                }
            });

    $(".contentBox").click(function() {
        if ($(this).attr("id") != "contentBox3") {
            window.location = $(this).find("a:first").attr("href");
        }
    });

    $("#subscribeForm").submit(function(e) {
        var isValid = validateEmail($("#newsletterEmail").val());
        if (!isValid) {
            e.preventDefault();
            alert("Invalid email address");
        }

        return isValid;
    });
});

function validateEmail(email) {
    var regExp = new RegExp("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])", "");
    return regExp.test(email);
}
