/* author: John Collins */
/* Adaptader: Toni */
/* Creation date: 30/12/02 */

var sWidth = 0;
var sHeight = 0;

//makes dynamic layer, target resolution is 1024x768 or cookie value "targetRes"
if (document.cookie != "") { // checks for the cookie
	var cookies = document.cookie.split("; ");
	var s = new String(cookies[0].split("=")[1]);
	if (s == "auto" || s == "") { // defaults to automatic scaling
		expireDate = new Date;
		expireDate.setDate(expireDate.getDate()-1); // sets the cookie to expire yesterday!
		sHeight = screen.height;
		sWidth = screen.width;
	}else{
		var findX = s.indexOf("x");
		sWidth = s.substring(0, findX);
		sHeight = s.substring(findX+1, s.length);
	}
}else{
	sHeight = screen.height;
	sWidth = screen.width;
}

var xu =1;
var yu = 1;
//detects if the browser is NS6+ or Mozilla 1+
isMoz = (!document.all && document.getElementById) ? true : false;

function makeLayer(id, top, left, width, height, position, visibility, backgroundColor, zIndex) {
	//alert("makeLayer("+id+","+top+","+left+","+width+","+height+","+position+","+visibility+","+backgroundColor+","+zIndex+")");

	//default attribute settings where none are provided
	position = (position == '') ? 'absolute' : position;
	visibility = (visibility == '') ? 'visible' : visibility;
	backgroundColor = (backgroundColor == '') ? null : backgroundColor;
	zIndex = (zIndex == '') ? '10' : zIndex;
	// centers on the x-axis in the 780x470 iframe!
	if (left == 'centX'){
		var frameHalfWidth = parseInt(390 * xu);
		var centerLayerWidth = parseInt(width * xu);
		var centX = parseInt(frameHalfWidth-(centerLayerWidth/2));
		left = centX;
	}
	// for debugging!
	//alert("makeLayer("+id+","+top+","+left+","+width+","+height+","+position+","+visibility+","+backgroundColor+","+zIndex+")");
	// layer attributes
	this.layer = document.getElementById(id);
	this.layer.style.position = position;
	this.layer.style.top = parseInt(top * yu);
	this.layer.style.left = parseInt(left * xu);
	this.layer.style.width = parseInt(width * xu);
	this.layer.style.height = parseInt(height * yu);
	this.layer.style.visibility = visibility;
	if (backgroundColor != null)
		this.layer.style.backgroundColor = backgroundColor;
	this.layer.style.zIndex = zIndex;
	// sets up a method for changing the opacity of an existing layer
	this.layer.setOpac = setOpac;
	return this.layer;
	
	function setOpac(newOpac) {
		// method to set the layer's opacity, opacity settings for IE and Mozilla/NS are handled differently
		if (isMoz == true) {
			this.style.MozOpacity = newOpac/100;
		}else{
			this.filters.alpha.opacity = newOpac;
		}
	}
}
