﻿//apre una finestra con tutti i menu
function apri_finestra(url, nomeWindow, lunghezza, altezza) {
	nome = nomeWindow;
	//alert("ciao");
	// ------------------------------------------
	// Altezza della finestra [numero]
	if (altezza == null) {
		altezza = screen.height-15;
	}
	// ------------------------------------------
	// Lunghezza della finestra [numero]
	if (lunghezza == null) {
		lunghezza = screen.width-15;
	}	
	// ------------------------------------------
	// Posiziona finestra al centro [true|false]
	centra = true;
	// ------------------------------------------
	// Distanza dal margine sinistro [numero]
	posX = 0;
	// ------------------------------------------
	// Distanza dal margine destro [numero]
	posY = 0;
	// ------------------------------------------
	// Visualizza a pieno schermo - solo IE4
	fullscreen='no';
	// ------------------------------------------
	// Ridimensionabile [yes|no]
	resizable='yes';
	// ------------------------------------------
	// Visualizza barra del menu [yes|no]
	menuB='yes';
	// ------------------------------------------
	// Visualizza barre di scorrimento [yes|no]
	scrollB='yes';	
	// ------------------------------------------
	// Visualizza barra di stato [yes|no]
	statusB='yes';	
	// ------------------------------------------

	if (centra) {
		posX = Math.round((screen.width - lunghezza)/2);
		posY = Math.round((screen.height - altezza)/2);		
	}

	caratteristiche = "menubar=" + menuB;
	caratteristiche += ",scrollbars=" + scrollB;
	caratteristiche += ",statusbar=" + statusB;		//Netscape
	caratteristiche += ",status=" + statusB;		//IE4
	caratteristiche += ",height=" + altezza;
	caratteristiche += ",width=" + lunghezza;
	caratteristiche += ",screenX=" + posX;			//Netscape
	caratteristiche += ",left=" + posX;			//IE4
	caratteristiche += ",screenY=" + posY;			//Netscape
	caratteristiche += ",top=" + posY;			//IE4
	caratteristiche += ",fullscreen=" + fullscreen; 	//solo IE4
	caratteristiche += ",resizable=" + resizable;

	popupWindow = window.open(url, nome, caratteristiche);
	popupWindow.opener = self;

}

//apre una finestra senza la barra del menu e la status bar
function apri_finestra_nobar(url, nomeWindow, lunghezza, altezza) {
	nome = nomeWindow;
	// ------------------------------------------
	// Altezza della finestra [numero]
	if (altezza == null) {
		altezza = 600;
	}
	// ------------------------------------------
	// Lunghezza della finestra [numero]
	if (lunghezza == null) {
		lunghezza = 800;
	}	
	// ------------------------------------------
	// Posiziona finestra al centro [true|false]
	centra = true;
	// ------------------------------------------
	// Distanza dal margine sinistro [numero]
	posX = 100;
	// ------------------------------------------
	// Distanza dal margine destro [numero]
	posY = 100;
	// ------------------------------------------
	// Visualizza a pieno schermo - solo IE4
	fullscreen='no';
	// ------------------------------------------
	// Ridimensionabile [yes|no]
	resizable='yes';
	// ------------------------------------------
	// Visualizza barra del menu [yes|no]
	menuB='no';
	// ------------------------------------------
	// Visualizza barre di scorrimento [yes|no]
	scrollB='yes';	
	// ------------------------------------------
	// Visualizza barra di stato [yes|no]
	statusB='no';	
	// ------------------------------------------

	if (centra) {
		posX = Math.round((screen.width - lunghezza)/2);
		posY = Math.round((screen.height - altezza)/2);		
	}

	caratteristiche = "menubar=" + menuB;
	caratteristiche += ",scrollbars=" + scrollB;
	caratteristiche += ",statusbar=" + statusB;		//Netscape
	caratteristiche += ",status=" + statusB;		//IE4
	caratteristiche += ",height=" + altezza;
	caratteristiche += ",width=" + lunghezza;
	caratteristiche += ",screenX=" + posX;			//Netscape
	caratteristiche += ",left=" + posX;			//IE4
	caratteristiche += ",screenY=" + posY;			//Netscape
	caratteristiche += ",top=" + posY;			//IE4
	caratteristiche += ",fullscreen=" + fullscreen; 	//solo IE4
	caratteristiche += ",resizable=" + resizable;

	popupWindow = window.open(url, nome, caratteristiche);
	popupWindow.focus();
	popupWindow.opener = self;
	//document.form1.action=pag;
	//opener.form1.submit();
	
	//document.form1.action=url;
	
	//document.form1.target="importa_allegato";
	
	//document.form1.submit();
	
	//popupWindow.name.value=nome
	//alert(popupWindow.name.value)

}

