gecko=(navigator.userAgent.indexOf('Gecko')>0)? 1 : 0;

function OpenWin(url,w,h,opt,name)
{
if (!name) name='aux';	
eval("if (window."+name+") "+name+".close();");
l=parseInt((screen.availWidth-w)/2); if (l>300) l=300;
t=parseInt((screen.availHeight-h)/2-40); if (t>100) t=100; if (t<10) t=10;
dim="left="+l+",top="+t+",width="+w+",height="+h+",resizable=yes";
if (gecko)
	{ 
	h+=45; w+=30; 
	if (opt) dim=opt+","+dim;	
	}
else if (opt) dim+=","+opt;		
eval(name+"=window.open(url,'"+name+"',dim);");
}

function sizeWindow(wAdd,hAdd,obj,cId)
{
if (!wAdd) wAdd=10; if (!hAdd) hAdd=10;  if (!obj) obj=window; if (!cId) cId='sdim'; 
dim=obj.document.getElementById(cId);
myW=dim.offsetWidth+wAdd; myH=dim.offsetHeight+hAdd;
if (myW > screen.availWidth*0.9) myW=screen.availWidth*0.9;
if (myH > screen.availHeight*0.9) myH=screen.availHeight*0.9; 
if (gecko && window.locationbar.visible) { myH+=20; }
obj.resizeTo(myW,myH);
}

function Help(url)
{ 
h=screen.availWidth;
OpenWin(url,380,560,'scrollbars=yes,top=10,left='+(h-310),'help'); 
}

function Formati()
{ OpenWin("/admin/include/formati.html",320,screen.availHeight-80,"top=10,left=50", "help"); }
