﻿$(document).ready(function () {
    $('.animation').innerfade({
        speed: 1600,
        timeout: 6000,
        containerheight: '335px'
    });
    var Email = $('#NewsletterEmailtxt');
    var FormErrorMsg = $('#NewsletterMsg');
    $('#NewsletterButton').click(function () {
        var continueForm = true;
        if (!isValidEmailAddress(Email.val())) {
            continueForm = false;
            FormErrorMsg.show();
            goToByScroll(FormErrorMsg);
        }
        if (continueForm) {
            $('#form1').validationEngine('detach');
        }
        return continueForm;
    });
});
function goToByScroll(element) {
    var el = $.browser.opera ? $('html') : $('html, body');
    el.animate({
        scrollTop: $(element).offset().top
    }, 'slow');
}
function isValidEmailAddress(emailAddress) {
    var pattern = new RegExp(/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);
    return pattern.test(emailAddress)
}
