var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;
	
// open a popup centered in user's screen
function popCenter(page, name, w, h, scroll) {
	 var winl = (screen.width - w) / 2;
	 var wint = (screen.height - h) / 2;
	 winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',toolbar=1,menubar=1,resizable=1';
	 win = window.open(page, name, winprops);
	 win.focus();
}

function setVisibility(LayerChoice) {
	if (ie4) {
		if(document.all[LayerChoice].style.display == "none") {
			document.all[LayerChoice].style.display = "block";
		}
		else {
			document.all[LayerChoice].style.display = "none";
		}
	}
	if (ns4) {
		if(document.layers[LayerChoice].display == "hide") {
			document.layers[LayerChoice].display = "Show";
		}
		else {
			document.layers[LayerChoice].display = "hide";
		}
	}
	if (ns6) {
		if(document.getElementById([LayerChoice]).style.display == "none") {
			document.getElementById([LayerChoice]).style.display = "block";
		}
		else {
			document.getElementById([LayerChoice]).style.display = "none";
		}
	}
}

var hide  = true;

function setLyr(obj,lyr) {
	var newX = findPosX(obj);
	var newY = findPosY(obj);
	var x = new getObj(lyr);
	x.style.top = newY + 20 + 'px';
	x.style.left = newX + 'px';
}

function findPosX(obj) {
	var curleft = 0;
		if (obj.offsetParent) {
			while (obj.offsetParent) {
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj) {
	var curtop = 0;
	var printstring = '';
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			printstring += ' element ' + obj.tagName + ' has ' + obj.offsetTop;
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
		window.status = printstring;
	return curtop;
}

function getObj(name) {
	if (document.getElementById) {
		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
	}
	else if (document.all) {
		this.obj = document.all[name];
		this.style = document.all[name].style;
	}
	else if (document.layers) {
		if (document.layers[name]) {
			this.obj = document.layers[name];
			this.style = document.layers[name];
		}
		else {
			this.obj = document.layers.testP.layers[name];
			this.style = document.layers.testP.layers[name];
		}
	}
}