Project

General

Profile

1
/* This notice must be untouched at all times, and must not be removed.
2

    
3
wz_dragdrop.js	v. 4.91
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) Walter Zorn. All rights reserved.
10
Created 26. 8. 2002 by Walter Zorn (Web: http://www.walterzorn.com )
11
Last modified: 10.10.2008
12

    
13
This DHTML & Drag&Drop Library adds Drag&Drop functionality to:
14
- images, even those not positioned via layers,
15
  nor via stylesheets or any other kind of "hard-coding";
16
- relatively and absolutely positioned layers (DIV elements).
17
Moreover, it provides extended DHTML capabilities.
18

    
19
LICENSE: LGPL
20

    
21
This library is free software; you can redistribute it and/or
22
modify it under the terms of the GNU Lesser General Public
23
License (LGPL) as published by the Free Software Foundation; either
24
version 2.1 of the License, or (at your option) any later version.
25

    
26
This library is distributed in the hope that it will be useful,
27
but WITHOUT ANY WARRANTY; without even the implied warranty of
28
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
29

    
30
For more details on the GNU Lesser General Public License,
31
see http://www.gnu.org/copyleft/lesser.html
32
*/
33

    
34

    
35
// PATH TO THE TRANSPARENT 1*1 PX IMAGE (required by NS 4 as spacer)
36
var spacer = 'transparentpixel.gif';
37

    
38

    
39

    
40

    
41
//window.onerror = new Function('return true;');
42

    
43

    
44
// Optional commands passed to SET_DHTML() on the html-page (g: may be applied globally, i: individually)
45
var CLONE            = 'C10nE';   // i  img      clone image
46
var COPY            = 'C0pY';    // i  img      create copies
47
var DETACH_CHILDREN = 'd37aCH';  // i  lyr      detach images
48
var HORIZONTAL        = 'H0r1Z';   // i  img,lyr  horizontally draggable only
49
var MAXHEIGHT        = 'm7x8I';   // i  img,lyr  maximum height limit, "
50
var MAXOFFBOTTOM    = 'm7xd0wN'; // i  img,lyr  downward offset limit
51
var MAXOFFLEFT        = 'm7x23Ft'; // i  img,lyr  leftward offset limit
52
var MAXOFFRIGHT        = 'm7x0Ff8'; // i  img,lyr  rightward offset limit
53
var MAXOFFTOP        = 'm7xu9';   // i  img,lyr  upward offset limit
54
var MAXWIDTH        = 'm7xW1';   // i  img,lyr  maximum width limit, use with resizable or scalable
55
var MINWIDTH        = 'm1nw1';   // i  img,lyr  minimum width limit, "
56
var MINHEIGHT        = 'm1n8I';   // i  img,lyr  minimum height limit, "
57
var NO_ALT            = 'no81T';   // gi img      disable alt and title attributes
58
var NO_DRAG            = 'N0d4Ag';  // i  img,lyr  disable draggability
59
var RESET_Z            = 'r35E7z';  // gi img,lyr  reset z-index when dropped
60
var RESIZABLE        = 'r5IZbl';  // gi img,lyr  resizable if <ctrl> or <shift> pressed
61
var SCALABLE        = 'SCLbl';   // gi img,lyr  scalable           "
62
var SCROLL            = 'sC8lL';   // gi img,lyr  enable auto scroll functionality
63
var TRANSPARENT        = 'dIApHAn'; // gi img,lyr  translucent while dragged
64
var VERTICAL        = 'V3Rt1C';  // i  img,lyr  vertically draggable only
65
var dd_cursors = new Array(
66
	'c:default',
67
	'c:crosshair',
68
	'c:e-resize',
69
	'c:hand',
70
	'c:help',
71
	'c:move',
72
	'c:n-resize',
73
	'c:ne-resize',
74
	'c:nw-resize',
75
	'c:s-resize',
76
	'c:se-resize',
77
	'c:sw-resize',
78
	'c:text',
79
	'c:w-resize',
80
	'c:wait'
81
);
82
for(var dd_i = dd_cursors.length; dd_i;)
83
{--dd_i;
84
	eval('var CURSOR_' + (dd_cursors[dd_i].substring(2).toUpperCase().replace('-', '_')) + ' = "' + dd_cursors[dd_i] + '";');
85
}
86
var dd_u = "undefined";
87
function 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 != dd_u);
102
	this.n6 = !!(typeof window.getComputedStyle != dd_u && typeof document.createRange != dd_u);
103
	this.w3c = !!(!this.op && !this.ie && !this.n6 && document.getElementById);
104
	this.ce = !!(document.captureEvents && document.releaseEvents && !this.n6);
105
	this.px = this.n4? '' : 'px';
106
	this.tWait = this.w3c? 40 : 10;
107
	this.noRecalc = false;
