// JavaScript Document
var s=navigator.userAgent.toLowerCase();
var isIE8 = s.indexOf("msie 8.0")>0
var isIE7 = s.indexOf("msie 7.0")>0
var isIE6 = (s.indexOf("msie 6.0")>0) && (!isIE8) && (!isIE7)
/*Ajax.Responders.register({
	onCreate: function() {
		if($('box') && Ajax.activeRequestCount > 1)
			Effect.Appear('box',{duration: 0.25, queue: 'end'});
	},
	onComplete: function() {
		if($('box') && (Ajax.activeRequestCount == 1 || Ajax.activeRequestCount == 0))
			Effect.Fade('box',{duration: 0.25, queue: 'end'});
	},
	onFailure : function(resp) {
   		alert("Si e verificato un problema di richiesta asincrona.");
 	}
});*/

function CloseLoading(){
	if(Ajax.activeRequestCount == 0)
		Effect.Fade('box',{duration: 0.25, queue: 'end'});
}

function loadswfTransparent(swf,w,h){
	document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"");
    document.write("codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\"");
	document.write("width=\""+w+"\" height=\""+h+"\">");
    document.write("<param name='movie' value='"+swf+"' />\n");
    document.write("<param name='quality' value='high' />\n");
	document.write("<param name='wmode' value='transparent' />\n");
    document.write("<embed src=\""+swf+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+w+"\" height=\""+h+"\" wmode=\"transparent\"></embed>");
    document.write("</object>\n");
}

function verLogin(frm){
	if (frm.userid.value == "" || frm.password.value == ""){
		errorString = "Userid e password sono obbligatori";
		if (frm.userid.value == ""){
			frm.userid.focus();
		}
		else{
			frm.password.focus();
    	}
		alert(errorString); 
		return false;
	}
}

