$('a.anchor').remove().prependTo('body');		//move them anchors so that we don't run into problems for people who actually have javascript
$("a.menu").click(function(){
	myAnchor = $(this).attr("href");
	$('#menu a').removeClass("current");
	$('#menu a[href=' +myAnchor+ ']').addClass("current");
	
	var myClass = '.' + myAnchor.split('#')[1];  //let's deal with the classes, not the anchors!
	var offset = $(myClass).position().left;
	var containerBgPosX = (offset/960)*5; 
	var midgroundBgPosX = (offset/960)*20;

    $("#menu").slideUp("fast", function(){

		$("#container").animate({
			marginLeft: -offset,
			backgroundPosition: -containerBgPosX + "% 100%"
		}, { duration: 2000, easing: 'easeInOutSine' });
		
		$("#midground").animate({
			backgroundPosition: -midgroundBgPosX + "% 100%"
		}, { duration: 2000, easing: 'easeInOutSine', complete:function(){ if (offset > 1) $("#menu").slideToggle("fast") }
		
		});
	
	});
	
	var asyncURL = "";
	switch(myClass) {
		case ".meetamy":
			asyncURL = "http://amyeverhart.net/meet-amy/";
			displayAJAX(asyncURL);
			break;
		case ".byamy":
			asyncURL = "http://amyeverhart.net/by-amy/";
			displayAJAX(asyncURL);
			break;
		case ".greenergrass":
			asyncURL = "http://amyeverhart.net/blog/";
			displayAJAX(asyncURL);
			break;
		case ".newsworthy":
			asyncURL = "http://amyeverhart.net/newsworthy/";
			displayAJAX(asyncURL);
			break;
		case ".contact":
			asyncURL = "http://amyeverhart.net/contact/";
			displayAJAX(asyncURL);
			break;
		default:
			var asyncURL = "";
			//we're home.
	}					
	
	function displayAJAX(asyncURL){
		$.ajax({
		  url: asyncURL,
		  success: function(html){
		    $(myClass).html(html);
			$(".gallery a").attr("rel", "gallery");
			$(".gallery a").fancybox();
		  }
		});
	}
	
});

//main menu animations was here before


//H2 Image Replacement

//Top Menu Rollovers
$('#menu a img').hover(function(){
	var oldsrc = $(this).attr("src");
	var newsrc = oldsrc.split(".gif")[0] + "-selected.gif";
	$(this).attr("src", newsrc);
}, function(){
	var oldsrc = $(this).attr("src");
	var newsrc = oldsrc.split("-selected.gif")[0] + ".gif";
	$(this).attr("src", newsrc);
});

//	NAVIGATIONY STUFF
var myFile = document.location.toString();
if (myFile.match('#')) { // the URL contains an anchor
	// $('div#menu a[href="' + myAnchor + '"]').parent().click();  // click the navigation item corresponding to the anchor
	var myAnchor = '#' + myFile.split('#')[1];
	$('#menu a[href=' +myAnchor+ ']').click();
} else {
  	//Actually, Don't do anything since we're at the home screen.
	// $('#menu a[href=#home]').click();
}