/* =========================== */
/*  LUSANET GALLERY MODULE     */
/*  VERSIE 1.0.00              */
/*  2010 KW 1                  */
/* =========================== */
/*  © 2010 LuSaneT Group       */
/*  www.lusanet.nl             */
/* =========================== */
/*  Fotoalbum                  */
/*  includes/gallery.js        */
/* =========================== */

	var IE = document.all?true:false;
	
	// =========================
	//  WINDOW FORMAAT OPHALEN 
	// =========================
		 function getWindowSize() {
			var myWidth = 0, myHeight = 0;
			if( typeof( window.innerWidth ) == 'number' ) {
				//Non-IE
				myWidth = window.innerWidth;
				myHeight = window.innerHeight;
			}
			else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
				//IE 6+ in 'standards compliant mode'
				myWidth = document.documentElement.clientWidth;
				myHeight = document.documentElement.clientHeight;
			}
			else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
				//IE 4 compatible
				myWidth = document.body.clientWidth;
				myHeight = document.body.clientHeight;
			}
			
			return [myWidth, myHeight];
		 }
	 
	// ====================
	//  SCROLL TOP BEPALEN 
	// ====================
		function getScrollHeight() {
		   var h = window.pageYOffset ||
		           document.body.scrollTop ||
		           document.documentElement.scrollTop;
		           
		   return h ? h : 0;
		}
	 
	// =========================
	//  GALLERY LAYER WEERGEVEN 
	// =========================
		function openGalleryLayer() {				
			// Venster centreren
				var imageWidth = document.getElementById("galleryLayerImage").style.width.replace('px', '');
				var imageHeight = document.getElementById("galleryLayerImage").style.height.replace('px', '');
				var windowLeft = document.getElementById("wrapper").offsetLeft;
				var windowTop = (getWindowSize()[1] - imageHeight) / 2;
					
				// Vanaf wrapper positie gaan we centreren
					if(imageWidth < 998) {
						windowLeft += (1000 - imageWidth) / 2;
					}

				// Voorkom dat het venster buiten het scherm valt
					if(windowLeft < 0) {
						windowLeft = 0;
					}
					
					if(windowTop < 0) {
						windowTop = 0;
					}

				document.getElementById("galleryLayerWindow").style.width = imageWidth+"px";
				document.getElementById("galleryLayerWindow").style.marginLeft = windowLeft+"px";
				document.getElementById("galleryLayerWindow").style.marginTop = windowTop + getScrollHeight() +"px";
				
			// Layer weergeven
				document.getElementById("galleryLayer").style.display = "block";
				
			// IE snapt de left = 0, right = 0 niet...
				if(IE) {
					document.getElementById("galleryLayer").style.width = getWindowSize()[0]+"px";
				}				

		}
	
	// =======================
	//  PHOTO LAYER VERBERGEN 
	// =======================
		function closeGalleryLayer() {
			document.getElementById("galleryLayer").style.display = "";
		}
