<!-- // JavaScript Document
$(function() {
	// email address
	$('a.email').each(function() {
		var HIAAPartiIndirizzo = $(this).attr('href').split('/');
		var HIASIndirizzo = (HIAAPartiIndirizzo[HIAAPartiIndirizzo.length - 1]).replace('.htm#', '@').replace('?', '.');
		$(this).attr('href', 'mailto:' + HIASIndirizzo);
		$(this).text(HIASIndirizzo);
	});

	// slideshow
	$('ul#slideshow').innerfade({
		speed: 4000,
		timeout: 8000,
		type: 'random',
		containerheight: 245
	});

	// fancybox
	if($('div.gallery').size() > 0) {
		$('div.gallery a').fancybox();
	}
	if($('#body a[rel]:has(img)').size() > 0) {
		$('#body a[rel]:has(img)').fancybox();
	}

	// form
	if($('form').size() > 0) {
		$('.dependent:not(".show")').hide();

		// tipo impianto
		$('select#HIFSTipo').change(function() {
			if($(this).val() == 'ascensore') {
				$('#building').fadeIn();
			}
			else {
				$('select#HIFSEdificio option').removeAttr('selected');
				$('select#HIFSEdificio option:eq(0)').attr('selected', 'selected');
				$('#building:visible').removeClass('show').fadeOut();
			}
		});

		// portata
		$('select#HIFSPersone').change(function() {
			HIANIndex = $('option:selected', this).index();
			$('select#HIFSKg option').removeAttr('selected');
			$('select#HIFSKg option:eq(' + HIANIndex + ')').attr('selected', 'selected');
		});
		$('select#HIFSKg').change(function() {
			HIANIndex = $('option:selected', this).index();
			$('select#HIFSPersone option').removeAttr('selected');
			$('select#HIFSPersone option:eq(' + HIANIndex + ')').attr('selected', 'selected');
		});

		// fermate
		$('input[name=HIFRFermate]').change(function() {
			if($(this).val() == 'piu di 5') {
				$('input#HIFTFermate')
					.val('quante?')
					.css({
						 color:	'#999'
					})
					.focus(function() {
						if($(this).val() == 'quante?') {
							$(this)
								.val('')
								.css({
									 color: '#000'
								});
						}
					});
				$('.dependent:has(input#HIFTFermate)').fadeIn();
			}
			else {
				$('input#HIFTFermate').val('');
				$('.dependent:has(input#HIFTFermate:visible)').removeClass('show').fadeOut();
			}
		});

		// struttura/tamponamento
		$('select#HIFSStruttura').change(function() {
			if($(this).val().indexOf('autoportante') > -1) {
				$('#tamponage').fadeIn();
			}
			else {
				$('select#HIFSTamponamento option').removeAttr('selected');
				$('select#HIFSTamponamento option:eq(0)').attr('selected', 'selected');
				$('#tamponage:visible').removeClass('show').fadeOut();
			}
		});

		// finiture
		$('input:checkbox[id^="HIFCFiniture"][id$="_altro"]').change(function() {
			if($(this).prop('checked')) {
				$(this).closest('p').find('input[type="text"]')
					.val('specificare...')
					.css({
						 color:	'#999'
					})
					.focus(function() {
						if($(this).val() == 'specificare...') {
							$(this)
								.val('')
								.css({
									 color: '#000'
								});
						}
					});
				$(this).closest('p').find('span.dependent').fadeIn();
			}
			else {
				$(this).closest('p').find('input[type="text"]').val('');
				$(this).closest('p').find('span.dependent:visible').removeClass('show').fadeOut();
			}
		});

		// tagliafuoco
		$('select#HIFSTagliafuoco').change(function() {
			if($(this).val() == 'si') {
				$('#minutes').fadeIn();
			}
			else {
				$('select#HIFSMinuti option').removeAttr('selected');
				$('select#HIFSMinuti option:eq(0)').attr('selected', 'selected');
				$('#minutes:visible').removeClass('show').fadeOut();
			}
		});

		$('form').validationEngine();
	}
});

-->
