$(document).ready(function() {
	
	
	// Clear & Refill fields
	autoFill($("#ea"), "your email address");

	function autoFill(id, v){
		$(id).css({ color: "#8e8e8e" }).attr({ value: v }).focus(function(){
			if($(this).val()==v){
				$(this).val("").css({ color: "#333" });
			}
		}).blur(function(){
			if($(this).val()==""){
				$(this).css({ color: "#8e8e8e" }).val(v);
			}
		});
	}
	
	
	// Open external links in new windows
	$(function() { 
		$('a[href^=http]').click( function() {
			window.open(this.href);
			return false;
		});
	});
	
	
	
	
	
	// Show map
	
	$("#page-contact dd a").click(function () { 
   		$("#map").load("/inc/map-contact.php");
    });
	
		
	// Show full lisy of press items
	$("#show-full-list").click(function () { 
   		$(".show").slideToggle();
		$(this).hide();
    });
	
	
	// Find the first paragraph in the RR descriptions so the spaceing looks right
	
	//$("#recommended-reading .description p:first-child ").addClass("first");
	
	
	
	
	
	
	
	// VALIDATE Newsletter FORM //////////////////////////
	
	
	 
 $("form#newsletterFORM").submit(function() {
										  
	// reset previous alerts	
	$("#header-newsletter legend").removeClass("hide");
	//$(".success").addClass("hide");
	$(".alert").hide();
	
	
	var $returnvalue;
	$returnvalue = true;


		
	
	// Check if blank
	if ($("#ea").val() == "" || $("#ea").val() == "your email address") {

		$("#header-newsletter legend").addClass("hide");
		//$(".success").addClass("hide");
		$(".alert").show();
		$returnvalue = false;
		$("input#ea").addClass("not-filled-out");
	}

	// Submit form (or not)
	
	return $returnvalue;
});
 
 
	// Clear alerts
	$("#ea").keyup(function () {	
		$(this).removeClass("not-filled-out");
		$("#header-newsletter legend").removeClass("hide");
		//$(".success").addClass("hide");
		$(".alert").hide();

	});
	
	
	
	



	

});


