//permette o meno il settaggio notifiche lette
var permessoSettaNotifiche = 0


function apriNotifiche(){
	if (notificheOpened == 0) {
		notificheOpened =1;
		
		$('#notificheBox').attr("class","notificheBoxVisible");
		$('#notificheButton').attr("class","notificheButtonSelected");
		
		if (startRecuperaNotifiche==1){
			//var numeroNotifiche = 0
			numeroNotifiche = document.getElementById("numNotificheHid").value;
			if (numeroNotifiche > 0){
				$('#notificheNumber').attr('class', 'notificheNumberInv');
				//parte il count per segnare le notifiche lette
				permessoSettaNotifiche = 1
				setTimeout("settaLetteNotificheAj()",4*1000);
			}
		}
	}else{
		notificheOpened =0;
		
		$('#notificheBox').attr("class","notificheBoxInvisible");
		$('#notificheButton').attr("class","notificheButtonUnselected");
		
		if (startRecuperaNotifiche == 1){
			//var numeroNotifiche = 0
			document.getElementById("numNotificheHid").value;
			if (numeroNotifiche > 0){
				$('#notificheNumber').attr('class', 'notificheNumberVis');
				//blocco il count per segnare le notifiche lette
				permessoSettaNotifiche = 0;
	
			}
		}
	}
}
		



//Recupera i messaggi e li mette nel box
function recuperaNotificheAj(){
	$.ajax({
	   type: "GET",
	   url: "/interactive/notifiche/no_recupera_notifiche_aj.asp",
	   //data: "name=John&location=Boston",
	   data: "",
	   success: function(msg){
		 //alert( "Data Saved: " + msg );
			$('#notificheBox').html(msg);
			var numeroNotifiche = document.getElementById("numNotificheHid").value;
			//var numeroNotifiche = 0
			if (numeroNotifiche > 0){
				$('#notificheNumber').html(numeroNotifiche);
				$('#notificheNumber').attr('class', 'notificheNumberVis');
			}else{
				$('#notificheNumber').attr('class', 'notificheNumberInv');
			}
	   }
	})
	setTimeout("recuperaNotificheAj()",60*1000);
}



function settaLetteNotificheAj(){
	if (permessoSettaNotifiche==1) {
		$.ajax({
		   type: "GET",
		   url: "/interactive/notifiche/no_setta_lette_aj.asp",
		   //data: "name=John&location=Boston",
		   data: "",
		   success: function(msg){
			 //alert( "Data Saved: " + msg );
				recuperaNotificheAj();
		   }
		})
	}
}


function inviaEmailNotificheAj(){
	$.ajax({
	   type: "GET",
	   url: "/interactive/notifiche/no_invia_email_aj.asp",
	   //data: "name=John&location=Boston",
	   data: "",
	   success: function(msg){
		//alert( "Data Saved: " + msg );
		//recuperaNotificheAj();
	   }
	})
}

setTimeout("inviaEmailNotificheAj()",8*1000);


