// ----------------------------------------------------------------------------------------------------
// Combo - das clevere CMS!
// Copyright (c) 1999-2006 by Marcus Ollas, Germany
// All Rights Reserved
// ----------------------------------------------------------------------------------------------------
var COMBO = {
    // --------------------------------------------------
    tickerContainer: null,
    tickerTimer: null,
    tickerAbstand: 15,
    insideContainer: null,
    marginTop: 0,
    leseZeit: 4000,
    moveTime: 20,
    inManagement: false,
    // --------------------------------------------------
    setTickerContainer: function(reference) {
        COMBO.tickerContainer = reference;
    },
    // --------------------------------------------------
    setTickerAbstand: function(abstand) {
        COMBO.tickerAbstand = abstand;
    },
    // --------------------------------------------------
    moveTicker: function() {
        if (!COMBO.tickerContainer)
            return ;

		if (COMBO.insideContainer) {
            window.setTimeout("COMBO.moveTicker()",COMBO.moveTime);
			return ;
		}
        var entries = COMBO.tickerContainer.getElementsByTagName("DIV");
        if (COMBO.marginTop == -(entries[0].offsetHeight + COMBO.tickerAbstand)) {
            var first = entries[0];
            COMBO.tickerContainer.replaceChild(entries[1],first);
            first.style.marginTop = 0;
            COMBO.tickerContainer.appendChild(first);
            COMBO.marginTop = 0;
            COMBO.startTicker();
        }
        else {
            COMBO.marginTop-- ;
            entries[0].style.marginTop = COMBO.marginTop;
            window.setTimeout("COMBO.moveTicker()",COMBO.moveTime);
        }
    },
    // --------------------------------------------------
	enterTicker: function() {
       	COMBO.insideContainer = true;
    },
    // --------------------------------------------------
	exitTicker: function() {
       	COMBO.insideContainer = false;
    },
    // --------------------------------------------------
    startTicker: function() {
        if (COMBO.tickerContainer)
            COMBO.tickerTimer = window.setTimeout("COMBO.moveTicker()",COMBO.leseZeit);
    },
    // --------------------------------------------------
	isSafari: function() {
		return (navigator.userAgent.indexOf("Safari") != -1);
	},
    // --------------------------------------------------
    filename: function(value) {
    	if (value == null || value == "")
    		return "";
    	
    	var s = value.lastIndexOf("\\");
    	if (s == -1)
	    	s = value.lastIndexOf("/");
    	
    	return value.substr(s + 1);
    },
    // --------------------------------------------------
    cleanFilename: function(value) {
		if (value)
	    	value = value.replace(/ /g,"_");
    	return value;
    },
    // --------------------------------------------------
    currentRow: null,
    // --------------------------------------------------
	markRow: function(ref,objectId) {
		if (COMBO.currentRow) {
			COMBO.currentRow.className = 'Row' +
				((COMBO.currentRow.rowIndex % 2) ? 'Even' : 'Odd');
		}
		if (ref) {
			ref.parentNode.className = 'Selected';
			COMBO.currentRow = ref.parentNode;

			if (el = document.getElementById('naviMoveUp'))
				el.disabled = false;
			if (el = document.getElementById('naviMoveDown'))
				el.disabled = false;
			if (el = document.getElementById('naviMoveUpId'))
				el.value = objectId;
			if (el = document.getElementById('naviMoveDownId'))
				el.value = objectId;
			if (el = document.getElementById('parentElement'))
				el.value = objectId;
		}
	},
    // --------------------------------------------------
    // --------------------------------------------------
    activateContextMenu : function() {
    	document.oncontextmenu = function(ereignis) {
			if (!ereignis) {
				var ereignis = window.event;
				var x = ereignis.x;
				var y = ereignis.y;
			}
			else {
				var x = ereignis.pageX;
				var y = ereignis.pageY;
			}
			if (!ereignis.ctrlKey) {
				with(ComboPopup) {
					style.top = y;
					style.left = x;
	    			style.visibility = 'visible';
		    	}
		    	document.onkeydown = function(ereignis) {
	    			if (!ereignis) var ereignis = window.event;
	    			if (ereignis.keyCode == 27) {
	    				document.onkeydown = function(ereignis) {};
	    				document.onclick = function(ereignis) {};
		    			with(ComboPopup) {
			    			style.visibility = 'hidden';
							style.top = style.left = 0;
		    			}
		    		}
		    	};
		    	document.onclick = function(ereignis) {
    				document.onclick = function(ereignis) {};
   					document.onkeydown = function(ereignis) {};
	   				with(ComboPopup) {
    					style.visibility = 'hidden';
						style.top = style.left = 0;
					}
	    		};
   				return false;
   			}
   			return true;
    	};
    },
    // --------------------------------------------------
    // --------------------------------------------------
	pageLinkOver : function(ref) {
		return COMBO.handleMouseAction(ref,true);
	},
	pageLinkOut : function(ref) {
		return COMBO.handleMouseAction(ref,false);
	},
	handleMouseAction : function(ref,over) {
		var id = ref.id.substr(4);

		// check for and highlight map dots...
		var dot = document.getElementById("Dot" + id);
		if (dot) {
			dot.childNodes[0].src = over ? 'images/dot1.gif' : 'images/t1.gif';
			ref.style.color = over ? '#DC0067' : '#003C81';
		}
	},
    // --------------------------------------------------
    // --------------------------------------------------
	setManagement : function() {
		COMBO.inManagement = true;
	},
    // --------------------------------------------------
    // --------------------------------------------------
	leavePage : function() {
		var request = null;

		if (COMBO.inManagement)
			return ;

		// Microsoft Internet Explorer
		try {
			request = new ActiveXObject("Msxml2.XMLHTTP"); }
		catch(e) {
			try {
				request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e) {
				// Mozilla/Firefox/Safari etc.
				try {
					request = new XMLHttpRequest();
				}
				catch(e) {}
			}
		}
		if (request) {
			var url = document.location.href;
			url += (url.indexOf('?') == -1 ? '?' : '&') + 'ajaxAction=leavePage';
			// request synchron (!) senden
			request.open('GET',url,false);
			request.send(null);
		}
	},
    // --------------------------------------------------
    // Management Functions
    // --------------------------------------------------
	management : {
	    // --------------------------------------------------
	    extendedOptions : function(button) {
	    // --------------------------------------------------
			var table = COMBO.tools.getParentTag(button,'TABLE');
			if (table)
				table.className = 'Extended';
	    	button.blur();
	    },
	    // --------------------------------------------------
	    simpleOptions : function(button) {
	    // --------------------------------------------------
			var table = COMBO.tools.getParentTag(button,'TABLE');
			if (table)
				table.className = 'Simple';
	    	button.blur();
	    },
/*
			         '<SCRIPT LANGUAGE="JavaScript">' .
			         'function toggleOptions(button) {' .
			         'var table = document.getElementById("ViewOptionsContainer");' .
			         'COMBO.tools.toggleClass(table,"Simple","Extended");' .
			         'COMBO.tools.toggleClass(button,"Simple","Extended");' .
			         'button.innerHTML = (table.className == "Simple" ? "Erweiterte" : "Einfache") + " Optionen";' .
			         'button.blur();' .
			         '}' .
			         '</SCRIPT>';

*/
		tree : {
			lastItem : null,
			changeHandler : null,
			activateHandler : function(doc,changeHandler) {
				COMBO.management.tree.changeHandler = changeHandler;

				var cfss = doc.getElementsByTagName("UL");
				for (e = 0; e < cfss.length; e++) {
					if (cfss[e].id == "TreeSelector") {
						cfss[e].onclick = COMBO.management.tree.handleItem;
					}
				}
				var lis = doc.getElementsByTagName("LI");
				for (e = 0; e < lis.length; e++) {
					if (lis[e].className == 'PreSelected')
						if (lis[e].scrollIntoView)
							lis[e].scrollIntoView(false);
				}
			},
			domEbene : function(el) {
				var ebene = 0;
				while (el = el.parentNode)
					if (el.tagName == 'LI')
						ebene++ ;
				return ebene;
			},
			hasChildren : function(el) {
				if (el)
					for (c = 0; c < el.childNodes.length; c++)
						if (el.childNodes[c].tagName == 'UL')
							return true;
				return false;
			},
			getChild : function(el,tagName) {
				if (el)
					for (c = 0; c < el.childNodes.length; c++)
						if (el.childNodes[c] &&
						    el.childNodes[c].tagName &&
						    el.childNodes[c].tagName.toUpperCase() == tagName.toUpperCase())
							return el.childNodes[c];
				return null;
			},
			mark : function(el) {
				el.className = 'Selected';
				COMBO.management.tree.lastItem = el;
			},
			unmark : function(el) {
				el.className = '';
			},
			handleItem : function(arg) {
				// Eventhandling MS, Opera
				if (!arg) {
					var event = window.event;
					var el = event.srcElement;
				}
				// Gecko, Safari etc.
				else {
					var event = arg;
					var el = event.target;
				}
				// ggf. Event an Parent Node <LI> "uebergeben"
				if (el.tagName == 'SPAN')
					el = el.parentNode;

				// Markieren
				if (el.tagName == 'LI') {
					if (COMBO.management.tree.lastItem)
						COMBO.management.tree.unmark(COMBO.management.tree.lastItem);
					COMBO.management.tree.mark(el);

					// Folder auf-/zuklappen
					if (COMBO.management.tree.hasChildren(el) || event.type == 'dblclick') {
/*						var ul = (el.childNodes && el.childNodes.length > 2 ? el.childNodes[3] : null);
						alert(ul);*/
						if (el.childNodes && (ul = COMBO.management.tree.getChild(el,"UL")) && ul.tagName == 'UL') {
							if (ul.style.display != 'block') {
								if (span = COMBO.management.tree.getChild(el,"SPAN"))
									span.style.background = 'url(images/minus.gif) left center no-repeat';
								ul.style.display = 'block';
							}
							else {
								if (span = COMBO.management.tree.getChild(el,"SPAN"))
									span.style.background = 'url(images/plus.gif) left center no-repeat';
								ul.style.display = 'none';
							}
						}
					}
					// Datei ausgew?hlt...
					else {
						// Handler aufrufen!
						if (COMBO.management.tree.changeHandler)
							COMBO.management.tree.changeHandler(el);
					}
				}
				return false;
			}
		},
		file : {
			getExtension : function(path) {
				if (path && (pp = path.lastIndexOf(".")) != -1)
					return path.substr(pp+1).toLowerCase();
				return path;
			},
			isImage : function(path) {
				var ext = COMBO.management.file.getExtension(path);
				return (ext == 'jpg' || ext == 'jpeg' ||
				        ext == 'gif' || ext == 'png'  ||
				        ext == 'tif' || ext == 'tiff' ||
				        ext == 'bmp');
			},
			isFlash : function(path) {
				var ext = COMBO.management.file.getExtension(path);
				return (ext == 'swf');
			},
			isPdf : function(path) {
				var ext = COMBO.management.file.getExtension(path);
				return (ext == 'pdf');
			},
			isMidi : function(path) {
				var ext = COMBO.management.file.getExtension(path);
				return (ext == 'mid' || ext == 'midi');
			},
			isMpeg : function(path) {
				var ext = COMBO.management.file.getExtension(path);
				return (ext == 'mp2' || ext == 'mp3' || ext == 'mpeg' || ext == 'mpeg2');
			},
			replaceChild : function(container,current,newobj) {
				if (current)
					container.replaceChild(newobj,current);
				else
					container.appendChild(newobj);

				return newobj;
			},
			refreshDimensions : function(element,id) {
				var width = null;
				var height = null;

				if (element) {
					width = element.width;
					height = element.height;
				}
				var elWidth, elHeight, elEinheit;
				if (elWidth = document.getElementById("width" + id))
					elWidth.value = (width ? width : '');
				if (elHeight = document.getElementById("height" + id))
					elHeight.value = (height ? height : '');
				if (elEinheit = document.getElementById("einheit" + id))
					elEinheit.selectedIndex = 0;
			},
			setPath : function(id,path) {
				// Wert im versteckten Formularfeld setzen
				var hidden = document.getElementById("content" + id);
				if (hidden)
					hidden.value = path;

				// Dimensionen initialisieren
			    COMBO.management.file.refreshDimensions(null,id);

				// get reference to file container
				var container = document.getElementById("FileContainer" + id);
				var current = (container && container.childNodes ? container.childNodes[0] : null);
				
				// Keine Bilddatei oder Browser nicht DOM/AJAX-f?hig?
				// Dann Formular abschicken und Seite neu aufbauen!
				if (!COMBO.management.file.isImage(path) || !container) {
					if (hidden && hidden.form) {
						var action = document.getElementById('formAction');
						if (action)
							action.value = 'fileChangedTo.' + id;
						hidden.form.submit();
					}
					return ;
				}
				// Bilddateien
				container.innerHTML = '<IMG ID="Object' + id + 
				                      '" ONLOAD="COMBO.management.file.refreshDimensions(this,\'' +
				                      id + '\')" SRC="../' + path + '"/>';
			}
		},
		pane : {
			over : function(ref,borderColor,bgColor) {
				ref.style.backgroundColor = bgColor;
				ref.style.border = '1px solid ' + borderColor;
			},
			out : function(ref,paneBg) {
				ref.style.border = '0px';
//				ref.style.backgroundColor = (paneBg ? paneBg : '#FFFFFF');
				ref.style.background = (paneBg ? paneBg : '');
			}
		},
		page : {
			nameChanged : function(elRef,neu) {
				// 2006-09-17 marcus@ollas.de
				// Nach Seitennamen?nderung ggf. Titel anpasssen
				if (elRef && elRef.value && elRef.value.length > 0) {
					var elDeutsch = document.getElementById("title_0");
					if (elDeutsch) {
						if (elDeutsch.value.length == 0 || confirm("Titel '" + elDeutsch.value + "' mit Seitennamen ersetzen?"))
							elDeutsch.value = elRef.value;
					}
				}
			}
		},
		navigation : {
			linkedPageChanged : function(selRef,neu) {
				// 2006-09-17 marcus@ollas.de
				// Bei neuen Navigationspunkten:
				// wenn der deutsche Titel leer ist, den Seitennamen vorschlagen!
				if (selRef && neu) {
					var elDeutsch = document.getElementById("eldeutsch");
					if (elDeutsch) {
						if (elDeutsch.value.length == 0 || confirm("Seitennamen im Navigationspunkt verwenden?")) {
							var inner = selRef.options[selRef.selectedIndex].innerHTML;
							elDeutsch.value = inner.replace(/&nbsp;/g,"");
						}
					}	
				}
			}
		}
	},
    // --------------------------------------------------
    // gallery: COMBO Image Gallery Functions
    // --------------------------------------------------
    gallery : {
    	id : null,
    	current : 0,
    	images : null,
    	details : null,
    	width : null,
    	height : null,
    	// ------------------------------
	    init : function(id,images,details) {
    	// ------------------------------
			COMBO.gallery.id = id;
			COMBO.gallery.images = images;
			COMBO.gallery.details = details;
    	},
    	// ------------------------------
    	getImage : function() {
    	// ------------------------------
	    	return document.getElementById("GalleryImage" + COMBO.gallery.id);
    	},
    	// ------------------------------
    	getText : function() {
    	// ------------------------------
	    	return document.getElementById("GalleryText" + COMBO.gallery.id);
    	},
    	// ------------------------------
    	back : function() {
    	// ------------------------------
	    	if (COMBO.gallery.current > 0)
   				COMBO.gallery.show(--COMBO.gallery.current);
    		return false;
	    },
    	// ------------------------------
    	next : function() {
    	// ------------------------------
	    	if (COMBO.gallery.current < COMBO.gallery.images.length - 1)
    			COMBO.gallery.show(++COMBO.gallery.current);
    		return false;
    	},
    	// ------------------------------
    	show : function(index) {
    	// ------------------------------
    		if (index > -1 && index < COMBO.gallery.images.length &&
    		                  index != COMBO.gallery.current) {
    			COMBO.gallery.current = index;
    			if (img = COMBO.gallery.getImage()) {
    				img.src = COMBO.gallery.images[COMBO.gallery.current];
    				img.alt = COMBO.gallery.details[COMBO.gallery.current];
    			}
    			if (txt = COMBO.gallery.getText())
    				txt.innerHTML = COMBO.gallery.details[COMBO.gallery.current];
    		}
    		return false;
    	},
    	// ------------------------------
    	thumbOver : function(imageRef,src) {
    	// ------------------------------
//    		dpos = imageRef.src.lastIndexOf('.');
//    		imageRef.src = imageRef.src.substr(0,dpos) + ".over" + imageRef.src.substr(dpos);
			imageRef.src = src;
    	},
    	// ------------------------------
    	thumbOut : function(imageRef,src) {
    	// ------------------------------
			imageRef.src = src;
    	},
    	// ------------------------------
    	diashow : {
    		imageRef : null,
    		parentRef : null,
    		images : null,
    		currentIndex : 0,
    		opacity : 1.0,
    		pause : 5000,
    		steps : 0.05,
    		delay : 60,
    		random : false,	// not implemented yet :(
    		infinite : true,
	    	// ------------------------------
	    	// ------------------------------
	    	next : function() {
	    		if (!COMBO.gallery.diashow.images)
	    			return null;

				if (++COMBO.gallery.diashow.currentIndex >= COMBO.gallery.diashow.images.length) {
					if (!COMBO.gallery.diashow.infinite)
						return null;
					COMBO.gallery.diashow.currentIndex = 0;
				}
				return COMBO.gallery.diashow.images[COMBO.gallery.diashow.currentIndex];
	    	},
	    	// ------------------------------
	    	// ------------------------------
	    	setOpacity : function(value) {
	    		if (COMBO.gallery.diashow.imageRef) {
					COMBO.gallery.diashow.imageRef.style.filter = 'alpha(opacity=' + (value * 100) + ')';	// IE
					COMBO.gallery.diashow.imageRef.style.opacity = value;									// Gecko
				}
	    	},
	    	// ------------------------------
	    	// ------------------------------
			fadeOut : function() {

				if (COMBO.gallery.diashow.opacity > 0.0) {
					COMBO.gallery.diashow.setOpacity(COMBO.gallery.diashow.opacity -= COMBO.gallery.diashow.steps);
					window.setTimeout("COMBO.gallery.diashow.fadeOut()",COMBO.gallery.diashow.delay);
				}
				else if ((src = COMBO.gallery.diashow.next()) != null) {
					COMBO.gallery.diashow.setOpacity(COMBO.gallery.diashow.opacity = 0.0);
					COMBO.gallery.diashow.imageRef.src = src;
					window.setTimeout("COMBO.gallery.diashow.fadeIn()",COMBO.gallery.diashow.pause);
				}
			},
	    	// ------------------------------
	    	// ------------------------------
			fadeIn : function() {
				if (COMBO.gallery.diashow.opacity < 1.0) {
					COMBO.gallery.diashow.setOpacity(COMBO.gallery.diashow.opacity += COMBO.gallery.diashow.steps);
					window.setTimeout("COMBO.gallery.diashow.fadeIn()",COMBO.gallery.diashow.delay);
				}
				else if ((src = COMBO.gallery.diashow.next()) != null) {
					COMBO.gallery.diashow.setOpacity(COMBO.gallery.diashow.opacity = 1.0);
					COMBO.gallery.diashow.parentRef.style.background = 'url(' + src + ') no-repeat top left';
					window.setTimeout("COMBO.gallery.diashow.fadeOut()",COMBO.gallery.diashow.pause);
				}
			},
	    	// ------------------------------
	    	// ------------------------------
			init : function(images,pause,delay,steps,offset,random,infinite) {
				COMBO.gallery.diashow.images = images;
				COMBO.gallery.diashow.pause = pause;
				COMBO.gallery.diashow.delay = delay;
				COMBO.gallery.diashow.steps = steps;
				COMBO.gallery.diashow.currentIndex = offset;
				COMBO.gallery.diashow.random = random;
				COMBO.gallery.diashow.infinite = infinite;
			},
	    	// ------------------------------
	    	// ------------------------------
			checkReferences : function() {
				if (!COMBO.gallery.diashow.imageRef || !COMBO.gallery.diashow.parentRef) {
					COMBO.gallery.diashow.imageRef = document.getElementById("GalleryImage" + COMBO.gallery.id);
					COMBO.gallery.diashow.parentRef = document.getElementById("DiashowContainer" + COMBO.gallery.id);
					return false;
				}
				return true;
			},
	    	// ------------------------------
	    	// ------------------------------
			start : function() {
				// Referenzen pr?fen und ggf. 1/2 Sekunde warten...
				if (!COMBO.gallery.diashow.checkReferences()) {
					window.setTimeout("COMBO.gallery.diashow.start()",500);
					return ;
				}
				var src = COMBO.gallery.diashow.next();
				if (src) {
					COMBO.gallery.diashow.parentRef.style.background = 'url(' + src + ') no-repeat top left';
					window.setTimeout("COMBO.gallery.diashow.fadeOut()",COMBO.gallery.diashow.pause);
				}
			},
	    	// ------------------------------
	    	// ------------------------------
	    	wysiwygNPL : function(ref,id) {
	    		if (el = document.getElementById('random' + id))
	    			el.disabled = (!ref.checked);
	    		if (el = document.getElementById('labelRandom' + id))
	    			el.disabled = (!ref.checked);
	    		if (el = document.getElementById('infinite' + id))
	    			el.disabled = (!ref.checked);
	    		if (el = document.getElementById('labelInfinite' + id))
	    			el.disabled = (!ref.checked);
	    		if (el = document.getElementById('pause' + id))
	    			el.disabled = (!ref.checked);
	    		if (el = document.getElementById('labelPause' + id + '-1'))
	    			el.disabled = (!ref.checked);
	    		if (el = document.getElementById('step' + id))
	    			el.disabled = (!ref.checked);
	    		if (el = document.getElementById('delay' + id))
	    			el.disabled = (!ref.checked);
	    		if (el = document.getElementById('labelPause' + id + '-2'))
	    			el.disabled = (!ref.checked);
	    		if (el = document.getElementById('labelFading' + id + '-1'))
	    			el.disabled = (!ref.checked);
	    		if (el = document.getElementById('labelFading' + id + '-2'))
	    			el.disabled = (!ref.checked);
	    		if (el = document.getElementById('labelFading' + id + '-3'))
	    			el.disabled = (!ref.checked);
	    	}
    	},
    	EasyUpload : {
    		image: null,
    		imageWidth : null,
    		imageHeight : null,
    		currentSizeLabel : null,
    		currentPositionLabel : null,
			elementTop : null,
			elementLeft : null,
			elementWidth : null,
			elementHeight : null,
			checkUpload : function(button) {
				if (!button.form.elements['uploadFile'].value) {
					alert('Bitte eine lokale Bilddatei ausw?hlen.');
					button.form.elements['uploadFile'].focus();
					return false;
				}
				return true;				
			},
			secureUpload : function(form) {
				if (form.elements['action'].value != 'ABORT!') {
					if (form.elements['action'].value == 'SAVE!') {
						form.elements['saveFile'].disabled = true;
					}
					else {
						form.elements['submitFile'].disabled = true;
						if (tm = document.getElementById("TopMessage")) {
							if (tbody = tm.firstChild) {
								if (tr = tbody.firstChild) {
									if (td = tr.firstChild) {
										td.innerHTML = 'Datei wird hochgeladen...';
										tm.style.visibility = 'visible';
									}
								}
							}
						}
					}
				}
			},
    		getImage : function() {
    			if (!COMBO.gallery.EasyUpload.image) {
    				COMBO.gallery.EasyUpload.image = document.getElementById('EasyUploadImage');
    			}
    			return COMBO.gallery.EasyUpload.image;
    		},
    		refreshSize : function(iW,iH,aW,aH) {
    			if (COMBO.gallery.EasyUpload.currentSizeLabel)
					COMBO.gallery.EasyUpload.currentSizeLabel.innerHTML = aW + ' x ' + aH + ' Pixel (' +
					                                                      Math.round((aW * 100) / iW) + '%)';
    			if (COMBO.gallery.EasyUpload.elementWidth)
    				COMBO.gallery.EasyUpload.elementWidth.value = aW;
    			if (COMBO.gallery.EasyUpload.elementHeight)
    				COMBO.gallery.EasyUpload.elementHeight.value = aH;
    		},
    		refreshPosition : function(left,top) {
    			if (COMBO.gallery.EasyUpload.currentPositionLabel)
					COMBO.gallery.EasyUpload.currentPositionLabel.innerHTML = left + ' / ' + top + ' Pixel';
    			if (COMBO.gallery.EasyUpload.elementTop)
    				COMBO.gallery.EasyUpload.elementTop.value = top;
    			if (COMBO.gallery.EasyUpload.elementLeft)
    				COMBO.gallery.EasyUpload.elementLeft.value = left;
    		},
    		zoomIn : function(iW,iH,gW,gH) {
    			if (image = COMBO.gallery.EasyUpload.getImage()) {
					var ratio = iW / iH;
    				var aW = parseInt(image.style.width);
    				var aH = parseInt(image.style.height);
    				var nW = aW * 1.05;
					var nH = nW / ratio;
					COMBO.gallery.EasyUpload.imageHeight = image.style.height = parseInt(nH);
					COMBO.gallery.EasyUpload.imageWidth = image.style.width = parseInt(nW);

					var dH = parseInt((aH - nH) / 2);
					var dW = parseInt((aW - nW) / 2);
					var top = image.style.marginTop = parseInt(image.style.marginTop) + dH;
					var left = image.style.marginLeft = parseInt(image.style.marginLeft) + dW;
					
					COMBO.gallery.EasyUpload.refreshSize(iW,iH,parseInt(nW),parseInt(nH));
					COMBO.gallery.EasyUpload.refreshPosition(parseInt(left),parseInt(top));
    			}
    		},
    		zoomOut : function(iW,iH,gW,gH) {
    			if (image = COMBO.gallery.EasyUpload.getImage()) {
					var ratio = iW / iH;
    				var aW = parseInt(image.style.width);
    				var aH = parseInt(image.style.height);
    				if (aW - gW < aH - gH) {
	    				var nW = Math.max(aW / 1.05, gW);
						var nH = nW / ratio;
    				}
    				else {
	    				var nH = Math.max(aH / 1.05, gH);
						var nW = nH * ratio;
    				}
					COMBO.gallery.EasyUpload.imageHeight = image.style.height = parseInt(nH);
					COMBO.gallery.EasyUpload.imageWidth = image.style.width = parseInt(nW);

					var dH = parseInt((aH - nH) / 2);
					var dW = parseInt((aW - nW) / 2);
					var top = image.style.marginTop = Math.max(Math.min(parseInt(image.style.marginTop) + dH,0),-(nH-gH));
					var left = image.style.marginLeft = Math.max(Math.min(parseInt(image.style.marginLeft) + dW,0),-(nW-gW));

					COMBO.gallery.EasyUpload.refreshSize(iW,iH,parseInt(nW),parseInt(nH));
					COMBO.gallery.EasyUpload.refreshPosition(parseInt(left),parseInt(top));
    			}
    		},
    		moveUp : function(iW,iH,gW,gH) {
    			if (image = COMBO.gallery.EasyUpload.getImage()) {
    				var aH = parseInt(image.style.height);
    				var mtop = Math.max(parseInt(image.style.marginTop) - 10,-(aH-gH));
    				image.style.marginTop = mtop;
					COMBO.gallery.EasyUpload.refreshPosition(parseInt(image.style.marginLeft),mtop);
    			}
    		},
    		moveDown : function(iW,iH,gW,gH) {
    			if (image = COMBO.gallery.EasyUpload.getImage()) {
    				var mtop = Math.min(parseInt(image.style.marginTop) + 10,0);
    				image.style.marginTop = mtop;
					COMBO.gallery.EasyUpload.refreshPosition(parseInt(image.style.marginLeft),mtop);
    			}
    		},
    		moveLeft : function(iW,iH,gW,gH) {
    			if (image = COMBO.gallery.EasyUpload.getImage()) {
    				var aW = parseInt(image.style.width);
    				var mleft = Math.max(parseInt(image.style.marginLeft) - 10,-(aW-gW));
    				image.style.marginLeft = mleft;
					COMBO.gallery.EasyUpload.refreshPosition(mleft,parseInt(image.style.marginTop));
    			}
    		},
    		moveRight : function(iW,iH,gW,gH) {
    			if (image = COMBO.gallery.EasyUpload.getImage()) {
    				var mleft = Math.min(parseInt(image.style.marginLeft) + 10,0);
    				image.style.marginLeft = mleft;
					COMBO.gallery.EasyUpload.refreshPosition(mleft,parseInt(image.style.marginTop));
    			}
    		},
    		dragX : null,
    		dragY : null,
    		dragTop : null,
    		dragLeft : null,
    		dragImage : false,
    		mouseDown : function(event) {
    			if (!event) {
    				var event = window.event;
    				var element = event.srcElement;
    				var x = event.x;
    				var y = event.y
    			}
    			else {
    				var element = event.target;
    				var x = event.screenX;
    				var y = event.screenY;
    			}
    			if (element.id == "EasyUploadImage") {
	    			COMBO.gallery.EasyUpload.dragX = x;
					COMBO.gallery.EasyUpload.dragY = y;
	    			COMBO.gallery.EasyUpload.dragTop = parseInt(element.style.marginTop);
					COMBO.gallery.EasyUpload.dragLeft = parseInt(element.style.marginLeft);
	   				COMBO.gallery.EasyUpload.dragImage = element;
		   			COMBO.gallery.EasyUpload.dragImage.style.cursor = 'move';
		   			return false;
		   		}
		   		return true;
    		},
    		mouseUp : function(event) {
    			if (COMBO.gallery.EasyUpload.dragImage) {
		   			COMBO.gallery.EasyUpload.dragImage.style.cursor = 'default';
   					COMBO.gallery.EasyUpload.dragImage = null;
	   				return false;
	   			}
	   			return true;
    		},
    		mouseMove : function(event) {
    			if (COMBO.gallery.EasyUpload.dragImage) {
	    			if (!event) {
	    				var event = window.event;
	    				var x = event.x;
	    				var y = event.y
	    			}
	    			else {
	    				var x = event.screenX;
	    				var y = event.screenY;
	    			}
    				var dX = x - COMBO.gallery.EasyUpload.dragX;
    				var dY = y - COMBO.gallery.EasyUpload.dragY;
    				var mtop = COMBO.gallery.EasyUpload.dragImage.style.marginTop = parseInt(Math.max(Math.min(COMBO.gallery.EasyUpload.dragTop + dY,0),-(COMBO.gallery.EasyUpload.imageHeight-COMBO.gallery.height)));
    				var mleft = COMBO.gallery.EasyUpload.dragImage.style.marginLeft = parseInt(Math.max(Math.min(COMBO.gallery.EasyUpload.dragLeft + dX,0),-(COMBO.gallery.EasyUpload.imageWidth-COMBO.gallery.width)));

					COMBO.gallery.EasyUpload.refreshPosition(mleft,mtop);
	
	    			return false;
    			}
    			return true;
    		}
    	}
    },
    // --------------------------------------------------
    // tools: COMBO use-/helpfull Functions
    // --------------------------------------------------
    tools : {
    	toggleClass : function(ref,class1,class2) {
    		if (ref)
    			ref.className = (ref.className == class1 ? class2 : class1);
    	},
    	getParentTag : function(ref,tagName) {
    		while (ref && ref.tagName != tagName) {
    			ref = ref.parentNode;
    		}
    		return ref;
    	}
    }
    // --------------------------------------------------
    // --------------------------------------------------
};
// ----------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------
function markRow(ref)
{
}
// ----------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------