$(document).ready(function(){
	$.YQL("select * from atom where url='http://graphicallyherdingthemasses.blogspot.com/feeds/posts/default' | truncate(count=1)",function(data){
		var blog=data.query.results.entry;
		//$.each(blogPost,function(index, blog){
			$('#posts').append("<li id='post0' onclick='window.location=\"http://graphicallyherdingthemasses.blogspot.com\"'><strong>"+blog.title.content+"</strong><p>"+blog.content.content.replace(/<.*?>/g, '').substr(0,75)+"...</p><small></small></li>");
		//});	
	});
	$.YQL("select * from rss where url='http://twitter.com/statuses/user_timeline/9542882.rss' | truncate(count=3)",function(data){
		var tweet=data.query.results.item;
		$.each(tweet, function(index, tweet){
			$('#tweets').append("<li id='tweet"+index+"' onclick='window.location=\"http://twitter.com/justinsane98\"'>"+tweet.title.replace(/^.*?:/,"")+"<small></small></li>");
		});	
	});
	$.YQL("select * from xml where url='http://api.flickr.com/services/rest/?method=flickr.people.getPublicPhotos&api_key=3e4f36d5faee97e5a39a788a66e82516&user_id=74519193@N00&extras=url_m&per_page=3'",function(data){
		var photo=data.query.results.rsp.photos.photo;
		$.each(photo,function(index, photo){
			$('#photos').append("<li id='photo"+index+"' onclick='window.location=\"http://www.flickr.com/photos/justinshearer/\"'><img src='"+photo.url_m+"' alt='"+photo.title+"'/><span>"+photo.title+"</span><small></small></li>");
		});
	});
	$('#work').click(function(){
		if(!$(this).hasClass('selected')){
			$(this).addClass('selected');
			$('#play,#about').removeClass('selected');
			$('#tweet0,#aboutSection').fadeOut(200);
			$('#tweet1').fadeOut(600);
			$('#tweet2').fadeOut(400);
			$('#photo1').fadeOut(800);
			$('#photo2').fadeOut(1000);
			$('#post0').fadeOut(1200);
			$('#photo0').fadeOut(1400,function(){
				$('#playSection,#aboutSection').hide();
				$('#workSection').show();
				$('#work0').fadeIn(200);
				$('#work1').fadeIn(600);
				$('#work2').fadeIn(400);
				$('#work3').fadeIn(1400);
				$('#work4').fadeIn(800);
				$('#work5').fadeIn(1000);
				$('#work6').fadeIn(1200);	
			});
		}
		return false;
	});
	$('#play').click(function(){
		if(!$(this).hasClass('selected')){
			$(this).addClass('selected');
			$('#work,#about').removeClass('selected');
			$('#work0,#aboutSection').fadeOut(200);
			$('#work1').fadeOut(600);
			$('#work2').fadeOut(400);
			$('#work3').fadeOut(800);
			$('#work4').fadeOut(1000);
			$('#work5').fadeOut(1200);
			$('#work6').fadeOut(1400,function(){
				$('#workSection,#aboutSection').hide();
				$('#playSection').show();
				$('#tweet0').fadeIn(200);
				$('#tweet1').fadeIn(600);
				$('#tweet2').fadeIn(400);
				$('#post0').fadeIn(1400);
				$('#photo0').fadeIn(800);
				$('#photo1').fadeIn(1000);
				$('#photo2').fadeIn(1200);	
			});
		}
		return false;
	});
	$('#about').click(function(){
		if(!$(this).hasClass('selected')){
			$(this).addClass('selected');
			$('#play,#work').removeClass('selected');
			$('#tweet0,#work0').fadeOut(200);
			$('#tweet1,#work1').fadeOut(600);
			$('#tweet2,#work2').fadeOut(400);
			$('#photo1,#work3').fadeOut(800);
			$('#photo2,#work4').fadeOut(1000);
			$('#post0,#work5').fadeOut(1200);
			$('#photo0,#work6').fadeOut(1400);
			$('#aboutSection').delay(1400).fadeIn(200,function(){
				$('#playSection,#workSection').hide();
			});
		}
		return false;
	});
});

$(window).load(function(){
	$('#workSection li').hover(function(){
		$('#workSection li').clearQueue().not(this).fadeTo('fast',0.5);
	},function(){
		$('#workSection li').clearQueue().not(this).fadeTo('fast',1);
	});
	$('#playSection li').hover(function(){
		$('#playSection li').clearQueue().not(this).fadeTo('fast',0.5);
	},function(){
		$('#playSection li').clearQueue().not(this).fadeTo('fast',1);
	});
});