108
}
109
var dd = new WZDD();
110

    
111
dd.Int = function(d_x, d_y)
112
{
113
	return isNaN(d_y = parseInt(d_x))? 0 : d_y;
114
};
115
dd.getWndW = function()
116
{
117
	return dd.Int(
118
		(dd.db && !dd.op && !dd.w3c && dd.db.clientWidth)? dd.db.clientWidth
119
		: (window.innerWidth || 0)
120
	);
121
};
122
dd.getWndH = function()
123
{
124
	return dd.Int(
125
		(dd.db && !dd.op && !dd.w3c && dd.db.clientHeight)? dd.db.clientHeight
126
		: (window.innerHeight || 0)
127
	);
128
};
129
dd.getScrollX = function()
130
{
131
	return dd.Int(window.pageXOffset || (dd.db? dd.db.scrollLeft : 0));
132
};
133
dd.getScrollY = function()
134
{
135
	return dd.Int(window.pageYOffset || (dd.db? dd.db.scrollTop : 0));
136
};
137
dd.getPageXY = function(d_o)
138
{
139
	if(dd.n4 && d_o)
140
	{
141
		dd.x = d_o.pageX || 0;
142
		dd.y = d_o.pageY || 0;
143
	}
144
	else
145
	{
146
		dd.x = dd.y = 0; //global helper vars
147
		while(d_o)
148
		{
149
			dd.x += dd.Int(d_o.offsetLeft);
150
			dd.y += dd.Int(d_o.offsetTop);
151
			d_o = d_o.offsetParent || null;
152
		}
153
	}
154
};
155
dd.getCssXY = function(d_o)
156
{
157
	if(d_o.div)
158
	{
159
		if(dd.n4)
160
		{
161
			d_o.cssx = d_o.div.x;
162
			d_o.cssy = d_o.div.y;
163
		}
164
		else if(dd.ie4)
165
		{
166
			d_o.cssx = d_o.css.pixelLeft;
167
			d_o.cssy = d_o.css.pixelTop;
168
		}
169
		else
170
		{
171
			d_o.css.left = d_o.css.top = 0 + dd.px;
172
			dd.getPageXY(d_o.div);
173
			d_o.cssx = d_o.x - dd.x;
174
			d_o.cssy = d_o.y - dd.y;
175
			d_o.css.left = d_o.cssx + dd.px;
176
			d_o.css.top = d_o.cssy + dd.px;
177
		}
178
	}
179
	else
180
	{
181
		d_o.cssx = 0;
182
		d_o.cssy = 0;
183
	}
184
};
185
dd.getImgW = function(d_o)
186
{
187
	return d_o? dd.Int(d_o.width) : 0;
188
};
189
dd.getImgH = function(d_o)
190
{
191
	return d_o? dd.Int(d_o.height) : 0;
192
};
193
dd.getDivW = function(d_o)
194
{
195
	return dd.Int(
196
		dd.n4? (d_o.div? d_o.div.clip.width : 0)
197
		: d_o.div? (d_o.div.offsetWidth || d_o.css.pixelWidth || d_o.css.width || 0)
198
		: 0
199
	);
200
};
201
dd.getDivH = function(d_o)
202
{
203
	return dd.Int(
204
		dd.n4? (d_o.div? d_o.div.clip.height : 0)
205
		: d_o.div? (d_o.div.offsetHeight || d_o.css.pixelHeight || d_o.css.height || 0)
206
		: 0
207
	);
208
};
209
dd.getWH = function(d_o)
210
{
211
	d_o.w = dd.getDivW(d_o);
212
	d_o.h = dd.getDivH(d_o);
213
	if(d_o.css)
214
	{
215
		d_o.css.width = d_o.w + dd.px;
216
		d_o.css.height = d_o.h + dd.px;
217
		d_o.dw = dd.getDivW(d_o)-d_o.w;
218
		d_o.dh = dd.getDivH(d_o)-d_o.h;
219
		d_o.css.width = (d_o.w-d_o.dw) + dd.px;
220
		d_o.css.height = (d_o.h-d_o.dh) + dd.px;
221
	}
222
	else d_o.dw = d_o.dh = 0;
223
};
224
dd.getCssProp = function(d_o, d_pn6, d_pstyle, d_pn4)
225
{
226
	if(d_o && dd.n6) return ''+window.getComputedStyle(d_o, null).getPropertyValue(d_pn6);
227
	if(d_o && d_o.currentStyle) return ''+eval('d_o.currentStyle.'+d_pstyle);
228
	if(d_o && d_o.style) return ''+eval('d_o.style.'+d_pstyle);
229
	if(d_o && dd.n4) return ''+eval('d_o.'+d_pn4);
230
	return '';
231
};
232
dd.getDiv = function(d_x, d_d)
233
{
234
	d_d = d_d || document;
235
	if(dd.n4)
236
	{
237
		if(d_d.layers[d_x]) return d_d.layers[d_x];
238
		for(var d_i = d_d.layers.length; d_i;)
239
		{
240
			var d_y = dd.getDiv(d_x, d_d.layers[--d_i].document);
241
			if(d_y) return d_y;
242
		}
243
	}
244
	if(dd.ie) return d_d.all[d_x] || null;
245
	if(d_d.getElementById) return d_d.getElementById(d_x) || null;
246
	return null;
247
};
248
dd.getImg = function(d_o, d_nm, d_xy, d_w)
249
{
250
	d_w = d_w || window;
251
	var d_img;
252
	if(document.images && (d_img = d_w.document.images[d_nm]))
253
	{
254
		if(d_xy)
255
		{
256
			if(dd.n4)
257
			{
258
				dd.getPageXY(d_w);
259
				d_o.defx = d_img.x + dd.x;
260
				d_o.defy = d_img.y + dd.y;
261
			}
262
			else
263
			{
264
				dd.getPageXY(d_img);
265
				d_o.defx = dd.x;
266
				d_o.defy = dd.y;
267
			}
268
		}
269
		return d_img;
270
	}
271
	if(dd.n4) for(var d_i = d_w.document.layers.length; d_i;)
272
	{
273
		var d_y = dd.getImg(d_o, d_nm, d_xy, d_w.document.layers[--d_i]);
274
		if(d_y) return d_y;
275
	}
276
	return null;
277
};
278
dd.getParent = function(d_o, d_p)
279
{
280
	if(dd.n4)
281
	{
282
		for(var d_i = dd.elements.length; d_i;)
283
		{
284
			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]))
285
				d_p.addChild(d_o, d_p.detach, 1);
286
		}
287
	}
288
	else
289
	{
290
		d_p = d_o.is_image? dd.getImg(d_o, d_o.oimg.name) : (d_o.div || null);
291
		while(d_p && !!(d_p = d_p.offsetParent || d_p.parentNode || null))
292
		{
293
			if(d_p.ddObj)
294
			{
295
				d_p.ddObj.addChild(d_o, d_p.ddObj.detach, 1);
296
				break;
297
			}
298
		}
299
	}
300
};
301
dd.getCmd = function(d_o, d_cmd, d_cmdStr)
302
{
303
	var d_i = d_o.id.indexOf(d_cmd), d_j,
304
	d_y = (d_i >= 0)*1;
305
	if(d_y)
306
	{
307
		d_j = d_i+d_cmd.length;
308
		if(d_cmdStr) d_o.cmd += d_o.id.substring(d_i, d_j);
309
		d_o.id = d_o.id.substring(0, d_i) + d_o.id.substring(d_j);
310
	}
311
	return d_y;
312
};
313
dd.getCmdVal = function(d_o, d_cmd, d_cmdStr, int0)
314
{
315
	var d_i = d_o.id.indexOf(d_cmd), d_j,
316
	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;
317
	if(!int0 && d_y || int0 && d_y >= 0)
318
	{
319
		d_j = d_i+d_cmd.length+(""+d_y).length;
320
		if(d_cmdStr) d_o.cmd += d_o.id.substring(d_i, d_j);
321
		d_o.id = d_o.id.substring(0, d_i) + d_o.id.substring(d_j);
322
	}
323
	return d_y;
324
};
325
dd.addElt = function(d_o, d_p)
326
{
327
	dd.elements[d_o.name] = dd.elements[d_o.index = dd.elements.length] = d_o;
328
	if(d_p) d_p.copies[d_o.name] = d_p.copies[d_p.copies.length] = d_o;
329
};
330
dd.mkWzDom = function()
331
{
332
	var d_o, d_l = dd.elements.length, d_i;
333
	for(d_i = d_l; d_i;) dd.getParent(dd.elements[--d_i]);
334
	for(d_i = d_l; d_i;)
335
	{
336
		if((d_o = dd.elements[--d_i]).children && !d_o.parent)
337
		{
338
			for(var d_j = d_o.children.length; d_j;)
339
			{--d_j;
340
				d_o.children[d_j].setZ(d_o.z+d_o.children[d_j].z, 1);
341
			}
342
		}
343
	}
344
};
345
dd.addProps = function(d_o)
346
{
347
	if(d_o.is_image)
348
	{
349
		d_o.div = dd.getDiv(d_o.id);
350
		d_o.css = (d_o.div && typeof d_o.div.style != dd_u)? d_o.div.style : null;
351
		d_o.nimg = (dd.n4 && d_o.div)? d_o.div.document.images[0] : (document.images[d_o.id+"NI1m6G"] || null);
352
		if(!d_o.noalt && !dd.noalt && d_o.nimg && d_o.oimg)
353
		{
354
			d_o.nimg.alt = d_o.oimg.alt || '';
355
			d_o.nimg.title = d_o.oimg.title;
356
			d_o.nimg.onmouseover = d_o.oimg.onmouseover;
357
			d_o.nimg.onmouseout = d_o.oimg.onmouseout;
358
		}
359
		d_o.bgColor = '';
360
	}
361
	else
362
	{
363
		d_o.bgColor = dd.getCssProp(d_o.div, 'background-color','backgroundColor','bgColor').toLowerCase();
364
		if(dd.n6 && d_o.div)
365
		{
366
			var d_c = d_o.bgColor.toLowerCase();
367
			if(d_c.indexOf('rgb') >= 0)
368
			{
369
				d_c = d_c.substring(4, d_c.length-1).split(',');
370
				d_o.bgColor = '#';
371
				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);
372
			}
373
			else d_o.bgColor = d_c;
374
		}
375
	}
