function GoLogin()
{
	document.login.submit();
}

function GoLogout()
{
	document.logout.submit();
}


function POST(cart, page, pid, TF)
{
	document.post.dir.value = cart;
	document.post.url.value = page;
	document.post.paramid.value = pid;
	document.post.FT.value = TF;
	document.post.submit();
}

function SiteSearch()
{
	cosa = document.Search.keywords.value;

	TF = "1:1:"+cosa;

	POST(1, 'SiteSearch', '', TF);
}

function GoSearchUser()
{
	var n = 0;
	var QS = "";
	var URL = document.Search.url.value;
	var EleArray = document.Search.qualstatus.length;

	while (n < (EleArray))
		{
			if(document.Search.qualstatus[n].checked == true)
				{
					QS = document.Search.qualstatus[n].value;
				}
			n++;
		}
	cosa = document.Search.checerca.value;
	dove = document.Search.dir.value;

	TF = "1:1:"+cosa+":"+QS;

	POST(dove, URL, '', TF);

}

function CALENDAR(giorno, mese, anno)
{
	document.calendar.chday.value = giorno;
	document.calendar.month.value = mese;
	document.calendar.year.value = anno;
	document.calendar.submit();
}

function SubmitGlobalNews()
{
	PrendiHTML();
	var stoppa=0;
	if ((document.Editor.AlertPub.value == 1) && (document.Editor.PubGN.checked == true))
	{
		stoppa=1;
		var ConfirmTX = "Attenzione!!!\n\nSi è scelta l'opzione di inserire la News nella Mailing List.\n\nLa Mailing List diverrà attiva immediatamente e la News verrà inserita nelle code di evasione immediatamente.\n\nNon sarà possibile annullare questa operazione!!!\n\nDesiderate continuare?";
		if (window.confirm(ConfirmTX) == true)
		{
			stoppa=0;
		}
		else
		{
			return false;
		}
	}
	if (stoppa==0)
	{
		document.Editor.submit();
	}
	else
	{
		return false;
	}
}

function SubmitNewsLetter()
{
	PrendiHTML();
	var stoppa=0;
	if ((document.Editor.AlertPub.value == 1))
	{
		stoppa=1;
		var ConfirmTX = "Attenzione!!!\n\nLa Mailing List diverrà attiva immediatamente e la Newsletter verrà inserita nelle code di evasione immediatamente.\n\nNon sarà possibile annullare questa operazione!!!\n\nDesiderate continuare?";
		if (window.confirm(ConfirmTX) == true)
		{
			stoppa=0;
		}
		else
		{
			return false;
		}
	}
	if (stoppa==0)
	{
		document.Editor.submit();
	}
	else
	{
		return false;
	}
}

function ViewNEWS(IDN)
{
	document.ModNews.subazione.value = "Preview";
	document.ModNews.paramnews.value = IDN;
	document.ModNews.submit();
}

function ModNEWS(IDN)
{
	document.ModNews.subazione.value = "Modify";
	document.ModNews.paramnews.value = IDN;
	document.ModNews.submit();
}

function SubmitModNews()
{
	PrendiHTML();
	var stoppa=1;
	// Caso in cui oldpub=1 e pub=1
	if ((document.Editor.Pub.checked == true) && (document.Editor.OldPub.value == 1))
	{
		var ConfirmTX = "Attenzione!!!\n\nLa news è collegata alla Mailing List.\n\nTutte le modifiche avranno effetto anche su quest\'ultima.\n\nDesiderate continuare?";
		if (window.confirm(ConfirmTX) == true)
		{
			document.Editor.mycaso.value=1;
			stoppa=0;
		}
		else
		{
			return false;
		}
	}
	// Caso in cui oldpub=1 e pub=0
	if ((document.Editor.Pub.checked == false) && (document.Editor.OldPub.value == 1))
	{
		if(document.Editor.AlertPub.value != 1)
		{
			var ConfirmTX = "Attenzione!!!\n\nLa news è collegata alla Mailing List.\n\nSi è scelto di eliminare il collegamento.\n\nLa news verrà cancellata dalla Mailing List.\n\nDesiderate continuare?";
			if (window.confirm(ConfirmTX) == true)
			{
				stoppa=0;
				document.Editor.mycaso.value=2;
			}
			else
			{
				return false;
			}
		}
		else
		{
			stoppa=0;
			document.Editor.mycaso.value=2;
		}
	}
	// Caso in cui oldpub=0 e pub=1
	if ((document.Editor.Pub.checked == true) && (document.Editor.OldPub.value == 0))
	{
		var ConfirmTX = "Attenzione!!!\n\nSi è scelta l'opzione di inserire la News nella Mailing List.\n\n";
		if(document.Editor.AlertPub.value == 1)
		{
			ConfirmTX += "La Mailing List diverrà attiva immediatamente e la News verrà inserita nelle code di evasione immediatamente.\n\nNon sarà possibile annullare questa operazione!!!\n\n";
		}
		ConfirmTX += "Desiderate continuare?";

		if (window.confirm(ConfirmTX) == true)
		{
			stoppa=0;
			document.Editor.mycaso.value=3;
		}
		else
		{
			return false;
		}
	}
	// Caso in cui oldpub=0 e pub=0
	if ((document.Editor.Pub.checked == false) && (document.Editor.OldPub.value == 0))
	{
		stoppa=0;
		document.Editor.mycaso.value=4;
	}

	if (stoppa==0)
	{
		document.Editor.submit();
	}
	else
	{
		return false;
	}
}