//apre una finestra senza niente e di dimensione fissa
function apri_finestra_noscrollbar(url, nomeWindow, lunghezza, altezza) {
	nome = nomeWindow;
	// ------------------------------------------
	// Altezza della finestra [numero]
	if (altezza == null) {
		altezza = 600;
	}
	// ------------------------------------------
	// Lunghezza della finestra [numero]
	if (lunghezza == null) {
		lunghezza = 800;
	}	
	// ------------------------------------------
	// Posiziona finestra al centro [true|false]
	centra = true;
	// ------------------------------------------
	// Distanza dal margine sinistro [numero]
	posX = 100;
	// ------------------------------------------
	// Distanza dal margine destro [numero]
	posY = 100;
	// ------------------------------------------
	// Visualizza a pieno schermo - solo IE4
	fullscreen='no';
	// ------------------------------------------
	// Ridimensionabile [yes|no]
	resizable='no';
	// ------------------------------------------
	// Visualizza barra del menu [yes|no]
	menuB='no';
	// ------------------------------------------
	// Visualizza barre di scorrimento [yes|no]
	scrollB='no';	
	// ------------------------------------------
	// Visualizza barra di stato [yes|no]
	statusB='no';	
	// ------------------------------------------
	// Visualizza barra degli indirizzi [yes|no]
	location='yes';	
	// ------------------------------------------

	if (centra) {
		posX = Math.round((screen.width - lunghezza)/2);
		posY = Math.round((screen.height - altezza)/2);		
	}

	caratteristiche = "menubar=" + menuB;
	caratteristiche += ",scrollbars=" + scrollB;
	caratteristiche += ",statusbar=" + statusB;		//Netscape
	caratteristiche += ",status=" + statusB;		//IE4
	caratteristiche += ",height=" + altezza;
	caratteristiche += ",width=" + lunghezza;
	caratteristiche += ",screenX=" + posX;			//Netscape
	caratteristiche += ",left=" + posX;			//IE4
	caratteristiche += ",screenY=" + posY;			//Netscape
	caratteristiche += ",top=" + posY;			//IE4
	caratteristiche += ",fullscreen=" + fullscreen; 	//solo IE4
	caratteristiche += ",resizable=" + resizable;
	caratteristiche += ",location=" + location;

	popupWindow = window.open(url, nome, caratteristiche);
	popupWindow.opener = self;
}

//apre una finestra fuori dallo schermo
function apri_finestra_download(url, nomeWindow, lunghezza, altezza) {
	nome = nomeWindow;
	//alert("ciao");
	// ------------------------------------------
	// Altezza della finestra [numero]
	if (altezza == null) {
		altezza = screen.height-15;
	}
	// ------------------------------------------
	// Lunghezza della finestra [numero]
	if (lunghezza == null) {
		lunghezza = screen.width-15;
	}	
	// ------------------------------------------
	// Posiziona finestra al centro [true|false]
	centra = false;
	// ------------------------------------------
	// Distanza dal margine sinistro [numero]
	posX = 1000;
	// ------------------------------------------
	// Distanza dal margine destro [numero]
	posY = 1000;
	// ------------------------------------------
	// Visualizza a pieno schermo - solo IE4
	fullscreen='no';
	// ------------------------------------------
	// Ridimensionabile [yes|no]
	resizable='yes';
	// ------------------------------------------
	// Visualizza barra del menu [yes|no]
	menuB='yes';
	// ------------------------------------------
	// Visualizza barre di scorrimento [yes|no]
	scrollB='yes';	
	// ------------------------------------------
	// Visualizza barra di stato [yes|no]
	statusB='yes';	
	// ------------------------------------------

	if (centra) {
		posX = Math.round((screen.width - lunghezza)/2);
		posY = Math.round((screen.height - altezza)/2);		
	}

	caratteristiche = "menubar=" + menuB;
	caratteristiche += ",scrollbars=" + scrollB;
	caratteristiche += ",statusbar=" + statusB;		//Netscape
	caratteristiche += ",status=" + statusB;		//IE4
	caratteristiche += ",height=" + altezza;
	caratteristiche += ",width=" + lunghezza;
	caratteristiche += ",screenX=" + posX;			//Netscape
	caratteristiche += ",left=" + posX;			//IE4
	caratteristiche += ",screenY=" + posY;			//Netscape
	caratteristiche += ",top=" + posY;			//IE4
	caratteristiche += ",fullscreen=" + fullscreen; 	//solo IE4
	caratteristiche += ",resizable=" + resizable;

	popupWindow = window.open(url, nome, caratteristiche);
	popupWindow.opener = self;

}

//Espande la finestra a tutto schermo
function espandi_fin() {			
	window.moveTo(0,0);
	window.resizeTo(screen.width,screen.height);
}

//submit form
function invia_form(pag,nome_form) {
	//alert(pag);
	str = "document."+nome_form+".action='"+pag+"';"
	str2 = "document."+nome_form+".submit()"+";"
	eval(str);
	eval(str2);
}

//submit form e apre finestra
function invia_finestra_nobar(pag,nome,larg,lung) {
	//alert(pag)	
	document.form1.action="apri_finestra_nobar("+pag+", "+nome+", "+larg+", "+lung+")";		
	document.form1.submit();
}

