$(document).ready(function() {
	
	// Set up content width
	var columnWidth = 480;
	var extrasWidth = 620;
	var articles = $('#content article').length;
	var contentWidth = (articles * columnWidth) + extrasWidth;
	$('#content').width(contentWidth);
	$('section').width(contentWidth+310);
	if( $('.header .nav-tab7').length > 0 ){
		$('.header').width('1125px');
	}
	
	function removeLink(target){
		$target = $(target+' a');
		$target.replaceWith( '<span>'+$target.text()+'</span>' );
	}
	
	if( $('#con-twitter a').length == 0 ){ $('#con-twitter').append('<span>Twitter</span>'); }
	
	$('#subscribe .field').defaultValue('Email Address');
	$('#search-lifecast .field').defaultValue('Search My LifeCast');
		
	$('.article .date').wrapInner('<span></span>');
	$('.header nav li:last').addClass('last');
	$('div.frame').wrapInner('<div class="frame-content"></div>').prepend('<div class="frame-header"></div>').append('<div class="frame-footer"></div>');
	$('.article .content a, .post-quote blockquote p, .post-quote blockquote li, .article h1, .article h1 a').addClass('theme');
	
	$('.article .permalink a').tipsy({gravity: 's', fade: true});
	
	$('.dedicated').closest('.article').addClass('ns-post').append('<a href="http://nonsociety.com" class="ns-small theme-bg">NonSociety Post</a>');
	
	var $aboutTwitter = $('.about-twitter');
	$aboutTwitter.height( $('.tweet-content').height() );
	$('.twitter-about').hover(
		function(){
			$aboutTwitter.fadeIn('fast');
		},
		function(){
			$aboutTwitter.fadeOut('fast');
		}
	);
	
	// Replace missing paragraph tags if no block-level elements in content block
	$(".content:not(:has(p,dl,div,noscript,blockquote,form,hr,table,fieldset,address,ol,ul,h1,h2,h3,h4,h5,h6,dialog))").wrapInner("<p></p>");
	$("blockquote:not(:has(p))").wrapInner("<p></p>");
	$(".content:has(p.answer_form_container)").each(function() {
		if ($(this).find("p").length==1) {
			var html = $(this).html();
			var i = html.indexOf("<p");
			html = "<p>" + html.substring(0, i) + "</p>" + html.substring(i);
			$(this).html(html);
		}
	});
	if($("#pagetype").length) $("#follow").hide();

});