376
	if(dd.scalable) d_o.scalable = d_o.resizable^1;
377
	else if(dd.resizable) d_o.resizable = d_o.scalable^1;
378
	d_o.setZ(d_o.defz);
379
	d_o.cursor = d_o.cursor || dd.cursor || 'auto';
380
	d_o._setCrs(d_o.nodrag? 'auto' : d_o.cursor);
381
	d_o.diaphan = d_o.diaphan || dd.diaphan || 0;
382
	d_o.opacity = 1.0;
383
	d_o.visible = true;
384
};
385
dd.initz = function()
386
{
387
	if(!(dd && (dd.n4 || dd.n6 || dd.ie || dd.op || dd.w3c))) return;
388
	else if(dd.n6 || dd.ie || dd.op || dd.w3c) dd.recalc(1);
389
	var d_drag = (document.onmousemove == DRAG),
390
	d_resize = (document.onmousemove == RESIZE);
391
	if(dd.loadFunc) dd.loadFunc();
392
	if(d_drag) dd.setMovHdl(DRAG);
393
	else if(d_resize) dd.setMovHdl(RESIZE);
394
	if(d_drag || d_resize) dd.setUpHdl(DROP);
395
	dd.setDwnHdl(PICK);
396
};
397
dd.finlz = function()
398
{
399
	if(dd.ie && dd.elements)
400
	{
401
		dd.noRecalc = true;
402
		for(var d_i = dd.elements.length; d_i;)
403
			dd.elements[--d_i].del();
404
		dd.noRecalc = false;
405
	}
406
	if(dd.uloadFunc) dd.uloadFunc();
407
};
408
dd.setCe = function(d_e, d_fnc)
409
{
410
	d_fnc? document.captureEvents(d_e) : document.releaseEvents(d_e);
411
};
412
dd.setDwnHdl = function(d_x)
413
{
414
	if(document.onmousedown != d_x)
415
	{
416
		dd.downFunc = document.onmousedown;
417
		document.onmousedown = d_x;
418
		if(dd.ce) dd.setCe(Event.MOUSEDOWN, d_x);
419
	}
420
};
421
dd.setMovHdl = function(d_x)
422
{
423
	if(document.onmousemove != d_x)
424
	{
425
		dd.moveFunc = document.onmousemove;
426
		document.onmousemove = d_x;
427
		if(dd.ce) dd.setCe(Event.MOUSEMOVE, d_x);
428
	}
429
};
430
dd.setUpHdl = function(d_x)
431
{
432
	if(document.onmouseup != d_x)
433
	{
434
		dd.upFunc = document.onmouseup;
435
		document.onmouseup = d_x;
436
		if(dd.ce) dd.setCe(Event.MOUSEUP, d_x);
437
	}
438
};
439
dd.evt = function(d_e)
440
{
441
	this.but = (this.e = d_e || window.event).which || this.e.button || 0;
442
	this.button = (this.e.type == 'mousedown')? this.but
443
		: (dd.e && dd.e.button)? dd.e.button
444
		: 0;
445
	this.src = this.e.target || this.e.srcElement || null;
446
	this.src.tag = ("" + (this.src.tagName || this.src)).toLowerCase();
447
	this.x = dd.Int(this.e.pageX || this.e.clientX || 0);
448
	this.y = dd.Int(this.e.pageY || this.e.clientY || 0);
449
	if(dd.ie)
450
	{
451
		this.x += dd.getScrollX() - (dd.ie && !dd.iemac)*1;
452
		this.y += dd.getScrollY() - (dd.ie && !dd.iemac)*1;
453
	}
454
	this.modifKey = this.e.modifiers? this.e.modifiers&Event.SHIFT_MASK : (this.e.shiftKey || false);
455
};
456
dd.getEventTarget = function(d_e, d_s, d_n)
457
{
458
	d_e = d_e || window.event;
459
	if(d_e && (d_s = d_e.target || d_e.srcElement || null) != null)
460
	{
461
		if(null != (d_n = d_s.id || d_s.name || null))
462
		{
463
			if(d_n.indexOf("dIi15vNI1m6G") == d_n.length-12)
464
				return dd.elements[d_n.substring(0, d_n.length-12)] || null;
465
			if(d_n.indexOf("dIi15v") == d_n.length-6)
466
				return dd.elements[d_n.substring(0, d_n.length-6)] || null;
467
			return dd.elements[d_n] || null;
468
		}
469
	}
470
	return null;
471
};
472
dd.recalc = function(d_x)
473
{
474
	if(dd.noRecalc) return;
475
	for(var d_o, d_i = dd.elements.length; d_i;)
476
	{
477
		if(!(d_o = dd.elements[--d_i]).is_image && d_o.div)
478
		{
479
			dd.getWH(d_o);
480
			if(d_o.div.pos_rel)
481
			{
482
				dd.getPageXY(d_o.div);
483
				var d_dx = dd.x - d_o.x, d_dy = dd.y - d_o.y;
484
				d_o.defx += d_dx;
485
				d_o.x += d_dx;
486
				d_o.defy += d_dy;
487
				d_o.y += d_dy;
488
				for(var d_p, d_j = d_o.children.length; d_j;)
489
				{
490
					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))))
491
					{
492
						d_p.defx += d_dx;
493
						d_p.defy += d_dy;
494
						d_p.moveBy(d_dx, d_dy);
495
					}
496
				}
497
			}
498
		}
499
		else if(d_o.is_image && !dd.n4)
500
		{
501
			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));
502
			var d_defx = d_o.defx, d_defy = d_o.defy;
503
			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))
504
				d_o.moveBy(d_o.defx-d_defx, d_o.defy-d_defy);
505
		}
506
	}
