$(document).ready( function(){
	ROLL.rollover.init();
});

ROLL = {};

ROLL.rollover =
{
   init: function()
   {
      this.preload();

      $(".ro").hover(
         function () { $(this).attr( 'src', ROLL.rollover.newimage($(this).attr('src')) ); },
         function () { $(this).attr( 'src', ROLL.rollover.oldimage($(this).attr('src')) ); }
      );

      $(".robutton").hover(
         function () { $(this).attr( 'class', ROLL.rollover.newimagebutton($(this).attr('class')) ); },
         function () { $(this).attr( 'class', ROLL.rollover.oldimagebutton($(this).attr('class')) ); }
      );
  },

   preload: function()
   {
      $(window).bind('load', function() {
         $('.ro').each( function( key, elm ) { $('<img>').attr( 'src', ROLL.rollover.newimage( $(this).attr('src') ) ); });
      });
   },

   newimage: function( src )
   {
      return src.substring( 0, src.search(/(\.[a-z]+)$/) ) + '_on' + src.match(/(\.[a-z]+)$/)[0];
   },

   oldimage: function( src )
   {
      return src.replace(/_on\./, '.');
   },

   newimagebutton: function( src )
   {
      return src + '_on';
   },

   oldimagebutton: function( src )
   {
      return src.replace(/_on/, '');
   }
};

(function($){
	$.fn.linking = function(){
		var linked = $(this).attr("linked");
		var hijo = $(this).attr("hijo");
		var firstvalue = $(this).attr("firstvalue");
		if(linked == "true"){
			$.getJSON("./ajax.returnJson.php",{id: $(this).val(), hijo: hijo}, function(j){
				var options = '';
				options += '<option value="">' + firstvalue + '</option>';
				
				for (var i = 0; i < j.length; i++) {
					options += '<option value="' + j[i].index + '">' + j[i].value + '</option>';
				}
				$('#' + hijo).html(options);
				//$('#' + hijo + ' option:first').attr('selected', 'selected');
				$("#idcomuneFV option[value='"+$("#idcomuneZC_hidden").val()+"']").attr('selected', 'selected');
				$('#' + hijo).change();
			})
		}
		var update = $(this).attr("update");
		if(update == "true"){
			var hijos = $(this).attr("hijos").split('|');
			if (hijos[0]) {
			$.get("./ajax.returnValue.php",{id: $(this).val(), hijo: hijos[0]}, function(j){
				$('#' + hijos[0]).val(j);
				$('#' + hijos[0]).change();
			})
			}
			if (hijos[1]) {
			$.get("./ajax.returnValue.php",{id: $(this).val(), hijo: hijos[1]}, function(j){
				$('#' + hijos[1]).val(j);
				$('#' + hijos[1]).change();
			})
			}
			if (hijos[2]) {
			$.get("./ajax.returnValue.php",{id: $(this).val(), hijo: hijos[2]}, function(j){
				$('#' + hijos[2]).val(j);
				$('#' + hijos[2]).change();
			})
			}
			if (hijos[3]) {
			$.get("./ajax.returnValue.php",{id: $(this).val(), hijo: hijos[3]}, function(j){
				$('#' + hijos[3]).val(j);
				$('#' + hijos[3]).change();
			})
			}
			if (hijos[4]) {
			$.get("./ajax.returnValue.php",{id: $(this).val(), hijo: hijos[4]}, function(j){
				$('#' + hijos[4]).val(j);
				$('#' + hijos[4]).change();
			})
			}
			if (hijos[5]) {
			$.get("./ajax.returnValue.php",{id: $(this).val(), hijo: hijos[5]}, function(j){
				$('#' + hijos[5]).val(j);
				$('#' + hijos[5]).change();
			})
			}
			if (hijos[6]) {
			$.get("./ajax.returnValue.php",{id: $(this).val(), hijo: hijos[6]}, function(j){
				$('#' + hijos[6]).html(j);
			})
			}
		}
	}
})(jQuery);

$(function(){
	$("select").change(function(){
		$(this).linking();
	})
});

$(function(){
	$("#idcomuneZC_hidden").change(function(){
		$(this).linking();
	})
});

