$(window).ready( function ( ) {
						   
	//Load the social networking divs
	$.get('../calls/twitter.txt', function (tweet) {
		$("div#tweetbox").append(tweet);
	});
	
	$.get('../calls/flickr.php', function (photos) {
		$("div#flickr_container").append(photos).find("a.enlarge").fancybox({
			'scrolling'				: 	'no',
			'padding'				:	10,
			'showCloseButton'	:	true,
			'width'					:	500,
			'height'					:	500,
			'transitionIn'			:	'elastic',
			'transitionOut'			:	'elastic',
			'titlePosition'			:	'over',
			'cyclic'					:	true,
			'overlayColor'			:	'#fff'
		});								   
	});
	
	//The previous and next flickr arrow scrollers
	$(".prev").click( function( ){
		var wpos = $("div#flickr_wrapper").offset().left;
		var cpos = $("div#flickr_container").offset().left;
		
		if(cpos < wpos-80){
			cpos = cpos - wpos + 350;
			$("div#flickr_container").animate({left: cpos + "px"}, 300);	
		}else{
			return false;
		}
		
		return false;
	});
	
	$(".next").click( function( ){
		var wpos = $("div#flickr_wrapper").offset().left;
		var cpos = $("div#flickr_container").offset().left;
		var size = ($("div#flickr_container").find("img.photo").size())*80;
		size = (680 - size) + 350;
		
		if(cpos > size){
			cpos = cpos - wpos - 350;
			$("div#flickr_container").animate({left: cpos + "px"}, 300);
		}else{
			return false;
		}
		
		return false;
	});
	
	//The content div scroller
	$("header ul a").click( function( ) {
		var key = $(this).text();
		var cur = $("a.current").text();
				
		$("#"+cur).fadeOut(100);
		var t = setTimeout('$(\"#'+key+'\").slideDown(100).delay(100).fadeIn(100)', 100);
		
		$("a.current").removeClass("current");
		
		$("header ul li a").each(function( ){
			if($(this).text() == key){
				$(this).addClass("current");	
			}
		});

		return false;
	});
	
});