function SubmitModNewsLetter()
{
	PrendiHTML();
	var stoppa=0;
	if ((document.Editor.AlertPub.value == 1))
	{
		stoppa=1;
		var ConfirmTX = "Attenzione!!!\n\nQuesta Newsletter è collegata con una News del sito.\n\nLe modifiche saranno valide solo per la NewsLetter, mentre la news del sito rimmarrà invariata.\n\nDopo l\'operazione il collegamento tra la NewsLetter e la News del sito verrà interrotto.\n\nDesiderate continuare?";
		if (window.confirm(ConfirmTX) == true)
		{
			stoppa=0;
		}
		else
		{
			return false;
		}
	}
	if (stoppa==0)
	{
		document.Editor.submit();
	}
	else
	{
		return false;
	}
}

function DelNEWS(IDN, MyAl, Pub)
{
	ConfirmTX  = "Vuoi cancellare questa news ?\n";
	ConfirmTX += "ATTENZIONE !!!\n";
	ConfirmTX += "Una volta cancellata la news non potrà essere recuperata !\n\n";

	if(MyAl==1)
	{
		ConfirmTX += "ATTENZIONE !!!\n";
		ConfirmTX += "Questa news è stata inserita anche nel tabulato delle mailing list.\n\nQuesta operazione non avrà effetti sulla mailing list\n\n";
	}

	if(MyAl==2)
	{
		ConfirmTX += "ATTENZIONE !!!\n";
		ConfirmTX += "Questa news è stata inserita anche nel tabulato delle mailing list.\n\nQuesta operazione cancellerà la news dalla mailing list\n\n";
	}

	if(MyAl==3)
	{
		ConfirmTX += "ATTENZIONE !!!\n";
		ConfirmTX += "Questa news è stata inserita anche nel tabulato delle News del sito.\n\nQuesta operazione non avrà effetti sulla News del sito\n\n";
	}

	ConfirmTX += "Si desidera continuare?\n\n";

	if (window.confirm(ConfirmTX) == true)
	{
		document.ModNews.paramnews.value = IDN;
		document.ModNews.MyAl.value = MyAl;
		document.ModNews.OldPub.value = Pub;
		document.ModNews.makeaction.value = 'Delete';
		document.ModNews.submit();
	}	
}


function GoSearchRealm()
{
	var URL = document.Search.url.value;

	cosa = document.Search.checerca.value;

	TF = "1:1:"+cosa;

	POST('', URL, '', TF)

}


function EnterRealm(Realm)
{
	document.EnterRealm.IsSetRealm.value = Realm;
	document.EnterRealm.submit();
}


function IscriviRealmPerm(Usr, IDRealm, Realm)
{
	var ConfirmTX = "Vuoi abilitare la macrocategoria \""+Realm+"\" per l\'utente "+Usr+" ?";
	if (window.confirm(ConfirmTX) == true)
	{
		document.post1.paramRealm.value = IDRealm;
		document.post1.paramNomeRealm.value = Realm;
		document.post1.makeaction.value = "add";
		document.post1.submit();
	}	
}

function CancellaRealmPerm(Usr, IDPerm, Realm)
{
	var ConfirmTX = "Vuoi disabilitare la macrocategoria \""+Realm+"\" per l\'utente "+Usr+" ?";
	if (window.confirm(ConfirmTX) == true)
	{
		document.post1.paramPerm.value = IDPerm;
		document.post1.paramNomeRealm.value = Realm;
		document.post1.makeaction.value = "del";
		document.post1.submit();
	}	
}


function ChngPage(Inizio, Pagina)
{
	document.post3.jb.value = Inizio;
	document.post3.page.value = Pagina;
	document.post3.submit();
}
	
function RetLoginList(Inizio, Pagina)
{
	document.post2.submit();
}
	
