function Getbox(parent)
{
	if (typeof(parent) == "undefined") {
		parent = 0;
	}
	this.top = 0;
	this.left = 0;
	this.width = screen.width;
	this.height = screen.height;
	if (parent == 2) {
		this.top = window.screenTop;
		this.left = window.screenLeft;
		this.width = document.body.offsetWidth;
		this.height = document.body.offsetHeight;
	}
	else if (parent == 1) {
		this.width = screen.availWidth;
		this.height = screen.availHeight;
	}
	else if(parent == 0) {
		this.width = screen.width;
		this.height = screen.height;
	}
	else {
		this.top = parent.screenTop;
		this.left = parent.screenLeft;
		this.width = parent.document.body.offsetWidth;
		this.height = parent.document.body.offsetHeight;
	}
}

POP_win = 2;
POP_client = 1;
POP_tot = 0;

function PopUp(url,width,height,halign,valign,parent)
{
	var top = 0;
	var left = 0;
	box = new Getbox(parent);
	switch(halign) {
		case "":
		case "left":
		left = 0;
		break;
		case "right":
		left = box.width - width;
		break;
		case "center":
		left = (box.width - width) / 2;
		break;
		default:
		if (typeof(halign) == "string") {
			if (halign.search(/%/g) != "-1") {
				left = (box.width - width) * parseInt(halign) / 100;
			}
			else {
				left = parseInt(halign);
			}
		}
		else if (typeof(halign) == "number") {
			left = halign;
		}
	}
	switch(valign){
		case "":
		case "top":
		top = 0;
		break;
		case "bottom":
		top = box.height - height;
		break;
		case "center":
		top = (box.height - height) / 2;
		break;
		default:
		if (typeof(valign) == "string") {
			if (valign.search(/%/g) != "-1") {
				top = (box.height - height) * parseInt(valign) / 100;
			}
			else {
				top = parseInt(valign);
			}
		}
		else if (typeof(valign) == "number"){
			top = valign;
		}
	}
	top += box.top;
	left += box.left;
	window.open(url,"","width="+width+",height="+height+",top="+top+",left="+left);
	return;
}

function PopUp_Barra(url,width,height,halign,valign,parent,scrollbars,resizable)
{
	var top = 0;
	var left = 0;
	box = new Getbox(parent);
	switch(halign) {
		case "":
		case "left":
		left = 0;
		break;
		case "right":
		left = box.width - width;
		break;
		case "center":
		left = (box.width - width) / 2;
		break;
		default:
		if (typeof(halign) == "string") {
			if (halign.search(/%/g) != "-1") {
				left = (box.width - width) * parseInt(halign) / 100;
			}
			else {
				left = parseInt(halign);
			}
		}
		else if (typeof(halign) == "number") {
			left = halign;
		}
	}
	switch(valign){
		case "":
		case "top":
		top = 0;
		break;
		case "bottom":
		top = box.height - height;
		break;
		case "center":
		top = (box.height - height) / 2;
		break;
		default:
		if (typeof(valign) == "string") {
			if (valign.search(/%/g) != "-1") {
				top = (box.height - height) * parseInt(valign) / 100;
			}
			else {
				top = parseInt(valign);
			}
		}
		else if (typeof(valign) == "number"){
			top = valign;
		}
	}
	top += box.top;
	left += box.left;
	
	var menubar = 0;
	var locationbar = 0;
	var directories = 0;
	var statusbar = 0;
	var toolbar = 0;
	
	windowprops = "width=" + width + ",height=" + height + ",top=" + top + ",left=" + left;

	windowprops += (menubar ? ",menubars" : "") +
	(scrollbars ? ",scrollbars" : "") +
	(locationbar ? ",location" : "") +
	(directories ? ",directories" : "") +
	(resizable ? ",resizable" : "") +
	(statusbar ? ",status" : "") +
	(toolbar ? ",toolbar" : "");
	
	window.open(url,"",windowprops);
	return;
}