507
};
508
function WINSZ(d_x)
509
{
510
	if(d_x)
511
	{
512
		if(dd.n4)
513
		{
514
			dd.iW = innerWidth;
515
			dd.iH = innerHeight;
516
		}
517
		window.onresize = new Function('WINSZ();');
518
	}
519
	else if(dd.n4 && (innerWidth != dd.iW || innerHeight != dd.iH)) location.reload();
520
	else if(!dd.n4) setTimeout('dd.recalc()', 0xa);
521
}
522
WINSZ(1);
523

    
524
function DDObj(d_o, d_i)
525
{
526
	this.id = d_o;
527
	this.cmd = '';
528
	this.cpy_n = dd.getCmdVal(this, COPY);
529
	this.maxoffb = dd.getCmdVal(this, MAXOFFBOTTOM, 0, 1);
530
	this.maxoffl = dd.getCmdVal(this, MAXOFFLEFT, 0, 1);
531
	this.maxoffr = dd.getCmdVal(this, MAXOFFRIGHT, 0, 1);
532
	this.maxofft = dd.getCmdVal(this, MAXOFFTOP, 0, 1);
533
	var d_j = dd_cursors.length; while(d_j--)
534
		if(dd.getCmd(this, dd_cursors[d_j], 1)) this.cursor = dd_cursors[d_j].substring(2);
535
	this.clone = dd.getCmd(this, CLONE, 1);
536
	this.detach = dd.getCmd(this, DETACH_CHILDREN);
537
	this.scalable = dd.getCmd(this, SCALABLE, 1);
538
	this.horizontal = dd.getCmd(this, HORIZONTAL);
539
	this.noalt = dd.getCmd(this, NO_ALT, 1);
540
	this.nodrag = dd.getCmd(this, NO_DRAG);
541
	this.scroll = dd.getCmd(this, SCROLL, 1);
542
	this.resizable = dd.getCmd(this, RESIZABLE, 1);
543
	this.re_z = dd.getCmd(this, RESET_Z, 1);
544
	this.diaphan = dd.getCmd(this, TRANSPARENT, 1);
545
	this.vertical = dd.getCmd(this, VERTICAL);
546
	this.maxw = dd.getCmdVal(this, MAXWIDTH, 1, 1);
547
	this.minw = Math.abs(dd.getCmdVal(this, MINWIDTH, 1, 1));
548
	this.maxh = dd.getCmdVal(this, MAXHEIGHT, 1, 1);
549
	this.minh = Math.abs(dd.getCmdVal(this, MINHEIGHT, 1, 1));
550
	this.pickFunc = this.dragFunc = this.resizeFunc = this.dropFunc = null;
551

    
552
	this.name = this.id + (d_i || '');
553
	this.oimg = dd.getImg(this, this.id, 1);
554
	this.is_image = !!this.oimg;
555
	this.copies = new Array();
556
	this.children = new Array();
557
	this.parent = this.original = null;
558
	if(this.oimg)
559
	{
560
		this.id = this.name + "dIi15v";
561
		this.w = dd.getImgW(this.oimg);
562
		this.h = dd.getImgH(this.oimg);
563
		this.dw = this.dh = 0;
564
		this.defz = dd.Int(dd.getCssProp(this.oimg, 'z-index','zIndex','zIndex')) || 1;
565
		this.defsrc = this.src = this.oimg.src;
566
		this.htm = '<img name="' + this.id + 'NI1m6G"'+
567
			' src="' + this.oimg.src + '" '+
568
			'width="' + this.w + '" height="' + this.h + '">';
569
		this.t_htm = '<div id="' + this.id +
570
			'" style="position:absolute;'+
571
			'left:' + (this.cssx = this.x = this.defx) + 'px;'+
572
			'top:' + (this.cssy = this.y = this.defy) + 'px;'+
573
			'width:' + this.w + 'px;'+
574
			'height:' + this.h + 'px;">'+
575
			this.htm + '</div>';
576
	}
577
	else
578
	{
579
		if(!!(this.div = dd.getDiv(this.id)) && typeof this.div.style != dd_u) this.css = this.div.style;
580
		dd.getWH(this);
581
		if(this.div)
582
		{
583
			this.div.ddObj = this;
584
			this.div.pos_rel = dd.getCssProp(this.div, 'position','position','position') == "relative";
585
		}
586
		dd.getPageXY(this.div);
587
		this.defx = this.x = dd.x;
588
		this.defy = this.y = dd.y;
589
		dd.getCssXY(this);
590
		this.defz = dd.Int(dd.getCssProp(this.div, 'z-index','zIndex','zIndex'));
591
	}
592
	this.defw = this.w || 0;
593
	this.defh = this.h || 0;
594
}
595
DDObj.prototype.setPickFunc = function(d_x)
596
{
597
	this.pickFunc = d_x;
598
};
599
DDObj.prototype.setDragFunc = function(d_x)
600
{
601
	this.dragFunc = d_x;
602
};
603
DDObj.prototype.setResizeFunc = function(d_x)
604
{
605
	this.resizeFunc = d_x;
606
};
607
DDObj.prototype.setDropFunc = function(d_x)
608
{
609
	this.dropFunc = d_x;
610
};
611
DDObj.prototype.moveBy = function(d_x, d_y, d_kds, d_o)
612
{
613
	if(!this.div) return;
614
	this.x += (d_x = dd.Int(d_x));
615
	this.y += (d_y = dd.Int(d_y));
616
	if(!d_kds || this.is_image || this.parent != this.defparent)
617
	{
618
		(d_o = this.css || this.div).left = (this.cssx += d_x) + dd.px;
619
		d_o.top = (this.cssy += d_y) + dd.px;
620
	}
621
	for(var d_i = this.children.length; d_i;)
622
	{
623
		if(!(d_o = this.children[--d_i]).detached) d_o.moveBy(d_x, d_y, 1);
624
		d_o.defx += d_x;
625
		d_o.defy += d_y;
626
	}
627
};
628

    
629
DDObj.prototype.moveTo = function(d_x, d_y)
630
{
631
	this.moveBy(dd.Int(d_x)-this.x, dd.Int(d_y)-this.y);
632
};
633
DDObj.prototype.hide = function(d_m, d_o, d_p)
634
{
635
	if(this.div && this.visible)
636
	{
637
		d_p = this.css || this.div;
638
		if(d_m && !dd.n4)
639
		{
640
			this.display = dd.getCssProp(this.div, "display", "display", "display");
641
			if(this.oimg)
642
			{
643
				this.oimg.display = dd.getCssProp(this.oimg, "display", "display", "display");
644
				this.oimg.style.display = "none";
645
			}
646
			d_p.display = "none";
647
			dd.recalc();
648
		}
649
		else d_p.visibility = "hidden";
650
	}
651
	this.visible = false;
652
	for(var d_i = this.children.length; d_i;)
653
		if(!(d_o = this.children[--d_i]).detached) d_o.hide(d_m);
654
};
655
DDObj.prototype.show = function(d_o, d_p)
656
{
657
	if(this.div)
658
	{
659
		d_p = this.css || this.div;
660
		if(d_p.display && d_p.display == "none")
661
		{
662
			d_p.display = this.display || "block";
663
			if(this.oimg) this.oimg.style.display = this.oimg.display || "inline";
664
			dd.recalc();
665
		}
666
		else d_p.visibility = "visible";
667
	}
668
	this.visible = true;
669
	for(var d_i = this.children.length; d_i;)
670
		if(!(d_o = this.children[--d_i]).detached) d_o.show();
671
};
672
DDObj.prototype.resizeTo = function(d_w, d_h, d_o)
673
{
674
	if(!this.div) return;
675
	d_w = (this.w = dd.Int(d_w))-this.dw;
676
	d_h = (this.h = dd.Int(d_h))-this.dh;
677
	if(dd.n4)
678
	{
679
		this.div.resizeTo(d_w, d_h);
680
		if(this.is_image)
681
		{
682
			this.write('<img src="' + this.src + '" width="' + d_w + '" height="' + d_h + '">');
683
			(this.nimg = this.div.document.images[0]).src = this.src;
684
		}
685
	}
686
	else if(typeof this.css.pixelWidth != dd_u)
687
	{
688
		this.css.pixelWidth = d_w;
689
		this.css.pixelHeight = d_h;
690
		if(this.is_image)
691
		{
692
			(d_o = this.nimg.style).pixelWidth = d_w;
693
			d_o.pixelHeight = d_h;
694
		}
695
	}
696
	else
697
	{
698
		this.css.width = d_w + dd.px;
699
		this.css.height = d_h + dd.px;
700
		if(this.is_image)
701
		{
702
			(d_o = this.nimg).width = d_w;
703
			d_o.height = d_h;
704
			if(!d_o.complete) d_o.src = this.src;
705
		}
706
	}
707
};
708
DDObj.prototype.resizeBy = function(d_dw, d_dh)
709
{
710
	this.resizeTo(this.w+dd.Int(d_dw), this.h+dd.Int(d_dh));
711
};
712
DDObj.prototype.swapImage = function(d_x, d_cp)
713
{
714
	if(!this.nimg) return;
715
	this.nimg.src = d_x;
716
	this.src = this.nimg.src;
717
	if(d_cp)
718
	{
719
		for(var d_i = this.copies.length; d_i;)
720
		{--d_i;
721
			this.copies[d_i].src = this.copies[d_i].nimg.src = this.nimg.src;
722
		}
723
	}
724
};
725
DDObj.prototype.setBgColor = function(d_x)
726
{
727
	if(dd.n4 && this.div) this.div.bgColor = d_x;
728
	else if(this.css) this.css.background = d_x;
729
	this.bgColor = d_x;
730
};
731
DDObj.prototype.write = function(d_x, d_o)
732
{
733
	this.text = d_x;
734
	if(!this.div) return;
735
	if(dd.n4)
736
	{
737
		(d_o = this.div.document).open();
738
		d_o.write(d_x);
739
		d_o.close();
740
		dd.getWH(this);
741
	}
742
	else
743
	{
744
		this.css.height = 'auto';
745
		this.div.innerHTML = d_x;
746
		if(!dd.ie4) dd.recalc();
747
		if(dd.ie4 || dd.n6) setTimeout('dd.recalc();', 0); // n6.0: recalc twice
748
	}
749
};
750
DDObj.prototype.copy = function(d_n, d_p, d_b)
751
{
752
	if(!this.oimg) return;
753
	d_b = (dd.ie && document.all.tags('body'))? document.all.tags('body')[0] : document.getElementsByTagName? (document.getElementsByTagName('body')[0] || dd.db) : dd.db;
754
	for(d_n = d_n || 1; d_n > 0; --d_n)
755
	{
756
		var d_l = this.copies.length,
757
		d_o = new DDObj(this.name+this.cmd, d_l+1);
758
		if(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
		dd.addProps(d_o);
780
		d_o.original = this;
781
		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(dd.n4) d_o.defsrc = d_o.src = this.defsrc;
789
		d_o.swapImage(this.src);
790
	}
791
};
792
DDObj.prototype.addChild = function(d_kd, detach, defp)
793
{
794
	if(typeof d_kd != "object") d_kd = 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) 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
};
814
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) dd.getImg(d_kd, d_kd.oimg.name, 1);
826
	}
