

var currentSection = 5;
var totalSections = 11;
var imgArr = Array();



function preloadImages(){
    var i=0;
    for(i=0; i< totalSections; i++){
        imgArr[i] = new Image();
        imgArr[i].src = 'img/samplereport/section' + i + 'img.jpg';
    }
}

function closeAll(){
    var sec = 0;
    var box = 1;
    var secEl = null;
    var boxEl = null;
    while (1){
        secEl=document.getElementById('mSection' + sec);
        box = 1;
        if (secEl == null){
            break;
        }
        while (1){
            boxEl = document.getElementById('mS_'+sec+'_'+box);
            if (boxEl == null){
                break;
            } else {
                boxEl.style.display = 'none';
            }
            box++;
        }
        sec++;
    }
    return;
}


function showSection(newSection){
    var i=0;
    closeAll();
    while(1){
        var el=document.getElementById('mSection' + i);
        if (el == null){
            break;
        }
        el.style.display = 'none';
        i++;
    }
    el = document.getElementById('mSection'+newSection);
    if (el == null){return;}
    el.style.display='block';
    
    i=0;
    while(1){
        el = document.getElementById('smenu'+i)
        if (el == null){
            break;
        }
        el.className = '';
        i++;
    }
    el = document.getElementById('smenu'+newSection);
    if (el == null){return;}
    el.className='smenuCurrent';
    
    currentSection = newSection;
    el = document.getElementById('mboxNP');
    if (currentSection==0){
        el.innerHTML = '<a href="javascript:shownext();">Next</a> &raquo;'; 
    } else if (currentSection==10){
        el.innerHTML = '&laquo; <a href="javascript:showprevious();">Previous</a>'; 
    } else{
        el.innerHTML = '&laquo; <a href="javascript:showprevious();">Previous</a> | <a href="javascript:shownext();">Next</a> &raquo;'; 
    }
    
    return;
}


function showinfobox(sec, box){
    var i=1;
    while(1){
        var el = document.getElementById('mS_'+sec+'_'+i)
        if (el == null){break;}
        el.style.display='none';
        i++;
    }
    el=document.getElementById('mS_'+sec+'_'+box);
    el.style.display='block'
}

function closeinfobox(sec, box){
    var el=document.getElementById('mS_'+sec+'_'+box);
    if (el==null){return;}
    el.style.display='none';
    return;
}

function showprevious(){
    var n = currentSection-1;
    var el = document.getElementById('mSection'+n);
    if (el == null){return;} else {showSection(n);}
    return;
}

function shownext(){
    var n = currentSection+1;
    var el = document.getElementById('mSection'+n);
    if (el == null){return;} else {showSection(n);}
    return;
}


