// JavaScript Document © 2008 (mt) Media Temple, Inc. All Rights Reserved.

$(function() {
   	var code_box_height = 200;
	
	if ( ! $.browser.msie ) {
		$("code.draggable").each( function () {
                        var $this = $(this);
			var cheight = $this.innerHeight();
			var styles = $this.attr('class');
			if ( cheight <= code_box_height ){
				return true;
			}
			var cwidth = $this.innerWidth();
			var $textarea = $(document.createElement('textarea'))
				.attr({	"wrap"     : "off",
						"readonly" : "readonly",
						"class"    : "kb-resize " + styles,
						"width"    : cwidth,
						"height"   : code_box_height
					  })
				.width(cwidth)
				.height(code_box_height + "px")
				.html( "\n\n\n" + $this.html() )
				;
			( $this.parent('pre').length
			    ? $this.parent('pre')
                            : $this
                        ).replaceWith($textarea);
			
			$textarea.resizable({
				autohide: true,
				minHeight: 200,
				minWidth: cwidth,
				maxHeight: cheight + 30,
				handles: 's'
			});
		});	
		
		$(".ui-resizable-s").mousedown( function () {
			$(this).addClass("dragdown");
			});
		$(".ui-resizable-s").mouseup( function () {
			$(this).removeClass("dragdown");
			});
	} // end if not msie
}); // end document ready