function VerificaForm(f){
	if(f.name == "frm_registra") {
		if(f.nome.value == "") {
     		f.nome.focus();
     		alert("Il campo NOME e obbligatorio");
     		return false;
    	}
		if(f.cognome.value == "") {
     		f.cognome.focus();
     		alert("Il campo COGNOME e obbligatorio");
     		return false;
    	}
		if(f.giorno.value == "0" || f.mese.value == "0" || f.anno.value == "0"){
    		if (f.giorno.value == "0"){
				alert("La DATA DI NASCITA non e completa, inserisci il GIORNO DI NASCITA");
				f.giorno.focus();
				return false;
			}
		
			if (f.mese.value == "0"){
				alert("La DATA DI NASCITA non e completa, inserisci il MESE DI NASCITA");
				f.mese.focus();
				return false;
			}
		
			if (f.anno.value == "0"){
				alert("La DATA DI NASCITA non e completa, inserisci l'ANNO DI NASCITA");
				f.anno.focus();
				return false;
			}
    	}
		if (f.indirizzo.value == ""){
			alert("L'INDIRIZZO e obbligatorio");
			f.indirizzo.focus();
			return false;
		}
		
		if (f.cap.value == ""){
			alert("Il Codice Avviamento Postale (CAP) e obbligatorio");
			f.cap.focus();
			return false;
		}
		
		if (f.comune.value == ""){
			alert("Il COMUNE e obbligatorio");
			f.comune.focus();
			return false;
		}
		
		if (f.regolamento.value == "NO"){
			alert("E' necessario accettare esplicitamente il regolamento della community");
			f.regolamento.focus();
			return false;
		}
		
		if(f.errore.value == "SI"){
			alert("Sono presenti errori di validazione. Verificare indirizzo email e nome utente");
			return false;
		}
	}
	else if (f.name == "frm_concorso_scherzo") {
		if (f.nome.value == ""){
			f.nome.focus();
			alert("Il campo NOME e obbligatorio");
			return false;
		}
		
		if (f.cognome.value == ""){
			f.cognome.focus();
			alert("Il campo COGNOME e obbligatorio");
			return false;
		}
	
		if (f.cellulare.value == ""){
			alert("Il CELLULARE/RECAPITO TELEFONICO e obbligatorio");
			f.cellulare.focus();
			return false;
		}
		
		Ctrl = f.email;
		result = false;
		space_tokens = Ctrl.value.split(" ");
		if(space_tokens.length == 1)
		{
			at_tokens = Ctrl.value.split("@");
			if(at_tokens.length == 2)
			{
				if(at_tokens[1].length != 0)
				{
					right_dot_tokens = at_tokens[1].split(".");
					if(right_dot_tokens.length >= 2)
					{
						if (right_dot_tokens[1].length != 0)
						{
							result=true;
						}
					}
				}
			}
		}
	
		if (!result){
			alert("Inserisci un'indirizzo E-MAIL valido");
			Ctrl.focus();
			return (result);
		}
		
		if (f.nome_amico.value == ""){
			alert("Il NOME della persona da chiamare e obbligatorio");
			f.nome_amico.focus();
			return false;
		}
		
		if (f.telefono_amico.value == ""){
			alert("Il TELEFONO della persona da chiamare e obbligatorio");
			f.telefono_amico.focus();
			return false;
		}
	}
	else if (f.name == "frm_concorso") {
		if(f.testo.value == ""){
			alert("Devi dare la tua risposta!")
			return false
		}
	}
	else if (f.name == "frm_pressione_totale"){
		if (f.nome.value == ""){
			f.nome.focus();
			alert("Il campo NOME e obbligatorio");
			return false;
		}
		
		if (f.cognome.value == ""){
			f.cognome.focus();
			alert("Il campo COGNOME e obbligatorio");
			return false;
		}
	
		if (isNaN(f.eta.value)){
			alert("L/'eta e obbligatoria");
			f.eta.focus();
			return false;
		}
		
		if (f.professione.value == ""){
			alert("La PROFESSIONE e obbligatoria");
			f.professione.focus();
			return false;
		}
		if (f.cellulare.value == ""){
			alert("Il CELLULARE e obbligatorio");
			f.cellulare.focus();
			return false;
		}
		
		Ctrl = f.email;
		result = false;
		space_tokens = Ctrl.value.split(" ");
		if(space_tokens.length == 1)
		{
			at_tokens = Ctrl.value.split("@");
			if(at_tokens.length == 2)
			{
				if(at_tokens[1].length != 0)
				{
					right_dot_tokens = at_tokens[1].split(".");
					if(right_dot_tokens.length >= 2)
					{
						if (right_dot_tokens[1].length != 0)
						{
							result=true;
						}
					}
				}
			}
		}
	
		if (!result)
		{
			errorString = "Inserisci un'indirizzo E-MAIL valido";
			alert(errorString);
			Ctrl.focus();
			return (result);
		}
		
		if (f.tipo.value == "--"){
			alert("Si, ma che TIPO sei?");
			f.tipo.focus();
			return false;
		}
		if (f.regolamento.value == "NO"){
			alert("E' necessario accettare esplicitamente il regolamento del concorso");
			f.regolamento.focus();
			return false;
		}
		return true;
	}
	else if (f.name == "frm_sondaggio") {
		var numero = f.risposta.length
		for (i=0; i<numero; i++) {
			if (f.risposta[i].checked){
				var myAjax = new Ajax.Updater("div_comm_sondaggio", "ajax_comm_sondaggio_submit.asp", {
						method: "post", 
						parameters: "risposta="+encodeURIComponent(f.risposta[i].value)+"&idsondaggio="+encodeURIComponent(f.idsondaggio.value)
					});
				return false
			}
		}
		alert("Devi selezionare almeno un opzione per votare!")
		return false
	}
	else if (f.name == "frm_messaggio" || f.name == "frm_messaggio_invia") {
		if (f.testo.value=="") {
			alert("Indicare il TESTO della risposta");
			f.testo.focus();
			return false;
		} else {
			f.Submit.disabled = true;
			f.testo.readOnly = true;
			
			if (f.name == "frm_messaggio") {
				var myAjax = new Ajax.Updater("div_risposta", "ajax_messaggio_invia.asp", {
						method: "post", 
						parameters: "idroot="+encodeURIComponent(f.idroot.value)+"&testo="+encodeURIComponent(f.testo.value),
						insertion: Insertion.Bottom
					});
				f.Submit.disabled = false;
				f.testo.readOnly = false;
			} else {
				f.oggetto.readOnly = true;
				var pars = "iddest="+encodeURIComponent(f.iddest.value)+"&testo="+encodeURIComponent(f.testo.value)+"&oggetto="+encodeURIComponent(f.oggetto.value)
				if(f.moderatore){
					pars = pars + "&moderatore="+encodeURIComponent(f.moderatore.checked)
				}
				var myAjax = new Ajax.Updater("div_risposta", "ajax_messaggio_invia.asp", {
						method: "post", 
						parameters: pars
					});
				$(div_risposta).style.visibility = "visible"
				f.oggetto.value = ""
			}
			f.testo.value = ""
			
			return false
		}
	}else if(f.name == "frm_mess_multiplo"){
		var strIdDest = $("iddest").value;
		var arrIdDest = strIdDest.split(";");
		if (arrIdDest.length == 1) {
			alert("Selezionare almeno un destinatario");
			return false;
		} else if (f.testo.value=="") {
			alert("Indicare il TESTO del messaggio");
			f.testo.focus();
			return false;
		}
	}
	else if(f.name == "frm_comm_messaggio"){
		try {
			new Ajax.Request("edit_messaggio.asp?codice_HTML="+encodeURIComponent(f.messaggio.value)+"&id="+encodeURIComponent(f.id.value), {
				method: "post",
				onSuccess: function(transport) {
					new Ajax.Updater('div_comm_notifiche', 'ajax_comm_notifiche.asp', {method: 'post', parameters: 'tipo=1' })
					f.messaggio.value = ""
				},
				onFailure: function() {
					//alert('Oooops');
					alert("errore");
				}
			}
		);
		} catch(e) {
			alert('problem with Ajax request');
		}
		
		return false
		
	}
	else if(f.name == "frm_video_add") {
		if (f.titolo.value=="") {
			alert("Il TITOLO e obbligatorio");
			f.titolo.focus();
			return false;
		} else {
			f.Submit.disabled = true;
			f.idcategoria.readOnly = true;
			f.video.readOnly = true;
			f.titolo.readOnly = true;

			try {
				new Ajax.Request("ajax_video_add.asp", {
					method: "post",
					parameters: "id="+encodeURIComponent(f.id.value)+"&titolo="+encodeURIComponent(f.titolo.value)+"&idcategoria="+encodeURIComponent(f.idcategoria.value)+"&video="+encodeURIComponent(f.video.value),
					onSuccess: function(transport) {
						var retrieved_data = transport.responseText || 'no response';
							// HERE: This shows the HTML, but that is not what I need.
							if(retrieved_data == "OK"){
								parent.location.reload(true);
							}else {
								alert(retrieved_data)
							}
						},
					onFailure: function() {
						//alert('Oooops');
						alert("errore");
					}
				}
			);
			} catch(e) {
				alert('problem with Ajax request');
			}
			
			f.Submit.disabled = false;
			f.idcategoria.readOnly = true;
			f.video.readOnly = false;
			f.titolo.readOnly = false;
			
			return false
		}
	}
	else if (f.name == "frm_commento_blog") {
		if (f.testo.value=="") {
			alert("Indicare il TESTO della risposta");
			f.testo.focus();
			return false;
		} else {
			f.Submit.disabled = true;
			f.testo.readOnly = true;
			f.titolo.readOnly = true;
			
			var myAjax = new Ajax.Updater("div_risposta", "ajax_blog_commento_invia.asp", {
					method: "post", 
					parameters: "id="+encodeURIComponent(f.id.value)+"&idarticolo="+encodeURIComponent(f.idarticolo.value)+"&moderato="+encodeURIComponent(f.moderato.value)+"&idautore="+encodeURIComponent(f.idautore.value)+"&titolo="+encodeURIComponent(f.titolo.value)+"&testo="+encodeURIComponent(f.testo.value),
					insertion: Insertion.Bottom
				});
			f.Submit.disabled = false;
			f.testo.readOnly = false;
			f.titolo.readOnly = false;
			f.testo.value = ""
			
			return false
		}
	}
	else if(f.name == "frm_migliori"){
		var appo
		var sel_value = "";
		for (var i=0; i<f.elements.length; i++) {
			var e = f.elements[i];
			if((e.name == 'selezione') && (e.value != "")){
				sel_value = sel_value + e.value + ","
			}
		}

		for(i=0;i<f.selezione.length;i++){
			appo = f.selezione[i].value
			f.selezione[i].value = appo.replace(",", "_")
			sel_value = sel_value + ","
		}
		
		var div_migliori = "div_migliori_" + f.cat.value
		
		var myAjax = new Ajax.Updater(div_migliori, "ajax_migliori_submit.asp", {
				method: "post", 
				parameters: "cat="+encodeURIComponent(f.cat.value)+"&selezione="+encodeURIComponent(sel_value)
			});			
		return false
	}
	else if (f.name == "frm_commento_video") {
		if (f.testo.value=="") {
			alert("Indicare il TESTO della risposta");
			f.testo.focus();
			return false;
		} else {
			f.Submit.disabled = true;
			f.testo.readOnly = true;
			
			var myAjax = new Ajax.Updater("div_risposta", "ajax_video_commento_invia.asp", {
					method: "post", 
					parameters: "idvideo="+encodeURIComponent(f.idvideo.value)+"&idautore="+encodeURIComponent(f.idautore.value)+"&testo="+encodeURIComponent(f.testo.value),
					insertion: Insertion.Bottom
				});
			f.Submit.disabled = false;
			f.testo.readOnly = false;
			f.testo.value = ""
			
			return false
		}
	}
	else if (f.name == "frm_mod_profilo") {
		if(f.errore.value == "SI"){
			alert("Sono presenti errori di validazione. Verificare indirizzo email e nome utente");
			return false;
		}
		if (f.nome.value == ""){
			f.nome.focus();
			alert("Il campo NOME e obbligatorio");
			return false;
		}
	
		if (f.cognome.value == ""){
			f.cognome.focus();
			alert("Il campo COGNOME e obbligatorio");
			return false;
		}
	
		if (f.giorno.value == "0" && f.mese.value == "0" && f.anno.value == "0"){
			alert("La DATA DI NASCITA e obbligatoria");
			f.giorno.focus();
			return false;
		}
	
		if (f.giorno.value == "0"){
			alert("La DATA DI NASCITA non e completa, inserisci il GIORNO DI NASCITA");
			f.giorno.focus();
			return false;
		}
	
		if (f.mese.value == "0"){
			 alert("La DATA DI NASCITA non e completa, inserisci il MESE DI NASCITA");
			 f.mese.focus();
			return false;
		}
	
		if (f.anno.value == "0"){
			alert("La DATA DI NASCITA non e completa, inserisci l'ANNO DI NASCITA");
			f.anno.focus();
			return false;
		}
	
		if (f.indirizzo.value == ""){
			alert("L'INDIRIZZO e obbligatorio");
			f.indirizzo.focus();
			return false;
		}
		
		if (f.cap.value == ""){
			alert("Il Codice Avviamento Postale (CAP) e obbligatorio");
			f.cap.focus();
			return false;
		}
	
		Ctrl = f.email;
		result = false;
		space_tokens = Ctrl.value.split(" ");
		if (space_tokens.length == 1)
		{
			at_tokens = Ctrl.value.split("@");
			if (at_tokens.length == 2)
			{
					if (at_tokens[1].length != 0)
				{
					right_dot_tokens = at_tokens[1].split(".");
					if (right_dot_tokens.length >= 2)
					{
						if (right_dot_tokens[1].length != 0)
						{
							result=true;
						}
					}
				}
			}
		}
	
		if (!result){
			alert("Inserisci un'indirizzo E-MAIL valido");
			Ctrl.focus();
			return (result);
		}
		if(f.utente.value == ""){
			alert("Il NOME UTENTE e obbligatorio");
			f.utente.focus();
			return false;
		}
		if(f.password.value != ""){
			if(f.new_pass.value == ""){
				alert("Indicare la nuova password");
				f.new_pass.focus();
				return false;
			}
			else if(f.new_pass2.value == ""){
				alert("Riscrivere la nuova password");
				f.new_pass2.focus();
				return false;
			} 
			else if(f.new_pass2.value != f.new_pass.value){
				alert("Le nuove password non coincidono. Scrivere la stessa password nei campi appositi.");
				f.new_pass.value = ""
				f.new_pass2.value = ""
				f.new_pass.focus();
				return false;
			}
		}	
	} else if(f.name == "frm_photogallery_ins") {
		if(f.titolo.value == ""){
			alert("Il TITOLO e obbligatorio");
			f.titolo.focus();
			return false;
		}
		else if(f.foto.value == ""){
			alert("La prima FOTO e obbligatoria");
			f.foto.focus();
			return false;
		}
	} else if(f.name == "frm_opzioni_admin") {
		if(f.password.value == ""){
			alert("La PASSWORD non puo essere lasciata vuota");
			f.password.focus();
			return false;
		}
	}
}