$(function(){
	$("#idprovFV").change(function(){
		$(this).linking();
	})
});

(function($){
	$.fn.updating = function(){
		var hijo = $(this).attr("hijos");
		if ($('#' + hijo).val() == '' || $('#' + hijo).val() == '0,0' || $('#' + hijo).val() == '0') {
			$.get("./ajax.returnValue.php",{id: $(this).val(), hijo: hijo, type: $("input[name='tipo_intervento']:checked").val()}, function(j){
				$('#' + hijo).val(j);
			})
		}
	}
})(jQuery);

$(function(){
	$("#parete_K_impostato").change(function(){
		$(this).updating();
	})
});

$(function(){
	$("#soffitto_K_impostato").change(function(){
		$(this).updating();
	})
});

$(function(){
	$("#pavimento_K_impostato").change(function(){
		$(this).updating();
	})
});

$(function(){
	$("#finestre_K_impostato").change(function(){
		$(this).updating();
	})
});

$(function(){
	$("input[name='tipo_intervento']").change(function(){
		var linked = $(this).attr("linked");
		var update = $(this).attr("update");
		var hijos = $(this).attr("hijos").split('|');
		var hijos2 = $(this).attr("hijos2").split('|');
		var firstvalue = $(this).attr("firstvalue");
		if(linked == "true"){
			$.getJSON("./ajax.returnJson.php",{id: $("input[name='tipo_intervento']:checked").val(), hijo: hijos[0]}, function(j){
				var options = '';
				options += '<option value="">' + firstvalue + '</option>';
				
				for (var i = 0; i < j.length; i++) {
					options += '<option value="' + j[i].index + '">' + j[i].value + '</option>';
				}
				$('#' + hijos[0]).html(options);
				$('#' + hijos[0] + ' option:first').attr('selected', 'selected');
				$('#' + hijos[0]).change();
			});
			$.getJSON("./ajax.returnJson.php",{id: $("input[name='tipo_intervento']:checked").val(), hijo: hijos[1]}, function(j){
				var options = '';
				options += '<option value="">' + firstvalue + '</option>';
				
				for (var i = 0; i < j.length; i++) {
					options += '<option value="' + j[i].index + '">' + j[i].value + '</option>';
				}
				$('#' + hijos[1]).html(options);
				$('#' + hijos[1] + ' option:first').attr('selected', 'selected');
				$('#' + hijos[1]).change();
			});
			$.getJSON("./ajax.returnJson.php",{id: $("input[name='tipo_intervento']:checked").val(), hijo: hijos[2]}, function(j){
				var options = '';
				options += '<option value="">' + firstvalue + '</option>';
				
				for (var i = 0; i < j.length; i++) {
					options += '<option value="' + j[i].index + '">' + j[i].value + '</option>';
				}
				$('#' + hijos[2]).html(options);
				$('#' + hijos[2] + ' option:first').attr('selected', 'selected');
				$('#' + hijos[2]).change();
			});
			$.getJSON("./ajax.returnJson.php",{id: $("input[name='tipo_intervento']:checked").val(), hijo: hijos[3]}, function(j){
				var options = '';
				options += '<option value="">' + firstvalue + '</option>';
				
				for (var i = 0; i < j.length; i++) {
					options += '<option value="' + j[i].index + '">' + j[i].value + '</option>';
				}
				$('#' + hijos[3]).html(options);
				$('#' + hijos[3] + ' option:first').attr('selected', 'selected');
				$('#' + hijos[3]).change();
			});	
		}
		if(update == "true"){
			$.getJSON("./ajax.returnJson.php",{id: $("input[name='tipo_intervento']:checked").val(), hijo: hijos2[0]}, function(j){
				$('#' + hijos2[0] + '_min').val(j[0].min);
				$('#' + hijos2[0] + '_min_testo').html(j[0].min);
				$('#' + hijos2[0] + '_max').val(j[0].max);
				$('#' + hijos2[0] + '_max_testo').html(j[0].max);
			});
			$.getJSON("./ajax.returnJson.php",{id: $("input[name='tipo_intervento']:checked").val(), hijo: hijos2[1]}, function(j){
				$('#' + hijos2[1] + '_min').val(j[0].min);
				$('#' + hijos2[1] + '_min_testo').html(j[0].min);
				$('#' + hijos2[1] + '_max').val(j[0].max);
				$('#' + hijos2[1] + '_max_testo').html(j[0].max);
			});
			$.getJSON("./ajax.returnJson.php",{id: $("input[name='tipo_intervento']:checked").val(), hijo: hijos2[2]}, function(j){
				$('#' + hijos2[2] + '_min').val(j[0].min);
				$('#' + hijos2[2] + '_min_testo').html(j[0].min);
				$('#' + hijos2[2] + '_max').val(j[0].max);
				$('#' + hijos2[2] + '_max_testo').html(j[0].max);
			});
			$.getJSON("./ajax.returnJson.php",{id: $("input[name='tipo_intervento']:checked").val(), hijo: hijos2[3]}, function(j){
				$('#' + hijos2[3] + '_min').val(j[0].min);
				$('#' + hijos2[3] + '_min_testo').html(j[0].min);
				$('#' + hijos2[3] + '_max').val(j[0].max);
				$('#' + hijos2[3] + '_max_testo').html(j[0].max);
			});
		}
	})
});

