jQuery(document).ready(function($) {
	
	var hash;
		
	if ( window.location.hash ) {
		hash = window.location.hash;
	}
	
	$('.external').attr('target','_blank');
	
	$('#query').focus(function()  {
		if ($(this).val() == 'Enter search term') {
			$(this).attr('value','');
		}
	}).blur(function() {
		if ($(this).val() == '') {
			$(this).attr('value','Enter search term');
		}
	});

	function initFeatureCarousel() {
		
		$("#feature-carousel").carouFredSel({
			auto: {
				delay: 3000,
				pauseDuration: 5000
			},
			height: 240,
			items: {
				height: 240,
				minimum: 1,
				visible: 1,
				width : 560
			},
			pagination  : {
				container       : "#feature-carousel-pagination",
				anchorBuilder   : function( nr, item ) {
					return '<li><a href="#">'+nr+'</a></li>';
				}
			},				
			scroll: {
				easing: "linear",
				pauseOnHover: true
			},
			width: 560
		});
		
	}
	
	function initSubscribe() {
		
		$('#subscribe-form-name').focus(function()  {
			if ($(this).val() == 'Name') {
				$(this).attr('value','');
			}
		}).blur(function() {
			if ($(this).val() == '') {
				$(this).attr('value','Name');
			}
		});
		
		$('#subscribe-form-email').focus(function()  {
			if ($(this).val() == 'Email Address') {
				$(this).attr('value','');
			}
		}).blur(function() {
			if ($(this).val() == '') {
				$(this).attr('value','Email Address');
			}
		});

		$.validator.addMethod("defaultName", function(value, element) {
			return value != element.defaultValue;
		}, "");		
		
		$("#subscribe-form").validate({
			errorPlacement: function(error, element) {}
		});
				
	}
	
	if ($("#feature-carousel").length != 0)
		initFeatureCarousel();
		
	if ($("#subscribe-form").length != 0)
		initSubscribe();
	
});
