$(document).ready(function(){
						   
	/* Services */
	
	/* Hide all pages except for web */

	$("#services .block").hide();
	
	$("#services #web-block").show();
	
	/* When a button is clicked, show that page */
	
	$("#services .banner-button").click(function() {
												 
		$("#services .block").hide();
														 
	});
	
	$("#services #web-button").click(function() {
												 
		$("#services #web-block").show();
														 
	});
	
	$("#services #print-button").click(function() {
												 
		$("#services #print-block").show();
														 
	});
	
	$("#services #branding-button").click(function() {
												 
		$("#services #branding-block").show();
														 
	});				   
	
	
	/* Portfolio */
						   
	$("#portfolio-main div.column").hover(function() { /* On hover of portfolio item */
								 
		$(this).find(".desc").animate({bottom: "0"}, {duration: 500}); /* Bring in description */
		
	}, function() {
		
		$(this).find(".desc").animate({bottom: "-190"}, {duration: 500});

		
	});
	
	/* Portfolio Item */
		
		$("#info-button").hover(function() { /* On hover of info button */
								 
		$("#portfolio-info").animate({bottom: "0"}, {duration: 350}); /* Bring in description */
		
	}, function() {
		
		$("#portfolio-info").animate({bottom: "-60px"}, {duration: 350});

	});
	
	/* Contact */
	
	$('form#contactForm').submit(function() {
		$('form#contactForm .error').remove();
		var hasError = false;
		
		$('.requiredField').each(function() {
			if(jQuery.trim($(this).val()) == '') {
				
				var labelText = $(this).prev('label').text();
				$append('<p class="error">Please fill out all the required fields.</span>');
				hasError = true;
				
			} else if($(this).hasClass('email')) {
				
				var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
				
				if(!emailReg.test(jQuery.trim($(this).val()))) {
					
					var labelText = $(this).prev('label').text();
					$(this).parent().append('<span class="error">You entered an invalid '+labelText+'.</span>');
					hasError = true;
					
				}
			}
		});
		
		
		if(!hasError) {
			$('form#contactForm li.buttons button').fadeOut('normal', function() {
				$(this).parent().append('<img src="/wp-content/themes/td-v3/images/template/loading.gif" alt="Loading…" height="31" width="31" />');
			});
			
			var formInput = $(this).serialize();
			$.post($(this).attr('action'),formInput, function(data){
				$('form#contactForm').slideUp("fast", function() {
					$(this).before('<p class="thanks">Thanks for contacting us! You can be sure we will reply within the next 48 hours.</p>');
				});
			});
		}

		return false;

	});

	
	/* Links In New Window */

	$('a.blank').click(function(){
		this.target = "_blank";
	});		
		
});

/* Portfolio Item Image Swap */

function swapBanner(image, elemId) {

	$("#" + elemId).css("background", "url( " + image + " ) center");
	
	return false;
	
}
