/*
* Copyright 2008 Municipality of Ancona
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

var divSuffix = "-page-";

//Initialize view of all summaries
function summaryPagerInit(divPrefix) {
    if (document.getElementById) {
        for (var i=0; i<divPrefix.length; i++)
            showHidePage(divPrefix[i], 1);
    }     
}

//Show / Hide a summary Page
function showHidePage(divPrefix, pageNum) {
    var currentPage = 1;
    var completeDivId = divPrefix + divSuffix + currentPage;
    if (document.getElementById) {
        // Get current visible section
        var element = document.getElementById(completeDivId);
        while (element != null) {           	    
            // Toggle sections visibility
            if (currentPage == pageNum) 
                showDiv(completeDivId);
            else
                hideDiv(completeDivId);  
                
            currentPage++;
            
            // Cycle through other divs
            completeDivId = divPrefix + divSuffix + currentPage;
            element = document.getElementById(completeDivId)
        } 
    }
}

//Hides a div
function hideDiv(divName) 
{
    if (document.getElementById) 
    { 
        // DOM3 = IE5, NS6
        var theDiv = document.getElementById(divName);
        if (theDiv != null) {
            theDiv.style.display = 'none';
            theDiv.style.visibility = 'hidden';
        }
    }
}

//Shows a Div
function showDiv(divName) {
    if (document.getElementById) 
    { 
        // DOM3 = IE5, NS6
        var theDiv = document.getElementById(divName);
        if (theDiv != null) {
            theDiv.style.display = 'block';
            theDiv.style.visibility = 'visible';
        }
    }
}
