
function goSearch(id,chiama,valore,speciale,livello,web)
	{
		var f = eval("document.frmCerca"+id);
		if (chiama == 'argomento')
			valore = f.sel_argomento.options[f.sel_argomento.selectedIndex].text;
		f.chiamante.value = chiama;
		f.search.value = valore;
		f.livello.value = livello;
		f.speciale.value = speciale;
		f.webId.value = web;
		f.pag.value = id;
		f.page.value = '';
		f.action = 'visualizzaMenu.asp';
		f.submit();
	}
	
	function elimina(idMenu,forumId,speciale,livello,web)
	{
		if (window.confirm('Sei sicuro di voler eliminare il messaggio?'))
		{
			var linkRitorno = 'aggiornamentoMessaggi.asp?tipoAzione=5&amp;idContenutoPiazza='+idMenu+'&amp;idContenuto='+forumId+'&amp;speciale='+speciale+'&amp;livello='+livello;
			if (web != '0')
				linkRitorno = linkRitorno + '&amp;webId='+web;
			window.location.href = linkRitorno;
		}	
	}
	
	function eseguiRicerca(idMenuVisualised,cerca,special,level,webId)
	{
		var f = eval("window.document.frmCerca"+idMenuVisualised);
		word = f.txtcerca.value;
		if (word == '')
			window.alert('Attenzione!!!\nNessun termine inserito');
		else
			goSearch(idMenuVisualised,cerca,word,special,level,webId)	
	}
	
	
	function paginazione(idMenu,page,speciale,livello,web,chiama,valore,ordinamento,esegui,tipo)
	{
	document.forms[0].elements['ordine'].value = ordinamento;
	document.forms[0].elements['pag'].value = idMenu;
	document.forms[0].elements['page'].value = page;
	document.forms[0].elements['speciale'].value = speciale;
	document.forms[0].elements['livello'].value = livello;
	document.forms[0].elements['webId'].value = web;
	if (esegui == 1)
	{
		document.forms[0].elements['ricerca'].value =1;
		if (tipo == 1)
		{
			if (document.forms[0].elements['argomento'] != null)
			{
				var argomento = document.forms[0].elements['argomento'].value;
				document.forms[0].elements['txtRicercaArgomento'].value = argomento;
				document.forms[0].elements['argomento'].value = argomento;
			}
			var oggetto = document.forms[0].elements['oggetto'].value;
			document.forms[0].elements['txtRicercaOggetto'].value = oggetto;
			document.forms[0].elements['oggetto'].value = oggetto;
		}	
	
		if (tipo == 2)
		{
			var titolo = document.forms[0].elements['titolo'].value;
			document.forms[0].elements['txtRicercaTitolo'].value = titolo;
			document.forms[0].elements['titolo'].value = titolo;
		
			var corpo = document.forms[0].elements['corpo'].value;
			document.forms[0].elements['txtRicercaCorpo'].value = corpo;
			document.forms[0].elements['corpo'].value = corpo;
		}
	
		if ((tipo == 1) || (tipo == 2))
		{
			var nome =document.forms[0].elements['nome'].value;
			document.forms[0].elements['txtRicercaNome'].value = nome;
			document.forms[0].elements['nome'].value = nome;
		
			var data = document.forms[0].elements['data'].value;
			document.forms[0].elements['txtRicercaData'].value = data;
			document.forms[0].elements['data'].value = data;
		}
	}
	else
		document.forms[0].elements['ricerca'].value =0;
	document.forms[0].elements['eseguiRicerca'].value = esegui;
	if ((chiama != '0') && (valore != '0'))
	{
		if (chiama == 'argomento')
			valore = document.frmVisualizzaMenu.sel_argomento.options[document.frmVisualizzaMenu.sel_argomento.selectedIndex].text;
		document.forms[0].elements['chiamante'].value = chiama;
		document.forms[0].elements['search'].value = valore;	
	}
	
	document.forms[0].action = 'visualizzaMenu.asp';
	document.forms[0].submit(); 
}

