var activeNav = 0;
var activeSubNav = 0;

function roll(id) 
{
    hideSubNav();
	if (document.getElementById("snm_" + id)) {
	    activeNav = id;
	    document.getElementById("snm_" + id).style.display = "block";
	    document.getElementById("snm_" + id).style.visibility = "visible";
	}
}

function unroll(id) 
{
    if (activeNav != id) {
	    if (document.getElementById("snm_" + id)) {
	        document.getElementById("snm_" + id).style.display = "none";
	        document.getElementById("snm_" + id).style.visibility = "hidden";
	        activeNav = 0;
	    }
	}
	setNav();
}

function sub_roll(mid,sid) 
{
    hideSubNav();
	document.getElementById("snm_" + mid).style.display = "block";
	document.getElementById("snm_" + mid).style.visibility = "visible";
	
}

function sub_unroll(mid,sid) 
{
	document.getElementById("snm_" + mid).style.display = "none";
	document.getElementById("snm_" + mid).style.visibility = "hidden";
	setNav();
}

function setNav() 
{
	if (activeNav != 0) {
	    if (document.getElementById("n" + activeNav)) {
	        document.getElementById("snm_" + activeNav).style.display = "block";
	        document.getElementById("snm_" + activeNav).style.visibility = "visible";
	    }
	}
}

function hideSubNav() 
{
	if (activeNav != 0 && document.getElementById("snm_" + activeNav)) {
	    document.getElementById("snm_" + activeNav).style.display = "none";
	    document.getElementById("snm_" + activeNav).style.visibility = "hidden";
	}
}

var ogch = 0; // original content height

function doWhite() {
    
    var wh = WindowHeight();
    var ch; // content height
    if (ogch==0) {
        ch = $("#site_contentheight").height()-15;
        ogch = ch;
    } else {
        ch = ogch;
        ogch = 0;
    }
    
    var check;
    if (ch<wh) {
        //alert('content is shorter than window ch = ' + ch + ', win = ' + wh);
        check = wh-ch;
        if (check<=30) {
            ch = wh-45;
        } else {
            ch = wh-65;
        }
    } else if (ch>wh) {
        //alert('content is taller than window = ' + ch + ', win = ' + wh);
        ch = ch;
    }else {
//        browser adjustments for white background on body content
//        alert('con = ' + cf + ', win = ' + wh);
//        if ($.browser.safari) {
//            ch = 552;
//        } else if ($.browser.msie) {
//            ch = 547;
//        } else if ($.browser.mozilla) {
//            ch = 552;
//        } else if ($.browser.opera) {
//            ch = 548;
//        }
    }
    $("#WhiteHeight").attr("style","height:"+ch+"px;background:url('/images/white-opacity-50.png');background-repeat:repeat-y;background-position:center top;");
}

function doHeight() {

    var wh = WindowHeight();
    var ch; // content height
    if (ogch == 0) {
        ch = $("#site_contentheight").height() - 15;
        ogch = ch;
    } else {
        ch = ogch;
        ogch = 0;
    }

    var check;
    if (ch < wh) {
        //alert('content is shorter than window ch = ' + ch + ', win = ' + wh);
        check = wh - ch;
        if (check <= 30) {
            ch = wh - 45;
        } else {
            ch = wh - 65;
        }
    } else if (ch > wh) {
        //alert('content is taller than window = ' + ch + ', win = ' + wh);
        ch = ch;
    } else {
        //        browser adjustments for white background on body content
        //        alert('con = ' + cf + ', win = ' + wh);
        //        if ($.browser.safari) {
        //            ch = 552;
        //        } else if ($.browser.msie) {
        //            ch = 547;
        //        } else if ($.browser.mozilla) {
        //            ch = 552;
        //        } else if ($.browser.opera) {
        //            ch = 548;
        //        }
    }
    $("#HeightAdjust").height(ch);
}

function WindowHeight() {
    var winY = $(document.window).height();
    return winY;
    
}

