/* Copyright (c) 2008 Kean Loong Tan http://www.gimiti.com/kltan
 * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * Name: jSize
 * Version: 1.0 (April 29, 2008)
 * Requires: jQuery 1.2+
 */
(function($){$.fn.jSize=function(options){var opts=$.extend({},$.fn.jSize.defaults,options);var x,y,iniW,iniH,sliderW,sliderH,minW,maxW,minH,maxH,obj,curH;var allow=false;if(opts.type=="left-right"){sliderW=$(this).width();minW=$(this).parent().width()-sliderW-parseInt($(opts.static).css("max-width"));maxW=$(this).parent().width()-sliderW-parseInt($(opts.static).css("min-width"));$(this).mousedown(function(e){allow=true;x=e.pageX;iniW=$(opts.c1).width();});$().mouseup(function(e){allow=false;});$().mousemove(function(e){if(allow){var left=iniW-(x-e.pageX);$(opts.c1).css("width",left+"px");$(opts.c2).css("margin-left",$(opts.c1).width()+sliderW+"px");$("#debug").html("mousemove: "+(x-e.pageX)+"<br>left: "+left+"<br>.left: "+$(opts.c1).css("width")+"<br>right's leftmargin: "+$(opts.c2).css("margin-left"));}});}
else if(opts.type=="top-bottom"){sliderH=$(this).height();minH=$(this).parent().height()-sliderH-parseInt($(opts.static).css("max-height"));maxH=$(this).parent().height()-sliderH-parseInt($(opts.static).css("min-height"));if(opts.c1==opts.static){curH=$(opts.c1).parent().height()-$(opts.c1).height()-sliderH;$(opts.c2).css("min-height",minH+'px');$(opts.c2).css("max-height",maxH+'px');$(opts.c2).height(curH+"px");}
else if(opts.c2==opts.static){curH=$(opts.c2).parent().height()-$(opts.c2).height()-sliderH;$(opts.c1).css("min-height",minH+'px');$(opts.c1).css("max-height",maxH+'px');$(opts.c1).height(curH+"px");}
$(this).mousedown(function(e){allow=true;y=e.pageY;iniH=$(opts.c1).height();obj=this;});$().mouseup(function(e){allow=false;});$().mousemove(function(e){if(allow){var top=iniH-(y-e.pageY);var rest=$(obj).parent().height()-top-sliderH;$(opts.c1).css("height",top+"px");$(opts.c2).css("height",rest+"px");$("#debug").html("mousemove: "+(y-e.pageY)+"<br>calced: "+top+"<br>.top: "+$(opts.c1).css("height")+"<br>.bottom: "+$(opts.c2).height()+" <br>parent height: "+$(obj).parent().height());}});}};$.fn.jSize.defaults={type:"left-right"};})(jQuery);