function CheckEmail(Ctrl){
	result = false;
	space_tokens = Ctrl.value.split(" ");
	if(space_tokens.length == 1)
	{
		at_tokens = Ctrl.value.split("@");
   		if(at_tokens.length == 2)
		{
			if(at_tokens[1].length != 0)
			{
				right_dot_tokens = at_tokens[1].split(".");
				if(right_dot_tokens.length >= 2)
				{
					if (right_dot_tokens[1].length != 0)
					{
						result=true;
					}
				}
			}
		}
	}	
	
	CheckEmail = result
}

function ValidatorAjax(ctrl, img, f){
	var label, url
	
	if(f == "frm_registra"){
		if($(ctrl).name == "email"){
			label = "indirizzo email"
			url = "ajax_check_email.asp?valore=" + encodeURIComponent($(ctrl).value)
		}else if($(ctrl).name == "utente"){
			label = "nome utente"
			url = "ajax_check_utente.asp?valore=" + encodeURIComponent($(ctrl).value)
		}
	}
	else{
		if($(ctrl).name == "email"){
			label = "indirizzo email"
			url = "ajax_check_email_mod.asp?valore=" + encodeURIComponent($(ctrl).value) + "&idutente=" + encodeURIComponent($('id').value)
		}else if($(ctrl).name == "utente"){
			label = "nome utente"
			url = "ajax_check_utente_mod.asp?valore=" + encodeURIComponent($(ctrl).value) + "&idutente=" + encodeURIComponent($('id').value)
		}
	}
	if($(ctrl).value == ""){
		$(img).src = "img/elementi/punto_interrogativo.gif";
		$(img).title = "Inserire un " + label + " valido"
		$('errore').value = "SI"
	} else {
		try {
			
			new Ajax.Request(
				url, {
					method: "post",
					onSuccess: function(transport) {
						var retrieved_data = transport.responseText || 'no response';
							// HERE: This shows the HTML, but that is not what I need.
							if(retrieved_data == "OK"){
								$(img).src = "img/elementi/visto.gif";
								$(img).title = label + " valido"
								$("errore").value = "NO"
							}else if(retrieved_data == "ESISTE"){
								$(img).src = "img/elementi/x.gif";
								$(img).title = label + " gia presente"
								$("errore").value = "SI"
							}else if(retrieved_data == "NON_VALIDO"){
								$(img).src = "img/elementi/punto_interrogativo.gif";
								$(img).title = "Inserire un " + label + " valido"
								$("errore").value = "SI"
							}
						},
					onFailure: function() {
						//alert('Oooops');
					}
				}
			);
		} catch(e) {
			alert('problem with Ajax request');
		}
	}
}

