	function openpopup(picture, picwidth, picheight) {
		if(document.getElementById) {
			var myImage = document.getElementById('popupbody').getElementsByTagName("img")[0];

			myImage.width  = 0;
			myImage.height = 0; 
			myImage.src    = "#";
			myImage.style.display = "none";
			//myImage.style.border = "none";
			var yoffset = 0;
			if (window.pageYOffset) {
				yoffset = window.pageYOffset;
			} 
			else if (window.document.documentElement.scrollTop){
				yoffset = window.document.documentElement.scrollTop;
			}
			else if (document.body && document.body.scrollTop) {
				yoffset = document.body.scrollTop;
			}
			
			var picLeft = ((screen.width-picwidth)/2);
			var picTop  = ((screen.height-picheight)/4+yoffset);
			
			if (document.cookie) {
				var c = document.cookie.substring(0,document.cookie.indexOf(";"));
				var tmp = c.split(",");
				var args = new Array();
				for (var i=0; i<tmp.length; i++)
					args[i] = tmp[i].split("=");	
				//alert("DEBUG "+(args[3][1] == window.location.href) +"  " +args[3][1] +"  "+ window.location.href);
				if (args.length == 4 && args[0][1] == "DERLETZTEKICK" && args[1][0] == "PICTOP" && args[2][0] == "PICLEFT" && args[3][1] == window.location.href) {
					picTop  = isNaN(parseInt(args[1][1]))?picTop:parseInt(args[1][1]);
					picLeft = isNaN(parseInt(args[2][1]))?picLeft:parseInt(args[2][1]);
					picTop  = (picTop<0)?10:picTop;
					picLeft = (picLeft<0)?10:picLeft;
				}
			}
			
			document.getElementById('csspopup').style.display = "inline";
			document.getElementById('csspopup').style.left = picLeft + "px";			
			document.getElementById('csspopup').style.top = picTop + "px";
			document.getElementById('csspopup').style.width = (picwidth+30) + "px";
			document.getElementById('popuphead').style.width = picwidth + "px";
			document.getElementById('popupbody').style.height = (picheight + 25) + "px";
			//document.getElementById('popupbody').style.backgroundImage = "url(" + picture + ")";
			
			myImage.src    = picture;
			myImage.onload = function(e){
				this.width  = picwidth;
				this.height = picheight;
				myImage.style.display = "inline";
			}
			
			window.scrollTo(0,yoffset);
			return false;
		}
	}

	function closepopup() {
		if(document.getElementById) {
			var myImage = document.getElementById('popupbody').getElementsByTagName("img")[0];
			myImage.width  = 0;
			myImage.height = 0; 
			myImage.src    = "";
			myImage.style.display = "none";
			document.getElementById('csspopup').style.display = "none";
			return true;
		}
		else {
			return false;
		}
	}
	
	// Drag&Drop from http://javascript.jstruebig.de/javascript/67/
	(function() {
	
		window.DragObject = function (e_o, o) {
	
			// private Variabeln
			var obj;             		// Dieses Objekt empfängt den Event
			var move;           		// Dieses Objekt wird bewegt
			var start_pos = []; 	// Die Startposition des Elements
    		var zIndex;
	    
			// private Funktionen
		var Index = function(z) { move.style.zIndex = z; };
	
			this.ini = function(e_o, o) {
				if(!e_o) return alert('kein Objekt');
				obj = e_o;
				move = o || e_o;
				zIndex = move.style.zIndex || 0;
				move.style.position = 'absolute';
				obj.style.cursor = 'move';
			
				// Event aktivieren
				var self = this;
				obj.onmousedown = function(e) { dragObject = self; drag_start(e); };
			};
			this.ondrop = function() {return true;};
			this.ondrag = function() {return true;};
			this.onstart = function() {return true;};
			this.getPos = function() {
				var o = move;
				var t = l = 0;
				if(typeof o.offsetTop != 'undefined') {
					t += o.offsetTop;
					l += o.offsetLeft;
				}
				return [t, l];
			};
			this.setPos = function(t, l) {
				if(typeof t != 'undefined' && t != null) move.style.top = t + 'px';
				if(typeof l != 'undefined' && l != null) move.style.left = l + 'px';
			};
			this.start = function(e) {
				start_pos = this.getPos();
				var evt_pos = getEvtPos(e);
			
				start_pos[0] -= evt_pos[0];
				start_pos[1] -= evt_pos[1];
				Index(999);
				this.onstart(e);
			};
		
			this.move = function(e) {
				var evt_pos = getEvtPos(e);
				var new_top = evt_pos[0] + start_pos[0];
				var new_left = evt_pos[1] + start_pos[1];
				if( this.ondrag(e, new_top, new_left) != false) this.setPos( new_top, new_left);
			};
			this.end  = function (e) { 
				Index(zIndex); 
				var evt_pos = getEvtPos(e);
				var last_top = evt_pos[0] + start_pos[0];
				var last_left = evt_pos[1] + start_pos[1];
				var c = "NAME=DERLETZTEKICK,PICTOP="+last_top+",PICLEFT="+last_left+",DOCHREF="+window.location.href+";";
				document.cookie = c;
					
				this.ondrop(e); 			
			};
			if(e_o) this.ini(e_o, o);
		}
		var dragObject = null;
	
		function drag_start(e) {
			if( !dragObject ) return true;
			dragObject.start(e);
			document.onmouseup   = function (e) {
				document.onmouseup = document.onmousemove = null;
				dragObject.end(e);
				dragObject = null;
				return false;
			};
			document.onmousemove = function(e) {
				if(!dragObject) return end_drag(e);
				dragObject.move( e );
				return false;
			};
			if(e && e.preventDefault) e.preventDefault()
			return false;
		}

		function getEvtPos(e) {
			if(!e) e = window.event;
			var t = e.pageY ? e.pageY : e.clientY + window.document.body.scrollTop;
			var l = e.pageX ? e.pageX : e.clientX + window.document.body.scrollLeft;
			return [t, l];
		}

	})();
	
	var DOMContentLoaded = false;
	function addContentLoadListener (func) {
		if (document.addEventListener) {
			var DOMContentLoadFunction = function () {
				window.DOMContentLoaded = true;
				func();
			};
			document.addEventListener("DOMContentLoaded", DOMContentLoadFunction, false);
		}
		var oldfunc = (window.onload || new Function());
		window.onload = function () {
			if (window.DOMContentLoaded)
				return;
			oldfunc();
			func();
		};
	}	
	
	function initGallery() {
		new DragObject( document.getElementById('popuphead'), document.getElementById('csspopup') );
	}
	
	window.addContentLoadListener(initGallery);
	/*
	window.onload = function(e){
		new DragObject( document.getElementById('popuphead'), document.getElementById('csspopup') );
	}*/
