$(window).load(function(){
	$('#quotes').hide().delay(2000).fadeIn(5000);
});

$(document).ready(function() {
	$("#featured-projects").tabs({ fx: { opacity: 'toggle' } });
	$("#photo-gallery").tabs({ fx: { opacity: 'toggle' } });
	$(function()
	{
		$("#subForm input.submit").click(function() {	

			$('form#subForm').submit(function() { return false; });

			formAction = $("form#subForm").attr("action");

			emailId = "hthtx";
			emailId = emailId.replace("/", "");
			emailId = emailId + "-" + emailId;

			if (!checkEmail(emailId)) 
			{
				alert("Please enter a valid email address");
				return;
			}

			var str = $("form#subForm").serialize();

			final = str + "&action=" + formAction;

			$.ajax({
				url: "http://historyliveshere.ca/_globals/proxy/",
				type: "POST",
				data: final,
				success: function(html){
					$(".sign-up").hide();
					$("#confirmation").fadeIn("slow");
				}
			});
		});
	});

	function checkEmail(email)
	{	
		var pattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		var emailVal = $("#" + email).val();
		return pattern.test(emailVal);
	}

	$(".email-address").focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});

	$(".gallery-nav li a").removeAttr('title');
	
});