827
};
828
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
};
833
DDObj.prototype.detachChild = function(d_kd)
834
{
835
	(d_kd = (typeof d_kd != "object")? this.children[d_kd]: d_kd).detached = 1;
836
};
837
DDObj.prototype.setZ = function(d_x, d_kds, d_o)
838
{
839
	if(d_kds)
840
	{
841
		for(var d_dz = d_x-this.z, d_i = this.children.length; d_i;)
842
			if(!(d_o = this.children[--d_i]).detached) d_o.setZ(d_o.z+d_dz, 1);
843
	}
844
	dd.z = Math.max(dd.z, this.z = this.div? ((this.css || this.div).zIndex = d_x) : 0);
845
};
846
DDObj.prototype.maximizeZ = function()
847
{
848
	this.setZ(dd.z+1, 1);
849
};
850
DDObj.prototype._resetZ = function(d_o)
851
{
852
	if(this.re_z || dd.re_z)
853
	{
854
		this.setZ(this.defz);
855
		for(var d_i = this.children.length; d_i;)
856
			if(!(d_o = this.children[--d_i]).detached) d_o.setZ(d_o.defz);
857
	}
858
};
859
DDObj.prototype.setOpacity = function(d_x)
860
{
861
	this.opacity = d_x;
862
	this._setOpaRel(1.0, 1);
863
};
864
DDObj.prototype._setOpaRel = function(d_x, d_kd, d_y, d_o)
865
{
866
	if(this.css && (this.diaphan || d_kd))
867
	{
868
		d_y = this.opacity*d_x;
869
		if(typeof this.css.MozOpacity != dd_u) this.css.MozOpacity = d_y;
870
		else if (typeof this.css.opacity != dd_u) this.css.opacity = d_y;
871
		else if(typeof this.css.filter != dd_u)
872
			this.css.filter = "Alpha(opacity="+parseInt(100*d_y)+")";
873
		for(var d_i = this.children.length; d_i;)
874
			if(!(d_o = this.children[--d_i]).detached) d_o._setOpaRel(d_x, 1);
875
	}
876
};
877
DDObj.prototype.setCursor = function(d_x)
878
{
879
	this._setCrs(this.cursor = (d_x.indexOf('c:')+1)? d_x.substring(2) : d_x);
880
};
881
DDObj.prototype._setCrs = function(d_x)
882
{
883
	if(this.css) this.css.cursor = ((!dd.ie || dd.iemac) && d_x == 'hand')? 'pointer' : d_x;
884
};
885
DDObj.prototype.setDraggable = function(d_x)
886
{
887
	this.nodrag = !d_x*1;
888
	this._setCrs(d_x? this.cursor : 'auto');
889
};
890
DDObj.prototype.setResizable = function(d_x)
891
{
892
	this.resizable = d_x*1;
893
	if(d_x) this.scalable = 0;
894
};
895
DDObj.prototype.setScalable = function(d_x)
896
{
897
	this.scalable = d_x*1;
898
	if(d_x) this.resizable = 0;
899
};
900
DDObj.prototype.setHorizontal = function(d_x)
901
{
902
	this.horizontal = d_x*1;
903
};
904
DDObj.prototype.setVertical = function(d_x)
905
{
906
	this.vertical = d_x*1;
907
};
908
DDObj.prototype.getEltBelow = function(d_ret, d_x, d_y)
909
{
910
	var d_o, d_cmp = -1, d_i = dd.elements.length; while(d_i--)
911
	{
912
		d_o = dd.elements[d_i];
913
		d_x = d_o.x-this.w/2;
914
		d_y = d_o.y-this.h/2;
915
		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)
916
		{
917
			if(d_o.z > d_cmp)
918
			{
919
				d_cmp = d_o.z;
920
				d_ret = d_o;
921
			}
922
		}
923
	}
924
	return d_ret;
