﻿//Window Resize Code
    window.onload = function(){
	    adjustHeight(document.getElementById('imgTest').height);
    }

    window.onresize = function(){
        document.getElementById('bg-bottomfade').style.top = '0';
    			
        adjustHeight(document.getElementById('imgTest').height);
    }


    function adjustHeight(overall){
        //257 equals the height of the bottom fade.
        //overall equals the height of imgTest.
        /*
         *adjTop equals overall minus the height of the bottom fade. 
         *  This is used to set the top position to position the fade at the bottom.
        */
        var adjTop = overall - 257;
        
        if (document.getElementById("stage").offsetHeight > overall){
            //If the stage is taller than the overall height then adjTop to the height of the stage minus the height of the bottom fade and set the top position.
            adjTop = document.getElementById("stage").offsetHeight - 257; 
            document.getElementById('bg-bottomfade').style.top = adjTop + "px";
        }else{
            //Set the top position of the bottom fade.
            document.getElementById('bg-bottomfade').style.top = adjTop + "px";
        }
        
    }
    
//Blackout
    function blackout(vis) {
        var zindex = 8;
        var opacity = 75
        var opaque = 0.75;
        var bgcolor = '#000000';
        var dark = document.getElementById("blackout");
        var tbody = document.getElementsByTagName("body")[0];
        if (!dark) {
            var tnode = document.createElement("div");
            tnode.style.position = 'fixed';
            tnode.style.zIndex = zindex;
            tnode.style.top = '0px';
            tnode.style.display = 'none';
            tnode.id = 'blackout';
            tbody.appendChild(tnode);
            dark = document.getElementById('blackout');
        }
        if (vis) {
            var pageWidth = '100%';
            var pageHeight = '100%';
            dark.style.opacity = opaque;
            dark.style.MozOpacity = opaque;
            dark.style.filter = 'alpha(opacity=' + opacity + ')';
            dark.style.zIndex = zindex;
            dark.style.backgroundColor = bgcolor;
            dark.style.width = pageWidth;
            dark.style.height = pageHeight;
            dark.style.display = 'inline';
        } else {
            dark.style.display = 'none';
        }
    }

    function showarea(div) {
        blackout(true);
        document.getElementById(div).style.display = "inline";

        if (window.pageYOffset) {
            var pop = window.pageYOffset + 15;
            document.getElementById(div).style.top = pop + 'px';
        } else {
            var pop = document.documentElement.scrollTop + 15;
            document.getElementById(div).style.top = pop + 'px';
        }
    }

    function cancel(div) {
        document.getElementById(div).style.display = "none";
        blackout(false);
    }
    
//Button Rollovers
    function btnRO_On(btn){
        document.getElementById(btn).style.backgroundImage = 'url(/images/btn_bg2.jpg)';
    }
    
    function btnRO_Off(btn){
        document.getElementById(btn).style.backgroundImage = 'url(/images/btn_bg.jpg)';
    }
