
/************************************
	Finestre pop-up

	Author: l. bianchi
************************************/

var popWnd = null;

function openWnd(href, w, h, x, y , nomefinestra, properties)
{
//	if (popWnd && !popWnd.closed) popWnd.close();
	
	var winWidth = w;
	var winHeight = h;
	var xPos;
	var yPos;
	
	if (!x) { 	xPos = (screen.availWidth-winWidth)/2;		} else {xPos=x;}
	if (!y) { 	yPos = (screen.availHeight-winHeight)/2;	} else {yPos=y;}
	if (!properties) {properties=",titlebar=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,status=no";} else 
		{properties=","+properties;	} 
	if (!nomefinestra) {nomefinestra="_blank";}
	//popWnd = this.open(href, "_blank", "innerWidth=" + w + ",innerHeight=" + h + ",width=" + w + ",height=" + h + ",top=" + yPos + ",left=" + xPos+properties);
        popWnd = this.open(href, nomefinestra, "innerWidth=" + w + ",innerHeight=" + h + ",width=" + w + ",height=" + h + ",top=" + yPos + ",left=" + xPos+properties);

}


function popClose()
{
	if (popWnd && !popWnd.closed) popWnd.close();
}

window.onunload = popClose;


/* Check del numero minimo di caratteri su un campo di un form, ritorna true se corretto, messaggio d'errore e false se non lo è*/
function minimum(champ,nbre) 
{ 
if (champ.length < nbre) 
{ 
alert("Inserire almeno "+nbre+" caratteri") 
return false; 
} 
return true; 
} 

/* Check del numero massimo di caratteri su un campo di un form, ritorna true se corretto, messaggio d'errore e false se non lo è*/
function maximum(champ,nbre) 
{ 
if (champ.length > nbre) 
{ 
alert("Inserire non piu' di "+nbre+" caratteri") 
return false; 
} 
return true; 
} 


/* Check del numero max di caratteri su una stringa, 
ritorna la stringa in ingresso se di lunghezza minore di max
ritorna stringa troncata con [...] se maggiore
come estensione usa ext_link e se non specificato [...]
*/
function show_only_min(str,maxchar,ext_link) 
{ 
myString = new String(str);

if (!ext_link){ext_link="[...]";}

if (myString.length > maxchar) 
{ 
	myString=myString.slice(0,maxchar); 
	myString=myString.concat(" ","<SPAN onMouseOut=\"self.status=''\" onMouseOver=\"self.status='",str,"'\">",ext_link,"</SPAN>");
return myString  ; 
} 
return str; 
} 

/* Aggiunge spazi alla stringa fino a farla di almeno grandezza size */

function spaceUpTo(str,size)
{
myString = new String(str);

if (myString.length < size) 
{ for(i=0; i<eval(1+size-myString.length); i++) 
 	myString=myString.concat(" ");
	myString=myString.slice(0,size); 
}	
return myString  ; 

}
