function move(id) {
		
  		$("#"+id).animate({paddingLeft: "75px"}, 50);
		switch(String(id)) {
		case 'menu1':
			$("#menu2").animate({paddingLeft: "50px"}, 100);
			$("#menu3").animate({paddingLeft: "50px"}, 100);
			$("#menu4").animate({paddingLeft: "50px"}, 100);
			$("#menu5").animate({paddingLeft: "50px"}, 100);
			$("#menu6").animate({paddingLeft: "50px"}, 100);
		break;
		
		case 'menu2':
			$("#menu1").animate({paddingLeft: "50px"}, 100);
			$("#menu3").animate({paddingLeft: "50px"}, 100);
			$("#menu4").animate({paddingLeft: "50px"}, 100);
			$("#menu5").animate({paddingLeft: "50px"}, 100);
			$("#menu6").animate({paddingLeft: "50px"}, 100);
		break;
		
		case 'menu3':
			$("#menu1").animate({paddingLeft: "50px"}, 100);
			$("#menu2").animate({paddingLeft: "50px"}, 100);
			$("#menu4").animate({paddingLeft: "50px"}, 100);
			$("#menu5").animate({paddingLeft: "50px"}, 100);
			$("#menu6").animate({paddingLeft: "50px"}, 100);
		break;
		
		case 'menu4':
			$("#menu1").animate({paddingLeft: "50px"}, 100);
			$("#menu2").animate({paddingLeft: "50px"}, 100);
			$("#menu3").animate({paddingLeft: "50px"}, 100);
			$("#menu5").animate({paddingLeft: "50px"}, 100);
			$("#menu6").animate({paddingLeft: "50px"}, 100);
		break;
		
		case 'menu5':
			$("#menu1").animate({paddingLeft: "50px"}, 100);
			$("#menu2").animate({paddingLeft: "50px"}, 100);
			$("#menu3").animate({paddingLeft: "50px"}, 100);
			$("#menu4").animate({paddingLeft: "50px"}, 100);
			$("#menu6").animate({paddingLeft: "50px"}, 100);
		break;
		
		case 'menu6':
			$("#menu1").animate({paddingLeft: "50px"}, 100);
			$("#menu2").animate({paddingLeft: "50px"}, 100);
			$("#menu3").animate({paddingLeft: "50px"}, 100);
			$("#menu4").animate({paddingLeft: "50px"}, 100);
			$("#menu5").animate({paddingLeft: "50px"}, 100);
		break;
		}

	}
	
	function move_back(id) {
			$("#menu1").animate({paddingLeft: "50px"}, 100);
			$("#menu2").animate({paddingLeft: "50px"}, 100);
			$("#menu3").animate({paddingLeft: "50px"}, 100);
			$("#menu4").animate({paddingLeft: "50px"}, 100);
			$("#menu5").animate({paddingLeft: "50px"}, 100);
			$("#menu6").animate({paddingLeft: "50px"}, 100);
		}
		
		function energie_rinnovabili_show() {
		$("#opt").fadeOut("slow");
		$("#opt1").fadeIn("slow");
		}
		
		function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Indirizzo email non valido")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Indirizzo email non valido")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Indirizzo email non valido")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Indirizzo email non valido")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Indirizzo email non valido")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Indirizzo email non valido")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Indirizzo email non valido")
		    return false
		 }

 		 return true					
	}
		function validate_price() {
		var rgx = /^\d+\.\d{2}/;
		if (!rgx.test(document.form1.importo.value)) {
			return 0;
			} else {
			return 1;
			}
		}

		function check_lavora() {
		if (!(echeck(document.getElementById('email').value))) return false;
		if (document.getElementById('nome').value == "") {
			alert('Inserire il nome.');
			return false;
		}
		if (document.getElementById('cognome').value == "") {
			alert('Inserire il cognome.');
			return false;
		}
		if (document.getElementById('indirizzo').value == "") {
			alert('Inserire l\'indirizzo.');
			return false;
		}
		if (document.getElementById('citta').value == "") {
			alert('Inserire la citta\'.');
			return false;
		}
		if (document.getElementById('cellulare').value == "") {
			alert('Inserire il cellulare.');
			return false;
		}
		if (document.getElementById('telefonofisso').value == "") {
			alert('Inserire un numero fisso');
			return false;
		}
		if (document.getElementById('richiesta').value == "") {
			alert('Inserire la richiesta.');
			return false;
		}
		
		if (document.getElementById('privacy').checked == false) {
			alert('E\' necessario accettare il consenso al trattamento dei dati personali.');
			
			return false;
		}
		document.form1.submit();
		}
		
		function check_richiesta() {
		if (!(echeck(document.getElementById('email').value))) return false;
		if (document.getElementById('intestatario').value == "") {
			alert('Inserire l\'intestatario del contratto.');
			return false;
		}
		if (document.getElementById('numero').value == "") {
			alert('Inserire il numero del contratto.');
			return false;
		}
		if (document.getElementById('nominativo').value == "") {
			alert('Inserire il nominativo del defunto.');
			return false;
		}
		document.getElementById("Invia").value = "Attendere prego....";
		document.getElementById("Invia").disabled = true;
		
		document.form1.submit();
		
		}
		
		function check_richiesta2() {
		if (!(echeck(document.getElementById('email').value))) return false;
		if (document.getElementById('intestatario').value == "") {
			alert('Inserire l\'intestatario del contratto.');
			return false;
		}
		if (document.getElementById('numero').value == "") {
			alert('Inserire il numero del contratto.');
			return false;
		}
		if (document.getElementById('nominativo').value == "") {
			alert('Inserire il nominativo del defunto.');
			return false;
		}
		
		if (validate_price() == 0) { 
		alert("Inserire un prezzo nella forma: intero punto due decimali (es. 123.45)");
		return false; } 
		
		document.form1.submit();
		}
		
		function check_invio_email_pagamento(id) {
		if (validate_price() == 0) { 
		alert("Inserire un prezzo nella forma: intero punto due decimali (es. 123.45)");
		return false; } 
		if(confirm("Confermare l'invio dell'email di pagamento?")) 
			{ 
				document.form1.action = "write.php?mod=invio_email_pagamento&id=" + id;
				document.form1.submit();
			} else {
				return;
				}
		}
		
		function check_eliminazione_transazione(id) {
		if(confirm("Confermare l'eliminazione DEFINITIVA della transazione?")) 
			{ 
				document.location = "write.php?mod=elimina_transazione&id=" + id;
			} else {
				return;
				}
		}
		
		function view_brochure(id) {
			
		switch(String(id)) {
		case '1':
		document.getElementById('brochure').innerHTML = "<img src=\"img/brochure1.gif\" alt=\"flower\" width=\"260\" height=\"407\" />";
		break;
		
		case '2':
		document.getElementById('brochure').innerHTML = "<img src=\"img/brochure2.gif\" alt=\"flower\" width=\"260\" height=\"407\" />";
		
		break;
		
		case '3':
		document.getElementById('brochure').innerHTML = "<img src=\"img/brochure3.gif\" alt=\"flower\" width=\"260\" height=\"407\" />";
		
		break;
		
		case '4':
		document.getElementById('brochure').innerHTML = "<img src=\"img/brochure4.gif\" alt=\"flower\" width=\"260\" height=\"407\" />";
		
		break;
		}
		
		
		}
		function back_brochure() {
			
			docuemt.getElementById('brochure').innerHTML = "<img src=\"img/fiore.gif\" alt=\"flower\" width=\"260\" height=\"407\" />";
		
		}
		
		function preloadImages() {
 	 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}
	
	function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}
	
	$(function() {
    setInterval( "slideSwitch()", 8000 );
	});
	
	function cambia_data_grafico() {
		document.location.href = "visualizza_impianto_solare/?anno="+$('#anno').val()+"&mese="+$('#mese').val()+"&giorno="+$('#giorno').val();
	}
	
	function cambia_data_grafico_pannelli() {
		document.location.href = "grafici_temperatura_pannelli/?anno="+$('#anno').val()+"&mese="+$('#mese').val()+"&giorno="+$('#giorno').val();
	}

function cambia_data_grafico_energia_giornaliera() {
		document.location.href = "grafici_energia_giornaliera/?anno="+$('#anno').val()+"&mese="+$('#mese').val()+"&giorno="+$('#giorno').val();
	}
	
	function cambia_data_grafico_energia_mensile() {
		document.location.href = "grafici_energia_mensile/?anno="+$('#anno').val()+"&mese="+$('#mese').val()+"&giorno="+$('#giorno').val();
	}
function visualizza_grafico() {
	switch($('#select_chart').val()) {
	case "2":
	document.location.href = "grafici_temperatura_pannelli/";
	break;
	
	case "3":
	document.location.href = "grafici_energia_mensile/";
	break;
	
	case "4":
	document.location.href = "grafici_energia_giornaliera/";
	break;
	
	case "5":
	document.location.href = "grafici_energia_annuale/";
	break;
	
	default:
	break;
	}
}