function ordina(idMenu,speciale,livello,web,chiama,page,tipo)
{
	var valore;
	if (chiama == 'argomento')
	{
		 valore = document.frmVisualizzaMenu.sel_argomento.options[document.frmVisualizzaMenu.sel_argomento.selectedIndex].text;
		 document.forms[0].elements['chiamante'].value = chiama;
		 document.forms[0].elements['search'].value = valore;	
	}	
	else
	{
		if (chiama == 'cerca')
		{
			valore = document.forms[0].elements['txtcerca'].value;	
			 document.forms[0].elements['chiamante'].value = chiama;
		 document.forms[0].elements['search'].value = valore;	
		}	 
	}	
		
	var order = window.document.forms[0].elements['ordine'].value;
	
	var ricerca1=document.forms[0].elements['ricerca'].value;
	
	var esegui1=document.forms[0].elements['eseguiRicerca'].value;
	
	if (order == 'asc')
		window.document.forms[0].elements['ordine'].value = 'desc';
	if (order == 'desc' || order == '')
		window.document.forms[0].elements['ordine'].value = 'asc';	
	document.forms[0].elements['pag'].value = idMenu;
	document.forms[0].elements['livello'].value = livello;
	document.forms[0].elements['speciale'].value = speciale;
	document.forms[0].elements['webId'].value = web;
	document.forms[0].elements['page'].value = page;
	document.forms[0].elements['ricerca'].value = ricerca1;
	document.forms[0].elements['eseguiRicerca'].value = esegui1;
	document.forms[0].elements['tipoMenu'].value = tipo;
	
	if (esegui1 == 1)
	{
		if (tipo == 1)
		{
			if (document.forms[0].elements['argomento'] != null)
			{
				var argomento = document.forms[0].elements['argomento'].value;
				document.forms[0].elements['txtRicercaArgomento'].value = argomento;
				document.forms[0].elements['argomento'].value = argomento;
			}
			var oggetto = document.forms[0].elements['oggetto'].value;
			document.forms[0].elements['txtRicercaOggetto'].value = oggetto;
			document.forms[0].elements['oggetto'].value = oggetto;
		}	
	
		if (tipo == 2)
		{
			var titolo = document.forms[0].elements['titolo'].value;
			document.forms[0].elements['txtRicercaTitolo'].value = titolo;
			document.forms[0].elements['titolo'].value = titolo;
		
			var corpo = document.forms[0].elements['corpo'].value;
			document.forms[0].elements['txtRicercaCorpo'].value = corpo;
			document.forms[0].elements['corpo'].value = corpo;
		}
	
		if ((tipo == 1) || (tipo == 2))
		{
			var nome = document.forms[0].elements['nome'].value;
			document.forms[0].elements['txtRicercaNome'].value = nome;
			document.forms[0].elements['nome'].value = nome;
		
			var data = document.forms[0].elements['data'].value;
			document.forms[0].elements['txtRicercaData'].value = data;
			document.forms[0].elements['data'].value = data;
		}
	}
	
	document.forms[0].action = 'visualizzaMenu.asp';
	document.forms[0].submit();	
}

function eseguiRicerca1(idMenu,special,level,webId,ricerca,esegui)
{
		word = document.forms[0].elements['txtcerca'].value;
		if (word == '')
			window.alert('Attenzione!!!\nNessun termine inserito');
		else
			paginazione(idMenu,'1',special,level,webId,'cerca',word,'',ricerca,esegui)
}

function paginazione1(idMenu,forumId,page,speciale,livello,web)
{
	document.forms[0].elements['pag'].value = idMenu;
	document.forms[0].elements['page'].value = page;
	document.forms[0].elements['speciale'].value = speciale;
	document.forms[0].elements['livello'].value = livello;
	document.forms[0].elements['webId'].value = web;
	document.forms[0].elements['id'].value = forumId;
	document.forms[0].action = 'approfondimento.asp';
	document.forms[0].submit();
}