(function($){
	$.fn.showing = function(){
		var change = $(this).attr("change");
		var hijos = $(this).attr("hijos").split('|');
		if(change == "true"){
			$('#' + hijos[0]).html('');
			$.getJSON("./ajax.returnJson.php",{id: $(this).val(), hijo: hijos[0]}, function(j){
				if (j[0].img != "")
					$('#' + hijos[0]).html('<img src="/trasmittanze/'+j[0].img+'" align="left" />'+j[0].des);
				else
					$('#' + hijos[0]).html(''+j[0].des);
				$('#' + hijos[1]).val(j[0].K);
				$('#' + hijos[2]).val(j[0].costo);
				if ($("input[name='tipo_intervento']:checked").val() > 1) {
					if (hijos[3]) 
						$('#' + hijos[3]).val(j[0].K_partenza);
				}
			});
		}
	}
})(jQuery);

$(function(){
	$("select[name='tipologie_trasmittanza_parete']").change(function(){
		$(this).showing();
	})
});

$(function(){
	$("select[name='tipologie_trasmittanza_soffitto']").change(function(){
		$(this).showing();
	})
});

$(function(){
	$("select[name='tipologie_trasmittanza_pavimento']").change(function(){
		$(this).showing();
	})
});

$(function(){
	$("select[name='tipologie_trasmittanza_finestre']").change(function(){
		$(this).showing();
	})
});

  $(document).ready(function(){
    $("#inserisci").validate();
  });

  $(document).ready(function(){
	$("#bottoni").qtip({
		content: 'Per visualizzare, modificare, copiare e/o eliminare un preventivo cliccare sulle rispettive icone.',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#show").qtip({
		content: 'Cliccare su “Visualizza” per accedere all’elenco dei preventivi realizzati. Questa sezione permette di cercare,  aprire, modificare e/o eliminare i preventivi.',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#changepwd").qtip({
		content: 'Ti ricordiamo che, dopo il primo accesso, è necessario modificare la password che Edilclima ti ha assegnato. La nuova password dovrà avere almeno 8 caratteri.',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#int").qtip({
		content: 'È possibile personalizzare l’intestazione visibile sulle stampe dei tuoi preventivi.  Al momento di attivazione del servizio da parte di Edilclima l’intestazione coincide con la Ragione Sociale. Per modificare l’intestazione inserire, nell’apposito campo, il nome che vuoi far comparire sulle stampe dei preventivi. È possibile modificare l’intestazione in qualsiasi momento.',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#diversoE1").qtip({
		content: 'Nella versione attuale non è possibile effettuare simulazioni su edifici non residenziali.',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#comuniFVHelp").qtip({
		content: 'Se non trovi il tuo scegli il pi&ugrave; vicino.',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#orientamentoHelp").qtip({
		content: 'sud = 0° - est/ovest = 90°',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#inclinazioneHelp").qtip({
		content: 'orizzontale = 0° - verticale = 90°',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#maggiorazioneHelp").qtip({
		content: 'Maggiorazione del 5% per impianti “non integrati” la cui produzione energetica viene consumata per almeno il 70% dall’utenza. Maggiorazione del 5% per impianti “integrati” che sostituiscono coperture in eternit.',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#localiRisHelp").qtip({
		content: 'Esclusi ripostigli e disimpegno.',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#localiRafHelp").qtip({
		content: 'Esclusi ripostigli e disimpegno.',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#costo_energia").qtip({
		content: 'es. 0,2 &euro;/kWh',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#costo_esercizio").qtip({
		content: '&Egrave; il costo totale dei consumi dell\'intero edificio strutturale.',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#costo_metano").qtip({
		content: 'es. 0,7 &euro;/m<sup>3</sup>',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#k_impostato_parete_n").qtip({
		content: 'Valore di trasmittanza minimo da raggiungere nel caso di intervento (valore indicativo).',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#k_impostato_parete_r").qtip({
		content: 'Valore di trasmittanza di partenza nel caso di intervento (valore indicativo).',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#costo_impostato_parete").qtip({
		content: 'Costo di realizzazione della struttura ipotizzata.',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#k_voluto_parete").qtip({
		content: 'Valore di trasmittanza che si intende raggiungere con l’intervento (valore indicativo).',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#costo_voluto_parete").qtip({
		content: 'Costo di realizzazione della struttura ipotizzata per l’intervento.',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });
  $(document).ready(function(){
	$("#k_impostato_soffitto_n").qtip({
		content: 'Valore di trasmittanza minimo da raggiungere nel caso di intervento (valore indicativo).',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#k_impostato_soffitto_r").qtip({
		content: 'Valore di trasmittanza di partenza nel caso di intervento (valore indicativo).',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#costo_impostato_soffitto").qtip({
		content: 'Costo di realizzazione della struttura ipotizzata.',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#k_voluto_soffitto").qtip({
		content: 'Valore di trasmittanza che si intende raggiungere con l’intervento (valore indicativo).',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#costo_voluto_soffitto").qtip({
		content: 'Costo di realizzazione della struttura ipotizzata per l’intervento.',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });
  $(document).ready(function(){
	$("#k_impostato_pavimento_n").qtip({
		content: 'Valore di trasmittanza minimo da raggiungere nel caso di intervento (valore indicativo).',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#k_impostato_pavimento_r").qtip({
		content: 'Valore di trasmittanza di partenza nel caso di intervento (valore indicativo).',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#costo_impostato_pavimento").qtip({
		content: 'Costo di realizzazione della struttura ipotizzata.',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#k_voluto_pavimento").qtip({
		content: 'Valore di trasmittanza che si intende raggiungere con l’intervento (valore indicativo).',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#costo_voluto_pavimento").qtip({
		content: 'Costo di realizzazione della struttura ipotizzata per l’intervento.',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });
  $(document).ready(function(){
	$("#k_impostato_finestre_n").qtip({
		content: 'Valore di trasmittanza minimo da raggiungere nel caso di intervento (valore indicativo).',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#k_impostato_finestre_r").qtip({
		content: 'Valore di trasmittanza di partenza nel caso di intervento (valore indicativo).',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#costo_impostato_finestre").qtip({
		content: 'Costo di realizzazione della struttura ipotizzata.',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#k_voluto_finestre").qtip({
		content: 'Valore di trasmittanza che si intende raggiungere con l’intervento (valore indicativo).',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#costo_voluto_finestre").qtip({
		content: 'Costo di realizzazione della struttura ipotizzata per l’intervento.',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#DELTAcostoSTRUT").qtip({
		content: 'DELTA Costo strutture: Differenza tra il costo delle strutture scelte ed il costo delle strutture previste dal minimo di legge',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#EPIMIGLIORATOSTRUT").qtip({
		content: 'EPI MIGLIORATO strutture: Valore dell’indice di prestazione ottenuto con le strutture scelte migliorate rispetto a quelle previste dal minimo di legge',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#DELTAcostoIMP").qtip({
		content: 'DELTA Costo Impianto: Differenza tra il costo dell’impianto scelto e un impianto tradizionale con caldaia + solare termico',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(document).ready(function(){
	$("#EPIMIGLIORATOIMP").qtip({
		content: 'EPI MIGLIORATO Impianto: Valore dell’indice di prestazione ottenuto con l’impianto scelto rispetto a quello ottenuto con un impianto tradizionale con caldaia + solare termico',
		show: 'mouseover',
		hide: 'mouseout',
		style: {
		   width: 220,
		   background: '#DFE7F4',
		   color: '#454545',
		   textAlign: 'left',
		   border: {
			  width: 1,
			  radius: 3,
			  color: '#AAAAAA'
		   },
		   tip: 'topLeft',
		   name: 'light' // Inherit the rest of the attributes from the preset dark style
		}
	});
  });

  $(function() {
    $("#utenti").validate({
		submitHandler: function(form) {
			$(form).ajaxSubmit({
				target: "#result"
			});
		},
		rules: {
			password: {
				required: true,
				minlength: 8
		}
	  }
	});
  });

/* 
        Italian initialisation for the jQuery UI date picker plugin. 
        Written by Apaella (apae...@gmail.com). 
        Version 1.5b2 
*/ 
jQuery(function($){ 
        $.datepicker.regional['it'] = { 
            clearText: 'Svuota', clearStatus: '', 
                clearStatus: 'Cancella la data corrente', 
                closeText: 'Chiudi', closeStatus: '', 
                closeStatus: 'Chiudi senza cambiamenti', 
                prevText: '&nbsp;&laquo;', prevStatus: '', 
                prevStatus: 'Mostra il mese precedente', 
                nextText: '&raquo;&nbsp;', nextStatus: '', 
                nextStatus: 'Mostra il mese successivo', 
                currentText: 'Oggi', currentStatus: '', 
                currentStatus: 'Mostra il mese corrente', 
                monthNames: 
['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno', 
                'Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'], 
                monthNamesShort: ['Gen','Feb','Mar','Apr','Mag','Giu', 
                'Lug','Ago','Set','Ott','Nov','Dic'], 
                monthStatus: 'Mostra un altro mese', 
                yearStatus: 'Mostra un altro anno', 
                weekHeader: 'Sm', weekStatus: '', 
                weekStatus: 'Settimana dell\'anno', 
                dayNames: 
['Domenica','Luned&#236','Marted&#236','Mercoled&#236','Gioved&#236','Vener­d&#236','Sabato'], 
                dayNamesShort: ['Dom','Lun','Mar','Mer','Gio','Ven','Sab'], 
                dayNamesMin: ['Do','Lu','Ma','Me','Gio','Ve','Sa'], 
                dayStatus: 'Imposta DD come primo giorno della settimana', 
                dateStatus: 'Seleziona DD, M d', 
                dateFormat: 'dd/mm/yy', firstDay: 1, 
				changeMonth: true, 
				gotoCurrent: true,
                initStatus: 'Seleziona una data', 
                isRTL: false 
        }; 
        $.datepicker.setDefaults($.datepicker.regional['it']); 

}); 

$(function() {
	$("#data").datepicker();
});
  
$(function() {
	$("#permesso").datepicker();
});

$(function() {
	function formatItem(row) {
		return row[0];
	}
	function formatResult(row) {
		return row[0].replace(/(<.+?>)/gi, '');
	}
	
	$("#idcomune").autocomplete("autocomplete.comuni.php", {
		width: 260,
		max: 2000,
		delay: 1,
		mustMatch: true,
		formatResult: formatResult,
		selectFirst: false
	});
	$("#idcomune").result(function(event, data, formatted) {
		if (data)
			$("#idcomune_hidden").val(data[1]);
			$("#idcomune_hidden").change();
	});
	$("#idcomuneZC").autocomplete("autocomplete.comunizc.php", {
		width: 260,
		max: 2000,
		delay: 1,
		mustMatch: true,
		formatResult: formatResult,
		selectFirst: false
	});
	$("#idcomuneZC").result(function(event, data, formatted) {
		if (data)
			$("#idcomuneZC_hidden").val(data[1]);
			$("#idcomuneZC_hidden").change();
	});
});

