jQuery(function($) {
    // must explicitly set the height of all images before positiong the footer.
    $('#footer-bg').positionFooter(true);
    
    $('#subscribe-email').focus( function() { $(this).val(''); });
    $('#subscribe-form')
    .submit( 
        function() { 
            if (jQuery.subscribeIsSubmitted) {
           		// do nothing
			} else if ($('#subscribe-email').val().match(/^[ ]*[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}[ ]*$/i))  {
                $('#subscribe-emailconfirm').val( $('#subscribe-email').val());
                $('#subscribe-msg').text('Thank You. Subscribing...');
				jQuery.subscribeIsSubmitted=1;
                return true;
            } else  {
                $('#subscribe-msg').text('Please enter a valid email address');
            }
            return false;
        }
     );
    $('#subscribe-submit')
    .click( 
        function() { 
            if (jQuery.subscribeIsSubmitted) {
           		// do nothing
            } else if ($('#subscribe-email').val().match(/^[ ]*[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}[ ]*$/i))  {
                $('#subscribe-emailconfirm').val( $('#subscribe-email').val());
                $('#subscribe-form').submit();
                $('#subscribe-msg').text('Thank You. Subscribing...');
				jQuery.subscribeIsSubmitted=1;
                return true;
            } else  {
                $('#subscribe-msg').text('Please enter a valid email address');
            }
            return false;
        }
     );
    $('#contactus-submit') .click( 
        function() { 
            if (jQuery.contactIsSubmitted) {
                return false;
            }
			if ($('#contactus-name').val() == '') {
                $('#contactus-msg').text('Please tell us your name');
                return false;
            }
            if (!$('#contactus-email').val().match(/^[ ]*[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}[ ]*$/i))  {
                $('#contactus-msg').text('Please enter a valid email address');
                return false;
            }
            if ($('#contactus-message').val() == '') {
                $('#contactus-msg').text('Please enter a brief message');
                return false;
            }
            if ($('#contactus-code').val() == '') {
                $('#contactus-msg').text('Please enter the security code');
                return false;
            }
			jQuery.contactIsSubmitted=1;
        }
     );
    $('#login-submit') .click( 
        function() { 
            if ($('#login-username').val() == '') {
                $('#login-msg').text('Please provide a username');
                return false;
            }
            if ($('#login-password').val() == '') {
                $('#login-msg').text('Please provide a password');
                return false;
            }
        }
     );
});

