// Create a DHTML layer
function createLayer(name, left, top, width, height, visible, content, bg) {
	  var layer;
	  if (document.layers) {
	    document.writeln('<layer name="' + name + '" left=' + left + ' top=' + top + ' width=' + width + ' height=' + height +  ' visibility=' + (visible ? '"show"' : '"hide"') + ' bgcolor=' + bg + '>');
	    document.writeln(content);
	    document.writeln('</layer>');
	    layer = getLayer(name);
	    layer.width = width;
	    layer.height = height;
	  }
	
	  if (document.all) {
	    document.writeln('<div id="' + name + '" style="background-color: '+ bg +'; position:absolute; overflow:none; left:' + left + 'px; top:' + top + 'px; width:' + width + 'px; height:' + height + 'px;' + ' visibility:' + (visible ? 'visible;' : 'hidden;') +  '">');
	    document.writeln(content);
	    document.writeln('</div>');
	  }
		
	  clipLayer(name, 0, 0, width, height);
}

// get the layer object called "name"
function getLayer(name) {
	  if (document.layers)
	    return(document.layers[name]);
	  else if (document.all) {
	  	if ( eval('document.all.' + name) != null) {
		    layer = eval('document.all.' + name + '.style');
		    return(layer);
		} else
			return(null);
	  }
	  else
	    return(null);
}

// move layer to x,y
function moveLayer(name, x, y) {		
  	var layer = getLayer(name);		
	if (layer != null) {
	  	if (document.layers)
    		layer.moveTo(x, y);
	  	if (document.all) {
    		layer.left = x;
   			layer.top  = y;
	  	}
	}
}

// toggle layer to invisible
function hideLayer(name) {		
  	var layer = getLayer(name);		
	if (layer != null) {
	  	if (document.layers)
    		layer.visibility = "hide";
	  	if (document.all)
   			 layer.visibility = "hidden";
	}
}

// toggle layer to visible
function showLayer(name) {		
  	var layer = getLayer(name);		
	if (layer != null) {
	  	if (document.layers)
    		layer.visibility = "show";
	  	if (document.all) 
   		 layer.visibility = "visible";
	}
}

// clip layer display to clipleft, cliptip, clipright, clipbottom
function clipLayer(name, clipleft, cliptop, clipright, clipbottom) {		
	  var layer = getLayer(name);		
	  if (layer != null) {
		  if (document.layers) {
			    layer.clip.left   = clipleft;
			    layer.clip.top    = cliptop;
		    	layer.clip.right  = clipright;
			    layer.clip.bottom = clipbottom;
		  }
		  if (document.all)
			    layer.clip = 'rect(' + cliptop + ' ' +  clipright + ' ' + clipbottom + ' ' + clipleft +')';
	  }
}