$(document).ready(function() {
	$('ul.sf-menu').superfish({
		speed: 'slow',
		delay: 100
	});
	
	setInterval("checkAnchor()", 300);
	
	$("a[href=#home]").addClass("current");
	
	$(".sf-menu a").click(function() {
		$(".sf-menu a").removeClass("current");
		var theHref = "#" + $(this).attr("title");
		$("a[href="+theHref+"]").addClass("current");
	});		

});



var currentAnchor = null;
function checkAnchor(){
	if(currentAnchor != document.location.hash){
		currentAnchor = document.location.hash;
		if(!currentAnchor)
			query = "section=home";
		else
		{
			var splits = currentAnchor.substring(1).split('&');
			var section = splits[0];
			delete splits[0];
			var params = splits.join('&');
			var query = "section=" + section + params;
		}
		$("#content").fadeOut(1000);
		$("#loading").fadeIn(100);
		$("#placeholder").show();
		$.get("callbacks.php",query, function(data){
			$("#content").html(data);
			$("#loading").fadeOut(100);
			$("#content").fadeIn(1000);
			$("#placeholder").hide();
			$('.sidebar').corner("tl bl");
			$('.blurb').corner();
			$('.logos').corner();
			$('#featured').cycle();
			$('.featured_right div').click(function() { 
				var theIndex = $(this).attr("class");
				$('#featured').cycle({
					startingSlide: theIndex
				}); 
				return false; 
			}); 
			$("#twitter").getTwitter({
				userName: "thecrc",
				numTweets: 5,
				loaderText: "Loading tweets...",
				slideIn: true,
				showHeading: true,
				headingText: "Latest Tweets",
				showProfileLink: true
			});
		});
		
	}
}