source: trunk/instant_messenger/js/im_dragdrop.js @ 20

Revision 20, 41.0 KB checked in by niltonneto, 17 years ago (diff)

Inclusão do módulo Mensageiro Instantâneo no CVS.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1/* This notice must be untouched at all times.
2
3wz_dragdrop.js  v. 4.85
4The latest version is available at
5http://www.walterzorn.com
6or http://www.devira.com
7or http://www.walterzorn.de
8
9Copyright (c) 2002-2003 Walter Zorn. All rights reserved.
10Created 26. 8. 2002 by Walter Zorn (Web: http://www.walterzorn.com )
11Last modified: 3. 7. 2006
12
13This DHTML & Drag&Drop Library adds Drag&Drop functionality
14to the following types of html-elements:
15- images, even if not positioned via layers,
16  nor via stylesheets or any other kind of "hard-coding"
17- relatively and absolutely positioned layers (DIV elements).
18Moreover, it provides extended DHTML abilities.
19
20LICENSE: LGPL
21
22This library is free software; you can redistribute it and/or
23modify it under the terms of the GNU Lesser General Public
24License (LGPL) as published by the Free Software Foundation; either
25version 2.1 of the License, or (at your option) any later version.
26
27This library is distributed in the hope that it will be useful,
28but WITHOUT ANY WARRANTY; without even the implied warranty of
29MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
30
31For more details on the GNU Lesser General Public License,
32see http://www.gnu.org/copyleft/lesser.html
33*/
34
35
36// PATH TO THE TRANSPARENT 1*1 PX IMAGE (required by NS 4 as spacer)
37var IM_spacer = 'transparentpixel.gif';
38
39
40
41
42//window.onerror = new Function('return true;');
43
44
45// Optional commands passed to SET_DHTML() on the html-page (g: may be applied globally, i: individually)
46var IM_CLONE                    = 'C10nE';   // i  img    clone image
47var IM_COPY                      = 'C0pY';      // i  img         create copies
48var IM_DETACH_CHILDREN  = 'd37aCH';  // i  lyr    detach images
49var IM_HORIZONTAL          = 'H0r1Z';   // i  img,lyr  horizontally draggable only
50var IM_MAXHEIGHT                = 'm7x8I';   // i  img,lyr  maximum height limit, "
51var IM_MAXOFFBOTTOM      = 'm7xd0wN'; // i  img,lyr  downward offset limit
52var IM_MAXOFFLEFT          = 'm7x23Ft'; // i  img,lyr  leftward offset limit
53var IM_MAXOFFRIGHT        = 'm7x0Ff8'; // i  img,lyr  rightward offset limit
54var IM_MAXOFFTOP                = 'm7xu9';   // i  img,lyr  upward offset limit
55var IM_MAXWIDTH          = 'm7xW1';   // i  img,lyr  maximum width limit, use with resizable or scalable
56var IM_MINWIDTH          = 'm1nw1';   // i  img,lyr  minimum width limit, "
57var IM_MINHEIGHT                = 'm1n8I';   // i  img,lyr  minimum height limit, "
58var IM_NO_ALT              = 'no81T';   // gi img         disable alt and title attributes
59var IM_NO_DRAG            = 'N0d4Ag';  // i  img,lyr  disable draggability
60var IM_RESET_Z            = 'r35E7z';  // gi img,lyr  reset z-index when dropped
61var IM_RESIZABLE                = 'r5IZbl';  // gi img,lyr  resizable if <ctrl> or <shift> pressed
62var IM_SCALABLE          = 'SCLbl';   // gi img,lyr  scalable              "
63var IM_SCROLL              = 'sC8lL';   // gi img,lyr  enable auto scroll functionality
64var IM_TRANSPARENT        = 'dIApHAn'; // gi img,lyr  translucent while dragged
65var IM_VERTICAL          = 'V3Rt1C';  // i  img,lyr  vertically draggable only
66var IM_dd_cursors = new Array(
67        'im_c:default',
68        'im_c:crosshair',
69        'im_c:e-resize',
70        'im_c:hand',
71        'im_c:help',
72        'im_c:move',
73        'im_c:n-resize',
74        'im_c:ne-resize',
75        'im_c:nw-resize',
76        'im_c:s-resize',
77        'im_c:se-resize',
78        'im_c:sw-resize',
79        'im_c:text',
80        'im_c:w-resize',
81        'im_c:wait'
82);
83
84var IM_dd_i = IM_dd_cursors.length; while(IM_dd_i--)
85        eval('var IM_CURSOR_' + (IM_dd_cursors[IM_dd_i].substring(5).toUpperCase().replace('-', '_')) + ' = "' + IM_dd_cursors[IM_dd_i] + '";');
86var IM_dd_u = "undefined";
87function IM_WZDD()
88{
89        this.elements = new Array(0);
90        this.obj = null;
91        this.n = navigator.userAgent.toLowerCase();
92        this.db = (document.compatMode && document.compatMode.toLowerCase() != "backcompat")?
93                document.documentElement
94                : (document.body || null);
95        this.op = !!(window.opera && document.getElementById);
96        if(this.op) document.onmousedown = new Function('e',
97                'if(((e = e || window.event).target || e.srcElement).tagName == "IMAGE") return false;');
98        this.ie = !!(this.n.indexOf("msie") >= 0 && document.all && this.db && !this.op);
99        this.iemac = !!(this.ie && this.n.indexOf("mac") >= 0);
100        this.ie4 = !!(this.ie && !document.getElementById);
101        this.n4 = !!(document.layers && typeof document.classes != IM_dd_u);
102        this.n6 = !!(typeof window.getComputedStyle != IM_dd_u && typeof document.createRange != IM_dd_u);
103        this.w3c = !!(!this.op && !this.ie && !this.n6 && document.getElementById);
104        this.ce = !!(document.captureEvents && document.releaseEvents);
105        this.px = this.n4? '' : 'px';
106        this.tiv = this.w3c? 40 : 10;
107}
108var IM_dd = new IM_WZDD();
109
110IM_dd.Int = function(d_x, d_y)
111{
112        return isNaN(d_y = parseInt(d_x))? 0 : d_y;
113};
114IM_dd.getWndW = function()
115{
116        return IM_dd.Int(
117                (IM_dd.db && !IM_dd.op && !IM_dd.w3c && IM_dd.db.clientWidth)? IM_dd.db.clientWidth
118                : (window.innerWidth || 0)
119        );
120};
121IM_dd.getWndH = function()
122{
123        return IM_dd.Int(
124                (IM_dd.db && !IM_dd.op && !IM_dd.w3c && IM_dd.db.clientHeight)? IM_dd.db.clientHeight
125                : (window.innerHeight || 0)
126        );
127};
128IM_dd.getScrollX = function()
129{
130        return IM_dd.Int(window.pageXOffset || (IM_dd.db? IM_dd.db.scrollLeft : 0));
131};
132IM_dd.getScrollY = function()
133{
134        return IM_dd.Int(window.pageYOffset || (IM_dd.db? IM_dd.db.scrollTop : 0));
135};
136IM_dd.getPageXY = function(d_o)
137{
138        if(IM_dd.n4 && d_o)
139        {
140                IM_dd.x = d_o.pageX || 0;
141                IM_dd.y = d_o.pageY || 0;
142        }
143        else
144        {
145                IM_dd.x = IM_dd.y = 0; //global helper vars
146                while(d_o)
147                {
148                        IM_dd.x += IM_dd.Int(d_o.offsetLeft);
149                        IM_dd.y += IM_dd.Int(d_o.offsetTop);
150                        d_o = d_o.offsetParent || null;
151                }
152        }
153};
154IM_dd.getCssXY = function(d_o)
155{
156        if(d_o.div)
157        {
158                if(IM_dd.n4)
159                {
160                        d_o.cssx = d_o.div.x;
161                        d_o.cssy = d_o.div.y;
162                }
163                else if(IM_dd.ie4)
164                {
165                        d_o.cssx = d_o.css.pixelLeft;
166                        d_o.cssy = d_o.css.pixelTop;
167                }
168                else
169                {
170                        d_o.css.left = d_o.css.top = 0 + IM_dd.px;
171                        IM_dd.getPageXY(d_o.div);
172                        d_o.cssx = d_o.x - IM_dd.x;
173                        d_o.cssy = d_o.y - IM_dd.y;
174                        d_o.css.left = d_o.cssx + IM_dd.px;
175                        d_o.css.top = d_o.cssy + IM_dd.px;
176                }
177        }
178        else
179        {
180                d_o.cssx = 0;
181                d_o.cssy = 0;
182        }
183};
184IM_dd.getImgW = function(d_o)
185{
186        return d_o? IM_dd.Int(d_o.width) : 0;
187};
188IM_dd.getImgH = function(d_o)
189{
190        return d_o? IM_dd.Int(d_o.height) : 0;
191};
192IM_dd.getDivW = function(d_o)
193{
194        return IM_dd.Int(
195                IM_dd.n4? (d_o.div? d_o.div.clip.width : 0)
196                : d_o.div? (d_o.div.offsetWidth || d_o.css.pixelWidth || d_o.css.width || 0)
197                : 0
198        );
199};
200IM_dd.getDivH = function(d_o)
201{
202        return IM_dd.Int(
203                IM_dd.n4? (d_o.div? d_o.div.clip.height : 0)
204                : d_o.div? (d_o.div.offsetHeight || d_o.css.pixelHeight || d_o.css.height || 0)
205                : 0
206        );
207};
208IM_dd.getWH = function(d_o)
209{
210        d_o.w = IM_dd.getDivW(d_o);
211        d_o.h = IM_dd.getDivH(d_o);
212        if(d_o.css)
213        {
214                d_o.css.width = d_o.w + IM_dd.px;
215                d_o.css.height = d_o.h + IM_dd.px;
216                d_o.dw = IM_dd.getDivW(d_o)-d_o.w;
217                d_o.dh = IM_dd.getDivH(d_o)-d_o.h;
218      /*
219       * by Rodrigo Souza
220       * acrescentado Math.abs para corrigir retorno
221       * negativo ou ainda NaN
222       */
223                d_o.css.width = Math.abs(d_o.w-d_o.dw) + IM_dd.px;
224                d_o.css.height = Math.abs(d_o.h-d_o.dh) + IM_dd.px;
225        }
226        else d_o.dw = d_o.dh = 0;
227};
228IM_dd.getCssProp = function(d_o, d_pn6, d_pstyle, d_pn4)
229{
230        if(d_o && IM_dd.n6) return ''+window.getComputedStyle(d_o, null).getPropertyValue(d_pn6);
231        if(d_o && d_o.currentStyle) return ''+eval('d_o.currentStyle.'+d_pstyle);
232        if(d_o && d_o.style) return ''+eval('d_o.style.'+d_pstyle);
233        if(d_o && IM_dd.n4) return ''+eval('d_o.'+d_pn4);
234        return '';
235};
236IM_dd.getDiv = function(d_x, d_d)
237{
238        d_d = d_d || document;
239        if(IM_dd.n4)
240        {
241                if(d_d.layers[d_x]) return d_d.layers[d_x];
242                for(var d_i = d_d.layers.length; d_i--;)
243                {
244                        var d_y = IM_dd.getDiv(d_x, d_d.layers[d_i].document);
245                        if(d_y) return d_y;
246                }
247        }
248        if(IM_dd.ie) return d_d.all[d_x] || null;
249        if(d_d.getElementById) return d_d.getElementById(d_x) || null;
250        return null;
251};
252IM_dd.getImg = function(d_o, d_nm, d_xy, d_w)
253{
254        d_w = d_w || window;
255        var d_img;
256        if(document.images && (d_img = d_w.document.images[d_nm]))
257        {
258                if(d_xy)
259                {
260                        if(IM_dd.n4)
261                        {
262                                IM_dd.getPageXY(d_w);
263                                d_o.defx = d_img.x + IM_dd.x;
264                                d_o.defy = d_img.y + IM_dd.y;
265                        }
266                        else
267                        {
268                                IM_dd.getPageXY(d_img);
269                                d_o.defx = IM_dd.x;
270                                d_o.defy = IM_dd.y;
271                        }
272                }
273                return d_img;
274        }
275        if(IM_dd.n4) for(var d_i = d_w.document.layers.length; d_i--;)
276        {
277                var d_y = IM_dd.getImg(d_o, d_nm, d_xy, d_w.document.layers[d_i]);
278                if(d_y) return d_y;
279        }
280        return null;
281};
282IM_dd.getParent = function(d_o, d_p)
283{
284        if(IM_dd.n4)
285        {
286                for(d_p, d_i = IM_dd.elements.length; d_i--;)
287                {
288                        if(!((d_p = IM_dd.elements[d_i]).is_image) && d_p.div && (d_p.div.document.layers[d_o.name] || d_o.oimg && d_p.div.document.images[d_o.oimg.name]))
289                                d_p.addChild(d_o, d_p.detach, 1);
290                }
291        }
292        else
293        {
294                d_p = d_o.is_image? IM_dd.getImg(d_o, d_o.oimg.name) : (d_o.div || null);
295                while(d_p && !!(d_p = d_p.offsetParent || d_p.parentNode || null))
296                {
297                        if(d_p.ddObj)
298                        {
299                                d_p.ddObj.addChild(d_o, d_p.ddObj.detach, 1);
300                                break;
301                        }
302                }
303        }
304};
305IM_dd.getCmd = function(d_o, d_cmd, d_cmdStr)
306{
307        var d_i = d_o.id.indexOf(d_cmd), d_j,
308        d_y = (d_i >= 0)*1;
309        if(d_y)
310        {
311                d_j = d_i+d_cmd.length;
312                if(d_cmdStr) d_o.cmd += d_o.id.substring(d_i, d_j);
313                d_o.id = d_o.id.substring(0, d_i) + d_o.id.substring(d_j);
314        }
315        return d_y;
316};
317IM_dd.getCmdVal = function(d_o, d_cmd, d_cmdStr, int0)
318{
319        var d_i = d_o.id.indexOf(d_cmd), d_j,
320        d_y = (d_o.id.indexOf(d_cmd) >= 0)? IM_dd.Int(d_o.id.substring(d_o.id.indexOf(d_cmd)+d_cmd.length)) : int0? -1 : 0;
321        if(!int0 && d_y || int0 && d_y >= 0)
322        {
323                d_j = d_i+d_cmd.length+(""+d_y).length;
324                if(d_cmdStr) d_o.cmd += d_o.id.substring(d_i, d_j);
325                d_o.id = d_o.id.substring(0, d_i) + d_o.id.substring(d_j);
326        }
327        return d_y;
328};
329IM_dd.addElt = function(d_o, d_p)
330{
331        IM_dd.elements[d_o.name] = IM_dd.elements[d_o.index = IM_dd.elements.length] = d_o;
332        if(d_p) d_p.copies[d_o.name] = d_p.copies[d_p.copies.length] = d_o;
333};
334IM_dd.mkWzDom = function()
335{
336        var d_o, d_i = IM_dd.elements.length; while(d_i--) IM_dd.getParent(IM_dd.elements[d_i]);
337        d_i = IM_dd.elements.length; while(d_i--)
338        {
339                d_o = IM_dd.elements[d_i];
340                if(d_o.children && !d_o.parent)
341                {
342                        var d_j = d_o.children.length; while(d_j--)
343                                d_o.children[d_j].setZ(d_o.z+d_o.children[d_j].z, 1);
344                }
345        }
346};
347IM_dd.addProps = function(d_o)
348{
349        var d_i, d_c;
350        if(d_o.is_image)
351        {
352                d_o.div = IM_dd.getDiv(d_o.id);
353                d_o.css = (d_o.div && typeof d_o.div.style != IM_dd_u)? d_o.div.style : null;
354                d_o.nimg = (IM_dd.n4 && d_o.div)? d_o.div.document.images[0] : (document.images[d_o.id+"NI1m6G"] || null);
355                if(!d_o.noalt && !IM_dd.noalt && d_o.nimg && d_o.oimg)
356                {
357                        d_o.nimg.alt = d_o.oimg.alt || '';
358                        if(d_o.oimg.title) d_o.nimg.title = d_o.oimg.title;
359                }
360                d_o.bgColor = '';
361        }
362        else
363        {
364                d_o.bgColor = IM_dd.getCssProp(d_o.div, 'background-color','backgroundColor','bgColor').toLowerCase();
365                if(IM_dd.n6 && d_o.div)
366                {
367                        if((d_c = d_o.bgColor).indexOf('rgb') >= 0)
368                        {
369                                d_c = d_c.substring(4, d_c.length-1).split(',');
370                                d_o.bgColor = '#';
371                                for(d_i = 0; d_i < d_c.length; d_i++) d_o.bgColor += parseInt(d_c[d_i]).toString(0x10);
372                        }
373                        else d_o.bgColor = d_c;
374                }
375        }
376        if(IM_dd.scalable) d_o.scalable = d_o.resizable^1;
377        else if(IM_dd.resizable) d_o.resizable = d_o.scalable^1;
378        d_o.setZ(d_o.defz);
379        d_o.cursor = d_o.cursor || IM_dd.cursor || 'auto';
380        d_o._setCrs(d_o.nodrag? 'auto' : d_o.cursor);
381        d_o.diaphan = d_o.diaphan || IM_dd.diaphan || 0;
382        d_o.opacity = 1.0;
383        d_o.visible = true;
384};
385IM_dd.initz = function()
386{
387        if(!(IM_dd && (IM_dd.n4 || IM_dd.n6 || IM_dd.ie || IM_dd.op || IM_dd.w3c))) return;
388        else if(IM_dd.n6 || IM_dd.ie || IM_dd.op || IM_dd.w3c) IM_dd.recalc(1);
389        var d_drag = (document.onmousemove == IM_DRAG),
390        d_resize = (document.onmousemove == IM_RESIZE);
391        if(IM_dd.loadFunc) IM_dd.loadFunc();
392        if(d_drag) IM_dd.setMovHdl(IM_DRAG);
393        else if(d_resize) IM_dd.setMovHdl(IM_RESIZE);
394        if(d_drag || d_resize) IM_dd.setUpHdl(IM_DROP);
395        IM_dd.setDwnHdl(IM_PICK);
396};
397IM_dd.finlz = function()
398{
399        if(IM_dd.ie && IM_dd.elements)
400        {
401                var d_i = IM_dd.elements.length; while(d_i--)
402                        IM_dd.elements[d_i].del();
403        }
404        if(IM_dd.uloadFunc) IM_dd.uloadFunc();
405};
406IM_dd.setCe = function(d_e, d_fnc)
407{
408        d_fnc? document.captureEvents(d_e) : document.releaseEvents(d_e);
409};
410IM_dd.setDwnHdl = function(d_x)
411{
412        if(document.onmousedown != d_x)
413        {
414                //IM_dd.downFunc = document.onmousedown;
415                document.onmousedown = d_x;
416                if(IM_dd.ce) IM_dd.setCe(Event.MOUSEDOWN, d_x);
417        }
418};
419IM_dd.setMovHdl = function(d_x)
420{
421        if(document.onmousemove != d_x)
422        {
423                IM_dd.moveFunc = document.onmousemove;
424                document.onmousemove = d_x;
425                if(IM_dd.ce) IM_dd.setCe(Event.MOUSEMOVE, d_x);
426        }
427};
428IM_dd.setUpHdl = function(d_x)
429{
430        if(document.onmouseup != d_x)
431        {
432                IM_dd.upFunc = document.onmouseup;
433                document.onmouseup = d_x;
434                if(IM_dd.ce) IM_dd.setCe(Event.MOUSEUP, d_x);
435        }
436};
437IM_dd.evt = function(d_e)
438{
439        this.but = (this.e = d_e || window.event).which || this.e.button || 0;
440        this.button = (this.e.type == 'mousedown')? this.but
441                : (IM_dd.e && IM_dd.e.button)? IM_dd.e.button
442                : 0;
443        this.src = this.e.target || this.e.srcElement || null;
444        this.src.tag = ("" + (this.src.tagName || this.src)).toLowerCase();
445        this.x = IM_dd.Int(this.e.pageX || this.e.clientX || 0);
446        this.y = IM_dd.Int(this.e.pageY || this.e.clientY || 0);
447        if(IM_dd.ie)
448        {
449                this.x += IM_dd.getScrollX() - (IM_dd.ie && !IM_dd.iemac)*1;
450                this.y += IM_dd.getScrollY() - (IM_dd.ie && !IM_dd.iemac)*1;
451        }
452        this.modifKey = this.e.modifiers? this.e.modifiers&Event.SHIFT_MASK : (this.e.shiftKey || false);
453};
454IM_dd.getEventTarget = function(d_e, d_s, d_n)
455{
456        d_e = d_e || window.event;
457        if(d_e && (d_s = d_e.target || d_e.srcElement || null) != null)
458        {
459                if(null != (d_n = d_s.id || d_s.name || null))
460                {
461                        if(d_n.indexOf("dIi15vNI1m6G") == d_n.length-12)
462                                return IM_dd.elements[d_n.substring(0, d_n.length-12)] || null;
463                        if(d_n.indexOf("dIi15v") == d_n.length-6)
464                                return IM_dd.elements[d_n.substring(0, d_n.length-6)] || null;
465                        return IM_dd.elements[d_n] || null;
466                }
467        }
468        return null;
469};
470IM_dd.recalc = function(d_x)
471{
472        var d_o, d_i = IM_dd.elements.length; while(d_i--)
473        {
474                if(!(d_o = IM_dd.elements[d_i]).is_image && d_o.div)
475                {
476                        IM_dd.getWH(d_o);
477                        if(d_o.div.pos_rel)
478                        {
479                                IM_dd.getPageXY(d_o.div);
480                                var d_dx = IM_dd.x - d_o.x, d_dy = IM_dd.y - d_o.y;
481                                d_o.defx += d_dx;
482                                d_o.x += d_dx;
483                                d_o.defy += d_dy;
484                                d_o.y += d_dy;
485                                var d_p, d_j = d_o.children.length; while(d_j--)
486                                {
487                                        if(!(d_p = d_o.children[d_j]).detached && (d_o != d_p.defparent || !(d_p.is_image && IM_dd.getImg(d_p, d_p.oimg.name, 1))))
488                                        {
489                                                d_p.defx += d_dx;
490                                                d_p.defy += d_dy;
491                                                d_p.moveBy(d_dx, d_dy);
492                                        }
493                                }
494                        }
495                }
496                else if(d_o.is_image && !IM_dd.n4)
497                {
498                        if(IM_dd.n6 && d_x && !d_o.defw) d_o.resizeTo(d_o.defw = IM_dd.getImgW(d_o.oimg), d_o.defh = IM_dd.getImgH(d_o.oimg));
499                        var d_defx = d_o.defx, d_defy = d_o.defy;
500                        if(!(d_o.parent && d_o.parent != d_o.defparent) && (d_x || !d_o.detached || d_o.horizontal || d_o.vertical) && IM_dd.getImg(d_o, d_o.oimg.name, 1))
501                                d_o.moveBy(d_o.defx-d_defx, d_o.defy-d_defy);
502                }
503        }
504};
505function IM_WINSZ(d_x)
506{
507        if(d_x)
508        {
509                if(IM_dd.n4)
510                {
511                        IM_dd.iW = innerWidth;
512                        IM_dd.iH = innerHeight;
513                }
514                window.onresize = new Function('IM_WINSZ();');
515        }
516        else if(IM_dd.n4 && (innerWidth != IM_dd.iW || innerHeight != IM_dd.iH)) location.reload();
517        else if(!IM_dd.n4) setTimeout('IM_dd.recalc()', 0xa);
518}
519IM_WINSZ(1);
520
521function IM_DDObj(d_o, d_i)
522{
523        this.id = d_o;
524        this.cmd = '';
525        this.cpy_n = IM_dd.getCmdVal(this, IM_COPY);
526        this.maxoffb = IM_dd.getCmdVal(this, IM_MAXOFFBOTTOM, 0, 1);
527        this.maxoffl = IM_dd.getCmdVal(this, IM_MAXOFFLEFT, 0, 1);
528        this.maxoffr = IM_dd.getCmdVal(this, IM_MAXOFFRIGHT, 0, 1);
529        this.maxofft = IM_dd.getCmdVal(this, IM_MAXOFFTOP, 0, 1);
530        var d_j = IM_dd_cursors.length; while(d_j--)
531                if(IM_dd.getCmd(this, IM_dd_cursors[d_j], 1)) this.cursor = IM_dd_cursors[d_j].substring(2);
532        this.clone = IM_dd.getCmd(this, IM_CLONE, 1);
533        this.detach = IM_dd.getCmd(this, IM_DETACH_CHILDREN);
534        this.scalable = IM_dd.getCmd(this, IM_SCALABLE, 1);
535        this.horizontal = IM_dd.getCmd(this, IM_HORIZONTAL);
536        this.noalt = IM_dd.getCmd(this, IM_NO_ALT, 1);
537        this.nodrag = IM_dd.getCmd(this, IM_NO_DRAG);
538        this.scroll = IM_dd.getCmd(this, IM_SCROLL, 1);
539        this.resizable = IM_dd.getCmd(this, IM_RESIZABLE, 1);
540        this.re_z = IM_dd.getCmd(this, IM_RESET_Z, 1);
541        this.diaphan = IM_dd.getCmd(this, IM_TRANSPARENT, 1);
542        this.vertical = IM_dd.getCmd(this, IM_VERTICAL);
543        this.maxw = IM_dd.getCmdVal(this, IM_MAXWIDTH, 1, 1);
544        this.minw = Math.abs(IM_dd.getCmdVal(this, IM_MINWIDTH, 1, 1));
545        this.maxh = IM_dd.getCmdVal(this, IM_MAXHEIGHT, 1, 1);
546        this.minh = Math.abs(IM_dd.getCmdVal(this, IM_MINHEIGHT, 1, 1));
547        this.pickFunc = this.dragFunc = this.resizeFunc = this.dropFunc = null;
548
549        this.name = this.id + (d_i || '');
550        this.oimg = IM_dd.getImg(this, this.id, 1);
551        this.is_image = !!this.oimg;
552        this.copies = new Array();
553        this.children = new Array();
554        this.parent = this.original = null;
555        if(this.oimg)
556        {
557                this.id = this.name + "dIi15v";
558                this.w = IM_dd.getImgW(this.oimg);
559                this.h = IM_dd.getImgH(this.oimg);
560                this.dw = this.dh = 0;
561                this.defz = IM_dd.Int(IM_dd.getCssProp(this.oimg, 'z-index','zIndex','zIndex')) || 1;
562                this.defsrc = this.src = this.oimg.src;
563                this.htm = '<img name="' + this.id + 'NI1m6G"'+
564                        ' src="' + this.oimg.src + '" '+
565                        'width="' + this.w + '" height="' + this.h + '">';
566                this.t_htm = '<div id="' + this.id +
567                        '" style="position:absolute;'+
568                        'left:' + (this.cssx = this.x = this.defx) + 'px;'+
569                        'top:' + (this.cssy = this.y = this.defy) + 'px;'+
570                        'width:' + this.w + 'px;'+
571                        'height:' + this.h + 'px;">'+
572                        this.htm + '</div>';
573        }
574        else
575        {
576                if(!!(this.div = IM_dd.getDiv(this.id)) && typeof this.div.style != IM_dd_u) this.css = this.div.style;
577                IM_dd.getWH(this);
578                if(this.div)
579                {
580                        this.div.ddObj = this;
581                        this.div.pos_rel = ("" + (this.div.parentNode? this.div.parentNode.tagName : this.div.parentElement? this.div.parentElement.tagName : '').toLowerCase().indexOf('body') < 0);
582                }
583                IM_dd.getPageXY(this.div);
584                this.defx = this.x = IM_dd.x;
585                this.defy = this.y = IM_dd.y;
586                IM_dd.getCssXY(this);
587                this.defz = IM_dd.Int(IM_dd.getCssProp(this.div, 'z-index','zIndex','zIndex'));
588        }
589        this.defw = this.w || 0;
590        this.defh = this.h || 0;
591}
592IM_DDObj.prototype.setPickFunc = function(d_x)
593{
594        this.pickFunc = d_x;
595};
596IM_DDObj.prototype.setDragFunc = function(d_x)
597{
598        this.dragFunc = d_x;
599};
600IM_DDObj.prototype.setResizeFunc = function(d_x)
601{
602        this.resizeFunc = d_x;
603};
604IM_DDObj.prototype.setDropFunc = function(d_x)
605{
606        this.dropFunc = d_x;
607};
608IM_DDObj.prototype.moveBy = function(d_x, d_y, d_kds, d_o)
609{
610        if(!this.div) return;
611        this.x += (d_x = IM_dd.Int(d_x));
612        this.y += (d_y = IM_dd.Int(d_y));
613        if(!d_kds || this.is_image || this.parent != this.defparent)
614        {
615                (d_o = this.css || this.div).left = (this.cssx += d_x) + IM_dd.px;
616                d_o.top = (this.cssy += d_y) + IM_dd.px;
617        }
618        var d_i = this.children.length; while(d_i--)
619        {
620                if(!(d_o = this.children[d_i]).detached) d_o.moveBy(d_x, d_y, 1);
621                d_o.defx += d_x;
622                d_o.defy += d_y;
623        }
624};
625IM_DDObj.prototype.moveTo = function(d_x, d_y)
626{
627        this.moveBy(IM_dd.Int(d_x)-this.x, IM_dd.Int(d_y)-this.y);
628};
629IM_DDObj.prototype.hide = function(d_m, d_o, d_p)
630{
631        if(this.div && this.visible)
632        {
633                d_p = this.css || this.div;
634                if(d_m && !IM_dd.n4)
635                {
636                        this.display = IM_dd.getCssProp(this.div, "display", "display", "display");
637                        if(this.oimg)
638                        {
639                                this.oimg.display = IM_dd.getCssProp(this.oimg, "display", "display", "display");
640                                this.oimg.style.display = "none";
641                        }
642                        d_p.display = "none";
643                        IM_dd.recalc();
644                }
645                else d_p.visibility = "hidden";
646        }
647        this.visible = false;
648        var d_i = this.children.length; while(d_i--)
649                if(!(d_o = this.children[d_i]).detached) d_o.hide(d_m);
650};
651IM_DDObj.prototype.show = function(d_o, d_p)
652{
653        if(this.div)
654        {
655                d_p = this.css || this.div;
656                if(d_p.display && d_p.display == "none")
657                {
658                        d_p.display = this.display || "block";
659                        if(this.oimg) this.oimg.style.display = this.oimg.display || "inline";
660                        IM_dd.recalc();
661                }
662                else d_p.visibility = "visible";
663        }
664        this.visible = true;
665        var d_i = this.children.length; while(d_i--)
666                if(!(d_o = this.children[d_i]).detached) d_o.show();
667};
668IM_DDObj.prototype.resizeTo = function(d_w, d_h, d_o)
669{
670        if(!this.div) return;
671        d_w = (this.w = IM_dd.Int(d_w))-this.dw;
672        d_h = (this.h = IM_dd.Int(d_h))-this.dh;
673        if(IM_dd.n4)
674        {
675                this.div.resizeTo(d_w, d_h);
676                if(this.is_image)
677                {
678                        this.write('<img src="' + this.src + '" width="' + d_w + '" height="' + d_h + '">');
679                        (this.nimg = this.div.document.images[0]).src = this.src;
680                }
681        }
682        else if(typeof this.css.pixelWidth != IM_dd_u)
683        {
684                this.css.pixelWidth = d_w;
685                this.css.pixelHeight = d_h;
686                if(this.is_image)
687                {
688                        (d_o = this.nimg.style).pixelWidth = d_w;
689                        d_o.pixelHeight = d_h;
690                }
691        }
692        else
693        {
694      /*
695       * by Rodrigo Souza
696       * acrescentado Math.abs para corrigir retorno
697       * negativo ou ainda NaN
698       */
699                this.css.width = Math.abs(d_w) + IM_dd.px;
700                this.css.height = Math.abs(d_h) + IM_dd.px;
701                if(this.is_image)
702                {
703                        (d_o = this.nimg).width = d_w;
704                        d_o.height = d_h;
705                        if(!d_o.complete) d_o.src = this.src;
706                }
707        }
708};
709IM_DDObj.prototype.resizeBy = function(d_dw, d_dh)
710{
711        this.resizeTo(this.w+IM_dd.Int(d_dw), this.h+IM_dd.Int(d_dh));
712};
713IM_DDObj.prototype.swapImage = function(d_x, d_cp)
714{
715        if(!this.nimg) return;
716        this.nimg.src = d_x;
717        this.src = this.nimg.src;
718        if(d_cp)
719        {
720                var d_i = this.copies.length; while(d_i--)
721                        this.copies[d_i].src = this.copies[d_i].nimg.src = this.nimg.src;
722        }
723};
724IM_DDObj.prototype.setBgColor = function(d_x)
725{
726        if(IM_dd.n4 && this.div) this.div.bgColor = d_x;
727        else if(this.css) this.css.background = d_x;
728        this.bgColor = d_x;
729};
730IM_DDObj.prototype.write = function(d_x, d_o)
731{
732        this.text = d_x;
733        if(!this.div) return;
734        if(IM_dd.n4)
735        {
736                (d_o = this.div.document).open();
737                d_o.write(d_x);
738                d_o.close();
739                IM_dd.getWH(this);
740        }
741        else
742        {
743                this.css.height = 'auto';
744                this.div.innerHTML = d_x;
745                if(!IM_dd.ie4) IM_dd.recalc();
746                if(IM_dd.ie4 || IM_dd.n6) setTimeout('IM_dd.recalc();', 0); // n6.0: recalc twice
747        }
748};
749IM_DDObj.prototype.copy = function(d_n, d_p, d_b)
750{
751        if(!this.oimg) return;
752        d_b = (IM_dd.ie && document.all.tags('body'))? document.all.tags('body')[0] : document.getElementsByTagName? (document.getElementsByTagName('body')[0] || IM_dd.db) : IM_dd.db;
753        d_n = d_n || 1;
754        while(d_n--)
755        {
756                var d_l = this.copies.length,
757                d_o = new IM_DDObj(this.name+this.cmd, d_l+1);
758                if(IM_dd.n4)
759                {
760                        d_o.id = (d_p = new Layer(d_o.w)).name;
761                        d_p.clip.height = d_o.h;
762                        d_p.visibility = 'show';
763                        (d_p = d_p.document).open();
764                        d_p.write(d_o.htm);
765                        d_p.close();
766                }
767                else if(d_b && d_b.insertAdjacentHTML) d_b.insertAdjacentHTML("AfterBegin", d_o.t_htm);
768                else if(document.createElement && d_b && d_b.appendChild)
769                {
770                        d_b.appendChild(d_p = document.createElement("dIi15v"));
771                        d_p.innerHTML = d_o.htm;
772                        d_p.id = d_o.id;
773                        d_p.style.position = 'absolute';
774                        d_p.style.width = d_o.w + 'px';
775                        d_p.style.height = d_o.h + 'px';
776                }
777                else if(d_b && d_b.innerHTML) d_b.innerHTML += d_o.t_htm;
778                d_o.defz = this.defz+1+d_l;
779                IM_dd.addProps(d_o);
780                d_o.original = this;
781                IM_dd.addElt(d_o, this);
782                if(this.parent)
783                {
784                        this.parent.addChild(d_o, this.detached);
785                        d_o.defparent = this.defparent;
786                }
787                d_o.moveTo(d_o.defx = this.defx, d_o.defy = this.defy);
788                if(IM_dd.n4) d_o.defsrc = d_o.src = this.defsrc;
789                d_o.swapImage(this.src);
790        }
791};
792IM_DDObj.prototype.addChild = function(d_kd, detach, defp)
793{
794        if(typeof d_kd != "object") d_kd = IM_dd.elements[d_kd];
795        if(d_kd.parent && d_kd.parent == this || d_kd == this || !d_kd.is_image && d_kd.defparent && !defp) return;
796
797        this.children[this.children.length] = this.children[d_kd.name] = d_kd;
798        d_kd.detached = detach || 0;
799        if(defp) d_kd.defparent = this;
800        else if(this == d_kd.defparent && d_kd.is_image) IM_dd.getImg(this, d_kd.oimg.name, 1);
801        if(!d_kd.defparent || this != d_kd.defparent)
802        {
803                d_kd.defx = d_kd.x;
804                d_kd.defy = d_kd.y;
805        }
806        if(!detach)
807        {
808                d_kd.defz = d_kd.defz+this.defz-(d_kd.parent? d_kd.parent.defz : 0)+(!d_kd.is_image*1);
809                d_kd.setZ(d_kd.z+this.z-(d_kd.parent? d_kd.parent.z : 0)+(!d_kd.is_image*1), 1);
810        }
811        if(d_kd.parent) d_kd.parent._removeChild(d_kd, 1);
812        d_kd.parent = this;
813};
814IM_DDObj.prototype._removeChild = function(d_kd, d_newp)
815{
816        if(typeof d_kd != "object") d_kd = this.children[d_kd];
817        var d_oc = this.children, d_nc = new Array();
818        for(var d_i = 0; d_i < d_oc.length; d_i++)
819                if(d_oc[d_i] != d_kd) d_nc[d_nc.length] = d_oc[d_i];
820        this.children = d_nc;
821        d_kd.parent = null;
822        if(!d_newp)
823        {
824                d_kd.detached = d_kd.defp = 0;
825                if(d_kd.is_image) IM_dd.getImg(d_kd, d_kd.oimg.name, 1);
826        }
827};
828IM_DDObj.prototype.attachChild = function(d_kd)
829{
830        (d_kd = (typeof d_kd != "object")? this.children[d_kd]: d_kd).detached = 0;
831        d_kd.setZ(d_kd.defz + this.z-this.defz, 1);
832};
833IM_DDObj.prototype.detachChild = function(d_kd)
834{
835        (d_kd = (typeof d_kd != "object")? this.children[d_kd]: d_kd).detached = 1;
836};
837IM_DDObj.prototype.setZ = function(d_x, d_kds, d_o)
838{
839        if(d_kds)
840        {
841                var d_dz = d_x-this.z,
842                d_i = this.children.length; while(d_i--)
843                        if(!(d_o = this.children[d_i]).detached) d_o.setZ(d_o.z+d_dz, 1);
844        }
845        IM_dd.z = Math.max(IM_dd.z, this.z = this.div? ((this.css || this.div).zIndex = d_x) : 0);
846};
847IM_DDObj.prototype.maximizeZ = function()
848{
849        this.setZ(IM_dd.z+1, 1);
850};
851IM_DDObj.prototype._resetZ = function(d_o)
852{
853        if(this.re_z || IM_dd.re_z)
854        {
855                this.setZ(this.defz);
856                var d_i = this.children.length; while(d_i--)
857                        if(!(d_o = this.children[d_i]).detached) d_o.setZ(d_o.defz);
858        }
859};
860IM_DDObj.prototype.setOpacity = function(d_x)
861{
862        this.opacity = d_x;
863        this._setOpaRel(1.0, 1);
864};
865IM_DDObj.prototype._setOpaRel = function(d_x, d_kd, d_y, d_o)
866{
867        if(this.css && (this.diaphan || d_kd))
868        {
869                d_y = this.opacity*d_x;
870                if(typeof this.css.MozOpacity != IM_dd_u) this.css.MozOpacity = d_y;
871                else if(typeof this.css.filter != IM_dd_u)
872                        this.css.filter = "Alpha(opacity="+parseInt(100*d_y)+")";
873                else this.css.opacity = d_y;
874                var d_i = this.children.length; while(d_i--)
875                        if(!(d_o = this.children[d_i]).detached) d_o._setOpaRel(d_x, 1);
876        }
877};
878IM_DDObj.prototype.setCursor = function(d_x)
879{
880        this._setCrs(this.cursor = (d_x.indexOf('c:')+1)? d_x.substring(2) : d_x);
881};
882IM_DDObj.prototype._setCrs = function(d_x)
883{
884        if(this.css) this.css.cursor = ((!IM_dd.ie || IM_dd.iemac) && d_x == 'hand')? 'pointer' : d_x;
885};
886IM_DDObj.prototype.setDraggable = function(d_x)
887{
888        this.nodrag = !d_x*1;
889        this._setCrs(d_x? this.cursor : 'auto');
890};
891IM_DDObj.prototype.setResizable = function(d_x)
892{
893        this.resizable = d_x*1;
894        if(d_x) this.scalable = 0;
895};
896IM_DDObj.prototype.setScalable = function(d_x)
897{
898        this.scalable = d_x*1;
899        if(d_x) this.resizable = 0;
900};
901IM_DDObj.prototype.getEltBelow = function(d_ret, d_x, d_y)
902{
903        var d_o, d_cmp = -1, d_i = IM_dd.elements.length; while(d_i--)
904        {
905                d_o = IM_dd.elements[d_i];
906                d_x = d_o.x-this.w/2;
907                d_y = d_o.y-this.h/2;
908                if(d_o.visible && d_o.z < this.z && this.x >= d_x && this.x <= d_x+d_o.w && this.y >= d_y && this.y <= d_y+d_o.h)
909                {
910                        if(d_o.z > d_cmp)
911                        {
912                                d_cmp = d_o.z;
913                                d_ret = d_o;
914                        }
915                }
916        }
917        return d_ret;
918};
919IM_DDObj.prototype.del = function(d_os, d_o)
920{
921        var d_i;
922        if(this.parent && this.parent._removeChild) this.parent._removeChild(this);
923        if(this.original)
924        {
925                this.hide();
926                if(this.original.copies)
927                {
928                        d_os = new Array();
929                        for(d_i = 0; d_i < this.original.copies.length; d_i++)
930                                if((d_o = this.original.copies[d_i]) != this) d_os[d_o.name] = d_os[d_os.length] = d_o;
931                        this.original.copies = d_os;
932                }
933        }
934        else if(this.is_image)
935        {
936                this.hide();
937                if(this.oimg)
938                {
939                  if(IM_dd.n4) this.oimg.src = this.defsrc;
940                  else this.oimg.style.visibility = 'visible';
941                }
942        }
943        else if(this.moveTo)
944        {
945                if(this.css) this.css.cursor = 'default';
946                this.moveTo(this.defx, this.defy);
947                this.resizeTo(this.defw, this.defh);
948        }
949        d_os = new Array();
950        for(d_i = 0; d_i < IM_dd.elements.length; d_i++)
951        {
952                if((d_o = IM_dd.elements[d_i]) != this) d_os[d_o.name] = d_os[d_o.index = d_os.length] = d_o;
953                else d_o._free();
954        }
955        IM_dd.elements = d_os;
956        if(!IM_dd.n4) IM_dd.recalc();
957};
958IM_DDObj.prototype._free = function()
959{
960        for(var d_i in this)
961                this[d_i] = null;
962        IM_dd.elements[this.name] = null;
963};
964IM_dd.n4RectVis = function(vis)
965{
966        for(var d_i = 4; d_i--;)
967        {
968                IM_dd.rectI[d_i].visibility = IM_dd.rectA[d_i].visibility = vis? 'show' : 'hide';
969                if(vis) IM_dd.rectI[d_i].zIndex = IM_dd.rectA[d_i].zIndex = IM_dd.z+2;
970        }
971};
972IM_dd.n4RectPos = function(d_o, d_x, d_y, d_w, d_h)
973{
974        d_o.x = d_x;
975        d_o.y = d_y;
976        d_o.clip.width = d_w;
977        d_o.clip.height = d_h;
978};
979// NN4: Draw img sizing rect
980IM_dd.n4Rect = function(d_w, d_h)
981{
982        var d_i;
983        if(!IM_dd.rectI)
984        {
985                IM_dd.rectI = new Array();
986                IM_dd.rectA = new Array();
987        }
988        if(!IM_dd.rectI[0])
989        {
990                for(d_i = 4; d_i--;)
991                {
992                        (IM_dd.rectI[d_i] = new Layer(1)).bgColor = '#000000';
993                        (IM_dd.rectA[d_i] = new Layer(1)).bgColor = '#ffffff';
994                }
995        }
996        if(!IM_dd.rectI[0].visibility || IM_dd.rectI[0].visibility == 'hide') IM_dd.n4RectVis(1);
997        IM_dd.obj.w = d_w;
998        IM_dd.obj.h = d_h;
999        for(d_i = 4; d_i--;)
1000        {
1001                IM_dd.n4RectPos(IM_dd.rectI[d_i], IM_dd.obj.x + (!(d_i-1)? (IM_dd.obj.w-1) : 0), IM_dd.obj.y + (!(d_i-2)? (IM_dd.obj.h-1) : 0), d_i&1 || IM_dd.obj.w, !(d_i&1) || IM_dd.obj.h);
1002                IM_dd.n4RectPos(IM_dd.rectA[d_i], !(d_i-1)? IM_dd.rectI[1].x+1 : (IM_dd.obj.x-1), !(d_i-2)? IM_dd.rectI[2].y+1 : (IM_dd.obj.y-1), d_i&1 || IM_dd.obj.w+2, !(d_i&1) || IM_dd.obj.h+2);
1003        }
1004};
1005IM_dd.reszTo = function(d_w, d_h)
1006{
1007        if(IM_dd.n4 && IM_dd.obj.is_image) IM_dd.n4Rect(d_w, d_h);
1008        else IM_dd.obj.resizeTo(d_w, d_h);
1009};
1010IM_dd.embedVis = function(d_vis)
1011{
1012        var d_o = new Array('iframe', 'applet', 'embed', 'object');
1013        var d_i = d_o.length; while(d_i--)
1014        {
1015                var d_p = IM_dd.ie? document.all.tags(d_o[d_i]) : document.getElementsByTagName? document.getElementsByTagName(d_o[d_i]) : null;
1016                if(d_p)
1017                {
1018                        var d_j = d_p.length; while(d_j--)
1019                        {
1020                                var d_q = d_p[d_j];
1021                                while(d_q.offsetParent || d_q.parentNode)
1022                                {
1023                                        if((d_q = d_q.parentNode || d_q.offsetParent || null) == IM_dd.obj.div)
1024                                        {
1025                                                d_p[d_j].style.visibility = d_vis;
1026                                                break;
1027                                        }
1028                                }
1029                        }
1030                }
1031        }
1032};
1033IM_dd.maxOffX = function(d_x, d_y)
1034{
1035        return(
1036                (IM_dd.obj.maxoffl+1 && (d_y = IM_dd.obj.defx-IM_dd.obj.maxoffl)-d_x > 0
1037                || IM_dd.obj.maxoffr+1 && (d_y = IM_dd.obj.defx+IM_dd.obj.maxoffr)-d_x < 0)? d_y
1038                : d_x
1039        );
1040};
1041IM_dd.maxOffY = function(d_x, d_y)
1042{
1043        return(
1044                (IM_dd.obj.maxofft+1 && (d_y = IM_dd.obj.defy-IM_dd.obj.maxofft)-d_x > 0
1045                || IM_dd.obj.maxoffb+1 && (d_y = IM_dd.obj.defy+IM_dd.obj.maxoffb)-d_x < 0)? d_y
1046                : d_x
1047        );
1048};
1049IM_dd.inWndW = function(d_x, d_y)
1050{
1051        var d_wx = IM_dd.getScrollX(),
1052        d_ww = IM_dd.getWndW();
1053        return(
1054                ((d_y = d_wx+2)-d_x > 0) || ((d_y = d_wx+d_ww+IM_dd.obj.w-2)-d_x < 0)? d_y
1055                : d_x
1056        );
1057};
1058IM_dd.inWndH = function(d_x, d_y)
1059{
1060        var d_wy = IM_dd.getScrollY(),
1061        d_wh = IM_dd.getWndH();
1062        return(
1063                ((d_y = d_wy+2)-d_x > 0) || ((d_y = d_wy+d_wh+IM_dd.obj.h-2)-d_x < 0)? d_y
1064                : d_x
1065        );
1066};
1067// These two funcs limit the size of element when mouseresized.
1068// Implemented 22.5.2003 by Gregor Ltolf, modified by Walter Zorn
1069IM_dd.limW = function(d_w)
1070{
1071        return(
1072                (IM_dd.obj.minw-d_w > 0)? IM_dd.obj.minw
1073                : (IM_dd.obj.maxw > 0 && IM_dd.obj.maxw-d_w < 0)? IM_dd.obj.maxw
1074                : d_w
1075        );
1076};
1077IM_dd.limH = function(d_h)
1078{
1079        return(
1080                (IM_dd.obj.minh-d_h > 0)? IM_dd.obj.minh
1081                : (IM_dd.obj.maxh > 0 && IM_dd.obj.maxh-d_h < 0)? IM_dd.obj.maxh
1082                : d_h
1083        );
1084};
1085// Optional autoscroll-page functionality. Courtesy Cedric Savarese.
1086// Modified by Walter Zorn.
1087function IM_DDScroll()
1088{
1089        if(!IM_dd.obj || !IM_dd.obj.scroll && !IM_dd.scroll || IM_dd.ie4 || IM_dd.whratio)
1090        {
1091                IM_dd.scrx = IM_dd.scry = 0;
1092                return;
1093        }
1094        var d_bnd = 0x1c,
1095        d_wx = IM_dd.getScrollX(), d_wy = IM_dd.getScrollY();
1096        if(IM_dd.msmoved)
1097        {
1098                var d_ww = IM_dd.getWndW(), d_wh = IM_dd.getWndH(), d_y;
1099                IM_dd.scrx = ((d_y = IM_dd.e.x-d_ww-d_wx+d_bnd) > 0)? (d_y>>=2)*d_y
1100                        : ((d_y = d_wx+d_bnd-IM_dd.e.x) > 0)? -(d_y>>=2)*d_y
1101                        : 0;
1102                IM_dd.scry = ((d_y = IM_dd.e.y-d_wh-d_wy+d_bnd) > 0)? (d_y>>=2)*d_y
1103                        : ((d_y = d_wy+d_bnd-IM_dd.e.y) > 0)? -(d_y>>=2)*d_y
1104                        : 0;
1105        }
1106        if(IM_dd.scrx || IM_dd.scry)
1107        {
1108                window.scrollTo(
1109                        d_wx + (IM_dd.scrx = IM_dd.obj.is_resized? IM_dd.limW(IM_dd.obj.w+IM_dd.scrx)-IM_dd.obj.w : IM_dd.obj.vertical? 0 : (IM_dd.maxOffX(IM_dd.obj.x+IM_dd.scrx)-IM_dd.obj.x)),
1110                        d_wy + (IM_dd.scry = IM_dd.obj.is_resized? IM_dd.limH(IM_dd.obj.h+IM_dd.scry)-IM_dd.obj.h : IM_dd.obj.horizontal? 0 : (IM_dd.maxOffY(IM_dd.obj.y+IM_dd.scry)-IM_dd.obj.y))
1111                );
1112                IM_dd.obj.is_dragged? IM_dd.obj.moveTo(IM_dd.obj.x+IM_dd.getScrollX()-d_wx, IM_dd.obj.y+IM_dd.getScrollY()-d_wy)
1113                        : IM_dd.reszTo(IM_dd.obj.w+IM_dd.getScrollX()-d_wx, IM_dd.obj.h+IM_dd.getScrollY()-d_wy);
1114        }
1115        IM_dd.msmoved = 0;
1116        window.setTimeout('IM_DDScroll()', 0x33);
1117}
1118function IM_PICK(d_ev)
1119{
1120        IM_dd.e = new IM_dd.evt(d_ev);
1121        if(IM_dd.e.x >= IM_dd.getWndW()+IM_dd.getScrollX() || IM_dd.e.y >= IM_dd.getWndH()+IM_dd.getScrollY()) return true; // on scrollbar
1122        var d_o, d_t, d_cmp = -1, d_i = IM_dd.elements.length; while(d_i--)
1123        {
1124                d_o = IM_dd.elements[d_i];
1125                if(IM_dd.n4 && IM_dd.e.but > 1 && IM_dd.e.src == d_o.oimg && !d_o.clone) return false;
1126                if(d_o.visible && IM_dd.e.but <= 1 && IM_dd.e.x >= d_o.x && IM_dd.e.x <= d_o.x+d_o.w && IM_dd.e.y >= d_o.y && IM_dd.e.y <= d_o.y+d_o.h)
1127                {
1128                        if(d_o.z > d_cmp && (d_t = IM_dd.e.src.tag).indexOf('inpu') < 0 && d_t.indexOf('texta') < 0 && d_t.indexOf('sele') < 0 && d_t.indexOf('opti') < 0 && d_t.indexOf('scrol') < 0)
1129                        {
1130                                d_cmp = d_o.z;
1131                                IM_dd.obj = d_o;
1132                        }
1133                }
1134        }
1135        if(IM_dd.obj)
1136        {
1137                if(IM_dd.obj.nodrag) IM_dd.obj = null;
1138                else
1139                {
1140                        IM_dd.e.e.cancelBubble = true;
1141                        var d_rsz = IM_dd.e.modifKey && (IM_dd.obj.resizable || IM_dd.obj.scalable);
1142                        if(IM_dd.op)
1143                        {
1144                                (d_o = document.getElementById('OpBlUr')).style.pixelLeft = IM_dd.e.x;
1145                                d_o.style.pixelTop = IM_dd.e.y;
1146                                (d_o = d_o.children[0].children[0]).focus();
1147                                d_o.blur();
1148                        }
1149                        else if(IM_dd.ie && !IM_dd.ie4)
1150                        {
1151                                if(document.selection && document.selection.empty) document.selection.empty();
1152                                IM_dd.db.onselectstart = function()
1153                                {
1154                                        event.returnValue = false;
1155                                };
1156                        }
1157                        if(d_rsz)
1158                        {
1159                                IM_dd.obj._setCrs('se-resize');
1160                                IM_dd.obj.is_resized = 1;
1161                                IM_dd.whratio = IM_dd.obj.scalable? IM_dd.obj.defw/IM_dd.obj.defh : 0;
1162                                if(IM_dd.ie)
1163                                {
1164                                        if(IM_dd.ie4)
1165                                        {
1166                                                window.IM_dd_x = IM_dd.getScrollX();
1167                                                window.IM_dd_y = IM_dd.getScrollY();
1168                                        }
1169                                        setTimeout(
1170                                                'if(IM_dd.obj && document.selection && document.selection.empty)'+
1171                                                '{'+
1172                                                        'document.selection.empty();'+
1173                                                        'if(IM_dd.ie4) window.scrollTo(window.IM_dd_x, window.IM_dd_y);'+
1174                                                '}'
1175                                        ,0);
1176                                }
1177                                IM_dd.setMovHdl(IM_RESIZE);
1178                                IM_dd.reszTo(IM_dd.obj.w, IM_dd.obj.h);
1179                        }
1180                        else
1181                        {
1182                                IM_dd.obj.is_dragged = 1;
1183                                IM_dd.setMovHdl(IM_DRAG);
1184                        }
1185                        IM_dd.setUpHdl(IM_DROP);
1186                        IM_dd.embedVis('hidden');
1187                        IM_dd.obj._setOpaRel(0.7);
1188                        IM_dd.obj.maximizeZ();
1189                        IM_dd.ofx = IM_dd.obj.x+IM_dd.obj.w-IM_dd.e.x;
1190                        IM_dd.ofy = IM_dd.obj.y+IM_dd.obj.h-IM_dd.e.y;
1191                        if(window.IM_my_PickFunc) IM_my_PickFunc();
1192                        if(IM_dd.obj.pickFunc) IM_dd.obj.pickFunc();
1193                        IM_DDScroll();
1194                        return !(
1195                                IM_dd.obj.is_resized
1196                                || IM_dd.n4 && IM_dd.obj.is_image
1197                                || IM_dd.n6 || IM_dd.w3c
1198                        );
1199                }
1200        }
1201        if(IM_dd.downFunc) return IM_dd.downFunc(d_ev);
1202        return true;
1203}
1204function IM_DRAG(d_ev)
1205{
1206        if(!IM_dd.obj || !IM_dd.obj.visible) return true;
1207        if(IM_dd.ie4 || IM_dd.w3c || IM_dd.n6 || IM_dd.obj.children.length > 0xf)
1208        {
1209                if(IM_dd.wait) return false;
1210                IM_dd.wait = 1;
1211                setTimeout('IM_dd.wait = 0;', IM_dd.tiv);
1212        }
1213        IM_dd.e = new IM_dd.evt(d_ev);
1214        if(IM_dd.ie && !IM_dd.e.but)
1215        {
1216                IM_DROP(d_ev);
1217                return true;
1218        }
1219        IM_dd.msmoved = 1;
1220        IM_dd.obj.moveTo(
1221                IM_dd.obj.vertical? IM_dd.obj.x : IM_dd.maxOffX(IM_dd.inWndW(IM_dd.ofx+IM_dd.e.x)-IM_dd.obj.w),
1222                IM_dd.obj.horizontal? IM_dd.obj.y : IM_dd.maxOffY(IM_dd.inWndH(IM_dd.ofy+IM_dd.e.y)-IM_dd.obj.h)
1223        );
1224
1225        if(window.IM_my_DragFunc) IM_my_DragFunc();
1226        if(IM_dd.obj.dragFunc) IM_dd.obj.dragFunc();
1227        if(IM_dd.moveFunc) return IM_dd.moveFunc(d_ev);
1228        return false;
1229}
1230function IM_RESIZE(d_ev)
1231{
1232        if(!IM_dd.obj || !IM_dd.obj.visible) return true;
1233        if(IM_dd.wait) return false;
1234        IM_dd.wait = 1;
1235        setTimeout('IM_dd.wait = 0;', IM_dd.tiv);
1236        IM_dd.e = new IM_dd.evt(d_ev);
1237        if(IM_dd.ie && !IM_dd.e.but)
1238        {
1239                IM_DROP(d_ev);
1240                return true;
1241        }
1242        IM_dd.msmoved = 1;
1243        var d_w = IM_dd.limW(IM_dd.inWndW(IM_dd.ofx+IM_dd.e.x)-IM_dd.obj.x), d_h;
1244        if(!IM_dd.whratio) d_h = IM_dd.limH(IM_dd.inWndH(IM_dd.ofy+IM_dd.e.y)-IM_dd.obj.y);
1245        else
1246        {
1247                d_h = IM_dd.limH(IM_dd.inWndH(Math.round(d_w/IM_dd.whratio)+IM_dd.obj.y)-IM_dd.obj.y);
1248                d_w = Math.round(d_h*IM_dd.whratio);
1249        }
1250        IM_dd.reszTo(d_w, d_h);
1251        if(window.IM_my_ResizeFunc) IM_my_ResizeFunc();
1252        if(IM_dd.obj.resizeFunc) IM_dd.obj.resizeFunc();
1253        if(IM_dd.moveFunc) return IM_dd.moveFunc(d_ev);
1254        return false;
1255}
1256function IM_DROP(d_ev)
1257{
1258        if(IM_dd.obj)
1259        {
1260                if(IM_dd.obj.is_dragged)
1261                {
1262                        if(!IM_dd.obj.is_image) IM_dd.getWH(IM_dd.obj);
1263                }
1264                else if(IM_dd.n4)
1265                {
1266                        if(IM_dd.obj.is_image)
1267                        {
1268                                IM_dd.n4RectVis(0);
1269                                IM_dd.obj.resizeTo(IM_dd.obj.w, IM_dd.obj.h);
1270                        }
1271                }
1272                if(!IM_dd.n4 || !IM_dd.obj.is_image) IM_dd.recalc();
1273                IM_dd.setMovHdl(IM_dd.moveFunc);
1274                IM_dd.setUpHdl(IM_dd.upFunc);
1275                if(IM_dd.db) IM_dd.db.onselectstart = null;
1276                IM_dd.obj._setOpaRel(1.0);
1277                IM_dd.obj._setCrs(IM_dd.obj.cursor);
1278                IM_dd.embedVis('visible');
1279                IM_dd.obj._resetZ();
1280                IM_dd.e = new IM_dd.evt(d_ev);
1281                if(window.IM_my_DropFunc) IM_my_DropFunc();
1282                if(IM_dd.obj.dropFunc) IM_dd.obj.dropFunc();
1283                IM_dd.msmoved = IM_dd.obj.is_dragged = IM_dd.obj.is_resized = IM_dd.whratio = 0;
1284                IM_dd.obj = null;
1285        }
1286        IM_dd.setDwnHdl(IM_PICK);
1287}
1288function IM_SET_DHTML()
1289{
1290        var d_a = arguments, d_ai, d_htm = '', d_o, d_i = d_a.length;
1291   while(d_i--)
1292        {
1293                if(!(d_ai = d_a[d_i]).indexOf('c:')) IM_dd.cursor = d_ai.substring(2);
1294                else if(d_ai == IM_NO_ALT) IM_dd.noalt = 1;
1295                else if(d_ai == IM_SCROLL) IM_dd.scroll = 1;
1296                else if(d_ai == IM_RESET_Z) IM_dd.re_z = 1;
1297                else if(d_ai == IM_RESIZABLE) IM_dd.resizable = 1;
1298                else if(d_ai == IM_SCALABLE) IM_dd.scalable = 1;
1299                else if(d_ai == IM_TRANSPARENT) IM_dd.diaphan = 1;
1300                else
1301                {
1302                        d_o = new IM_DDObj(d_ai);
1303                        IM_dd.addElt(d_o);
1304                        d_htm += d_o.t_htm || '';
1305                        if(d_o.oimg && d_o.cpy_n)
1306                        {
1307                                var d_j = 0; while(d_j < d_o.cpy_n)
1308                                {
1309                                        var d_p = new IM_DDObj(d_o.name+d_o.cmd, ++d_j);
1310                                        IM_dd.addElt(d_p, d_o);
1311                                        d_p.defz = d_o.defz+d_j;
1312                                        d_p.original = d_o;
1313                                        d_htm += d_p.t_htm;
1314                                }
1315                        }
1316                }
1317        }
1318        if (IM_dd.n4 || IM_dd.n6 || IM_dd.ie || IM_dd.op || IM_dd.w3c) document.write(
1319                (IM_dd.n4? '<div style="position:absolute;"><\/div>\n'
1320                : (IM_dd.op && !IM_dd.op6)? '<div id="OpBlUr" style="position:absolute;visibility:hidden;width:0px;height:0px;"><form><input type="text" style="width:0px;height:0px;"><\/form><\/div>'
1321                : '') + d_htm
1322        );
1323        IM_dd.z = 0x33;
1324        d_i = IM_dd.elements.length; while(d_i--)
1325        {
1326                IM_dd.addProps(d_o = IM_dd.elements[d_i]);
1327                if(d_o.is_image && !d_o.original && !d_o.clone)
1328                        IM_dd.n4? d_o.oimg.src = IM_spacer : d_o.oimg.style.visibility = 'hidden';
1329        }
1330        IM_dd.mkWzDom();
1331        if(window.onload) IM_dd.loadFunc = window.onload;
1332        if(window.onunload) IM_dd.uloadFunc = window.onunload;
1333        window.onload = IM_dd.initz;
1334        window.onunload = IM_dd.finlz;
1335        IM_dd.setDwnHdl(IM_PICK);
1336}
1337function IM_ADD_DHTML(d_o) // layers only!
1338{
1339        d_o = new IM_DDObj(d_o);
1340        IM_dd.addElt(d_o);
1341        IM_dd.addProps(d_o);
1342        IM_dd.mkWzDom();
1343}
1344
1345
1346
1347
1348////////////////////////////////////////////////////////////
1349// If not needed, all code below this line may be removed
1350
1351
1352// For backward compatibility
1353IM_dd.d = document;                     // < v. 2.72
1354var RESET_ZINDEX = IM_RESET_Z; // < 3.44
1355var KEYDOWN_RESIZE = IM_RESIZABLE; // < 4.43
1356var CURSOR_POINTER = IM_CURSOR_HAND; // < 4.44
1357var NO_SCROLL = '';              // < v. 4.49
1358
1359
1360
1361////////////////////////////////////////////////////////////
1362// FUNCTIONS FOR EXTENDED SCRIPTING
1363// Use these for your own extensions,
1364// or to call functions defined elsewhere
1365
1366
1367
1368/* my_PickFunc IS AUTOMATICALLY CALLED WHEN AN ITEM STARTS TO BE DRAGGED.
1369The following objects/properties are accessible from here:
1370
1371- dd.e: current mouse event
1372- dd.e.property: access to a property of the current mouse event.
1373  Mostly requested properties:
1374  - dd.e.x: document-related x co-ordinate
1375  - dd.e.y: document-related y co-ord
1376  - dd.e.src: target of mouse event (not identical with the drag drop object itself).
1377  - dd.e.button: currently pressed mouse button. Left button: dd.e.button <= 1
1378
1379- dd.obj: reference to currently dragged item.
1380- dd.obj.property: access to any property of that item.
1381- dd.obj.method(): for example dd.obj.resizeTo() or dd.obj.swapImage() .
1382  Mostly requested properties:
1383        - dd.obj.name: image name or layer ID passed to SET_DHTML();
1384        - dd.obj.x and dd.obj.y: co-ordinates;
1385        - dd.obj.w and dd.obj.h: size;
1386        - dd.obj.is_dragged: 1 while item is dragged, else 0;
1387        - dd.obj.is_resized: 1 while item is resized, i.e. if <ctrl> or <shift> is pressed, else 0
1388
1389For more properties and details, visit the API documentation
1390at http://www.walterzorn.com/dragdrop/api_e.htm (english) or
1391http://www.walterzorn.de/dragdrop/api.htm (german)      */
1392function IM_my_PickFunc()
1393{
1394}
1395
1396
1397
1398
1399/* my_DragFunc IS CALLED WHILE AN ITEM IS DRAGGED
1400See the description of my_PickFunc above for what's accessible from here. */
1401function IM_my_DragFunc()
1402{
1403        //window.status = 'dd.elements.' + dd.obj.name + '.x  = ' + dd.obj.x + '         dd.elements.' + dd.obj.name + '.y = ' + dd.obj.y;
1404}
1405
1406
1407
1408
1409/* my_ResizeFunc IS CALLED WHILE AN ITEM IS RESIZED
1410See the description of my_PickFunc above for what's accessible from here. */
1411function IM_my_ResizeFunc()
1412{
1413        //window.status = 'dd.elements.' + dd.obj.name + '.w  = ' + dd.obj.w + '         dd.elements.' + dd.obj.name + '.h = ' + dd.obj.h;
1414}
1415
1416
1417
1418
1419/* THIS ONE IS CALLED ONCE AN ITEM IS DROPPED
1420See the description of my_PickFunc for what's accessible from here.
1421Here may be investigated, for example, what's the name (dd.obj.name)
1422of the dropped item, and where (dd.obj.x, dd.obj.y) it has been dropped... */
1423function IM_my_DropFunc()
1424{
1425}
Note: See TracBrowser for help on using the repository browser.