﻿$(function() {

    $('#fadeThis').append('<span class="hover"></span>').each(function() {
        var $span = $('> span.hover', this).css('opacity', 0);
        $(this).hover(function() {
            $span.stop().fadeTo(500, 1);
        }, function() {
            $span.stop().fadeTo(500, 0);
        });
    });

    $('#fadeThis2').append('<span class="hover"></span>').each(function() {
        var $span = $('> span.hover', this).css('opacity', 0);
        $(this).hover(function() {
            $span.stop().fadeTo(500, 1);
        }, function() {
            $span.stop().fadeTo(500, 0);
        });
    });

    $('#fadeThis3').append('<span class="hover"></span>').each(function() {
        var $span = $('> span.hover', this).css('opacity', 0);
        $(this).hover(function() {
            $span.stop().fadeTo(500, 1);
        }, function() {
            $span.stop().fadeTo(500, 0);
        });
    });

    $('#fadeThis4').append('<span class="hover"></span>').each(function() {
        var $span = $('> span.hover', this).css('opacity', 0);
        $(this).hover(function() {
            $span.stop().fadeTo(500, 1);
        }, function() {
            $span.stop().fadeTo(500, 0);
        });
    });

    $('#fadeThis5').append('<span class="hover"></span>').each(function() {
        var $span = $('> span.hover', this).css('opacity', 0);
        $(this).hover(function() {
            $span.stop().fadeTo(500, 1);
        }, function() {
            $span.stop().fadeTo(500, 0);
        });
    });

    function IsValidEmail(email) {
        var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
        return filter.test(email);
    }

    $(".emailbox").each(function() {
        $tb = $(this);
        if ($tb.val() != this.title) {

        }
    });

    $(".emailbox").focus(function() {
        $tb = $(this);
        if ($tb.val() == this.title) {
            $tb.val("");
        }
    });

    $(".emailbox").blur(function() {
        $tb = $(this);
        if ($.trim($tb.val()) == "") {
            $tb.val(this.title);
        }
    });


    var txtEmailAddress = $('#txtEmail');
    var txtName = $('#txtName');
    $('#lnkBtnNewsletterSignup').click(function(e) {
        txtEmailAddressValue = txtEmailAddress.val();
        txtNameValue = txtName.val();

        if ((txtNameValue == '') || (txtNameValue == 'Name')) {
            alert('Enter your Name');
            txtName.focus();
            return false;
        }
        else {
            if (txtEmailAddressValue == '') {
                alert('Enter a valid email address');
                txtEmailAddress.focus();
                return false;
            }
            else {
                if (!IsValidEmail(txtEmailAddressValue)) {
                    alert('Enter a valid email address');
                    txtEmailAddress.focus();
                    return false;
                }
                else {
                    return true;
                }
            }

        }


    });
    

});