925
};
926
DDObj.prototype.del = function(d_os, d_o)
927
{
928
	var d_i, d_l;
929
	if(this.parent && this.parent.removeChild) this.parent.removeChild(this);
930
	if(this.original)
931
	{
932
		this.hide();
933
		if(this.original.copies)
934
		{
935
			d_os = new Array();
936
			for(d_l = this.original.copies.length, d_i = 0; d_i < d_l; d_i++)
937
				if((d_o = this.original.copies[d_i]) != this) d_os[d_o.name] = d_os[d_os.length] = d_o;
938
			this.original.copies = d_os;
939
		}
940
	}
941
	else if(this.is_image)
942
	{
943
		this.hide();
944
		if(this.oimg)
945
		{
946
		  if(dd.n4) this.oimg.src = this.defsrc;
947
		  else this.oimg.style.visibility = 'visible';
948
		}
949
	}
950
	else if(this.moveTo)
951
	{
952
		if(this.css) this.css.cursor = 'default';
953
		this.moveTo(this.defx, this.defy);
954
		this.resizeTo(this.defw, this.defh);
955
	}
956
	d_os = new Array();
957
	for(d_l = dd.elements.length, d_i = 0; d_i < d_l; d_i++)
958
	{
959
		if((d_o = dd.elements[d_i]) != this) d_os[d_o.name] = d_os[d_o.index = d_os.length] = d_o;
960
		else d_o._free();
961
	}
962
	dd.elements = d_os;
963
	if(!dd.n4) dd.recalc();
964
};
965
DDObj.prototype._free = function()
966
{
967
	for(var d_i in this)
968
		this[d_i] = null;
969
	dd.elements[this.name] = null;
970
};
971
dd.n4RectVis = function(vis)
972
{
973
	for(var d_i = 4; d_i;)
974
	{--d_i;
975
		dd.rectI[d_i].visibility = dd.rectA[d_i].visibility = vis? 'show' : 'hide';
976
		if(vis) dd.rectI[d_i].zIndex = dd.rectA[d_i].zIndex = dd.z+2;
977
	}
978
};
979
dd.n4RectPos = function(d_o, d_x, d_y, d_w, d_h)
980
{
981
	d_o.x = d_x;
982
	d_o.y = d_y;
983
	d_o.clip.width = d_w;
984
	d_o.clip.height = d_h;
985
};
986
// NN4: Draw img sizing rect
987
dd.n4Rect = function(d_w, d_h)
988
{
989
	var d_i;
990
	if(!dd.rectI)
991
	{
992
		dd.rectI = new Array();
993
		dd.rectA = new Array();
994
	}
995
	if(!dd.rectI[0])
996
	{
997
		for(d_i = 4; d_i;)
998
		{
999
			(dd.rectI[--d_i] = new Layer(1)).bgColor = '#000000';
1000
			(dd.rectA[d_i] = new Layer(1)).bgColor = '#ffffff';
1001
		}
1002
	}
1003
	if(!dd.rectI[0].visibility || dd.rectI[0].visibility == 'hide') dd.n4RectVis(1);
1004
	dd.obj.w = d_w;
1005
	dd.obj.h = d_h;
1006
	for(d_i = 4; d_i;)
1007
	{--d_i;
1008
		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);
1009
		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);
1010
	}
1011
};
1012
dd.reszTo = function(d_w, d_h)
1013
{
1014
	if(dd.n4 && dd.obj.is_image) dd.n4Rect(d_w, d_h);
1015
	else dd.obj.resizeTo(d_w, d_h);
1016
};
1017
dd.embedVis = function(d_vis)
1018
{
1019
	var d_o = new Array('iframe', 'applet', 'embed', 'object');
1020
	for(var d_i = d_o.length; d_i;)
1021
	{--d_i;
1022
		var d_p = dd.ie? document.all.tags(d_o[d_i]) : document.getElementsByTagName? document.getElementsByTagName(d_o[d_i]) : null;
1023
		if(d_p)
1024
		{
1025
			for(var d_j = d_p.length; d_j;)
1026
			{
1027
				var d_q = d_p[--d_j];
1028
				while(d_q.offsetParent || d_q.parentNode)
1029
				{
1030
					if((d_q = d_q.parentNode || d_q.offsetParent || null) == dd.obj.div)
1031
					{
1032
						d_p[d_j].style.visibility = d_vis;
1033
						break;
1034
					}
1035
				}
1036
			}
1037
		}
1038
	}
1039
};
1040

    
1041
dd.maxOffX = function(d_x, d_y)
1042
{
1043
	return(
1044
		(dd.obj.maxoffl+1 && (d_y = dd.obj.defx-dd.obj.maxoffl)-d_x > 0
1045
		|| dd.obj.maxoffr+1 && (d_y = dd.obj.defx+dd.obj.maxoffr)-d_x < 0)? d_y
1046
		: d_x
1047
	);
1048
};
1049
dd.maxOffY = function(d_x, d_y)
1050
{
1051
	return(
1052
		(dd.obj.maxofft+1 && (d_y = dd.obj.defy-dd.obj.maxofft)-d_x > 0
1053
		|| dd.obj.maxoffb+1 && (d_y = dd.obj.defy+dd.obj.maxoffb)-d_x < 0)? d_y
1054
		: d_x
1055
	);
1056
};
1057
dd.inWndW = function(d_x, d_y)
1058
{
1059
	var d_wx = dd.getScrollX(),
1060
	d_ww = dd.getWndW();
1061
	return(
1062
		((d_y = d_wx+2)-d_x > 0) || ((d_y = d_wx+d_ww+dd.obj.w-2)-d_x < 0)? d_y
1063
		: d_x
1064
	);
1065
};
1066
dd.inWndH = function(d_x, d_y)
1067
{
1068
	var d_wy = dd.getScrollY(),
1069
	d_wh = dd.getWndH();
1070
	return(
1071
		((d_y = d_wy+2)-d_x > 0) || ((d_y = d_wy+d_wh+dd.obj.h-2)-d_x < 0)? d_y
1072
		: d_x
1073
	);
1074
};
1075
// These two funcs limit the size of element when mouseresized.
1076
// Implemented 22.5.2003 by Gregor Ltolf, modified by Walter Zorn
1077
dd.limW = function(d_w)
1078
{
1079
	return(
1080
		(dd.obj.minw-d_w > 0)? dd.obj.minw
1081
		: (dd.obj.maxw > 0 && dd.obj.maxw-d_w < 0)? dd.obj.maxw
1082
		: d_w
1083
	);
1084
};
1085
dd.limH = function(d_h)
1086
{
1087
	return(
1088
		(dd.obj.minh-d_h > 0)? dd.obj.minh
1089
		: (dd.obj.maxh > 0 && dd.obj.maxh-d_h < 0)? dd.obj.maxh
1090
		: d_h
1091
	);
1092
};
1093
// Optional autoscroll-page functionality. Courtesy Cedric Savarese.
1094
// Modified by Walter Zorn.
1095
function DDScroll()
1096
{
1097
	if(!dd.obj || !dd.obj.scroll && !dd.scroll || dd.ie4 || dd.whratio)
1098
	{
1099
		dd.scrx = dd.scry = 0;
1100
		return;
1101
	}
1102
	var d_bnd = 0x1c,
1103
	d_wx = dd.getScrollX(), d_wy = dd.getScrollY();
1104
	if(dd.msmoved)
1105
	{
1106
		var d_ww = dd.getWndW(), d_wh = dd.getWndH(), d_y;
1107
		dd.scrx = ((d_y = dd.e.x-d_ww-d_wx+d_bnd) > 0)? (d_y>>=2)*d_y
1108
			: ((d_y = d_wx+d_bnd-dd.e.x) > 0)? -(d_y>>=2)*d_y
1109
			: 0;
1110
		dd.scry = ((d_y = dd.e.y-d_wh-d_wy+d_bnd) > 0)? (d_y>>=2)*d_y
1111
			: ((d_y = d_wy+d_bnd-dd.e.y) > 0)? -(d_y>>=2)*d_y
1112
			: 0;
1113
	}
1114
	if(dd.scrx || dd.scry)
1115
	{
1116
		window.scrollTo(
1117
			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)),
1118
			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))
