$(window).load(function() {
	
	// Force max-width on images
	var max_width = 620; 	//Sets the max width, in pixels, for every image
	var selector = '.entry img'; 	//Sets the syntax for finding the images.  Defaults to all images.
	
	$(selector).each(function(){
		var width = $(this).width();
		var height = $(this).height();
		if (width > max_width) {
			//Set variables	for manipulation
			var ratio = (height / width );
			var new_width = max_width;
			var new_height = (new_width * ratio);
			
			//Shrink the image and add link to full-sized image
			$(this).height(new_height).width(new_width);
		}
	}
	);
	
	// Set sidebar height to content height for divider border
	var contentHeight = $('#content').height();
	if ($('#sidebar').height() < contentHeight ) {
		$('#sidebar').height(contentHeight);
	}
});

$(document).ready(function() {

	// Keep blogger list div's height when preloading
	var ch = $('#all_blogs').height();
	$('#all_blogs').height(ch);
	
	// Toggle blogger list on inner pages
	$('.view_all').click(function() {
		$('#all_blogs').slideToggle();
		return false;
	});
	$('#close').click(function() {
		$('#all_blogs').slideToggle();
		return false;
	});
	
	jQuery.fn.autolink = function () {
	return this.each( function(){
		var re = /((http|https|ftp):\/\/[\w?=&.\/-;#~%-]+(?![\w\s?&.\/;#~%"=-]*>))/g;
		$(this).html( $(this).html().replace(re, '<a href="$1">$1</a> ') );
	});
	}
	$('.profile').autolink();
	
	$('ol#comments li:last-child').css('border', 0);
	
});

/*
CSS Browser Selector v0.3.3 (Sep 09, 2009)
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',h=document.getElementsByTagName('html')[0],b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3')?g+' ff3':is('gecko/')?g:/opera(\s|\/)(\d+)/.test(ua)?'opera opera'+RegExp.$2:is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);