function DoPageShade ( url )
{
	$("body").append ("<div id='home_shade'></div><div id='home_shade_content_wrapper'><div id='home_shade_content'></div></div>");
	$("#home_shade").css ( { position: "fixed", top: 0, left: 0, width: "100%", height: "100%", backgroundColor: "#000", opacity: 0 } );
	$("#home_shade_content_wrapper").css ( { position: "absolute", width: "100%", top: 0, left: 0, opacity: 0 } );
	$("#home_shade").animate ( { opacity: 0.5 }, 1000 );
	$("#home_shade_content").html ( "<iframe style='border:none;' frameBorder='0' width='688' height='528' src='http://www.sudanactionnow.org/raise-awareness-on-facebook.html'></iframe><a class='close' href='#'>Close this window</a>" );
	$("#home_shade_content_wrapper").animate ( { opacity: 1 }, 500 );
	$("#home_shade_content .close").click(function(e){
		$.cookie ( 'sudannow_home_page_takeover', '85621567' );
		$("#home_shade").animate ( { opacity: 0 }, 1000 );
		$("#home_shade_content_wrapper").animate ( { opacity: 0 }, 500, "linear", function(){
			$("#home_shade").remove();
			$("#home_shade_content_wrapper").remove();
		});
		return false;
	});
	/*$("#home_shade_content").load ( url, function(){
		$("#home_shade_content_wrapper").animate ( { opacity: 1 }, 500 );
		$("#home_shade_content .close").click(function(e){
			$.cookie ( 'sudannow_home_page_takeover', '85621567' );
			$("#home_shade").animate ( { opacity: 0 }, 1000 );
			$("#home_shade_content_wrapper").animate ( { opacity: 0 }, 500, "linear", function(){
				$("#home_shade").remove();
				$("#home_shade_content_wrapper").remove();
			});
			return false;
		});
	});*/
}

function ResetPageShade()
{
	$.cookie ( 'sudannow_home_page_takeover', null );
}

$(document).ready(function(){
	$("#join .email").css ( { color: "#AAA" } );
	$("#join .zip").css ( { color: "#AAA" } );
	$("#join .catch").css ( { display: "none" } );
	$("#join .email").val ( "Enter Email Address" );
	$("#join .zip").val ( "Enter Zip Code" );
	$("#join .catch").val ( "" );
	
	$("#join .email").focus(function(){ if ( $(this).val() === "Enter Email Address" ) { $(this).css ( { color: "#000" } ); $(this).val ( "" ); } });
	$("#join .email").blur(function(){ if ( $(this).val() === "" ) { $(this).css ( { color: "#AAA" } );$(this).val ( "Enter Email Address" ); } });
	$("#join .zip").focus(function(){ if ( $(this).val() === "Enter Zip Code" ) { $(this).css ( { color: "#000" } ); $(this).val ( "" ); } });
	$("#join .zip").blur(function(){ if ( $(this).val() === "" ) { $(this).css ( { color: "#AAA" } );$(this).val ( "Enter Zip Code" ); } });
	
	$("#join").submit(function(){
		var valid = true;
		var email = $("#join .email").val();
		var zip = $("#join .zip").val();
		if ( email === "" || email === "Enter Email Address" )
		{
			$("#join .email").css ( { border: "solid 2px Red" } );
			valid = false;
		}
		else
		{
			$("#join .email").css ( { border: "solid 1px #555" } );
		}
		if ( zip === "" || zip === "Enter Zip Code" )
		{
			$("#join .zip").css ( { border: "solid 2px Red" } );
			valid = false;
		}
		else
		{
			$("#join .zip").css ( { border: "solid 1px #555" } );
		}
		return valid;
	});
	
	/*if ( ( window.location.pathname === "/" || window.location.pathname === "/index" ) && ( $.cookie ( 'sudannow_home_page_takeover' ) != 85621567 ) )
	{
		DoPageShade ( "/raise-awareness-on-facebook" );
	}*/
	$("#show_homepage_takover").click(function(){
		ResetPageShade();
		DoPageShade ( "/raise-awareness-on-facebook" );
		return false;
	});
});