1119
		);
1120
		dd.obj.is_dragged? dd.obj.moveTo(dd.obj.x+dd.getScrollX()-d_wx, dd.obj.y+dd.getScrollY()-d_wy)
1121
			: dd.reszTo(dd.obj.w+dd.getScrollX()-d_wx, dd.obj.h+dd.getScrollY()-d_wy);
1122
	}
1123
	dd.msmoved = 0;
1124
	window.setTimeout('DDScroll()', 0x33);
1125
}
1126
function PICK(d_ev)
1127
{
1128
	dd.e = new dd.evt(d_ev);
1129
	if(dd.e.x >= dd.getWndW()+dd.getScrollX() || dd.e.y >= dd.getWndH()+dd.getScrollY()) return true; // on scrollbar
1130
	for(var d_o, d_t, d_cmp = -1, d_i = dd.elements.length; d_i;)
1131
	{
1132
		d_o = dd.elements[--d_i];
1133
		if(dd.n4 && dd.e.but > 1 && dd.e.src == d_o.oimg && !d_o.clone) return false;
1134
		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)
1135
		{
1136
			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)
1137
			{
1138
				d_cmp = d_o.z;
1139
				dd.obj = d_o;
1140
			}
1141
		}
1142
	}
1143
	if(dd.obj)
1144
	{
1145
		if(dd.obj.nodrag) dd.obj = null;
1146
		else
1147
		{
1148
			dd.e.e.cancelBubble = true;
1149
			var d_rsz = dd.e.modifKey && (dd.obj.resizable || dd.obj.scalable);
1150
			if(dd.op)
1151
			{
1152
				(d_o = document.getElementById('OpBlUr')).style.pixelLeft = dd.e.x;
1153
				d_o.style.pixelTop = dd.e.y;
1154
				(d_o = d_o.children[0].children[0]).focus();
1155
				d_o.blur();
1156
			}
1157
			else if(dd.ie && !dd.ie4)
1158
			{
1159
				if(document.selection && document.selection.empty) document.selection.empty();
1160
				dd.db.onselectstart = function()
1161
				{
1162
					event.returnValue = false;
1163
				};
1164
			}
1165
			if(d_rsz)
1166
			{
1167
				dd.obj._setCrs('se-resize');
1168
				dd.obj.is_resized = 1;
1169
				dd.whratio = dd.obj.scalable? dd.obj.defw/dd.obj.defh : 0;
1170
				if(dd.ie)
1171
				{
1172
					if(dd.ie4)
1173
					{
1174
						window.dd_x = dd.getScrollX();
1175
						window.dd_y = dd.getScrollY();
1176
					}
1177
					setTimeout(
1178
						'if(dd.obj && document.selection && document.selection.empty)'+
1179
						'{'+
1180
							'document.selection.empty();'+
1181
							'if(dd.ie4) window.scrollTo(window.dd_x, window.dd_y);'+
1182
						'}'
1183
					,0);
1184
				}
1185
				dd.setMovHdl(RESIZE);
1186
				dd.reszTo(dd.obj.w, dd.obj.h);
1187
			}
1188
			else
1189
			{
1190
				dd.obj.is_dragged = 1;
1191
				dd.setMovHdl(DRAG);
1192
			}
1193
			dd.setUpHdl(DROP);
1194
			dd.embedVis('hidden');
1195
			dd.obj._setOpaRel(0.7);
1196
			dd.obj.maximizeZ();
1197
			dd.ofx = dd.obj.x+dd.obj.w-dd.e.x;
1198
			dd.ofy = dd.obj.y+dd.obj.h-dd.e.y;
1199
			if(window.my_PickFunc) my_PickFunc();
1200
			if(dd.obj.pickFunc) dd.obj.pickFunc();
1201
			DDScroll();
1202
			return !(
1203
				dd.obj.is_resized
1204
				|| dd.n4 && dd.obj.is_image
1205
				|| dd.n6 || dd.w3c
1206
			);
1207
		}
1208
	}
1209
	if(dd.downFunc) return dd.downFunc(d_ev);
1210
	return true;