function eliminaBagni(idMenu,forumId,speciale,livello,web)
{
	if (window.confirm('Sei sicuro di voler eliminare il messaggio?'))
	{
		var linkRitorno = 'aggiornamentoMessaggi.asp?tipoAzione=5&amp;idContenutoPiazza='+idMenu+'&amp;idContenuto='+forumId+'&amp;speciale='+speciale+'&amp;livello='+livello+'&amp;caller=bagni';
		if (web != '0')
			linkRitorno = linkRitorno + '&amp;webId='+web;
		window.location.href= linkRitorno;
	}	
}

function paginazione2(idMenu,page,speciale,livello,web)
{
	document.forms[0].elements['pag'].value = idMenu;
	document.forms[0].elements['page'].value = page;
	document.forms[0].elements['speciale'].value = speciale;
	document.forms[0].elements['livello'].value = livello;
	document.forms[0].elements['webId'].value = web;
	document.forms[0].action = 'bagni.asp';
	document.forms[0].submit();
}

function disattiva(speciale,livello,web)
	{
		if (window.confirm("Sei sicuro di voler cancellarti da Piazza Nettuno e di disattivare il tuo account ?"))
		{
			document.forms[0].elements['speciale'].value = speciale;
			document.forms[0].elements['livello'].value = livello;
			document.forms[0].elements['webId'].value = web;
			document.forms[0].action = 'disattiva.asp';
			document.forms[0].submit();
		}
	}

var _sLinkOver;
function LinkOver() {
	status=_sLinkOver; 
	return true;
}

function LinkOut() {
	status='';
}

function impostaPaginaWeb(sLinkText) {
	var thelinks = document.links;

	_sLinkOver = sLinkText;
	status =_sLinkOver;
	for (var j = 0; j < thelinks.length; j++) {
			if(document.links[j].name!='NORESET') {
				thelinks[j].onmouseover = LinkOver;
				thelinks[j].onmouseout = LinkOut;
			}
		}
}

function initPage() {
	impostaPaginaWeb('');
  }
  
  
function ricercaAvanzata(speciale,livello,menu,web,ordine,tipo)
{
	document.forms[0].elements['speciale'].value=speciale;
	
	document.forms[0].elements['livello'].value=livello;
	
	document.forms[0].elements['pag'].value=menu;
	
	document.forms[0].elements['webId'].value=web;
	
	document.forms[0].elements['page'].value=1;
	document.forms[0].elements['ordine'].value=ordine;
	
	document.forms[0].elements['ricerca'].value=1;
	document.forms[0].elements['eseguiRicerca'].value=1;
	document.forms[0].elements['tipoMenu'].value = tipo;
	
	document.forms[0].action='visualizzaMenu.asp';
	
	document.forms[0].submit();		
}

function ricercaAvanzataAnnuncio(speciale,livello,menu,web,ordine,tipo)
{
	if ((document.forms[0].elements['txtRicercaTitolo'].value == '') && (document.forms[0].elements['txtRicercaCorpo'].value == '') && (document.forms[0].elements['txtRicercaNome'].value == '') && (document.forms[0].elements['txtRicercaData'].value == ''))
		alert('Attenzione!!\nInserire almeno un termine per la ricerca');
	else
	{
		
		document.forms[0].elements ['titolo'].value = document.forms[0].elements['txtRicercaTitolo'].value;
		document.forms[0].elements['corpo'].value = document.forms[0].elements['txtRicercaCorpo'].value;
		document.forms[0].elements['nome'].value = document.forms[0].elements['txtRicercaNome'].value;
		var data = document.forms[0].elements['txtRicercaData'].value;
		
		if (data != '')
		{
			 if (data.length == 10)
			{
				var gg = data.substring(0,2);
				var mm = data.substring(3,5);
				var aa = data.substring(6,10);
				if ((gg > 0) && (gg < 32) && (mm > 0) && (mm < 13) && (aa > 2000))
				{
					document.forms[0].elements['data'].value = data;
					ricercaAvanzata(speciale,livello,menu,web,ordine,tipo);
				}
				else
					alert('Attenzione!!\nData non corretta');
			}
			else  
				alert('Attenzione!!\nInserire la data nel formato specificato');
		}
		else
		{
			document.forms[0].elements['data'].value = data;
			ricercaAvanzata(speciale,livello,menu,web,ordine,tipo);
		}
	}
}

