$(document).ready(function(){
  $(".auto-grow").autogrow();

		$("#explore-button").css("display", "block");
		$(".footer .nav-item").hover(function() {
		  $(this).css("background", "#C7E6F7");
		}, function() {
		  $(this).css("background", "transparent");
		});

		$("#explore-button").click(function(){
				if ($("#explore-wrapper").length == 0) {
					if ( $.browser.msie && /6.0/.test(navigator.userAgent) ) {
						$(".header select").css("visibility", "hidden");
					}
					$("#explore-button").css("background-position", "0 -29px");	
					
					if ($('body').is('.Magazines')) {
					  $("body").prepend('<div class="explore-wrapper" id="explore-wrapper"><div class="explore" id="explore"><p class="loading">Loading</p></div><a href="#close-explore" id="close-explore">close</a></div>');
					} else {
					  $("#wrapper").append('<div class="explore-wrapper" id="explore-wrapper"><div class="explore" id="explore"><p class="loading">Loading</p></div><a href="#close-explore" id="close-explore">close</a></div>');
					}
					
					
					var offset = $("#explore-button").offset();
					var offsetTop = offset["top"] + $("#explore-button").height();
					$("#explore-wrapper").css("top", offsetTop).fadeIn();
					$("#explore").html($(".site-navigation").html());
					return false;
				} else {
					removeExplore();
					return false;
				}
		});

		function removeExplore(){
			$("#explore-button").css("background-position", "0px 0px");		
			$("#explore-wrapper").fadeOut(function(){
				$("#explore-wrapper").remove();
			});
			if ( $.browser.msie && /6.0/.test(navigator.userAgent) ) {
				$(".header select").css("visibility", "visible");
			}
			return false;
		}

		$("#close-explore").live("click", function(){
			removeExplore();
			return false;
		});

		$("#top-link").click(function(){
			var targetOffset = $("#header").offset().top;
	    $('html,body').animate({scrollTop: targetOffset}, 1000);
			return false;
		});

		$('html').click(function(e){if($(e.target).parents('#explore-wrapper').length == 0) removeExplore();});
});

	function flash(el) {
		$(el)
		.fadeTo("slow", 0.2).animate({opacity: 1.0}, "slow").fadeTo("slow", 1)
		.fadeTo("slow", 0.2).animate({opacity: 1.0}, "slow").fadeTo("slow", 1);
	}