1211
}
1212
function DRAG(d_ev)
1213
{
1214
	if(!dd.obj || !dd.obj.visible) return true;
1215
	if(dd.ie4 || dd.w3c || dd.n6 || dd.obj.children.length > 0xf)
1216
	{
1217
		if(dd.wait) return false;
1218
		dd.wait = 1;
1219
		setTimeout('dd.wait = 0;', dd.tWait);
1220
	}
1221
	dd.e = new dd.evt(d_ev);
1222
	if(dd.ie && !dd.e.but)
1223
	{
1224
		DROP(d_ev);
1225
		return true;
1226
	}
1227
	dd.msmoved = 1;
1228
	dd.obj.moveTo(
1229
		dd.obj.vertical? dd.obj.x : dd.maxOffX(dd.inWndW(dd.ofx+dd.e.x)-dd.obj.w),
1230
		dd.obj.horizontal? dd.obj.y : dd.maxOffY(dd.inWndH(dd.ofy+dd.e.y)-dd.obj.h)
1231
	);
1232

    
1233
	if(window.my_DragFunc) my_DragFunc();
1234
	if(dd.obj.dragFunc) dd.obj.dragFunc();
1235
	if(dd.moveFunc) return dd.moveFunc(d_ev);
1236
	return false;
1237
}
1238
function RESIZE(d_ev)
1239
{
1240
	if(!dd.obj || !dd.obj.visible) return true;
1241
	if(dd.wait) return false;
1242
	dd.wait = 1;
1243
	setTimeout('dd.wait = 0;', dd.tWait);
1244
	dd.e = new dd.evt(d_ev);
1245
	if(dd.ie && !dd.e.but)
1246
	{
1247
		DROP(d_ev);
1248
		return true;
1249
	}
1250
	dd.msmoved = 1;
1251
	var d_w = dd.limW(dd.inWndW(dd.ofx+dd.e.x)-dd.obj.x), d_h;
1252
	if(!dd.whratio) d_h = dd.limH(dd.inWndH(dd.ofy+dd.e.y)-dd.obj.y);
1253
	else
1254
	{
1255
		d_h = dd.limH(dd.inWndH(Math.round(d_w/dd.whratio)+dd.obj.y)-dd.obj.y);
1256
		d_w = Math.round(d_h*dd.whratio);
1257
	}
1258
	dd.reszTo(d_w, d_h);
1259
	if(window.my_ResizeFunc) my_ResizeFunc();
1260
	if(dd.obj.resizeFunc) dd.obj.resizeFunc();
1261
	if(dd.moveFunc) return dd.moveFunc(d_ev);
1262
	return false;
1263
}
1264
function DROP(d_ev)
1265
{
1266
	if(dd.obj)
1267
	{
1268
		if(dd.obj.is_dragged)
1269
		{
1270
			if(!dd.obj.is_image) dd.getWH(dd.obj);
1271
		}
1272
		else if(dd.n4)
1273
		{
1274
			if(dd.obj.is_image)
1275
			{
1276
				dd.n4RectVis(0);
1277
				dd.obj.resizeTo(dd.obj.w, dd.obj.h);
1278
			}
1279
		}
1280
		if(!dd.n4 || !dd.obj.is_image) dd.recalc();
1281
		dd.setMovHdl(dd.moveFunc);
1282
		dd.setUpHdl(dd.upFunc);
1283
		if(dd.db) dd.db.onselectstart = null;
1284
		dd.obj._setOpaRel(1.0);
1285
		dd.obj._setCrs(dd.obj.cursor);
1286
		dd.embedVis('visible');
1287
		dd.obj._resetZ();
1288
		dd.e = new dd.evt(d_ev);
1289
		if(window.my_DropFunc) my_DropFunc();
1290
		if(dd.obj.dropFunc) dd.obj.dropFunc();
1291
		dd.msmoved = dd.obj.is_dragged = dd.obj.is_resized = dd.whratio = 0;
1292
		dd.obj = null;
1293
	}
1294
	dd.setDwnHdl(PICK);
1295
}
1296
function SET_DHTML()
1297
{
1298
	var d_a = arguments, d_ai, d_htm = '', d_o, d_i = d_a.length;
1299
	while(d_i)
1300
	{
1301
		if(!(d_ai = d_a[--d_i]).indexOf('c:')) dd.cursor = d_ai.substring(2);
1302
		else if(d_ai == NO_ALT) dd.noalt = 1;
1303
		else if(d_ai == SCROLL) dd.scroll = 1;
1304
		else if(d_ai == RESET_Z) dd.re_z = 1;
1305
		else if(d_ai == RESIZABLE) dd.resizable = 1;
1306
		else if(d_ai == SCALABLE) dd.scalable = 1;
1307
		else if(d_ai == TRANSPARENT) dd.diaphan = 1;
1308
		else
1309
		{
1310
			d_o = new DDObj(d_ai);
1311
			dd.addElt(d_o);
1312
			d_htm += d_o.t_htm || '';
1313
			if(d_o.oimg && d_o.cpy_n)
1314
			{
1315
				for(var d_l = d_o.cpy_n, d_j = 0; d_j < d_l;)
1316
				{
1317
					var d_p = new DDObj(d_o.name+d_o.cmd, ++d_j);
1318
					dd.addElt(d_p, d_o);
1319
					d_p.defz = d_o.defz+d_j;
1320
					d_p.original = d_o;
1321
					d_htm += d_p.t_htm;
1322
				}
1323
			}
1324
		}
1325
	}
1326
	if (dd.n4 || dd.n6 || dd.ie || dd.op || dd.w3c) document.write(
1327
		(dd.n4? '<div style="position:absolute;"><\/div>\n'
1328
		: (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>'
1329
		: '') + d_htm
1330
	);
1331
	dd.z = 0x33;
1332
	for(d_i = dd.elements.length; d_i;)
1333
	{
1334
		dd.addProps(d_o = dd.elements[--d_i]);
1335
		if(d_o.is_image && !d_o.original && !d_o.clone)
1336
			dd.n4? d_o.oimg.src = spacer : d_o.oimg.style.visibility = 'hidden';
1337
	}
1338
	dd.mkWzDom();
1339
	if(window.onload) dd.loadFunc = window.onload;
1340
	if(window.onunload) dd.uloadFunc = window.onunload;
1341
	window.onload = dd.initz;
1342
	window.onunload = dd.finlz;
1343
	dd.setDwnHdl(PICK);
1344
}
1345
function ADD_DHTML() // layers only!
1346
{
1347
	var d_a = arguments, d_o, d_i = d_a.length; while(d_i)
1348
	{
1349
		d_o = new DDObj(d_a[--d_i]);
1350
		dd.addElt(d_o);
1351
		dd.addProps(d_o);
1352
	}
1353
	dd.mkWzDom();
1354
}
1355

    
1356

    
1357

    
1358

    
1359
////////////////////////////////////////////////////////////
1360
// If not needed, all code below this line may be removed
1361

    
1362

    
1363
// For backward compatibility
1364
dd.d = document;			// < v. 2.72
1365
var RESET_ZINDEX = RESET_Z; // < 3.44
1366
var KEYDOWN_RESIZE = RESIZABLE; // < 4.43
1367
var CURSOR_POINTER = CURSOR_HAND; // < 4.44
1368
var NO_SCROLL = '';		 // < v. 4.49
1369

    
1370

    
1371

    
1372

    
1373
////////////////////////////////////////////////////////////
1374
// FUNCTIONS FOR EXTENDED SCRIPTING
1375
// Use these for your own extensions,
1376
// or to call functions defined elsewhere
1377

    
1378

    
1379

    
1380
/* my_PickFunc IS AUTOMATICALLY CALLED WHEN AN ITEM STARTS TO BE DRAGGED.
1381
The following objects/properties are accessible from here:
1382

    
1383
- dd.e: current mouse event
1384
- dd.e.property: access to a property of the current mouse event.
1385
  Mostly requested properties:
1386
  - dd.e.x: document-related x co-ordinate
1387
  - dd.e.y: document-related y co-ord
1388
  - dd.e.src: target of mouse event (not identical with the drag drop object itself).
1389
  - dd.e.button: currently pressed mouse button. Left button: dd.e.button <= 1
1390

    
1391
- dd.obj: reference to currently dragged item.
1392
- dd.obj.property: access to any property of that item.
1393
- dd.obj.method(): for example dd.obj.resizeTo() or dd.obj.swapImage() .
1394
  Mostly requested properties:
1395
	- dd.obj.name: image name or layer ID passed to SET_DHTML();
1396
	- dd.obj.x and dd.obj.y: co-ordinates;
1397
	- dd.obj.w and dd.obj.h: size;
1398
	- dd.obj.is_dragged: 1 while item is dragged, else 0;
1399
	- dd.obj.is_resized: 1 while item is resized, i.e. if <ctrl> or <shift> is pressed, else 0
1400

    
1401
For more properties and details, visit the API documentation
1402
at http://www.walterzorn.com/dragdrop/api_e.htm (english) or
1403
http://www.walterzorn.de/dragdrop/api.htm (german)	*/
1404
function my_PickFunc()
1405
{
1406
}
1407

    
1408

    
1409

    
1410

    
1411
/* my_DragFunc IS CALLED WHILE AN ITEM IS DRAGGED
1412
See the description of my_PickFunc above for what's accessible from here. */
1413
function my_DragFunc()
1414
{
1415
	//window.status = 'dd.elements.' + dd.obj.name + '.x  = ' + dd.obj.x + '	 dd.elements.' + dd.obj.name + '.y = ' + dd.obj.y;
1416
}
1417

    
1418

    
1419

    
1420

    
1421
/* my_ResizeFunc IS CALLED WHILE AN ITEM IS RESIZED
1422
See the description of my_PickFunc above for what's accessible from here. */
1423
function my_ResizeFunc()
1424
{
1425
	//window.status = 'dd.elements.' + dd.obj.name + '.w  = ' + dd.obj.w + '	 dd.elements.' + dd.obj.name + '.h = ' + dd.obj.h;
1426
}
1427

    
1428

    
1429

    
1430

    
1431
/* THIS ONE IS CALLED ONCE AN ITEM IS DROPPED
1432
See the description of my_PickFunc for what's accessible from here.
1433
Here may be investigated, for example, what's the name (dd.obj.name)
1434
of the dropped item, and where (dd.obj.x, dd.obj.y) it has been dropped... */
1435
function my_DropFunc()
1436
{
1437
}
(12-12/13)