   
function SetTabStyles(listItem, bodyID) {
    var listItemID = 0;
    var listObj = document.getElementById("GlryTabs");
    if (listObj) {
        var listObjChilds = listObj.getElementsByTagName("li");

        // last listitem is no tab
        var listObjChildsCount = listObjChilds.length - 1;

        for (var k = 0; k < listObjChildsCount ; k++) {
            if (listObjChilds[k].id == listItem) {
                listItemID = k;
            }
        }
        for (var i = 0; i < listObjChildsCount ; i++) {
            if ((i < (listItemID - 1)) || (i > (listItemID + 1))) {
                SetTabAnchorStyle(listObjChilds[i], 'GlryBtnStd');
            } 
            if (i == listItemID) {
                SetTabAnchorStyle(listObjChilds[i], 'GlryBtnActive');
            } 
            if (i == (listItemID + 1)) {
                SetTabAnchorStyle(listObjChilds[i], 'GlryBtnShadow');
            } 
            if (i == (listItemID - 1)) {
                SetTabAnchorStyle(listObjChilds[i], 'GlryBtnLeftSibling');
            }
        }
        var objLastTabShadow = document.getElementById("LastTabShadow");
        if (objLastTabShadow) {
            objLastTabShadow.style.display = (listItemID == (listObjChildsCount - 1)) ? "inline" : "none";
        }
    }
    for (var j = 0; j <= 5; j++) {
        var GlryTabBody = document.getElementById("GlryTabBody" + j);
        if (GlryTabBody) {
            if (GlryTabBody.id == "GlryTabBody" + bodyID) {
                GlryTabBody.style.display = "block";
            } else {
                GlryTabBody.style.display = "none";
            } 
        }
    }
}

function SetTabAnchorStyle(listItem, className) {
    var anchors = listItem.getElementsByTagName("a");
    anchors[0].className = className;
}


    var CurrentImageIdx = 0;
        
    function ShowHideLightbox(visible, idx) {
        var objQuickfinder = document.getElementById('Quickfinder');
        if (objQuickfinder) { 
            objQuickfinder .style.display = (visible == true) ? "none" : "inline";
        }
        var objOverlay = document.getElementById('Overlay');
        if (objOverlay) { 
            objOverlay.style.display = (visible == true) ? "block" : "none"; 
            if (visible == true) {
                resizeOverlay();
                if (idx >= 0) {
                    OpenImageIdx = (idx > (GalleryImages.length - 1)) ? CurrentImageIdx : idx;
                    CurrentImageIdx = OpenImageIdx;
                    BrowseLightbox(0);
                }
            }
        }
        var objLightbox = document.getElementById('LightboxContainer')
        if (objLightbox) { 
            objLightbox.style.display = (visible == true) ? "block" : "none";
        } 
    }
    
    function BrowseLightbox(pageIncrement) {
        if (GalleryImages.length == 0) return;
        var NextImageIdx = CurrentImageIdx + pageIncrement;
        NextImageIdx = (NextImageIdx > (GalleryImages.length - 1)) ? 0 : NextImageIdx;
        NextImageIdx = (NextImageIdx < 0) ? (GalleryImages.length - 1) : NextImageIdx;
        
        var ImageObj= document.getElementById('LightboxImage');
        if (ImageObj) {
            ImageObj.src = GalleryImages[NextImageIdx][0];
            var LightboxObj= document.getElementById('Lightbox');
            if (LightboxObj) {
                LightboxObj.style.width = (GalleryImages[NextImageIdx][2] + 60) + "px";
                resizeOverlay();
            }
        }
        
        var DownloadObj = document.getElementById('LightboxDownload');
        if (DownloadObj) {
            if (GalleryImages[NextImageIdx][1] != "") {
                DownloadObj.style.display = "inline";
                DownloadObj.href = "/php/download.php?d="+encodeURIComponent(GalleryImages[NextImageIdx][1]);
            } else {
                DownloadObj.style.display = "none";
            }
        }
        
        SetLightboxPager(NextImageIdx);
        
        CurrentImageIdx = NextImageIdx;
    }
   
    function SetLightboxPager(currentIdx, txt) {
        var PagerObj = document.getElementById('LightboxPager');
        if (PagerObj) {
              PagerObj.innerHTML = (currentIdx + 1) + " " +txmofn+" "+ GalleryImages.length;
        }
    }
    
    //SetLightboxPager(CurrentImageIdx);
    
    function resizeOverlay() {
        var obj = document.getElementById('Overlay');
        if (obj) {
           var arrayPageSize = getPageSize();
           obj.style.width = arrayPageSize[0] + 'px';
           obj.style.height = arrayPageSize[1] + 'px';
       }
    } 
    
    //
    // getPageSize()
    // Returns array with page width, height and window width, height
    // Core code from - quirksmode.com
    // Edit for Firefox by pHaez
    //
    function getPageSize(){
        
        var xScroll, yScroll;
        
        if (window.innerHeight && window.scrollMaxY) {    
            xScroll = window.innerWidth + window.scrollMaxX;
            yScroll = window.innerHeight + window.scrollMaxY;
        } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
            xScroll = document.body.scrollWidth;
            yScroll = document.body.scrollHeight;
        } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
            xScroll = document.body.offsetWidth;
            yScroll = document.body.offsetHeight;
        }
        
        var windowWidth, windowHeight;
            
        if (self.innerHeight) {    // all except Explorer
            if(document.documentElement.clientWidth){
                windowWidth = document.documentElement.clientWidth; 
            } else {
                windowWidth = self.innerWidth;
            }
            windowHeight = self.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
            windowWidth = document.documentElement.clientWidth;
            windowHeight = document.documentElement.clientHeight;
        } else if (document.body) { // other Explorers
            windowWidth = document.body.clientWidth;
            windowHeight = document.body.clientHeight;
        }    
        
        // for small pages with total height less then height of the viewport
        if(yScroll < windowHeight){
            pageHeight = windowHeight;
        } else { 
            pageHeight = yScroll;
        }
    
        // for small pages with total width less then width of the viewport
        if(xScroll < windowWidth){    
            pageWidth = xScroll;        
        } else {
            pageWidth = windowWidth;
        }
    
        arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);

        return arrayPageSize;
    }