function UserSubmit(url, value){
	try {
		new Ajax.Request(
			url + "?id=" + value, {
				method: "post",
				onSuccess: function(transport) {
					var retrieved_data = transport.responseText || 'no response';
						// HERE: This shows the HTML, but that is not what I need.
						alert(retrieved_data)
						return true
					},
				onFailure: function() {
					alert("Si e verificato un errore nella comunicazione con il server. Contattare lo Staff.")
					return false
				}
			}
		);
	} catch(e) {
		alert("Si e verificato un errore nella creazione dell'oggetto. Contattare lo Staff.");
		return false
	}
}

function ThumbSubmit(url, id, value, div){
	try {
		new Ajax.Request(
			url + "?id=" + encodeURIComponent(id)+"&valore=" + encodeURIComponent(value), {
				method: "post",
				onSuccess: function(transport) {
					var retrieved_data = transport.responseText || 'no response';
						// HERE: This shows the HTML, but that is not what I need.
						alert(retrieved_data)
						var myAjax = new Ajax.Updater(
							div, 
							'ajax_commento_gradimento_vedi.asp', 
							{
								method: "post", 
								parameters: "id=" + encodeURIComponent(id)
							});	 
						return true
					},
				onFailure: function() {
					alert("Si e verificato un errore nella comunicazione con il server. Contattare lo Staff.")
					return false
				}
			}
		);
	} catch(e) {
		alert("Si e verificato un errore nella creazione dell'oggetto. Contattare lo Staff.");
		return false
	}
}
function ThumbVideoSubmit(url, id, value, div){
	try {
		new Ajax.Request(
			url + "?id=" + encodeURIComponent(id)+"&valore=" + encodeURIComponent(value), {
				method: "post",
				onSuccess: function(transport) {
					var retrieved_data = transport.responseText || 'no response';
						// HERE: This shows the HTML, but that is not what I need.
						alert(retrieved_data)
						var myAjax = new Ajax.Updater(
							div, 
							'ajax_commento_video_gradimento_vedi.asp', 
							{
								method: "post", 
								parameters: "id=" + encodeURIComponent(id)
							});	 
						return true
					},
				onFailure: function() {
					alert("Si e verificato un errore nella comunicazione con il server. Contattare lo Staff.")
					return false
				}
			}
		);
	} catch(e) {
		alert("Si e verificato un errore nella creazione dell'oggetto. Contattare lo Staff.");
		return false
	}
}