function ricercaAvanzataDiscussione(argomento,speciale,livello,menu,web,ordine,tipo)
{
	var valore;
	if (argomento == 1) 
		if (document.forms[0].elements['txtRicercaArgomento'].value == '')
			valore = 1;
		else 
			valore = 0;
	else
		valore = 1;
		
	if ((valore == 1) && (document.forms[0].elements['txtRicercaOggetto'].value == '') && (document.forms[0].elements['txtRicercaNome'].value == '') && (document.forms[0].elements['txtRicercaData'].value == ''))
		alert('Attenzione!!\nInserire almeno un termine per la ricerca');
	else
	{
		if (argomento == 1) 
			document.forms[0].elements['argomento'].value = document.forms[0].elements['txtRicercaArgomento'].value;
							
		document.forms[0].elements['oggetto'].value = document.forms[0].elements['txtRicercaOggetto'].value;
		document.forms[0].elements['nome'].value = document.forms[0].elements['txtRicercaNome'].value;
		var data = document.forms[0].elements['txtRicercaData'].value;
		if (data != '')
		{
			 if (data.length == 10)
			{
				var gg = data.substring(0,2);
				var mm = data.substring(3,5);
				var aa = data.substring(6,10);
				if ((gg > 0) && (gg < 32) && (mm > 0) && (mm < 13) && (aa > 2000))
				{
					document.forms[0].elements['data'].value = data;
					ricercaAvanzata(speciale,livello,menu,web,ordine,tipo);
				}
				else
					alert('Attenzione!!\nData non corretta');
			}
			else  
				alert('Attenzione!!\nInserire la data nel formato specificato');
		}
		else
		{
			document.forms[0].elements['data'].value = data;
			ricercaAvanzata(speciale,livello,menu,web,ordine,tipo);
		}
	}
}


function ricercaAvanzataPersonalizzato(num,speciale,livello,menu,web,ordine,tipo)
{
		 var vuoto = 0;
	
	 var i = 0;
	var numero = num + 1;
	
	document.forms[0].elements['numeroCampi'].value=numero;
	while ((i < numero) && (vuoto !=1))
		if (document.forms[0].elements['txtRicerca' + i].value != '')
			vuoto = 1;
		else
			i =i+1;
								
	if (vuoto==0)
		alert('Attenzione!!\n Inserire almeno un termine per la ricerca!');
	else
	{
		for (num1 = 0; num1 < numero; num1++)
		{
			document.forms[0].elements['campo' + num1].value=document.forms[0].elements['txtRicerca' + num1].value;
		}
		
		ricercaAvanzata(speciale,livello,menu,web,ordine,tipo);
    }
}


function ricerca(special,level,idMenu,webId)
{
	document.forms[0].elements['ricerca'].value=1;
	document.forms[0].elements['speciale'].value=special;
	document.forms[0].elements['livello'].value=level;
	document.forms[0].elements['pag'].value=idMenu;
	document.forms[0].elements['webId'].value=webId;
	document.forms[0].elements['page'].value=1;
	document.forms[0].elements['ordine'].value='';
	document.forms[0].elements['eseguiRicerca'].value=0;
	document.forms[0].action='visualizzaMenu.asp';
	document.forms[0].submit();
}
