﻿// JScript File

function openWindowCentrata(file,w,h)
{
        openWindowCentrata(file,w,h,"_blank");
}


function openWindowCentrata(file,w,h,nomeWin)
{
	var offx=20
	var offy=60
	
	var oldw=0.0
	var oldh=0.0
	
//	l=(screen.width-w-offx)/1.1
//	t=(screen.height-h-offy)/2
    if(w>screen.availWidth-offx)
    {
        oldw=w;
        w=screen.availWidth-offx;
        h=h*w/oldw;
    }

	if(h>screen.availHeight-offy)
	{
	    oldh=h;
	    h=screen.availHeight-offy;
	    w=w*h/oldh;
	}
	
   	t=(screen.availHeight-h-offy/2)/2-100;
   	l=(screen.availWidth-w-offx/2)/2;
	
	var a
	
	a = window.open(file, nomeWin, "toolbar=no,menubar=no,scrollbars=no,resizable=no,status=no,location=no,directories=no,copyhistory=no,height="+h+",width="+w+",left="+l+",top="+t);
}



function openWindowBigImage(file,w,h,nomeWin)
{

	var offx=20
	var offy=60
	
	var oldw=0.0
	var oldh=0.0
	
	var resize=false;
//	l=(screen.width-w-offx)/1.1
//	t=(screen.height-h-offy)/2
    if(w>screen.availWidth-offx)
    {
        oldw=w;
        w=screen.availWidth-offx;
        h=h*w/oldw;
        resize=true;
    }

	if(h>screen.availHeight-offy)
	{
	    oldh=h;
	    h=screen.availHeight-offy;
	    w=w*h/oldh;
	    resize=true;
	}
	
   	t=(screen.availHeight-h-offy/2)/2-100;
   	l=(screen.availWidth-w-offx/2)/2;
	
	var a;
	// se ho effettuato un resize, comunico alla pagina chiamata l'avvenuto resize e le nuove dimensioni
	if(resize==true)
	{
	    if(file.indexOf("?")>=0)
	    {
	       file=file+"&resize=1&wResize="+w+"&hResize="+h;
	    }
	    else
	    {
	       file=file+"?resize=1&wResize="+w+"&hResize="+h;
	    }
	}
	else
	{
	    if(file.indexOf("?")>=0)
	    {
	       file=file+"&resize=0";
	    }
	    else
	    {
	       file=file+"?resize=0";
	    }
	}
	a = window.open(file, nomeWin, "toolbar=no,menubar=no,scrollbars=no,resizable=no,status=no,location=no,directories=no,copyhistory=no,height="+h+",width="+w+",left="+l+",top="+t);
	
}