function StatusSubmit(url, id, value){
	try {
		new Ajax.Request(
			url + "?id=" + encodeURIComponent(id)+"&valore=" + encodeURIComponent(value), {
				method: "post",
				onSuccess: function(transport) {
					var retrieved_data = transport.responseText || 'no response';
						// HERE: This shows the HTML, but that is not what I need.
						alert(retrieved_data)
						var myAjax = new Ajax.Updater(
							div, 
							'ajax_blog_vota_vedi.asp', 
							{
								method: "post", 
								parameters: "id=" + encodeURIComponent(id)
							});	 
						return true
					},
				onFailure: function() {
					alert(url + " " + id + " " + value)
					//alert("Si e verificato un errore nella comunicazione con il server. Contattare lo Staff.")
					return false
				}
			}
		);
	} catch(e) {
			alert(url + " " + id + " " + value)
		//alert("Si e verificato un errore nella creazione dell'oggetto. Contattare lo Staff.");
		return false
	}
}

function RatingSubmit(url, id, value, div){
	try {
		new Ajax.Request(
			url + ".asp?id=" + encodeURIComponent(id)+"&valore=" + encodeURIComponent(value), {
				method: "post",
				onSuccess: function(transport) {
					var retrieved_data = transport.responseText || 'no response';
						// HERE: This shows the HTML, but that is not what I need.
						alert(retrieved_data)
						var myAjax = new Ajax.Updater(
							div, 
							url+'_vedi.asp', 
							{
								method: "post", 
								parameters: "id=" + encodeURIComponent(id)
							});	 
						return true
					},
				onFailure: function() {
					alert("Si e verificato un errore nella comunicazione con il server. Contattare lo Staff.")
					return false
				}
			}
		);
	} catch(e) {
		alert("Si e verificato un errore nella creazione dell'oggetto. Contattare lo Staff.");
		return false
	}
}

