jQuery(document).ready(function($){
	
	//Enable external links
	$('a[rel~=external]').attr('target','_blank');
	
	//Setup form field with default value
	function setFieldValue(id,value){
		$('#'+id).val(value).focus(function(){
			if( $(this).val() == value)
				$(this).val('');
		}).blur(function(){
			if( $(this).val() == '')
				$(this).val(value);
		});
	}
	
	//Setup home page
	if( app == 'home' ){
		
		//Feature rotation
		// $('#feature-navigation').append("<ul></ul>");
		// $('#feature-slides').cycle({
		// 	timeout: 6000,
		// 	pager:'#feature-navigation ul:first',
		// 	pagerAnchorBuilder:function(elem,index){
		// 		return "<li><a href='#'>" + (index+1) + "</a></li>";
		// 	}
		// });
		
		//Most recent Tweets
		$.ajax({
			type: 'GET',
			url: 'http://twitter.com/statuses/user_timeline/ThreeShipsMedia.json?count=3',
			dataType: 'jsonp',
			success: function(json){
				$('#recent-tweets').html("");
				$.each(json, function(i, item){
					$('#recent-tweets').append("<li><p>"+item.text.replace(/(http:\/\/\S+)/g, "<a href='$1'>$1</a>")+"</p><p class='byline'>From "+item.source+"</p></li>");
				});
			}
		});
		
	} else if (app == 'blog') {
		
		// Show author info on hover
	    $('.author,.author-popup').hover(
	        function() {
	            $('.author-popup',$(this).parent()).stop().css('display', 'block').animate({opacity: 1}, 350);
	        },
	        function() {
	            $('.author-popup',$(this).parent()).stop().animate({opacity: 0}, 150, 'linear', function(){$(this).css('display', 'none');});
	        }
	    );
		
		//Most recent Tweets
		$.ajax({
			type: 'GET',
			url: 'http://twitter.com/statuses/user_timeline/ThreeShipsMedia.json?count=1',
			dataType: 'jsonp',
			success: function(json){
				$('#sidebar-tweet').html("");
				$.each(json, function(i, item){
					$('#sidebar-tweet').append("<p>"+item.text.replace(/(http:\/\/\S+)/g, "<a href='$1'>$1</a>")+"</p><p class='byline'>From "+item.source+"</p>");
				});
			}
		});
	
	} else {
		
		//Most recent Tweets
		$.ajax({
			type: 'GET',
			url: 'http://twitter.com/statuses/user_timeline/ThreeShipsMedia.json?count=1',
			dataType: 'jsonp',
			success: function(json){
				$('#sidebar-tweet').html("");
				$.each(json, function(i, item){
					$('#sidebar-tweet').append("<p>"+item.text.replace(/(http:\/\/\S+)/g, "<a href='$1'>$1</a>")+"</p><p class='byline'>From "+item.source+"</p>");
				});
			}
		});
		
	}
	
	//Setup IE dropdowns
	if( $.browser.msie && parseFloat($.browser.version) < 7.0 ){
		$('#menu li').hover(
			function(){
				$('ul:first',this).show();
			},
			function(){
				$('ul:first',this).hide();
			}
		);
	}
	
});