// aimsDHTML.js

/*
***************************************************************************************

DHTML layer functions

***************************************************************************************
*/

// Create a DHTML layer
function createLayer(name, inleft, intop, width, height, visible, content, morestyle,usePos) {
	var layer;

	// 'inleft' and 'intop' parameters are used for Netscape or when usePos is true.

	//document.writeln('<div id="' + name + '" style="position:absolute; overflow:hidden; left:' + inleft + 'px; top:' + intop + 'px; width:' + width + 'px; height:' + height + 'px;' + '; z-index:1; visibility:' + (visible ? 'visible;' : 'hidden;') +  morestyle +'">');
	if (gIsNav || usePos) {
	    document.writeln('<div id="' + name + '" style="position:absolute; overflow:hidden; left:' + inleft + 'px; top:' + intop + 'px; width:' + width + 'px; height:' + height + 'px;' + '; z-index:1; visibility:' + (visible ? 'visible;' : 'hidden;') +  morestyle +'">');
        }
        else {
            document.writeln('<div id="' + name + '" style="position:absolute; overflow:hidden; width:' + width + 'px; height:' + height + 'px;' + '; z-index:1; visibility:' + (visible ? 'visible;' : 'hidden;') +  morestyle +'">');
        }

	document.writeln(content);
	document.writeln('</div>');
}

// Get a DHTML layer
function getLayerHTML (name, inleft, intop, width, height, visible, content, morestyle,usePos) {

        var myhtml = '';
	// 'inleft' and 'intop' parameters are used for Netscape or when usePos is true.
	if (usePos) {
	    myhtml = '<div id="' + name + '" style="position:absolute; overflow:hidden; left:' + inleft + 'px; top:' + intop + 'px; width:' + width + 'px; height:' + height + 'px;' + '; z-index:1; visibility:' + (visible ? 'visible;' : 'hidden;') +  morestyle +'">';
        }
        else {
            myhtml = '<div id="' + name + '" style="position:absolute; overflow:hidden; width:' + width + 'px; height:' + height + 'px;' + '; z-index:1; visibility:' + (visible ? 'visible;' : 'hidden;') +  morestyle +'">';
        }

	return (myhtml + content + '</div>');
}

// check for existance of layer
function hasLayer(name) {
	var result = false;
	if (gIsNav4) {
		if (document.layers[name]!=null) result=true;
	}  else if (gIsIE) {
		if (eval('document.all.' + name)!=null) result=true;
	} else if (gIsNav) {
		var theElements = document.getElementsByTagName("DIV");
		var theObj;
		var j = -1;
		for (i=0;i<theElements.length;i++) {
			if (theElements[i].id==name) result=true;
		}
    }
	return result;
}


// get the layer object called "name"
function getLayer(name) {
	var theObj = document.getElementById(name);
	if (theObj!=null) {
		return theObj.style
	 }  else {
               alert ('Layer ' + name + ' is null ');
	    return(null);
	 }
}

function isVisible(name) {
	  var layer = getLayer(name);
	  if (gIsNav && layer.visibility == "show")
	    return(true);
	  if (gIsIE && layer.visibility == "visible")
	    return(true);
	  return(false);
}


// move layer to x,y
function moveLayer1(name, x, y) {		
   var layer = getLayer(name);
   if (layer == null)
      return;		
   layer.left = x + "px";
   layer.top  = y + "px";
}

function moveLayer (name, x, y) {
    // TBD: Check if youcan delete it.
}

// set layer background color
function setLayerBackgroundColor(name, color) {		
  	var layer = getLayer(name);		
	layer.backgroundColor = color;
}

// toggle layer to invisible
function hideLayer(name) {
        // alert (name);		
  	var layer = getLayer(name);		
  	layer.visibility = "hidden";
}

// toggle layer to visible
function showLayer(name) {		
  	var layer = getLayer(name);		
  	layer.visibility = "visible";
}

// clip layer display to clipleft, cliptip, clipright, clipbottom
// Not working with Mozilla Milestone 12 (Nav5)
function clipLayer2(name, clipleft, cliptop, clipright, clipbottom) {		
	  var layer = getLayer(name);		
	  layer.clip = 'rect(' + cliptop + ' ' +  clipright + ' ' + clipbottom + ' ' + clipleft +')';
}

function clipLayer(name, clipleft, cliptop, clipright, clipbottom) {		
	  var layer = getLayer(name);
	  var newWidth = clipright - clipleft;
		var newHeight = clipbottom - cliptop;
		layer.height = newHeight + "px";
		layer.width	= newWidth + "px";
		layer.top	= cliptop  + "px";
		layer.left	= clipleft + "px";

}

// replace layer's content with new content
// not working with Mozilla Milestone 12 (Nav5)
function replaceLayerContent(name, content) {
	var theObj = document.getElementById(name);
	if (theObj!=null) {	  
		theObj.innerHTML = content;	
	}
}



