// Functions for layers
var agt=navigator.userAgent.toLowerCase();
NS6 = (agt.indexOf('netscape')!=-1)||(agt.indexOf('firebird')!=-1);;
MAC = (navigator.appVersion.indexOf("Mac") != -1);
NS4 = (document.layers);
IE = (document.all);

function getLayer() {
	var obj;
 	var layer=getLayer.arguments[0];	
 	var layerParent=getLayer.arguments[1];
	if(NS4){
		if(layerParent != null) {
			obj = document.layers[layerParent].document.layers[layer];
		} else{
			obj = document.layers[layer];
		}
	}else if(IE) {
		obj = document.all[layer];
	}else if(NS6) {
		obj = document.getElementById(layer);
	}
	return obj;	
}
function updateLayer(obj, content) {
	if(!obj) {
		return
	}
	if(NS4){
		obj.document.open();
		obj.document.write(content);
		obj.document.close();	
	}else if(IE) {
		obj.innerHTML = content;
	}else if(NS6) {
		obj.innerHTML = content;
	}
}
function getLayerHeight(obj) {
	if(!obj) {
		return
	}
	if(NS4){
		return obj.clip.height;
	}else if(IE) {
		return obj.offsetHeight;
	}else if(NS6) {
		return obj.offsetHeight;
	}
}
function getLayerWidth(obj) {
	if(!obj) {
		return
	}
	if(NS4){
		return obj.clip.width;
	}else if(IE) {
		return obj.offsetWidth;
	}else if(NS6) {
		return obj.offsetWidth;
	}
}
function getLayerTop(obj) {
	if(!obj) {
		return
	}
	if(NS4){
		return obj.top;
	}else if(IE) {
		return obj.style.pixelTop;
	}else if(NS6) {
		return parseInt(obj.style.top);
	}
}
function getLayerLeft(obj) {
	if(!obj) {
		return
	}
	if(NS4){
		return obj.left;
	}else if(IE) {
		return obj.style.pixelLeft;
	}else if(NS6) {
		return parseInt(obj.style.left);
	}
}
function setLayerHeight(obj, h) {
	if(!obj) {
		return
	}
	if(NS4){
		obj.clip.height = h;
	}else if(IE) {
		obj.style.height = h;
	}else if(NS6) {
		obj.style.height = h + "px";
	}
}
function setLayerClip(obj, clip) {
	if(!obj) {
		return
	}
	if(NS4){
		obj.clip = clip;
	}else if(IE) {
		obj.style.clip = clip;
	}else if(NS6) {
		obj.style.clip = clip;
	}
}

function moveLayer(obj, x, y) {
	if(!obj) {
		return
	}
	if(NS4){
		obj.moveTo(x,y);
	}else if(IE) {
		obj.style.pixelLeft = x;
		obj.style.pixelTop = y;
	}else if(NS6) {
		obj.style.left = x + "px";
		obj.style.top = y + "px";
	}
}
function setLayerVisibility(obj, visible) {
	if(!obj) {
		return
	}
	if(visible) {
		strVis="visible";
	} else {
		strVis="hidden";
	}
	if(NS4){		
		obj.visibility = strVis;
	}else if(IE) {
		obj.style.visibility = strVis;
	}else if(NS6) {
		obj.style.visibility = strVis;
	}
}
function getLayerVisibility(obj) {
	if(!obj) {
		return
	}
	if(NS4){		
		strVis = obj.visibility;
	}else if(IE) {
		strVis = obj.style.visibility;
	}else if(NS6) {
		strVis = obj.style.visibility;
	}
	return (strVis=="visible");
}
function setLayerOpacity(obj, opac) {
	if(!obj) {
		return
	}
	if(IE) {
		obj.filters.item("DXImageTransform.Microsoft.Alpha").opacity = opac;
	}
}
function setLayerBackground(obj, color) {
	if(!obj) {
		return
	}
	if(NS4){		
		obj.bgColor = color;
	}else if(IE) {
		obj.style.backgroundColor = color;
	}else if(NS6) {
		obj.style.backgroundColor = color;
	}
}

// Function for getting the position when page is centered in page
function getxpos(xdistance, PAGE_WIDTH){
	screen_width = 0;
	position_x = xdistance;
	
	if(NS4 || NS6) {
		screen_width = window.innerWidth;
	} else {
		screen_width = document.body.clientWidth;
	}
	if(screen_width > PAGE_WIDTH) {
		position_x = xdistance + (screen_width-PAGE_WIDTH)/2; 
	}	
	if(NS4) {
		position_x -= 9;
	}
	return position_x;
}
function getypos(ydistance, PAGE_HEIGHT){
	screen_height = 0;
	position_y = ydistance;
	
	if(NS4 || NS6) {
		screen_height = window.innerHeight;
	} else {
		screen_height = document.body.clientHeight;
	}
	if(screen_height > PAGE_HEIGHT) {
		position_y = ydistance + (screen_height-PAGE_HEIGHT)/2;
	}	
	if(NS4) {
		position_y -= 9;
	}
	return position_y;
}
