


		/* ----------------------------------------------------------------------------------------
		 * Copyright 2005-2006 gPremper S.A. de C.V
		 * Developed by Niels Fröhling
		 */

		/* ------------------------------------------------------------------------------------------
		 */
		function picturePosition(obj) {
			var gallery = (obj.name ? getElms(obj.name) : null);

			for (var e = 0; gallery && (e < gallery.length); e++)
				if (obj == gallery.item(e))
					return e;

			return -1;
		}

		/* ------------------------------------------------------------------------------------------
		 */
		function pictureFull() {
		}

		function pictureScroll() {
		}

		/* ------------------------------------------------------------------------------------------
		 * image inline/outline presentation
		 */
		function pictureControlIn(evt, obj) {
			var   onbody = newElm('img');
			var onwindow = newElm('img');
			var anwindow = newElm('a');

			var o; if (o = getObj('CTRLOutline')) o.parentNode.removeChild(o);
			var i; if (i = getObj('CTRLInline' )) i.parentNode.removeChild(i);

			/* inline-popup button */
			onbody.id		= 'CTRLInline';
			onbody.src		= root + 'box/pics/zoom-inline.png';
			onbody.onclick	= function (e) { pictureInline(e, obj); return false; };

			/* outline-popup button */
			onwindow.id		= 'CTRLOutlineI';
			onwindow.src	= root + 'box/pics/zoom-outline.png';

			/* link for the outline-popup */
			anwindow.id		= 'CTRLOutline';
			anwindow.href	= obj.href;
			anwindow.title	= obj.title;
			anwindow.target	= obj.target;
			anwindow.appendChild(onwindow);

			/* create structure */
			obj.insertBefore(  onbody, obj.firstChild);
			obj.insertBefore(anwindow, obj.firstChild);
		}

		function pictureControlOut(evt, obj) {
			var te0 = getToTE(evt);

			/* we've left the thumbnail, or not? */
			var check = (te0 == null) ||
						(te0.id == 'CTRLOutline') || (te0.parentNode.id == 'CTRLOutline') ||
						(te0.id == 'CTRLInline' ) || (te0.parentNode.id == 'CTRLInline' );

			/* deconstruct the buttons if yes */
			if (!check) {
				if (obj.firstChild.id == 'CTRLOutline') obj.removeChild(obj.firstChild);
				if (obj.firstChild.id == 'CTRLInline' ) obj.removeChild(obj.firstChild);
			}

			return check;
		}

		/* ------------------------------------------------------------------------------------------
		 */
		function pictureDisplaying(evt, obj) {
			var pict = getObj('pbpicture');
			var imgp = pict.lastChild;

			/* set an initial style (actual size) */
			pict.style.width   = (parseInt(pict.offsetWidth ) - 4) + 'px';
			pict.style.height  = (parseInt(pict.offsetHeight) + 0) + 'px';
			pict.timer = setInterval(
				function () {
					/* interpolate the style to become the image-size */
					var toBeX = parseInt(imgp.width );
					var toBeY = parseInt(imgp.height);
					var isNwX = parseInt(pict.style.width );
					var isNwY = parseInt(pict.style.height);

					var wd = isNwX + ((toBeX + isNwX + 7) >> 3);
					var ht = isNwY + ((toBeY + isNwY + 7) >> 3);
				//	var wd = isNwX + 20;
				//	var ht = isNwY + 20;

        			pict.style.width   = (isNwX = Math.min(wd, toBeX)) + 'px';
        			pict.style.height  = (isNwY = Math.min(ht, toBeY)) + 'px';

					/* stop it if reached */
					if ((isNwX == toBeX) &&
						(isNwY == toBeY)) {
						clearInterval(pict.timer);

						/* remove the loading button */
						pict.removeChild(pict.firstChild);

						/* shift the image to the correct position */
						imgp.style.display = 'none';
						imgp.style.position = '';
						imgp.style.top	= '0px';
						imgp.style.left	= '0px';
						imgp.style.display = 'block';
					}
					else {
						imgp.style.cursor = 'pointer';
						imgp.onclick = getObj('close').onclick;
					}
				},
				100
			);
		}

		function pictureRemoving() {
			var body = getTag('body');
			var blck = getObj('blackback');
			var flow = getObj('centerflow');

			/* initial opacities */
			blck.style.opacity = 0.6; if (MSIE)	// 0.3, 0.15 (0.2), 0.1  (0.1), 0.05 (0.1) ...
			blck.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=60);';
			flow.style.opacity = 1.0; if (MSIE)	// 0.5, 0.25 (0.3), 0.15 (0.2), 0.10 (0.1) ...
			flow.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=100);';
			blck.timer = setInterval(
				function () {
					/* interpolate opacities */
					var xpb, opb = parseFloat(blck.style.opacity);
					var xpf, opf = parseFloat(flow.style.opacity);

					if (opb > 0.0) blck.style.opacity = opb = (xpb = Math.floor(10 * opb / 2)) / 10; if (MSIE) blck.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + (xpb * 10) + ');';
					if (opf > 0.0) flow.style.opacity = opf = (xpf = Math.floor(10 * opf / 2)) / 10; if (MSIE) flow.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + (xpf * 10) + ');';

					/* stop it if reached */
					if ((opb == 0.0) &&
						(opf == 0.0)) {
						clearInterval(blck.timer);

						/* kick it all away */
						pictureRemove();
					}
				},
				10
			);
		}

		/* ------------------------------------------------------------------------------------------
		 */
		var slideShowTime = 4000;

		function pictureSet(pos, grp) {
			var gallery = (grp ? getElms(grp) : null);

			if (gallery)
				pictureInsert(gallery.item(pos), true);
		}

		function pictureSlideshow(pos, grp) {
			var gallery = (grp ? getElms(grp) : null);
			var cche = getObj('centerflow');
			var pict = getObj('pbpicture');
			var imgp = getObj('pbpreview');

			/* we are possibly gone! */
			if (gallery && cche) {
				/* throw in the image without nav */
			//	if (picturePosition(pict.lastChild) != pos)
					pictureInsert(gallery.item(pos), !(pos < gallery.length - 1));

				/* there is another one */
				if (pos < gallery.length - 1) {
					/* we may reuse the object, or not */
					if (!imgp)
				    	imgp = newElm('img');
				    else
				    	cche = null;

					/* trigger swap after 4 seconds after the image is loaded */
					imgp.id         = 'pbpreview';
					imgp.style.position = 'absolute';
					imgp.style.top	= '-10000px';
					imgp.style.left	= '-10000px';
					imgp.onload		= function (e) { setTimeout(function () { pictureSlideshow(pos + 1, grp); }, slideShowTime); };
					imgp.src		= getQueryVariable('image', gallery.item(pos + 1).href);

					/* insert the structure */
					if (cche)
						cche.appendChild(imgp);
				}
				else if (imgp)
					/* remove the structure */
					cche.removeChild(imgp);
			}
		}

		/* ------------------------------------------------------------------------------------------
		 */
		function pictureInsert(obj, nav) {
			var gallery = (obj.name ? getElms(obj.name) : null);
			var pos  = picturePosition(obj);
			var ttlm = getObj('pbtitlem');
			var pict = getObj('pbpicture');
			var foot = getObj('pbfooter');
			var show = newElm('img');
			var imgp = newElm('img');
			var temp;

			/* clear the indicator */
			if (typeof ttlm.indicator != 'undefined')
				clearInterval(ttlm.indicator);

			/* clear the title-area */
			while (ttlm.firstChild)
				ttlm.removeChild(ttlm.firstChild);
			/* clear the picture-area */
			while (pict.firstChild)
				pict.removeChild(pict.firstChild);

			show.src		= root + 'pics/loading-circle.gif';
			show.title		=
			show.alt		= 'loading ...';
			show.style.padding = '5em';
			imgp.style.position = 'absolute';
			imgp.style.top	= '-10000px';
			imgp.style.left	= '-10000px';
			imgp.onload		= function (e) { pictureDisplaying(e, obj); };

			/* construct the structure */
		if (gallery && nav) {
			ttlm.appendChild(temp = newElm('div')); temp.appendChild(newTxt('|< ')); if (pos >                  0) temp.onclick = function (e) { pictureSet(                 0, obj.name); }; else temp.style.visibility = 'hidden';
			ttlm.appendChild(temp = newElm('div')); temp.appendChild(newTxt('<< ')); if (pos >                  0) temp.onclick = function (e) { pictureSet(           pos - 1, obj.name); }; else temp.style.visibility = 'hidden';
			ttlm.appendChild(newTxt((pos + 1) + ' / ' + gallery.length));
			ttlm.appendChild(temp = newElm('div')); temp.appendChild(newTxt(' >>')); if (pos < gallery.length - 1) temp.onclick = function (e) { pictureSet(           pos + 1, obj.name); }; else temp.style.visibility = 'hidden';
			ttlm.appendChild(temp = newElm('div')); temp.appendChild(newTxt(' >|')); if (pos < gallery.length - 1) temp.onclick = function (e) { pictureSet(gallery.length - 1, obj.name); }; else temp.style.visibility = 'hidden'; }
		else if (gallery && gallery.length > 1) {
			ttlm.innerHTML = ' ' + (pos + 1) + ' / ' + gallery.length + ' '; if (pos < gallery.length - 1)
			ttlm.indicator = setInterval(function () { var txt = ttlm.innerHTML; ttlm.innerHTML = '.' + txt + '.'; }, Math.floor(slideShowTime / 12)); }

			pict.appendChild(show);
			pict.appendChild(imgp);
			foot.innerHTML	= URLDecode(getQueryVariable('description', obj.href));

			/* then throw in the pre-load of the image */
			imgp.src		= getQueryVariable('image', obj.href);
		}

		function pictureLoading(evt, obj) {
			var gallery = (obj.name ? getElms(obj.name) : null);
			var body = getTag('body');
			/* seems not to work without tables, at least not
			 * easily (means reprogramming a coordinate-system)
			 */
			var flow = newElm('div');
			var cnta = newElm('table');
			var cntb = newElm('tbody');
			var cntr = newElm('tr');
			var cntd = newElm('td');
			var regn = newElm('table');
			var regb = newElm('tbody');
			var rgt1 = newElm('tr');
			var rgt2 = newElm('tr');
			var rgt3 = newElm('tr');
			var ttll = newElm('td');
			var ttlm = newElm('td');
			var ttlr = newElm('td');
			var pict = newElm('td');
			var foot = newElm('td');
			var full = newElm('img');
			var scrl = newElm('img');
			var clse = newElm('img');
			var strp = newElm('img');

			/* setup some basic element-attributes */
			flow.id = 'centerflow';
			cnta.id = 'centerback';
			regn.id = 'pictureback';
			rgt1.id = 'pbtitle';
			ttll.id = 'pbtitlel';
			ttlm.id = 'pbtitlem';
			ttlr.id = 'pbtitler';
			pict.id = 'pbpicture';
			foot.id = 'pbfooter';
			pict.colSpan = 3; pict.setAttribute('colspan', 3);
			foot.colSpan = 3; foot.setAttribute('colspan', 3);
			full.src		= root + 'box/pics/full.png'; full.title = 'scaled'; full.style.visibility = 'hidden';
			full.onclick	= function (e) { pictureFull(e, obj); };
			scrl.src		= root + 'box/pics/scroll.png'; scrl.title = 'original'; scrl.style.visibility = 'hidden';
			scrl.onclick	= function (e) { pictureScroll(e, obj); };
			strp.src		= root + 'box/pics/strip.png'; strp.title = 'slide-show';
			strp.onclick	= function (e) { pictureSlideshow(0, obj.name); };
			clse.src		= root + 'box/pics/close.png'; clse.title = 'close'; clse.id = 'close';
			clse.onclick	= function (e) { pictureRemoving(); };

			/* construct the structure */
			ttll.appendChild(full);
			ttll.appendChild(scrl); if (gallery && (gallery.length > 1))
			ttlr.appendChild(strp);
			ttlr.appendChild(clse);
			rgt1.appendChild(ttll);
			rgt1.appendChild(ttlm);
			rgt1.appendChild(ttlr);
			rgt2.appendChild(pict);
			rgt3.appendChild(foot);
			regb.appendChild(rgt1);
			regb.appendChild(rgt2);
			regb.appendChild(rgt3);
			regn.appendChild(regb);
			cntd.appendChild(regn);
			cntr.appendChild(cntd);
			cntb.appendChild(cntr);
			cnta.appendChild(cntb);
			flow.appendChild(cnta);

			/* copy offset from blackback */
			flow.style.top  = body.firstChild.style.top;
			flow.style.left = body.firstChild.style.left;

			/* insert the structure */
			body.insertBefore(flow, body.firstChild);

			/* start loading the image */
			pictureInsert(obj, true);
		}

		/* ------------------------------------------------------------------------------------------
		 */
		function pictureInline(evt, obj) {
			var body = getTag('body');
			var blck = newElm('div');

			/* our black background to hide the normal content */
			blck.id = 'blackback';

			/* there is a jump of the scrollpos if removing the overflow-property */
			blck.sL = (typeof body.parentNode.scrollLeft != 'undefined' ? body.parentNode.scrollLeft : window.pageXOffset);
			blck.sT = (typeof body.parentNode.scrollTop  != 'undefined' ? body.parentNode.scrollTop  : window.pageYOffset);

			window.scrollTo(0, 0);

//			blck.style.left = blck.sL + 'px';
//			blck.style.top  = blck.sT + 'px';

			/* suppress overflow-bars */ if (MSIE) {
			body.parentNode.style.overflow = 'hidden'; body.parentNode.style.height = '100%'; }
			body.style.overflow = 'hidden';            body.style.height = '100%';
			body.insertBefore(blck, body.firstChild);

			/* re-adjust the position */
//			setTimeout(function () {
//				window.scrollTo(blck.sL, blck.sT);
//
//				/* re-adjust the position (hick-up: bad!) */
//				blck.style.left = (typeof body.parentNode.scrollLeft != 'undefined' ? body.parentNode.scrollLeft : window.pageXOffset) + 'px';
//				blck.style.top  = (typeof body.parentNode.scrollTop  != 'undefined' ? body.parentNode.scrollTop  : window.pageYOffset) + 'px';
//			}, 0);

			/* initial opacities */
			blck.style.opacity = 0.0; if (MSIE)
			blck.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=0);';
			blck.timer = setInterval(
				function () {
					var opc = parseFloat(blck.style.opacity);

					if (opc < 0.6) {
						blck.style.opacity = '' + (opc =
							Math.min(Math.max(opc, 0.1) +
									 Math.max(opc, 0.1), 0.6)); if (MSIE)
						blck.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' +
							Math.floor(opc * 100) + ');';
					}

					/* stop it if reached */
					if (opc >= 0.6) {
						clearInterval(blck.timer);

						/* show the picture */
						pictureLoading(evt, obj);
					}
				},
				50
			);
		}

		/* ------------------------------------------------------------------------------------------
		 */
		function pictureRemove() {
			var body = getTag('body');
			var blck = getObj('blackback');
			var flow = getObj('centerflow');

			/* kill those introduced elements */
			body.removeChild(blck);
			body.removeChild(flow);

			/* get back overflow-bars */ if (MSIE) {
			body.parentNode.style.overflow = ''; body.parentNode.style.height = ''; }
			body.style.overflow = '';            body.style.height = '';

			/* re-adjust the position */
			setTimeout(function () {
				window.scrollTo(blck.sL, blck.sT);
			}, 0);
		}
