// ----------------------------------------------------------------------------------------------------
// image.js - Image JavaScript Part
// ----------------------------------------------------------------------------------------------------
var IMAGE = {
	showEnlarged : function(imgref) {
		var msie = (navigator.userAgent.indexOf('MSIE') != -1);
		var ovl = document.createElement('DIV');
		var big = document.createElement('IMG');
		
		ovl.className = 'FadingOverlay';
		ovl.style.width = Math.max(document.body.clientWidth,document.body.scrollWidth);
		ovl.style.height = Math.max(document.body.clientHeight,document.body.scrollHeight);
		document.body.appendChild(ovl);
		
		var opacity = 0;
		var fadeIn = function() {
		    if (opacity < 8) {
		       opacity++ ;
		       if (msie)
			       ovl.style.filter = 'Alpha(opacity=' + (opacity * 10) + ')';
			   else
			       ovl.style.opacity = (opacity / 10);
		       window.setTimeout(fadeIn,10);
		    }
		    else {
		        big.alt = big.title = 'Bild verkleinern mit Mausklick';
		        big.src = imgref.src.replace(/^(.*)\.(.*)$/,'$1.large.$2');
		        big.className = 'DetailedImage';
		        big.onload = function(event) {
		            document.body.appendChild(big);
		            big.style.top = parseInt((document.body.clientHeight - big.offsetHeight) / 2) + 'px';
		            big.style.left = parseInt((document.body.clientWidth - big.offsetWidth) / 2) + 'px';
					big.style.visibility = 'visible';
		            ovl.onclick = big.onclick = function(event) {
		                if (msie) {
		                    location.reload();
		                }
		                else {
							big.style.visibility = 'hidden';
							document.body.removeChild(big);

							var fadeOut = function() {
							    if (opacity > 0) {
							       opacity -= 1;
							       ovl.style.opacity = (opacity/10);
							       window.setTimeout(fadeOut,10);
							    }
							    else
							        document.body.removeChild(ovl);
							};
							window.setTimeout(fadeOut,10);
		                }
		            };
		        };
		    }
		};
		window.setTimeout(fadeIn,10);
	}
}
// ----------------------------------------------------------------------------------------------------
// end of image.js
// ----------------------------------------------------------------------------------------------------

