<!--
// Layer Management

//
// Global variable for clicked on layers
//

var SelectedLayer = null;

//
// FUNCTION FOR REFERENCE PROPERTY OF LAYERS
//

// reference for style attributes

function setLayer(layerName){
	if(NS){
		var layerRef = eval("document." + layerName);
	} else {
		var layerRef = eval("document.all." + layerName + ".style");
	}
	return layerRef;
}

// reference for document properties

function setLayerDocRef(layerName) {
	if(NS) {
		var LayerObj = eval("document." + layerName + ".document");
	} else {
		var LayerObj = eval("document.all." + layerName + ".document");
	}
	return LayerObj;
}

//
// END FUNCTION FOR REFERENCE PROPERTIE OF LAYERS
//

//
// FUNCTION FOR VISIBILITY PROPERTIE OF LAYERS
//

function toggleLayerVis(layerName){
	layerName = setLayer(layerName);
	if(layerName.visibility.charAt(0) == "h"){
		layerName.visibility = "visible";
	} else {
		layerName.visibility = "hidden";
	}
}

function showLayer(layerName){
	layerName = setLayer(layerName);
	layerName.visibility = "visible";
}

function hideLayer(layerName){
	layerName = setLayer(layerName);
	layerName.visibility = "hidden";
}

function hideAllLayers(){
	if(NS){
		for(i = 0; i < document.layers.length; i ++){
			document.layers[i].visibility = "hidden";
		}
	} else {
		for(i = 0; i < document.all.tags('DIV').length; i ++){
			document.all.tags('DIV')[i].style.visibility = "hidden";
		}
	}		
}

function showAllLayers(){
	if(NS){
		for(i = 0; i < document.layers.length; i ++){
			document.layers[i].visibility = "visible";
		}
	} else {
		for(i = 0; i < document.all.tags('DIV').length; i ++){
			document.all.tags('DIV')[i].style.visibility = "visible";
		}
	}
}

//
// END FUNCTION FOR VISIBILITY PROPERTIES OF LAYERS
//

//
// FUNCTIONS FOR LATERAL PROPERTIES OF LAYERS
//

// get left corner X of a layer

function getLayerX(layerName){
	layerName = setLayer(layerName);
	if(NS){
		return layerName.left;
	} else {
		return layerName.pixelLeft;
	}
}

// get layer clip width

function getLayerWidth(layerName){
	layerName = setLayer(layerName);
	if(NS){
		var layerWidth = layerName.clip.width;
	} else {
		var widthVar = layerName.width;
		widthVar = Number(widthVar.slice(0,-2));
		var layerWidth = widthVar;
	}
	return layerWidth;
}

// set clip width of a layer

function setLayerClipWidth(layerName, w){
	layerName = setLayer(layerName);
	if(NS){
		layerName.clip.width = w;
	} else {
		layerName.width = w;
	}
}

//
// END FUNCTIONS FOR LATERAL PROPERTIES OF LAYERS
//

//
// FUNCTIONS FOR VERTICAL PROPERTIES OF LAYERS
//

// get left corner Y of a layer

function getLayerY(layerName){
	layerName = setLayer(layerName);
	if(NS){
		return layerName.top;
	} else {
		return layerName.pixelTop;
	}
}


// get layer clip height

function getLayerHeight(layerName){
	layerName = setLayer(layerName);
	if(NS){
		var layerHeight = layerName.clip.height;
	} else {
		var heightVar = layerName.height;
		heightVar = Number(heightVar.slice(0,-2));
		var layerHeight = heightVar;
	}
	return layerHeight;
}

// set clip height of a layer

function setLayerClipHeight(layerName, h){
	layerName = setLayer(layerName);
	if(NS){
		layerName.clip.height = h;
	} else {
		layerName.clipHeight = h;
	}
}


//
// END FUNCTIONS FOR VERTICAL PROPERTIES OF LAYERS
//

//
// FUNCTIONS FOR POSITIONAL PROPERTIES OF LAYERS
//

// move layers to a particular position

function moveLayer(layerName, x, y){
	layerName = setLayer(layerName);
	if(NS){
		layerName.moveTo(x,y);
	} else {
		layerName.pixelLeft = x;
		layerName.pixelTop = y;
	}	
}

// move layer by some increment

function moveLayerBy(layerName, deltaX, deltaY){
	layerName = setLayer(layerName);
	if(NS){
		layerName.moveBy(deltaX,deltaY);
	} else {
		layerName.pixelLeft += deltaX;
		layerName.pixelTop += deltaY;
	}	
}

//
// END FUNCTIONS FOR POSITIONAL PROPERTIES OF LAYERS
//

//
// FUNCTION FOR Z INDEX OF LAYERS
//

function setZ(layerName, zOrder){
	layerName = setLayer(layerName);
	layerName.zIndex = zOrder;
}

//
// END FUNCTION FOR Z INDEX OF LAYERS
//

//
// FUNCTION FOR LAYER BACKGROUND
//

function setLayerBG(layerName, color){
	layerName = setLayer(layerName);
	if(NS){
		layerName.bgcolor = color;
	} else {
		layerName.backgroundColor = color;
	}
}

//
// END FUNCTION FOR LAYER BACKGROUND
//

//
// FUNCTION FOR CHECKING MOUSE CLICKS ON LAYER
//

function checkLayerHit(){
	if(NS){
		for(i = 0; i < document.layers.length; i ++){
			
			currentLayer = document.layers[i];
			if(clickX > currentLayer.left && clickX < currentLayer.clip.width){
				if(clickY > currentLayer.top && clickY < currentLayer.clip.height){
					// set SelectedLayer to name of layer
				}
			}
			
		}
	} else {
		for(i = 0; i < document.all.tags('DIV').length; i ++){
			
			currentLayer = document.all.tags('DIV')[i];
			
			var layerWidth = currentLayer.style.width;
			layerWidth = Number(layerWidth.slice(0,-2));
			
			var layerHeight = currentLayer.style.height;
			layerHeight = Number(layerHeight.slice(0,-2));
			
			if(clickX > currentLayer.style.pixelLeft && clickX < layerWidth){
				if(clickY > currentLayer.style.pixelTop && clickY < layerHeight){
					// set SelectedLayer to name of layer
				}
			}
			
		}
	}
		
}

//
// END FUNCTION FOR CHECKING MOUSE CLICKS ON LAYER
//
// -->