		

$(document).ready(function() {
			($("#admin").html() == "") ? $("#admin").hide() : $("#admin").show();
			(jQuery.makeArray($("#current-list td")).length == 0) ? $("#current").hide() : $("#current").show();
			$(".titleListStyle td").removeAttr("align");
			$("#blog-posts, #footer, #tweets, #jQueryPodcast-container").corner();
			if (!$.browser.webkit){
				$("#jQueryPodcast-header").parent().css("padding","0px");
			}
			var arrayCommentNames = jQuery.makeArray($(".commentBoxFooterStyle"));
			for (i=0;i<=arrayCommentNames.length;i++)
			{
				ScrubDate(i);
				$(".commentBoxFooterStyle:eq(" + i + ")").prependTo(".commentDateStyle:eq(" + i + ")");
				$(".commentDateStyle:eq(" + i + ")").wrapAll("<div class=\"CommentName\"></div>");			
			}
			var hiddendivs = "#contact-link, #subscribe-link, #recent-link, #month-link, #category-link, #popular-link";
			$(hiddendivs).click(function() {
				$("#" + $(this).html().toLowerCase()).show().shadow({ offset: 5, color: "#000000" });		
			});
			$(".close").click( function() { hideall(); });
			$("#search-link").click( function() { $("#search").toggle();});
			
			var url = "http://twitter.com/status/user_timeline/RedWolves.json?count=3&callback=?";
		$.getJSON(url,
        function(data){
			$.each(data, function(i, item) {
				$("img#profile").attr("src", item.user["profile_image_url"]); 
				$("#tweets ul").append("<li>" + item.text.linkify() + " <span class='created_at'>" + relative_time(item.created_at) + " via " + item.source + "</span></li>");
			});
        });
                var so = new SWFObject('/jwplayer/player.swf','mpl','255','85','9');
  		so.addParam('allowfullscreen','true');
 		so.addParam('allowscriptaccess','always');
  		so.addParam('wmode','opaque');
  		so.addVariable('playlistfile','/podcast/podcast.rss');
  		so.addVariable('playlistsize','65');
  		so.addVariable('bufferlength','8');
  		so.addVariable('playlist','bottom');
  		so.write('jQueryPodcast');
});
		

		
		function hideall()
		{
			$(".popup").hide().shadowDestroy();
		}
		
		function ScrubDate(i)
		{
			strDate = $(".commentDateStyle:eq(" + i + ")").text();
			strDate = strDate.substring(strDate.indexOf(", ") +2);
			strDate = strDate.substring(0, strDate.indexOf(" ("));
			strAMPM = strDate.substring(strDate.lastIndexOf(" ") + 1);
			strDate = strDate.substring(0, strDate.lastIndexOf(":"));
			$(".commentDateStyle:eq(" + i + ")").text("(" + strDate + " " + strAMPM + ")");
		}
		
String.prototype.linkify = function() {
	return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function(m) {
		return m.link(m);
	});
 }; 
 
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);
	  
	  var r = '';
	  if (delta < 60) {
	    r = 'a minute ago';
	  } else if(delta < 120) {
	    r = 'couple of minutes ago';
	  } else if(delta < (45*60)) {
	    r = (parseInt(delta / 60)).toString() + ' minutes ago';
	  } else if(delta < (90*60)) {
	    r = 'an hour ago';
	  } else if(delta < (24*60*60)) {
	    r = '' + (parseInt(delta / 3600)).toString() + ' hours ago';
	  } else if(delta < (48*60*60)) {
	    r = '1 day ago';
	  } else {
	    r = (parseInt(delta / 86400)).toString() + ' days ago';
	  }
	  
	  return r;
}