//Cambia pagina
function vai(pag){
	self.location.href=pag
}	

//modifica il messaggio sulla status bar
function mess_barra(messaggio) { //v1.0
  status=messaggio;
  document.MM_returnValue = true;
}

/*testo dinamico in documento*/
function testoHTML(quale, valore) {		
	valore = sostituisci(valore,"§","'");
	valore = sostituisci(valore,"£","\"");
	//alert(valore);
	document.getElementById(quale).innerHTML = valore;
}

function sostituisci(stringa,char1,char2) {
	temp = "" + stringa;
	while (temp.indexOf(char1)>-1) {
		pos= temp.indexOf(char1);
		temp = "" + (temp.substring(0, pos) + char2 + temp.substring((pos + char1.length), temp.length));
	}
	return temp;
}

/*Seleziona o deseleziona un gruppo di checkbox, appartenenti ad un form chiamato "form1", 
che si chiamano col medesimo prefisso concatenato ad un numero progressivo*/
//nome: il prefisso comune delle checkbox.
//tot: quante sono le checkbox in totale.
//check: true se voglio selezionarle, false se voglio deselezionarle.
function sel_tutti(nome,tot,check)
{
	for(i=1;i<=tot;i++)
	{
		el=nome+i;
		document.form1.elements[el].checked=check;
	}
}

/* fa comparire la finestra di conferma / annulla */
function scelta_mess(messaggio) {
	pass = confirm(messaggio)
	if (pass == 1) {		
		//invia(pag);
		return true;
	}
	else
	{
	    return false;
	}
}

/* setta visibile / invisibile */
function cambia_stato(quale) {
	//alert(document.getElementById(quale).style.visibility);
	if (document.getElementById(quale).style.visibility == 'visible') {
		//alert("1");
		document.getElementById(quale).style.visibility = 'hidden';
		document.getElementById(quale).style.display = 'none';
		//document.form1.Tigullio_vis.value = "invisibile"
		//document.all.testo.innerHTML = "Clicca sul titolo per rendere visibile il contenuto";
	} else {
		//alert("2");
		document.getElementById(quale).style.visibility = 'visible';
		document.getElementById(quale).style.display = 'block';
		//document.form1.Tigullio_vis.value = "visibile";
		//document.all.testo.innerHTML = "Clicca sul titolo per rendere invisibile il contenuto";
	}
}

/* setta visibile */
function visibile(quale) {	
	document.getElementById(quale).style.visibility = 'visible';
	document.getElementById(quale).style.display = 'block';	
}

/* setta invisibile */
function invisibile(quale) {	
	document.getElementById(quale).style.visibility = 'hidden';
	document.getElementById(quale).style.display = 'none';	
}

/* disabilita controllo */
function disabilita_tasto(nome_id) {
	//alert(document.getElementById(nome_id).disabled);
	document.getElementById(nome_id).disabled=true;
}

/* Effetto 3D*/
	/*
	function cambia_stile_menu(class_id, stato) {		
		nome_class = document.getElementById(class_id).className;
		//alert(nome_class);
		//alert(nome_class.indexOf('_'));
		if (nome_class.indexOf('_') <= 0) {			
			//nome_class = nome_class.toString();
			document.getElementById(class_id).className = nome_class+"_h";
		} else {
			Arr_nome_class = nome_class.split('_');
			//alert(Arr_nome_class[1]);
			document.getElementById(class_id).className = Arr_nome_class[0];
		}
	}
	*/
	function crea_link(pag) {				
		document.location.href = pag;		
	}
/* fine Effetto 3D*/

function cambia_stile_menu(id) {		
		NomeImg = document.getElementById(id).src;
		//alert(NomeImg);		
		ArrNomeImg = NomeImg.split("/");
		//alert(ArrNomeImg.length);
		//alert(ArrNomeImg.length);
		dirImg = ArrNomeImg[ArrNomeImg.length-2];
		nome_img = ArrNomeImg[ArrNomeImg.length-1];
		//alert(ArrNomeImg.lenght);
		
		
		trovato = nome_img.indexOf("_h.");
		//alert("trovato="+trovato);
		if (trovato == -1)
		{
		    Arr = nome_img.split(".");
		    nome_file = dirImg + "/" + Arr[0] + "_h." + Arr[1];
		    document.getElementById(id).src = nome_file;
		    //alert("1=" + nome_file);
		}	
		else
		{
		    Arr = nome_img.split(".");
		    Arr2 = Arr[0].split("_");		    
		    nome_file = dirImg + "/" +Arr2[0] + "." + Arr[1];
		    //alert(Arr[0]);
		    //alert(Arr[1]);
		    //alert(Arr2[0]);
		    //alert(Arr2[1]);
		    document.getElementById(id).src = nome_file;
		    //alert("2=" + nome_file);
		}			
	}

//submit form
function provaAlert(testo) {
	alert(testo);	
}

