function PopUp(url, height, width)
{
	var x = (screen.width - width)/2;
	var y = (screen.height - height)/2;
	window.open(url, null, 'width=' + width + ', height=' + height + ', left=' + x + ', top=' + y + ',status=0,toolbar=0,menubar=0,location=0');
}

function PopUpNome(url, nome , height, width)
{
	var x = (screen.width - width)/2;
	var y = (screen.height - height)/2;
	window.open(url, nome, 'width=' + width + ', height=' + height + ', left=' + x + ', top=' + y + ',status=0,toolbar=0,menubar=0,location=0,resizable=1');
}

function PopUpScroll(url, height, width, scroll)
{
	var x = (screen.width - width)/2;
	var y = (screen.height - height)/2;
	window.open(url, null, 'width=' + width + ', height=' + height + ', left=' + x + ', top=' + y + ',status=yes,toolbar=no,menubar=no,location=no,scrollbars=' + scroll);
}

function PopUpFullScreen(url)
{
	//var x = (screen.width - 900)/2;
	//var y = (screen.height - 900)/2;
	//window.open(url, null, 'left=' + x + ', top=' + y + ',fullscreen=no,status=yes,toolbar=no,menubar=no,location=no,scrollbars=no');
	window.open(url, 'base',"left=0,top=0,scrollbars=yes,resizable=yes,status=no,location=no,toolbar=no");
	//window.open(url, null,'fullscreen=yes','scrollbars=no');
	if (window.name != 'base') {
		//window.location = "../";
		window.opener=self;
		window.close();
	}	
}

function PopUpModal(url, height, width){ // by Ultima v1.2 
	var isBlocked=false;
	var myWin = null;
	var x = (screen.width - width)/2;
	var y = (screen.height - height)/2;
	if (document.layers){
		document.captureEvents(Event.MOUSEDOWN);
		document.onmousedown = checkFocus();
		isBlocked=true;
		
		myWin = window.open(url, null, 'width=' + width + ', height=' + height + ', left=' + x + ', top=' + y + ',status=yes,toolbar=no,menubar=no,location=no');
		myWin.focus();
	}	
	if (document.all)
	{
		myWin = window.open(url, null, 'width=' + width + ', height=' + height + ', left=' + x + ', top=' + y + ',status=yes,toolbar=no,menubar=no,location=no');
		myWin.focus();	
	}
	
	return myWin;
}

function PopUpModalNome(url, nome, height, width){ // by Ultima v1.2 
	var isBlocked=false;
	var myWin = null;
	var x = (screen.width - width)/2;
	var y = (screen.height - height)/2;
	if (document.layers){
		document.captureEvents(Event.MOUSEDOWN);
		document.onmousedown = checkFocus();
		isBlocked=true;
		
		myWin = window.open(url, nome, 'width=' + width + ', height=' + height + ', left=' + x + ', top=' + y + ',status=yes,toolbar=no,menubar=no,location=no');
		myWin.focus();
	}	
	if (document.all)
	{
		myWin = window.open(url, nome, 'width=' + width + ', height=' + height + ', left=' + x + ', top=' + y + ',status=yes,toolbar=no,menubar=no,location=no');
		myWin.focus();	
	}
}

function PopUpModalNomePosizione(url, nome, height, width, x, y){ // by Ultima v1.2 
	var isBlocked=false;
	var myWin = null;
	//var x = (screen.width - width)/2;
	//var y = (screen.height - height)/2;
	if (document.layers){
		document.captureEvents(Event.MOUSEDOWN);
		document.onmousedown = checkFocus();
		isBlocked=true;
		
		myWin = window.open(url, nome, 'width=' + width + ', height=' + height + ', left=' + x + ', top=' + y + ',status=yes,toolbar=no,menubar=no,location=no');
		myWin.focus();
	}	
	if (document.all)
	{
		myWin = window.open(url, nome, 'width=' + width + ', height=' + height + ', left=' + x + ', top=' + y + ',status=yes,toolbar=no,menubar=no,location=no');
		myWin.focus();	
	}
	
	return myWin;
}

function checkFocus(){
	if (myWin && !myWin.closed){
		myWin.focus();
		return false;			
	}else if (isBlocked) {
		document.releaseEvents(Event.MOUSEDOWN);
		document.onmousedown=null;			
		return true;	
	}
}
function PopUpNomeScroll(url, nome , height, width)
{
	var x = (screen.width - width)/2;
	var y = (screen.height - height)/2;
	window.open(url, nome, 'width=' + width + ', height=' + height + ', left=' + x + ', top=' + y + ',status=0,toolbar=0,menubar=0,location=0,scrollbars=yes');
}

function PopUpPosition(popUpString, nome, height, width)
{
	if(document.layers) document.captureEvents(Event.CLICK);
	

	//var e = (window.event)?event.keyCode:Event.CLICK.which;
	var e = window.event;

	var vDoc=(document.documentElement && document.documentElement.scrollTop)?document.documentElement:document.body;

	var mouseX=(e.pageX)?e.pageX:e.clientX+vDoc.scrollLeft;
	var mouseY=(e.pageY)?e.pageY:e.clientY;


	//alert("e.clientX " + e.clientX + " e.clientY " + e.clientY+ " vDoc.scrollLeft " + vDoc.scrollLeft+" vDoc.scrollTop " + vDoc.scrollTop+" mouseX " + mouseX +" mouseY " + mouseY);
	//mouseX = mouseX + window.screenLeft;
	//mouseY = mouseY + window.screenTop;

	mouseX = mouseX + window.screenLeft;
	//mouseY = (mouseY + height)/2;
	
	if( mouseY<height/2 )  
		mouseY = (mouseY + window.screenTop)/2;
	else
		mouseY = mouseY + window.screenTop;
	
	//popUp = PopUpModalNome('Calendar.aspx?formname=' + document.forms[0].name + '&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 'popupcal', 208, 165);
	//var popUp = PopUpModalNomePosizione('Calendar.aspx?formname=' + document.forms[0].name + '&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 'popupcal', 208, 165, mouseX, mouseY);
	var popUp = PopUpModalNomePosizione(popUpString, nome, height, width, mouseX, mouseY);

}