function showHide(div, pulsante, idautore, page){ 
	var index_pulsante = $(pulsante).id.indexOf("closed")

	if (index_pulsante != -1) {
		var url = page+".asp"
		var pars = "idautore="+escape(idautore);
		
		AjaxLoadUserPage(div, url, pars, new Effect.BlindDown(div, {duration:0.7}));
		
		$(pulsante).id = $(pulsante).id.substr(0, index_pulsante) + "open";
		$(pulsante).src="img/pannello/icone_community/meno.png"

		if($(pulsante).addEventListener) { //W3C
			$(pulsante).addEventListener("mouseover", function (e) {
															this.src = "img/pannello/icone_community/meno_roll.png";}, false);
			$(pulsante).addEventListener("mouseout", function (e) {
														   this.src = "img/pannello/icone_community/meno.png";}, false);
		} else {//IE
			$(pulsante).onmouseover=function() {
				this.src = "img/pannello/icone_community/meno_roll.png"};
			$(pulsante).onmouseout=function() {
				this.src = "img/pannello/icone_community/meno.png"};
		}
	} else if(index_pulsante == -1) {
		new Effect.BlindUp(div, {duration:0.7});
		$(pulsante).id = $(pulsante).id.substr(0, index_pulsante) + "closed";
		$(pulsante).src="img/pannello/icone_community/piu.png"
		
		if($(pulsante).addEventListener) { //W3C
			$(pulsante).addEventListener("mouseover", function (e) {
															this.src = "img/pannello/icone_community/piu_roll.png";}, false);
			$(pulsante).addEventListener("mouseout", function (e) {
														   this.src = "img/pannello/icone_community/piu.png";}, false);
		}else {//IE
			$(pulsante).onmouseover=function() {
				this.src = "img/pannello/icone_community/piu_roll.png";};
			$(pulsante).onmouseout=function() {
				this.src = "img/pannello/icone_community/piu.png";};
		}
	}    
	return false;
}

