$(window).load(function () {

	resizeFunc=function () {
                var $variableDiv=$('ol#forums');
                if ($variableDiv.length==0) {
                        var $variableDiv=$('div#plwrapforum');
                }


                var new_width=$(window).width() - $('div#sidebar_container').width() - 40;
                if (new_width<734) new_width=734;

                $variableDiv.css('width', new_width);

                $('div#postlist').imagefit();
                
        };

	$(window).resize(resizeFunc);

	resizeFunc();
	setTimeout(resizeFunc, 1000);
	
	$('input.postimod').click(function () {
		var v=$('span#post_inlinemod_count').html();
		$('span.inlinemodcount2').html(v);
	});
});





/* jquery.imagefit 
 *
 * Version 0.2 by Oliver Boermans <http://www.ollicle.com/eg/jquery/imagefit/>
 *
 * Extends jQuery <http://jquery.com>
 *
 */
(function($) {
	$.fn.imagefit = function(options) {
		var fit = {
			all : function(imgs){
				imgs.each(function(){
					fit.one(this);
					})
				},
			one : function(img){
				$(img)
					.width('100%').each(function()
					{
						$(this).height(Math.round(
							$(this).attr('startheight')*($(this).width()/$(this).attr('startwidth')))
						);
					})
				}
		};
		
		this.each(function(){
				var container = this;
				
				// store list of contained images (excluding those in tables)
				var imgs = $('img', container).not($("table img"));
				
				// store initial dimensions on each image 
				imgs.each(function(){
					if ($(this).width() > 300) {
						$(this).attr('startwidth', $(this).width())
							.attr('startheight', $(this).height())
							.css('max-width', $(this).attr('startwidth')+"px");
					
						fit.one(this);
					}
				});
				// Re-adjust when window width is changed
				//$(window).bind('resize', function(){
				//	fit.all(imgs);
				//});
			});
		return this;
	};
})(jQuery);

