$(document).ready(function () {
	
	// GLOBAL NAVIGATION 
	
		// Add class "hover" to h2#phillips-links for IE6 hover effect 
	  $("#phillips-links").hover(
	  	function() {
	    	$(this).addClass("hover");
	  	},
			function() {
	    	$(this).removeClass("hover");
	  	}
		);
		
		// Move #global-nav to hidden position 
		$("#global-nav").css("top", "-53px").addClass("tucked");
		
		// Slide #global-nav back in onclick of h2#phillips-links 
		$("#phillips-links").click(function() {
			if ($("#global-nav").hasClass("tucked")) {
				$("#global-nav").animate( { top:"0" }).removeClass("tucked");
			}
			else {
				$("#global-nav").animate( { top:"-53px" }).addClass("tucked");
			}
		});
	
	
	// CAUSE ANNOUNCEMENTS
	
	$("#announcement>dd").hide().addClass("hidden");
  $("#announcement>dt").click(function() {
  	if ($(this).next().hasClass("hidden")) {
		$(this).addClass("active");
  		$(this).next().show().removeClass("hidden");
  		$(this).find("span").removeClass("up").addClass("down");
  	}
  	else {
		$(this).removeClass("active");
  		$(this).next().hide().addClass("hidden");
  		$(this).find("span").removeClass("down").addClass("up");
  	};
  });
    
	  // Add hover effect in IE6
		  $("#announcement>dt").hover(
	      function () {
	        $(this).addClass("hover");
	      }, 
	      function () {
	        $(this).removeClass("hover");
	      }
	    );
	    
	// GENERIC COLLAPSIBLES
	$(".collapsible>dd").hide();
	$(".collapsible>dt").append('<span> &#8250;</span>');
	$(".collapsible>dt").toggle(
		function() {
			$(this).next().show();
			$(this).children('span').html(' &#8249;')
		}, function() {
			$(this).next().hide();
			$(this).children('span').html(' &#8250;')
		}
	);
	$(".collapsible>dt").hover(
    function () {
      $(this).addClass("hover");
    }, 
    function () {
      $(this).removeClass("hover");
    }
  );
    
	// CAUSE CHART ANIMATION
	
	$(".cause-block, #cause-progress-stats").hoverIntent(function() {
	    var originalWidth = $(this).find(".cause-chart-achieved").css("width");
	    var chartParams = { width: originalWidth };
	    $(this).find(".cause-chart-achieved").css("width", "0");
	    $(this).find(".cause-chart-achieved").animate(chartParams, 500, "easeInOutSine");
	},
	function(){});
	
	
	// CAUSE SHARING LIGHTBOX
	
	// Zoom the lightbox
	$("#cause-sharing-link").fancyZoom();
	
	// Preselect the sharing code
	$("textarea").focus(function(){
    // Select input field contents
    this.select();
	});
	
	
	// FOOTER SEARCH
	
		// Insert "search" text onload
		$("#searchbox").attr("value","Search");
		
		// Remove "search" text onactivation
		$("#searchbox").focus(function() {
			$(this).attr("value", "");
		});
		
		// Return "search" text onblur
		$("#searchbox").blur(function() {
			$(this).attr("value","Search");
		});
});