/* Author = DigS-Gov Projekt
* Fade options of the background
*/
var activeLayer = "layer1";

//function to return inactive layer
function getInactiveLayer() {
    return activeLayer == "layer2" ? "layer1" : "layer2";
}

//function to switch active layer
function switchLayer() {
    activeLayer == "layer1" ? activeLayer = "layer2" : activeLayer = "layer1";
}

//function to crossfade layers
function crossFade() {
    switchLayer();
    document.getElementById(getInactiveLayer()).style.zIndex = "0";
    document.getElementById(activeLayer).style.zIndex = "1";
    document.getElementById(activeLayer).style.opacity = "100%";
    document.getElementById(getInactiveLayer()).style.opacity = "0%";
}

//function to fade to black
function fadeToBlack() {
    document.getElementById(activeLayer).style.opacity = "0%";
    document.getElementById(getInactiveLayer()).style.opacity = "100%";
    document.getElementById(getInactiveLayer()).style.backgroundImage = "none";
    document.getElementById(getInactiveLayer()).style.backgroundColor = "#000";
    window.setTimeout(fadeBack,1000);
}

function fadeToBlack_slow() {
    document.getElementById(activeLayer).style.opacity = "0%";
    document.getElementById(getInactiveLayer()).style.opacity = "100%";
    document.getElementById(getInactiveLayer()).style.backgroundImage = "none";
    document.getElementById(getInactiveLayer()).style.backgroundColor = "#000";
    window.setTimeout(fadeBack, 2000);
}

//function to fade to black
function fadeToGrey() {
    document.getElementById(activeLayer).style.opacity = "20%";
    document.getElementById(getInactiveLayer()).style.opacity = "100%";
    document.getElementById(getInactiveLayer()).style.backgroundImage = "none";
    document.getElementById(getInactiveLayer()).style.backgroundColor = "#000";
    // window.setTimeout(fadeBack, 1000);
}

//function to return from black to scene
function fadeBack() {
    document.getElementById(activeLayer).style.opacity = "100%";
    document.getElementById(getInactiveLayer()).style.opacity = "0%";
}

//function to fade to white
function fadeToWhite() {
    document.getElementById(activeLayer).style.opacity = "0%";
    document.getElementById(getInactiveLayer()).style.opacity = "100%";
    document.getElementById(getInactiveLayer()).style.backgroundImage = "none";
    document.getElementById(getInactiveLayer()).style.backgroundColor = "#fff";
    window.setTimeout(fadeBack,1000);
}