/**
 * @author Ejnar
 */
 
            var imgNr = 1;
            var wheelCells;
            var cellsCount;
            var galleryImg = new Image();
            var galleryNextImg = new Image();
            var galleryPrevImg = new Image();
            var galleryOpen = 0;
            var wasBefore = 0;
			
            
            function loadNext(a){
                galleryNextImg.src = imgPlace + a + ".jpg";
            };
            
            function loadPrev(a){
                galleryPrevImg.src = imgPlace + a + ".jpg";
            };
            
            function showGallery(b){
            	if (galleryOpen < 1)
            	{
            		wasBefore = window.pageYOffset;
            		window.scrollTo(0,0);
            		galleryOpen = 1;
            	};
                document.getElementById("galleryImg").src = "../../graphics/timerGif.gif";
                imgNr = b;
                loadNext(b + 1);
                loadPrev(b - 1);
                galleryImg.src = imgPlace + b + ".jpg";
				
				 /* get the total number of images (cells of the wheelTable) for the counter */
                    wheelCells = document.getElementById("galleryWheelTable").getElementsByTagName("td");
                    cellsCount = wheelCells.length;
                    document.getElementById("galleryImgNr").innerHTML = b + "/" + cellsCount;
                    var newTitle = "&nbsp;&nbsp;&nbsp;&nbsp;" + document.getElementById("galleryThumb" + b).title;
                    document.getElementById("galleryImg").title = newTitle;
                    document.getElementById("galleryTxtTitle").innerHTML = newTitle;
				
                function runGallery(){
					document.getElementById("galleryImg").src = galleryImg.src;
                    document.getElementById("galleryHolder").style.visibility = "visible";
                };
                function setWH(){
                    var galleryH = galleryImg.height;
                    var galleryW = galleryImg.width;
                    document.getElementById("galleryFrame").style.height = galleryH + 60 + "px";
                    document.getElementById("galleryFrame").style.width = galleryW + 20 + "px";
                    document.getElementById("galleryImgHolder").style.height = galleryH + 50 + "px";
                    document.getElementById("galleryImgHolder").style.width = galleryW + "px";
                    runGallery();
                };
                galleryImg.onload = setWH;
                
            };
            function hideGallery(){
                document.getElementById("galleryHolder").style.visibility = "hidden";
                galleryOpen = 0;
                window.scrollBy(0,wasBefore);
            };
            function galleryNext(){
                if (imgNr < cellsCount) {
                    showGallery(imgNr + 1);
                }
                else {
                    showGallery(1);
                };
                };
            function galleryPrev(){
                if (imgNr >= 2) {
                    showGallery(imgNr - 1);
                }
                else {
                    showGallery(cellsCount);
                };
                };
