function aprifinestra (nomefile, larghezza, altezza, Finestra){
	var lef
	var to
	var la
	var al
	lef = (screen.width - larghezza) / 2;
	to = (screen.height - altezza)  / 2;
	
	if (((larghezza+50) > screen.width) || ((altezza+50) > screen.height)){
		if ((altezza+50) > screen.height){
			if ((larghezza + 40)>screen.width) {
				la = larghezza 
			}
			else{
				la = larghezza + 40
			}
			al = screen.height - 60
			lef = (screen.width - la) / 2
			to=0
		}
		if ((larghezza+50) > screen.width){
			la = screen.width-10
			if ((altezza + 50)>screen.height) {
				al = altezza - 60
			}
			else{
				al = altezza + 50
			}
			
			to = (screen.height - al) / 2
			lef=0
		} 
		if (((larghezza+50) > screen.width) && ((altezza+50) > screen.height)){
			la = screen.width -10
			al = screen.height -60
			lef = 0
			to = 0
		}
		win_popup = window.open(nomefile,Finestra,"toolbar= 0,location= 0,directories= 0,status= 0,menubar= 0,scrollbars= 1,resizable= 0,copyhistory= 0,width=" + la + ",height=" + al);
	}
	else{
		la = larghezza + 20
		al = altezza + 20
		lef = (screen.width - la) / 2;
		to = (screen.height - al)  / 2;
		
		win_popup = window.open(nomefile,Finestra,"toolbar= 0,location= 0,directories= 0,status= 0,menubar= 0,scrollbars= 0,resizable= 0,copyhistory= 0,width=" + la + ",height=" + al);
	}
	win_popup.moveTo(lef, to)
}

function apripopup(nomefile, larghezza, altezza, Finestra){
	win_popup = window.open(nomefile,Finestra,"toolbar= 0,location= 0,directories= 0,status= 0,menubar= 0,scrollbars= 1,resizable= 0,copyhistory= 0,width=" + larghezza + ",height=" + altezza);
}