/* ------------------------------------------------------------------------
	Do it when you're ready dawg!
------------------------------------------------------------------------- */

	$(function(){
		tabs.init();
		fix_height();
	});
	
	function fix_height(){
		if($('aside').height() > $('#content-container').height()) {
			$('#content-container').height($('aside>ul').height()+1);
			$('.featured').height($('#content-container').height() - $('#content-container .content').height() - 7);
		}else{
			$('aside>ul').height($('#content-container').height());
		}
	}
	
	function relative_time(time_value) {
		var values = time_value.split(" ");
		time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
		var parsed_date = Date.parse(time_value);
		var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
		var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
		delta = delta + (relative_to.getTimezoneOffset() * 60);

		if (delta < 60) {
			return 'Less than a minute ago';
		} else if(delta < 120) {
			return 'About a minute ago';
		} else if(delta < (60*60)) {
			return (parseInt(delta / 60)).toString() + ' minutes ago';
		} else if(delta < (120*60)) {
			return 'About an hour ago';
		} else if(delta < (24*60*60)) {
			return 'About ' + (parseInt(delta / 3600)).toString() + ' hours ago';
		} else if(delta < (48*60*60)) {
			return '1 day ago';
		} else {
			return (parseInt(delta / 86400)).toString() + ' days ago';
		}
	}
	
	tabs = {
		init : function(){
			$('.tabs').each(function(){
				$(this).find('.content:gt(0)').hide();

				$(this).find('ul.nav a').click(function(){
					$(this).parents('div.tabs').find('.content').hide();
					$($(this).attr('href')).show();

					$(this).parent().addClass('selected').siblings().removeClass('selected');

					return false;
				});
			});
		}
	}
