/*______________
|       ______  |   U I Z E     J A V A S C R I P T     A P I
|     /      /  |   -----------------------------------------
|    /    O /   |    MODULE : Uize.Widget.Marquee Class (version 1.0.0)
|   /    / /    |    AUTHOR : Chris van Rensburg (http://www.tomkidding.com)
|  /    / /  /| |    ONLINE : http://www.tomkidding.com/uize/uize-js-api
| /____/ /__/_| | COPYRIGHT : (c)2005-2006 Chris van Rensburg
|           |__ |   LICENSE : Distributed under the terms of the GNU General Public License
|_______________|             http://www.gnu.org/licenses/gpl.txt
*/
(function(){var c_a=true,c_b=false,c_c='undefined',c_d=Uize.Element;var c_e=Uize.Widget,c_f=c_e.Marquee=c_e.subclass(),c_g=c_f.prototype;var c_h={northWest:[0,0],north:[.5,0],northEast:[1,0],west:[0,.5],area:['both','both'],east:[1,.5],southWest:[0,1],south:[.5,1],southEast:[1,1]};c_g.c_i=function(){var c_j=this;if(c_j.wired()){var c_k=navigator.appName=='Microsoft Internet Explorer'&&document.compatMode!='CSS1Compat';
function c_l(c_m){function c_n(c_o){return parseInt(c_d.getStyleAttribute(c_p,'border'+c_o+'Width'));}var c_p=c_j.getNode(c_m);if(c_p)c_d.setCoords(c_p,[c_j.c_q,c_j.c_r,Math.max(c_j.c_s-(c_k?0:c_n('Left')+c_n('Right')),0),Math.max(c_j.c_t-(c_k?0:c_n('Top')+c_n('Bottom')),0)]);}c_l('area');c_l('areaBorder');var c_u=c_j.c_v?c_j.c_w.marqueeInfo.c_x:0;function c_y(c_z,c_A,c_B){var c_C=c_h[c_z],c_D=c_j.getNode(c_z),c_E=c_d.getDimensions(c_D);c_d.setStyle(c_D,{display:(!c_j.c_F&&(!c_j.c_G||c_C[0]==.5)&&(!c_j.c_H||c_C[1]==.5)&&(!c_j.c_I|| !c_j.c_v||(c_C[0]==c_u[0]&&c_C[1]==c_u[1])))?'block':'none',left:Math.round(c_A-(c_E.width-1)/2)+'px',top:Math.round(c_B-(c_E.height-1)/2)+'px'});}c_y('northWest',c_j.c_q,c_j.c_r);c_y('north',c_j.c_q+c_j.c_s/2,c_j.c_r);c_y('northEast',c_j.c_q+c_j.c_s-1,c_j.c_r);c_y('west',c_j.c_q,c_j.c_r+c_j.c_t/2);c_y('east',c_j.c_q+c_j.c_s-1,c_j.c_r+c_j.c_t/2);c_y('southWest',c_j.c_q,c_j.c_r+c_j.c_t-1);c_y('south',c_j.c_q+c_j.c_s/2,c_j.c_r+c_j.c_t-1);
c_y('southEast',c_j.c_q+c_j.c_s-1,c_j.c_r+c_j.c_t-1);}};c_g.c_J=function(c_q,c_r,c_s,c_t){var c_j=this;if(c_q!=c_j.c_q||c_r!=c_j.c_r||c_s!=c_j.c_s||c_t!=c_j.c_t){c_j.set({left:c_q,top:c_r,width:c_s,height:c_t});c_j.fireEvent('Position Changed');}};c_g.getCoords=function(){var c_j=this;return{left:c_j.c_q,top:c_j.c_r,width:c_j.c_s,height:c_j.c_t};};c_g.updateUi=c_g.c_i;c_g.wireUi=function(){var c_j=this;if(!c_j.wired()){var c_K=c_j.getNode();c_j.c_L={};var c_M,c_N,c_O,c_C,c_P;function c_Q(c_z){var c_C=c_h[c_z],c_R=c_j.c_L[c_z]=new c_e.Drag({dragRestTime:c_j.c_S,element:c_j.getNode(c_z),marqueeInfo:{c_z:c_z,c_C:c_C,c_x:[]}});c_R.addEventHandlers({'Before Drag Start':function(c_T){c_j.fireEvent(c_T)},'Drag Start':function(c_T){c_j.c_w=c_T.instance;c_j.set({c_v:c_a});c_M=c_d.getDimensions(c_K);c_N=[0,0,c_M.width-1,c_M.height-1];c_O=[c_N[2]/2,c_N[3]/2];c_P=[c_j.c_q,c_j.c_r,c_j.c_q+c_j.c_s-1,c_j.c_r+c_j.c_t-1];c_j.fireEvent(c_T);},'Drag Update':function(){var c_U=c_j.c_U,c_V=c_j.c_w.marqueeInfo,c_C=c_V.c_C,
c_x=c_V.c_x,c_W=[c_P[0],c_P[1],c_P[2],c_P[3]];c_x[0]=c_C[0];c_x[1]=c_C[1];function c_X(c_Y){if(c_C[c_Y]!=.5){var c_Z=c_R.eventDeltaPos[c_Y];if(c_C[c_Y]==='both'){if(c_j.c_0)c_Z=Math.min(Math.max(c_Z,-c_W[c_Y]),c_N[c_Y+2]-c_W[c_Y+2]);c_W[c_Y]+=c_Z;c_W[c_Y+2]+=c_Z;}else{var c_1=c_Y+c_C[c_Y]*2;c_W[c_1]+=c_Z;if(c_j.c_0){c_W[c_1]=Math.min(Math.max(c_W[c_1],c_N[c_Y]),c_N[c_Y+2]);}if(c_U==null&&c_W[c_Y]>c_W[c_Y+2]){var c_2=c_W[c_Y];c_W[c_Y]=c_W[c_Y+2];c_W[c_Y+2]=c_2;c_x[c_Y]=1-c_x[c_Y];}}}}c_X(0);c_X(1);var c_3=[Math.max(c_W[2]-c_W[0]+1,c_j.c_4),Math.max(c_W[3]-c_W[1]+1,c_j.c_5)],c_6=[(c_W[0]+c_W[2])/2,(c_W[1]+c_W[3])/2];var c_7=c_3[0]/c_3[1];if(c_U!=null){if(c_7!=c_U){var c_8=[c_3[1]*c_U,c_3[0]/c_U];function c_9(c_Y,c_ba){c_3[c_Y]=c_8[c_Y];if(c_j.c_0){c_3[c_Y]=Math.min(c_3[c_Y],c_ba);c_3[1-c_Y]=c_3[c_Y]*Math.pow(c_U,c_Y*2-1);}}function c_bb(c_Y){c_9(c_Y,(c_6[c_Y]<c_O[c_Y]?(c_6[c_Y]+.5):c_N[c_Y+2]-c_6[c_Y])*2);}function c_bc(c_Y){c_9(c_Y,(c_C[c_Y]==0?c_W[c_Y+2]:c_N[c_Y+2]-c_W[c_Y])+1);}if(c_C[0]==.5){c_bb(0);
}else if(c_C[1]==.5){c_bb(1);}else if(c_3[1]*c_8[0]>c_3[0]*c_8[1]){c_bc(0);}else{c_bc(1);}}function c_bd(c_Y){if(c_C[c_Y]==0){c_W[c_Y]=c_W[c_Y+2]-c_3[c_Y]+1;}else if(c_C[c_Y]==.5){c_W[c_Y]=c_6[c_Y]-(c_3[c_Y]-1)/2;}}c_bd(0);c_bd(1);}c_j.c_J(c_W[0],c_W[1],c_3[0],c_3[1]);},'Drag Rest':function(c_T){c_j.fireEvent(c_T)},'Drag Done':function(c_T){c_j.set({c_v:c_b});c_j.fireEvent(c_T);c_j.c_F=c_b;c_j.c_i();}});c_j.widgets.add(c_z,c_R);}c_Q('northWest');c_Q('north');c_Q('northEast');c_Q('west');c_Q('east');c_Q('southWest');c_Q('south');c_Q('southEast');c_Q('area');if(c_j.c_be){c_d.setStyle(c_K,{cursor:'crosshair'});c_j.wireNodeEvent(c_K,'onmousedown2',function(c_T){if(!c_T)c_T=event;var c_bf=c_d.getCoords(c_K),c_z=c_j.c_U==null?'northWest':'southEast';c_j.c_F=c_a;c_j.c_J(c_T.clientX+document.documentElement.scrollLeft-c_bf.left,c_T.clientY+document.documentElement.scrollTop-c_bf.top,c_j.c_4,c_j.c_5);return c_j.widgets.map[c_z].mousedown(c_T);});}c_e.prototype.wireUi.call(c_j);}};c_f.registerProperties({c_U:{
name:'aspectRatio',onChange:c_g.c_i},c_0:'constrain',c_F:'creatingNew',c_S:{name:'dragRestTime',onChange:function(){this.widgets.set({dragRestTime:this.c_S})}},c_G:{name:'fixedX',onChange:c_g.c_i},c_H:{name:'fixedY',onChange:c_g.c_i},c_t:{name:'height',onChange:c_g.c_i},c_I:'hideOtherHandlesInDrag',c_v:'inDrag',c_q:{name:'left',onChange:c_g.c_i},c_5:'minHeight',c_4:'minWidth',c_be:'shellLive',c_r:{name:'top',onChange:c_g.c_i},c_s:{name:'width',onChange:c_g.c_i}});c_f.set({c_U:null,c_F:c_b,c_0:c_a,c_S:250,html:function(){function c_bg(c_z){var c_bh='<img id="[#idPrefix]-'+c_z+'" src="[#blankGif]"'+(c_j.handleCssClass?(' class="'+c_j.handleCssClass+'"'):'')+' style="position:absolute; cursor:'+c_z.charAt(0)+c_z.replace(/[a-z]/g,'').toLowerCase()+'-resize; z-index:1000; display:none;'+(c_j.handleCssClass?'':(' width:7px; height:7px; background:#ccc; border:1px solid #fff;'))+'"/>';return c_bh;}var c_j=this,c_bh=
'<div id="[#idPrefix]-areaBorder" style="position:absolute; left:0px; top:0px; width:200px; height:200px; border:1px solid #000; background:url([#blankGif]); z-index:999;"></div>'+'<a id="[#idPrefix]-area" href="javascript://" style="display:block; position:absolute; left:0px; top:0px; width:200px; height:200px; border:1px dashed #fff; cursor:move; z-index:1000; background:url([#blankGif]);"></a>'+c_bg('northWest')+c_bg('north')+c_bg('northEast')+c_bg('west')+c_bg('east')+c_bg('southWest')+c_bg('south')+c_bg('southEast');return c_bh;},c_G:c_b,c_H:c_b,c_t:200,c_I:c_b,c_v:c_b,c_q:0,c_5:10,c_4:10,c_be:c_a,c_r:0,c_s:200,useNewIdSyntax:c_a});})();