$(document).ready(function() {
	
	// Open external links in new Window/Tab
	$("a[href^='http:']").not("[href*='" + window.location.host + "']").attr('target','_blank'); 
	
	// Lightbox
	$(".iframe").fancybox({
		'hideOnContentClick': true,
		'titleShow': false
	});
	
	// Form Validation
	if (document.getElementById('contact-form')) {
		$("#contact-form").validationEngine({
			
		});
	};
	
	// Fade
	$('.fadeThis').append('<span class="hover"></span>').each(function () {
		var $span = $('> span.hover', this).css('opacity', 0);
		$(this).hover(function () {
			$span.stop().fadeTo(300, 1);
		}, function () {
			$span.stop().fadeTo(300, 0);
		});
	});
	
	// Sliding Doors Button Fade Like a Total Baller
	$('.button').each(function () {
		$('span', this).addClass('sd');
		$(this).append('<span class="hover"></span><span class="sd2"></span>');
		var thisHover = $(".hover", this);
		$('.sd', this).clone().removeClass('sd').addClass('overlay').appendTo(thisHover);
		var $span = $('> span.hover', this).css('opacity', 0);
		var $span2 = $('> span.sd2', this).css('opacity', 0);
		$(this).hover(function () {
			$span.stop().fadeTo(200, 1);
			$span2.stop().fadeTo(200, 1);
		}, function () {
			$span.stop().fadeTo(200, 0);
			$span2.stop().fadeTo(200, 0);
		});
	});
	
	// Input value switcher
	$('#s').focus(function () {
		if ($('#s').val() == 'Search WP Testbed') {
			$('#s').val('');
			$('#s').css({'color' : '#124d7a', 'font-weight' : 'bold'}); //active
		}
	});
	
	$('#s').blur(function () {
		if ($('#s').val() == '') {
			$('#s').val('Search WP Testbed');
			$('#s').css({'color' : '#a2a2a2', 'font-weight' : 'normal'}); //inactive
		}
	});
	
});
