function openDialogWindow(sUrl, vArguments, sFeatures)
{
    var availWidth = window.screen.availWidth;
    var availHeight = window.screen.availHeight;
    var featuresSpec = sFeatures.replace(/dialogHeight=100%/, ("dialogHeight=" + availHeight)).replace(/dialogWidth=100%/, ("dialogWidth=" + availWidth));
    
    if (window.showModalDialog != undefined)
    {
        // IE browser
        var returnValue = window.showModalDialog (sUrl, vArguments, featuresSpec);
        featuresSpec += ";resizable:1";
        if (returnValue != undefined && returnValue == "reload") window.location.reload();
    } 
    else
    {
        // Non-IE; eg Firefox
        var featuresSpec = featuresSpec.replace(/;/g, ",").replace(/:/g, "=").replace(/dialogHeight/g, "height").replace(/dialogWidth/g, "width");
        featuresSpec += ",resizable=1";
        window.open (sUrl, vArguments, featuresSpec);
    }
}

function closeWindowAndRefreshParent()
{
    if (window.showModalDialog != undefined)
    {
        // IE browser
        window.returnValue = "reload";
    }
    else
    {
        // Non-IE; eg Firefox
        if (window.opener != null) window.opener.location.reload();
    }
    window.close();
}

function showHide(checkbox, id)
{
    var webPart = document.getElementById(id);
    var table = webPart.childNodes[0];
    table.style.display = checkbox.checked ? "block" : "none"; 
}

function SelectCurrentNavigation(applicationContext)
{
    var navNodes = getElementsByClassName("ealpNavHeader", "table", document.getElementById("mainLeft"));
    if (navNodes != null)
    {
        for (var i = 0; i < navNodes.length; i++)
        {
	        var spanNodes = navNodes[i].getElementsByTagName("span");
            if (spanNodes != null)
            {
		        var navContext =  spanNodes[0].innerHTML;
                if (navContext.toLowerCase() == applicationContext.toLowerCase())
                {
                    navNodes[i].className = navNodes[i].className + " ealpNavItemSelected";

	    	        var linkNodes = getElementsByClassName("ealpNavHeader", "a", navNodes[i]);
                    if (linkNodes != null && linkNodes.length == 1)
                    {
		                linkNodes[0].className = linkNodes[0].className + " ealpNavItemSelected";
                    }
                    
                    break;
                }
            }
        }
    }
}