window.onload = function(){
	//Configuration Options
	var max_width = 486; 	//Sets the max width, in pixels, for every image
	var selector = '#phpbb .postbody .content img'; 	//Sets the syntax for finding the images.  Defaults to all images.
				//For images inside of a particular element (id="abc") or class (class="abc"),
				//use '.abc img' or '#abc img' respectively.  Don't leave off the img tag!!!
	//End configuration options.  You don't need to change anything below here.
	
	$(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);
			$(this).wrap('<a href="'+$(this).attr('src')+'" class="lightbox"></a>');
			$(this).hover(function(){
				$(this).attr("title", "This image has been scaled down.  Click to view the original image.")
				$(this).css("cursor","pointer");
				});
			
		} //ends if statement
	} //ends each function
	);
	
	$('#phpbb .postprofile img').each(function(){
		if(this.width > 140){
			var height = $(this).height();
			var width = $(this).width();
			var ratio = Math.round(height / width);
			var new_width = 140;
			var new_height = (new_width * ratio);
			
			
			$(this).height(new_height).width(new_width);
		}
	});
	
	$('a.lightbox').lightBox();
};
