


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

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

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

			return -1;
		}

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

		function frameScroll() {
		}

		/* ------------------------------------------------------------------------------------------
		 * link inline/outline presentation
		 */
		function frameControlIn(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) { frameInline(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.appendChild(newTxt(' '));
			obj.appendChild(  onbody);
			obj.appendChild(anwindow);
		}

		function frameControlOut(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.lastChild.id == 'CTRLOutline') obj.removeChild(obj.lastChild);
				if (obj.lastChild.id == 'CTRLInline' ) obj.removeChild(obj.lastChild);
			}

			return check;
		}

		/* ------------------------------------------------------------------------------------------
		 */
		function frameDisplaying(evt, obj) {
			var pict = getObj('fbframe');
			var frmp = pict.lastChild;

			/* try to resize the iframe to the real width 4:3 */
			try {
				frmp.width  = measureFrameWidth('popframe');
				frmp.height = Math.floor(parseInt(frmp.width * 3) / 4);
			} catch(e) {}

			/* 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 link-size */
					var toBeX = parseInt(frmp.width );
					var toBeY = parseInt(frmp.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 */
						if (pict.firstChild.src.match(/circle/))
							pict.removeChild(pict.firstChild);

						/* shift the link to the correct position */
					//	frmp.style.display = 'none';
						frmp.style.position = '';
						frmp.style.top	= '0px';
						frmp.style.left	= '0px';
					//	frmp.style.display = 'block';

						if (MSIE && frmp.onload)
							frmp.detachEvent('onload', frmp.onload);

						frmp.onload = null;
					}
				},
				100
			);
		}

		function frameRemoving() {
			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 */
						frameRemove();
					}
				},
				10
			);
		}

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

		function frameSet(pos, grp) {
			var directory = (grp ? getElms(grp) : null);

			if (directory)
				frameInsert(directory.item(pos), true);
		}

		function frameSlideshow(pos, grp) {
			var directory = (grp ? getElms(grp) : null);
			var cche = getObj('centerflow');
			var pict = getObj('fbframe');
			var frmp = getObj('fbpreview');

			/* we are possibly gone! */
			if (directory && cche) {
				/* throw in the link without nav */
			//	if (framePosition(pict.lastChild) != pos)
					frameInsert(directory.item(pos), !(pos < directory.length - 1));

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

					/* trigger swap after 4 seconds after the link is loaded */
					frmp.id         = 'fbpreview';
					frmp.style.position = 'absolute';
					frmp.style.top	= '-10000px';
					frmp.style.left	= '-10000px';
					frmp.width      = '800px';
					frmp.height     = '600px';

					frmp.frameBorder   = 0; frmp.setAttribute('frameborder',  0);
					frmp.marginHeight  = 0; frmp.setAttribute('marginwidth',  0);
					frmp.marginWidth   = 0; frmp.setAttribute('marginheight', 0);
					frmp.style.padding = '0px';

					if (MSIE) {
						if (slideShowOnLoad/*frmp.onload*/)
							frmp.detachEvent('onload', slideShowOnLoad/*frmp.onload*/);
						frmp.attachEvent('onload', slideShowOnLoad/*frmp.onload*/ =
							function (e) { setTimeout(function () { frameSlideshow(pos + 1, grp); }, slideShowTime); });
					}
					else
						frmp.onload	=
							function (e) { setTimeout(function () { frameSlideshow(pos + 1, grp); }, slideShowTime); };

					/* insert the structure */
					if (cche)
						cche.appendChild(frmp);

					frmp.src = directory.item(pos + 1).href;
				}
				else if (frmp)
					/* remove the structure */
					cche.removeChild(frmp);
			}
		}

		/* ------------------------------------------------------------------------------------------
		 */
		function frameInsert(obj, nav) {
			var directory = (obj.name ? getElms(obj.name) : null);
			var pos  = framePosition(obj);
			var ttlm = getObj('fbtitlem');
			var pict = getObj('fbframe');
			var foot = getObj('fbfooter');
			var show = newElm('img');
			var frmp = newElm('iframe');
			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 frame-area */
			while (pict.firstChild)
				pict.removeChild(pict.firstChild);

			show.src		= root + 'pics/loading-circle.gif';
			show.style.padding = '5em';
			frmp.style.position = 'absolute';
			frmp.style.top	= '-10000px';
			frmp.style.left	= '-10000px';
			frmp.width      = '800px';
			frmp.height     = '600px';
			frmp.name		= 'popframe';

			frmp.frameBorder   = 0; frmp.setAttribute('frameborder',  0);
			frmp.marginHeight  = 0; frmp.setAttribute('marginwidth',  0);
			frmp.marginWidth   = 0; frmp.setAttribute('marginheight', 0);
			frmp.style.padding = '0px';

			if (MSIE)
				frmp.attachEvent('onload', frmp.onload =
					function (e) { frameDisplaying(e, obj); });
			else
				frmp.onload	=
					function (e) { frameDisplaying(e, obj); };

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

			pict.appendChild(show);
			pict.appendChild(frmp);
			foot.innerHTML	= '<a href="' + obj.href + '" target="' + obj.target + '">' + obj.innerHTML + '</a>';

			/* then throw in the pre-load of the link */
			frmp.src		= obj.href;
		}

		function frameLoading(evt, obj) {
			var directory = (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 = 'frameback';
			rgt1.id = 'fbtitle';
			ttll.id = 'fbtitlel';
			ttlm.id = 'fbtitlem';
			ttlr.id = 'fbtitler';
			pict.id = 'fbframe';
			foot.id = 'fbfooter';
			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) { frameFull(e, obj); };
			scrl.src		= root + 'box/pics/scroll.png'; scrl.title = 'original'; scrl.style.visibility = 'hidden';
			scrl.onclick	= function (e) { frameScroll(e, obj); };
			strp.src		= root + 'box/pics/strip.png'; strp.title = 'slide-show';
			strp.onclick	= function (e) { frameSlideshow(0, obj.name); };
			clse.src		= root + 'box/pics/close.png'; clse.title = 'close'; clse.id = 'close';
			clse.onclick	= function (e) { frameRemoving(); };

			/* construct the structure */
			ttll.appendChild(full);
			ttll.appendChild(scrl); if (directory && (directory.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 link */
			frameInsert(obj, true);
		}

		/* ------------------------------------------------------------------------------------------
		 */
		function frameInline(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);

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

			window.scrollTo(0, 0);

			/* 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 frame */
						frameLoading(evt, obj);
					}
				},
				50
			);
		}

		/* ------------------------------------------------------------------------------------------
		 */
		function frameRemove() {
			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);
		}
