var active = 1;
var max;
var url;
var base;

function setSection(_max)
{
    max = _max;
    var aLocation = document.location.toString().split("#");
    base = aLocation.length>1?aLocation[0]:aLocation;
    showSection(aLocation.length>1?aLocation[1]:1);
}

function prev()
{
    if(active>1)
    {
        document.location = base+"#"+(parseInt(active)-1);
        showSection(parseInt(active)-1);
    }
}
function next()
{
    if(active<max)
    {
        document.location = base+"#"+(parseInt(active)+1);
        showSection(parseInt(active)+1);
    }
}
function showSection(section)
{
    hiddenOldSection();
    document.getElementById("section"+section).style.display = "block";
    document.getElementById("count"+section).className  = "count active";
    active = section;

    if(active<=1)
    {
        document.getElementById("imgPrev").style.visibility = "hidden";
    }
    else
    {
        document.getElementById("imgPrev").style.visibility = "visible";
    }
    if(active>=max)
    {
        document.getElementById("imgNext").style.visibility = "hidden";
    }
    else
    {
        document.getElementById("imgNext").style.visibility = "visible";
    }
    window.scrollTo(0,0);
}
function getNextIndex(){
    return active+1;
}
function hiddenOldSection()
{
    var _active = active==undefined?1:active;
    document.getElementById("section"+_active).style.display = "none";
    document.getElementById("count"+_active).className  = "count";
}

var old = null;
function layerOpen(layer){
    if(old!=null){
        document.getElementById(old).style.display = "none";
        document.getElementById("link"+old).className = "";
    }
    document.getElementById(layer).style.display = "block";
    document.getElementById("link"+layer).className = "active";
    old=layer;
}