Subversion Repositories wimsdev

Rev

Rev 70 | Details | Compare with Previous | Last modification | View Log | RSS feed

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