String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

function getLayer( layer )
{
	var elem;
        if( document.getElementById ) // this is the way the standards work
                elem = document.getElementById( layer );
        else if( document.all ) // this is the way old msie versions work
                elem = document.all[layer];
        else if( document.layers ) // this is the way nn4 works
                elem = document.layers[layer];

	return elem;
}

//returns a pointer to the style of the layer
function getStyle( layer )
{
        var elem, vis;
        if( document.getElementById ) // this is the way the standards work
                elem = document.getElementById( layer );
        else if( document.all ) // this is the way old msie versions work
                elem = document.all[layer];
        else if( document.layers ) // this is the way nn4 works
                elem = document.layers[layer];

        vis = elem.style;

        // if the style.display value is blank we try to figure it out here
        if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
                vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';

        return vis;
}

//toggle the display value for the given layer (if it is none, it changes to block, and vice versa)
function toggleLayer(layer)
{
        var vis;
        vis = getStyle(layer);

        vis.display = (vis.display == '' || vis.display == 'block') ? 'none' : 'block';
}

//calls toggleLayer on two layers, one visible and one invisible, to swap the layers
function swapLayers( layer1, layer2 )
{
        toggleLayer(layer1);
        toggleLayer(layer2);
}

//sets "display: inline" for the style of the layer
function showLayerInline( layer )
{
        var vis;
        vis = getStyle(layer);

        vis.display = 'inline';
}

//sets "display: block" for the style of the layer
function showLayerBlock( layer )
{
        var vis;
        vis = getStyle(layer);

        vis.display = 'block';
}

//sets "display: none" for the style of the layer
function hideLayer( layer )
{
        var vis;
        vis = getStyle(layer);

        vis.display = 'none';
}

function resizeLayer(layer, width, height)
{
	var vis;
	vis = getStyle(layer);

	vis.width = width + 'px';
	vis.height = height + 'px';
}