function ShowHideNotifica(div, pulsante){
	var index_pulsante = $(pulsante).id.indexOf("giu")

	if (index_pulsante != -1) {
		new Effect.BlindDown(div, {duration:0.7});
		$(pulsante).id = $(pulsante).id.substr(0, index_pulsante) + "su";
		$(pulsante).src="img/pannello/icone_community/freccia_su_notifiche.png"
	}else{
		new Effect.BlindUp(div, {duration:0.7});
		$(pulsante).id = $(pulsante).id.substr(0, index_pulsante) + "giu";
		$(pulsante).src="img/pannello/icone_community/freccia_giu_notifiche.png"
		
	}
}
function AjaxLoadUserPage(div, url, pars, action) {		
	var myAjax = new Ajax.Updater(
		div, 
		url, 
		{
			method: "post", 
			parameters: pars,
			onSuccess: action
		});
} 

function caricaTesto(nomeFile) {
  	var url = "community/blog/"+nomeFile+".asp"
	var pars = "idblog="+escape(idblog)+"&idautore="+escape(idautore)+"&idarticolo="+escape(idarticolo)+"&moderato="+escape(moderato)+"&mese="+escape(mese)+"&anno="+escape(anno);
		
	var myAjax = new Ajax.Updater(
		nomeFile, 
		url, 
		{
			method: "post", 
			parameters: pars,
			onCreate: $(nomeFile).innerHTML = '<p align="center"><img src="img/loading.gif"></p>'
		});
} 

function selezionaTutti(f){
	for (var i = 0; i<f.elements.length; i++) {
 		var e = f.elements[i];
 		if ((e.name != 'selectall') && (e.type=='checkbox')) {
 			e.checked = f.selectall.checked;
 		}
 	}
}

function SubmitForm(f, pagina){
	f.action = pagina
	f.submit();
}

function Ajax_LoadSubSelect(ajax_page, targetSelect, selectedValue, pars) {
  	var url = ajax_page
	var obj = $(targetSelect);
	var pars = pars
		
	var myAjax = new Ajax.Request (
		url, 
		{
			method: "post", 
			parameters: pars,
			onComplete: function showResponse(originalRequest){
				//put returned XML in the textarea
				var resp = originalRequest.responseText;
				
				obj.options.length = 0;
				if(resp != ""){
					var arrOptions = resp.split(";");
					for(i = 0; i < arrOptions.length; i++){
						if(arrOptions[i] != ""){
							var arrId = arrOptions[i].split("|");
							if(arrId[0] == selectedValue){
								obj.options[obj.options.length] = 
								new Option(arrId[1], arrId[0], false, true);
							} else {
								obj.options[obj.options.length] = 
								new Option(arrId[1], arrId[0]);
							}
						}
					}
				}
			}
		});
} 

function AjaxLoadSection(div, url, pars){
	var myAjax = new Ajax.Updater(
		div, 
		url, 
		{
			method: "post", 
			parameters: pars
		});	
}
