function fix_objects() {
	$('object').each(function() {
		if ($(this).width() > 550) {
			var height = Math.ceil((1 - (($(this).width() - 550) / $(this).width())) * $(this).height());
			$(this).attr('width', 550);
			$(this).attr('height', height);
		}
	});
}
function fix_embeds() {
	$('embed').each(function() {
		if (parseInt($(this).attr('width')) > 550) {
			var height = Math.ceil((1 - ((parseInt($(this).attr('width')) - 550) / parseInt($(this).attr('width')))) * parseInt($(this).attr('height')));
			$(this).attr('width', 550);
			$(this).attr('height', height);
		}
	});
}
function fix_height() {
	var m_height = $('.main-column').height();
	var s_height = $('.side-column').height();
	if (m_height < s_height) {
		$('.main-column').css({ 'height' : s_height + 'px' });
	}
}
$(function() {
	// Fix embed widths
	fix_objects();
	fix_embeds();
	
	// Fix main-column height
	fix_height();
	
	var href = window.location.href.replace('http://zomm.com/blog/', '').replace('topics/', '');
	href = href.replace('http://zomm.com/blog/', '').split('/');
	href = href[0];
	$('#features-nav li a').each(function() {
		var link_href = $(this).attr('href').replace('http://zomm.com/blog/', '').replace('topics/', '').replace('/', '');
		if (link_href == href) {
			$(this).parent().addClass('selected');
		}
	});
	
	$('.post:last').addClass('last');
	
	if ($('body').hasClass('error404')) {
		$('body').find('#content-wrap').addClass('fineprint');
	}
});
