$(document).ready(function() {

		//MASTHEAD ROLLOVERS
		$("#masthead-social-connect li").hover(function(){
			//image
			var imgName = $("img", this).attr("src");
			$("a.rollover", this).css({'background' : 'url(' + imgName + ') no-repeat center bottom'});
			
			$("span", this).stop().fadeTo(450, 0 , function() {
				$("span", this).hide();
			});
			
			//txt
			//$("a.txt-rollover", this).css({'background-position' : '0 -21px'});
		}, function(){	
			//img
			$("span", this).stop().fadeTo(450, 1).show();
			
			//txt
			//$("a.txt-rollover", this).css({'background-position' : '0 0px'});
		
		});
		
		//SOCIAL CONNECT ROLLOVERS
		$(".social-connect li").hover(function(){
			$("a", this).css({"background-position" : "0 -49px"});
		}, function(){
			$("a", this).css({"background-position" : "0 0"});
		});
		
		
		//FORM
		$("input#email, input#name").focus(function(){
			$(this).css({"background-position" : "0 -31px"});
		});
		
		$("input#email, input#name").focusout(function(){
			$(this).css({"background-position" : "0 0"});
		});
		
		
		//EMAIL OBFUSCATION
		$(".obfs-email").each(function()
		{
			var email = String($(this).attr('href')).replace(/\s*\(.+\)\s*/, "@");
			$(this).attr('href', email);
		});
	
		//SUBSCRIBE AJAX SUBMIT
		$("#submit-button").click(function(e){
			e.preventDefault();
			if($("input#email").val() == "") alert("Please enter an email address to subscribe.");
			else{
				$.post('subscribe.php', 
				{email: $("input#email").val(),
			 	 name: $("input#name").val()}, 
				function(html){
					//CALLBACK FUNCTION
					$("#mailing-list-message").show();
				}, 'html');
			}
		});
});
