function openGalleryEntry(nr, width, height, slideshow) {	var docURL = document.URL;	var pos = docURL.indexOf("?OpenDocument");	if(pos != "-1") {		docURL = docURL.substring(0, pos);	}	var entryURL = docURL + "?OpenDocument&nr=" + nr;	if (slideshow) entryURL += "&slideshow";	var windowWidth =  width + 30;	var windowHeight = height + 150;	if (windowWidth < 404) windowWidth = 404;	var windowX = (screen.width - windowWidth) / 2;	var windowY = (screen.height - windowHeight) / 2;	var parameters = "width=" + windowWidth + ", height=" + windowHeight + ", left=" + windowX + ", top=" + windowY + ", location=no, status=no, toolbar=no, menubar=no, dependent=yes";	var entryWindow = window.open(entryURL, "entry", parameters);	if (entryWindow) entryWindow.focus();		}function openGalleryEntryEdit(nr, width, height, slideshow) {	var entryURL= "web/" + refUNID + "?OpenDocument&nr=" + nr;		var windowWidth =  width + 20;	var windowHeight = height + 150;	var windowX = (screen.width - windowWidth) / 2;	var windowY = (screen.height - windowHeight) / 2;	var parameters = "width=" + windowWidth + ", height=" + windowHeight + ", left=" + windowX + ", top=" + windowY + ", location=no, status=no, toolbar=no, menubar=no, dependent=yes";	var entryWindow = window.open(entryURL, "entry", parameters);	if(entryWindow) entryWindow.focus();	}function openZip(title) {	var docURL = document.URL;	var pos = docURL.indexOf("?OpenDocument");	if(pos != "-1") {		docURL = docURL.substring(0, pos);	}	var entryURL = docURL + "/$file/" + title;	window.location.href = entryURL;}function downloadOriginalImage() {	var docURL = document.URL;	var unid = middleStr(docURL + "?OpenDocument", "/web/", "?OpenDocument");	var dbPath = leftStr(rightStr(rightStr(docURL, "http://"), "/"), ".nsf") + ".nsf";	document.location.href = "/servlet/GetNotesAttachment?unid=" + unid + "&filename=" + g_fileName + "&dbpath=" + dbPath;}function resizeWindow(width, height) {	var windowWidth = width + 30;	if (windowWidth < 404) windowWidth = 404;	var windowHeight = height + 150;	window.resizeTo(windowWidth, windowHeight);	}function resizeMoveWindow(width, height) {	var windowWidth =  width + 30;	if (windowWidth < 404) windowWidth = 404;	var windowHeight = height + 150;	if(document.images["imgend"].offsetTop) {		while(document.images["imgend"].offsetTop + 50 > windowHeight) {			windowHeight += 10;		}	}	var windowX = (screen.width - windowWidth) / 2;	var windowY = (screen.height - windowHeight) / 2;	window.moveTo(windowX, windowY);		window.resizeTo(windowWidth, windowHeight);	}//Slideshowvar slideshowTimer;var isSlideshowRunning;var slideshowNextURL;var beginNr;var prevNr;var nextNr;var endNr;var slideshowTimeout;function galleryGoto(dest) {	switch (dest) {	case "begin":		nr = beginNr;		break;	case "prev":		nr = prevNr;		break;	case "next":		nr = nextNr;		break;	case "end":		nr = endNr;		break;	}	var docURL = document.URL;	var pos = docURL.indexOf("&nr");	if(pos != "-1") {		docURL = docURL.substring(0, pos);	}	var entryURL = docURL + "&nr=" + nr;		self.location.href = entryURL;}function slideshowNext() {	var docURL = document.URL;	var pos = docURL.indexOf("&nr");	if(pos != "-1") {		docURL = docURL.substring(0, pos);	}	var entryURL = docURL + "&nr=" + nextNr +"&slideshow";	if(nextNr != '') self.location.href = entryURL;	}function continueSlideshow() {		slideshowTimer = window.setTimeout("slideshowNext()", slideshowTimeout);}function startStopSlideshow() {	if(isSlideshowRunning) {		window.clearTimeout(slideshowTimer);		document.getElementById("startstop").innerHTML = startLabel;	}	else {			slideshowTimer = window.setTimeout("slideshowNext()", slideshowTimeout);		document.getElementById("startstop").innerHTML = stopLabel;	}	isSlideshowRunning = !isSlideshowRunning;}function startSlideshow() {	openGalleryEntry(1, 640, 480, true);}/************************************************************/var g_isSlideshowRunning = false;var g_slideshowTimer;//var g_slideshowTimeout;var g_imgCurrent;var g_imgBegin;var g_imgPrev;var g_imgNext;var g_imgEnd;	var g_slideSrc;var g_originalSrc;var g_unid;var g_fileName;var g_slideWidth;var g_slideHeight;var g_slideCaption;var g_slideNr;var g_slideCount;var g_showAtOnce;var g_isNextImageLoaded;  //true, when image is loaded, false, otherwise, is set by preloader imagefunction getCachePreventTime() {	 var now = new Date();	return "&rand=" + now.getTime() + escape( Math.round( Math.random() * 10000 ) );}function getNodeValue(obj, tag) {	if (obj.getElementsByTagName(tag)[0].firstChild)		return obj.getElementsByTagName(tag)[0].firstChild.nodeValue;	else		return "&nbsp;";}//is set by preloader image, when it is loaded, with onloadfunction setNextImageIsLoaded() {	//debugAppend('fertig: ' + document.getElementById("galleryimage").src);	g_isNextImageLoaded = true;	}//Ajax var xmlHttp = null;function createXMLHttpRequest() { 	if (xmlHttp) xmlHttp.abort();	xmlHttp = null;	/*if (window.ActiveXObject) { 			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 	}	else if (window.XMLHttpRequest) { 				xmlHttp = new XMLHttpRequest(); 	}		var req = false;*/  		if(window.XMLHttpRequest){		xmlHttp = new XMLHttpRequest();				if(xmlHttp.overrideMimeType){ xmlHttp.overrideMimeType('text/xml'); }	} 	else if(window.ActiveXObject){		try{ xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); }		catch(e){			try{ xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }			catch(e){}		}	}}function openImageGalleryEntry(imgNr) {		g_imgCurrent = imgNr;	var docURL = document.URL;	var pos = docURL.indexOf("?OpenDocument");	if(pos != -1) {		docURL = docURL.substring(0, pos);	}		var entryURL;		if (docURL.indexOf("/web/") != -1) entryURL = replStr(docURL, "/web/", "/webimagegalleryentryxml/") + "?OpenDocument&img=" + imgNr;	else entryURL = replStr(docURL, "/0/", "/webimagegalleryentryxml/") + "?OpenDocument&img=" + imgNr;	getGalleryEntryXML(entryURL);}var incarnationCounter = 0;//open gallery entry for next image, when current one is loadedfunction openImageGalleryEntryWhenLoaded(imgNr) {	//debug("jetzt warten");	if (!g_isNextImageLoaded) {		//debugAppend("imgNr: " + String(incarnationCounter++));		//give image some time load		window.setTimeout("openImageGalleryEntryWhenLoaded(" + imgNr + ")", 100);		}	else {		//debug("jetzt ist es da!");		openImageGalleryEntry(imgNr);	}}function getGalleryEntryXML(url) {		 	createXMLHttpRequest();		 	if (!xmlHttp) {		//showIndeterminate();	}	else {		xmlHttp.onreadystatechange = showGalleryEntryXML;		xmlHttp.open("GET", url + getCachePreventTime(), true);		xmlHttp.send(null);	}}//is called when xmlhttprequest sends resultfunction showGalleryEntryXML() {	var html = "";		var status;	if (xmlHttp.readyState == 4) {			try {      //firefox sometimes throws errors     			status = xmlHttp.status;		}		catch (e) {			status = 404;            /*alert("Network error!\nPlease try later.");            try {            alert("Failure: " +  + xmlHttp.statusText);            }            catch(e) {}*/        	}		//result is there		if (status == 200) {     					var response = xmlHttp.responseXML.documentElement;			g_imgBegin = getNodeValue(response, "imgbegin");			g_imgPrev = getNodeValue(response, "imgprev");			g_imgNext = getNodeValue(response, "imgnext");			g_imgEnd = getNodeValue(response, "imgend");						g_unid = getNodeValue(response, "unid"); 			g_fileName = getNodeValue(response, "filename"); 			g_slideSrc = g_unid + "/$file/slide_" + g_fileName;			g_originalSrc = g_unid + "/$file/" + g_fileName;			g_slideWidth = parseInt(getNodeValue(response, "width")); 			g_slideHeight = parseInt(getNodeValue(response, "height")),			g_slideCaption = getNodeValue(response, "caption"),			g_slideNr = getNodeValue(response, "nr"), 			g_slideCount = getNodeValue(response, "count")						//preloading images for slideshow			g_isNextImageLoaded = false;			document.getElementById("imagepreloader").src = g_slideSrc;			if (g_isSlideshowRunning) {					if (g_showAtOnce) {						//called from page, not div, don't wait for image to show						g_showAtOnce = false;						showGalleryEntryAjax();					}					else {													g_slideshowTimer = window.setTimeout("showGalleryEntryAjax()", g_slideshowTimeout);																	}			}			else {				showGalleryEntryAjax();			}								}			}}//show gallery entry, information is provided in global variablesfunction showGalleryEntryAjax() {		//g_slideWidth = 640;	//g_slideHeight = 600;	g_slideWidth = g_maximumImageWidth;	g_slideHeight = g_maximumImageHeight;	var shadeborder = 8;	 var divWidth = g_slideWidth + 7;  //38;	//var divHeight = height + 20;	var divHeight = g_slideHeight + 72;  //space below image	// magic numbers follow, do not try at home	//var popupWidth = divWidth;	//var popupHeight = divHeight - 36;	var shadeWidth = divWidth + 23;   //56;	var shadeHeight = divHeight + 69;/*	if (screen.width <= 800) {     	divHeight = 300;          popupHeight = 276;          shadeHeight = 353;	}*/	showLr("divContent");    	showLr("divContentShade");    		var elmShade = document.getElementById("divContentShade");	var elmPopup = document.getElementById("divContent");	var elmContent = document.getElementById("divContentInnerContent");	var divX = g_pageWidth / 2 - divWidth / 2;	//var divY = Math.round( (viewportGetHeight() - divHeight) / 2 ) + viewportGetScrollY();	var divAllHeight = (g_slideHeight + 127);	var divY = Math.round( (viewportGetHeight() - divAllHeight) / 2 ) + viewportGetScrollY();  //107 = space below image + padding-top to image	//debug("divY: " + String(divY));	if (divX < 0) { divX = 0; }	if (divY < 0) { divY = 0; }		elmShade.style.left = (divX - shadeborder) + "px";	elmShade.style.top = (divY - shadeborder) + "px";	elmShade.style.width = shadeWidth + "px";	elmShade.style.height = shadeHeight + "px";	elmPopup.style.left = divX + "px";	elmPopup.style.top = divY + "px";	elmPopup.style.width = divWidth + "px";	elmPopup.style.height = divHeight + "px";	elmContent.style.width = g_slideWidth + "px";	elmContent.style.height = g_slideHeight + "px";	document.getElementById("divContentTitle").style.width = (g_slideWidth - 1) + "px";	document.getElementById("closeButtonDivContent").style.left = (g_slideWidth - 7) + "px";	//document.getElementById("popupDivTitle").innerHTML = "<img src=\"" + layerTitleImg + "\" alt=\"" + layerTitle + "\">";      //g_openpopupDiv = sUrl;	document.getElementById("galleryimage").src = document.getElementById("imagepreloader").src; //g_slideSrc;	//document.getElementById("originalimage").href = g_originalSrc;	//document.getElementById("galleryimage").style.width = String(g_slideWidth) + "px";	//document.getElementById("galleryimage").style.height = String(g_slideHeight) + "px";	//document.getElementById("gallerytable").style.width = String(g_slideWidth + 2) + "px";	//document.getElementById("gallerytableinfo").style.width = String(g_slideWidth + 2) + "px";	//document.getElementById("gallerysp").style.width = String(g_slideWidth - 138) + "px";		document.getElementById("gallerycaption").innerHTML = g_slideCaption;	document.getElementById("gallerynrofcount").innerHTML = "(" + g_slideNr + "/" + g_slideCount + ")";	if (g_imgBegin == "-1") document.getElementById("gallerybegin").style.visibility = "hidden";	else document.getElementById("gallerybegin").style.visibility = "visible";	if (g_imgPrev == "-1") document.getElementById("galleryprev").style.visibility = "hidden";	else document.getElementById("galleryprev").style.visibility = "visible";	if (g_imgNext == "-1") document.getElementById("gallerynext").style.visibility = "hidden";	else document.getElementById("gallerynext").style.visibility = "visible";	if (g_imgEnd == "-1") document.getElementById("galleryend").style.visibility = "hidden";	else document.getElementById("galleryend").style.visibility = "visible";	if (g_imgNext == "-1") {		document.getElementById("startstop").src = "/icons/ecblank.gif";		document.getElementById("startstop").alt = "";	}	else {		document.getElementById("startstop").src = g_startStopSrc;		document.getElementById("startstop").alt = g_startStopAlt;	}	elmPopup.style.display = "block";	elmShade.style.display = "block";	elmContent.style.display = "block";		//debug("g_slideSrc: " + g_slideSrc);	//debugAppend("g_isNextImageLoaded: " + String(g_isNextImageLoaded));		if (g_isSlideshowRunning) {		if(g_imgNext != "-1") {					//if slideshow is running and current image is not the last in the slideshow open the next one			//if current image is already loaded, get the next one				if (g_isNextImageLoaded) {						//debugAppend("weiter");				openImageGalleryEntry(g_imgNext);										}			else {				//debugAppend("warten!!!!!!");				openImageGalleryEntryWhenLoaded(g_imgNext)			}					}		else {			//no more images, stop slideshow, so it is also stopped when jumped to another entry			g_startStopSrc = g_startSrc;					g_startStopAlt = g_startAlt;			g_isSlideshowRunning = !g_isSlideshowRunning;		}	}	}function galleryGoto(dest) {	stopSlideshow();	switch (dest) {	case "begin":				imgNr = g_imgBegin;		break;	case "prev":		imgNr = g_imgPrev;		break;	case "next":		imgNr = g_imgNext;		break;	case "end":		imgNr = g_imgEnd;		break;	}		openImageGalleryEntry(imgNr);}function stopSlideshow() {	if(g_isSlideshowRunning) {		window.clearTimeout(g_slideshowTimer);		xmlHttp.abort();		g_startStopSrc= g_startSrc;					g_startStopAlt = g_startAlt;		document.getElementById("startstop").src = g_startSrc;		document.getElementById("startstop").alt = g_startAlt;				g_isSlideshowRunning = false;	}		}function startStopSlideshow() {	if(g_isSlideshowRunning) {		window.clearTimeout(g_slideshowTimer);		xmlHttp.abort();		g_startStopSrc= g_startSrc;					g_startStopAlt= g_startAlt;						}	else {				openImageGalleryEntry(g_imgNext);						g_startStopSrc = g_stopSrc;				g_startStopAlt = g_stopAlt;			}	document.getElementById("startstop").src = g_startStopSrc;	document.getElementById("startstop").alt = g_startStopAlt;	g_isSlideshowRunning = !g_isSlideshowRunning;}//is called from page not divfunction startSlideshow() {	g_showAtOnce = true;	g_isSlideshowRunning = true;	g_startStopSrc = g_stopSrc;	g_startStopAlt = g_stopAlt;	openImageGalleryEntry(1);}function openGalleryEntryPrint() {	openGalleryEntryPrintWindow(g_imgCurrent);}function openGalleryEntryPrintWindow(imgNr) {	var docURL = document.URL;	var pos = docURL.indexOf("?OpenDocument");	if(pos != "-1") {		docURL = docURL.substring(0, pos);	}	var entryURL = replStr(docURL, "/web/", "/webimagegalleryentryprint/") + "?OpenDocument&img=" + imgNr;		var width = 640;	var height = 480;	var windowWidth =  width + 30;	var windowHeight = height + 130;	var windowX = (screen.width - windowWidth) / 2;	var windowY = (screen.height - windowHeight) / 2;	var parameters = "width=" + windowWidth + ", height=" + windowHeight + ", left=" + windowX + ", top=" + windowY + ", location=no, status=no, toolbar=no, menubar=no, dependent=yes";	var entryWindow = window.open(entryURL, "entry", parameters);	if (entryWindow) entryWindow.focus();		}function closeDivContent() {		stopSlideshow()	hideLr("divContent");	hideLr("divContentShade");}