function DLBckUpDB(File)
{
	document.DownLoadDB.chefile.value = File;
	document.DownLoadDB.submit();
}
	
	
function AttSospUser(Dir, Url, ID, FT, Cosa, Nome, Lang)
{
	switch(Cosa)
	{
		case '1':
			var DescCosaITA = 'Sospendere ';
			var DescCosaENG = 'Suspend ';
		break
		case '0':
			var DescCosaITA = 'Attivare ';
			var DescCosaENG = 'Activate ';
		break
	}
		
	switch(Lang)
	{
		case 'ita':
			ConfirmTX  = DescCosaITA;
			ConfirmTX += 'L\'Utente \"'+Nome+'\" ?\n\n';
		break
		case 'eng':
			ConfirmTX  = DescCosaENG;
			ConfirmTX += 'The User \"'+Nome+'\" ?\n\n';		
		break
	}
	if (window.confirm(ConfirmTX) == true)
	{
		var Parametro = ID+':'+Cosa+':'+Nome;
		document.post.paramid.value = Parametro;
		document.post.dir.value = Dir;
		document.post.url.value = Url;
		document.post.FT.value = FT;
		document.post.submit();
	}
}
	
function CmdBanner(Tipo, Id, Nome, FT)
{
	switch(Tipo)
	{
		case 'mod':
			POST(Tipo, 'Banner', Id, FT);
		break
		case 'del':
			ConfirmTX = 'Confermi di voler eliminare il Banner \"'+Nome+'\" ?\n\n';
			if (window.confirm(ConfirmTX) == true)
			{
				var NId=Id+'|'+Nome;
				POST(Tipo, 'Banner', NId, FT);
			}	
		break
	}
}

function SubmitPagina()
{
	PrendiHTML();
	document.Editor.submit();
}

function DeletePagina(ID, Titolo, Categ, Url, FT)
{
	ConfirmTX = 'Vuoi eliminare la pagina con titolo \"'+Titolo+'\" ?\n\n';
	ConfirmTX += 'ATTENZIONE !!!\n\n';
	ConfirmTX += 'Ogni dato riferito alla pagina verrà eliminato.\n\n';
	ConfirmTX += 'Desiderate Continuare?\n\n';

	if (window.confirm(ConfirmTX) == true)
	{
		var Parametro = Categ+':del';
		document.post.paramid.value = ID;
		document.post.dir.value = Parametro;
		document.post.url.value = Url;
		document.post.FT.value = FT;
		document.post.submit();
	}
}

function ApriPopUp(img)
{
	popup(img)
}

function ApriPopUpFOTO(img,tit,did)
{
	popupFotoDidasc(img,tit,did);
}

function OpenPopFoto(ID, Seq, Didascalia, urlaction)
{
	if(ID==0)
	{
		var PopCmd="Aggiungi Foto";
		var PopAct="add";
		var PopImg=0;
		var PopId=Seq;
	}
	else
	{
		var PopCmd="Modifica Foto";
		var PopAct="mod";
		var PopImg="img.php?t=FotoGallery&c=Img&r="+ID;
		var PopId=ID;
	}

	popupFoto(PopImg,PopCmd,Seq,Didascalia,urlaction);

	document.Foto.dir.value = document.EditorFoto.dir.value;
	document.Foto.FT.value = document.EditorFoto.FT.value;
	document.Foto.paramid.value = PopId;
	document.Foto.makeaction.value = PopAct;
}

function DeleteFoto(ID, Titolo, seq)
{
	ConfirmTX = 'Vuoi eliminare la foto n°'+seq+' della galleria\n\"'+Titolo+'\" ?\n\n';
	ConfirmTX += 'ATTENZIONE !!!\n\n';
	ConfirmTX += 'La foto non potrà essere recuperata.\n\n';
	ConfirmTX += 'Desiderate Continuare?\n\n';

	if (window.confirm(ConfirmTX) == true)
	{
		var Parametro = ID+':'+seq;
		document.EditorFoto.paramid.value = Parametro;
		document.EditorFoto.makeaction.value = 'del';
		document.EditorFoto.submit();
	}
}

function MoveFoto(azione, seq)
{
	document.EditorFoto.paramid.value = seq;
	document.EditorFoto.makeaction.value = azione;
	document.EditorFoto.submit();
}

function DeleteGallery(ID, Titolo, Url, FT)
{
	ConfirmTX = 'Vuoi eliminare la Galleria Fotografica con titolo \"'+Titolo+'\" ?\n\n';
	ConfirmTX += 'ATTENZIONE !!!\n\n';
	ConfirmTX += 'Ogni immagine della galleria verrà eliminata.\n\n';
	ConfirmTX += 'Desiderate Continuare?\n\n';

	if (window.confirm(ConfirmTX) == true)
	{
		var Parametro = 'Foto:del';
		document.post.paramid.value = ID;
		document.post.dir.value = Parametro;
		document.post.url.value = Url;
		document.post.FT.value = FT;
		document.post.submit();
	}
}
