function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "block";
}
function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }
}

var origWidth, origHeight;
if (document.layers) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

//layers = array of layer ids
//defaultLayerId = id of the layer to show by default
function LayerManager(layers, defaultLayerId)
{
    this._isInitialized = false;
    this._layers = layers;
    
    if (defaultLayerId)
    {
        this._defaultLayerId = defaultLayerId;
    }
    else
    {
        if (layers.length > 0)
        {
            this._defaultLayerId = layers[0];
        }
    }
    
    this._currentLayerId = this._defaultLayerId;
}
LayerManager.prototype.Initialize = function()
{
    // initially hid all layers
    for (var index = 0; index < this._layers.length; index++)
    {
        var el = document.getElementById(this._layers[index]);
        
        if (el)
        {
            if (el.id == this._defaultLayerId)
            {
                el.style.display = "block";
                this._currentLayer = el;
            }
            else
            {
                el.style.display = "none";
            }
        }
        
        if (!this._currentLayer)
        {
            this._currentLayer = document.getElementById(this._layers[0]);
        }
    }
    
    this._isInitialized = true;
}
LayerManager.prototype.Show = function(layerId)
{
    if (!this._isInitialized)
    {
        this.Initialize();
    }
    
    if (this._currentLayer && this._currentLayer.id != layerId)
    {
        var el = document.getElementById(layerId);
        
        if (el)
        {
            el.style.display = "block";
            this._currentLayer.style.display = "none";
            this._currentLayer = el;
            this._currentLayerId = el.id;
        }
    }
    
    return false;
}

var cur_lyr = "lyr1";	// holds id of currently visible layer
function swapLayers(id) {
  if (cur_lyr) hideLayer(cur_lyr);
  showLayer(id);
  cur_lyr = id;
}

function showLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "visible";
}

function hideLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "hidden";
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}


