// FUNZIONE HOME

function fnHome(bHome)
{
	if(!$.browser.mobile && $.browser.flash)
	{
		if(bHome == 'false')
		{
			$("#footer").hide();
			$(".frase-home").hide();
			$("#top #container_menu").css("top", "-60px");
			$("#top #container_menu").css("opacity", "0");
			$("#top #h1").hide();
		}else{
			$("#flashHome").remove();
			$("#top #h1").fadeIn();
			$('#map_canvas_overlay').fadeOut();
			var t=setTimeout("fnAnimateAll()", 1000);
		}
	}else if(bHome == 'false' && $.browser.mobile || !$.browser.flash)
	{
		$("#flashHome").remove();
		$("#footer").hide();
		$("#top #container_menu").css("top", "-60px");
		$("#top #container_menu").css("opacity", "0");
		$("#top #h1").hide();
		$("#top #h1").fadeIn();
		$('#map_canvas_overlay').fadeOut();
		var t=setTimeout("fnAnimateAll()", 1000);
	}
}
function fnAnimateAll()
{
	$('#top #container_menu').animate({
		top: '+=70',
		opacity: '1',
	}, 500);
	$("#start-content").fadeIn();
	$("#footer").fadeIn();
	$(".frase-home").fadeIn();
}

//FUNZIONE FORM

//focus / blur

function fnFocusForm(form, Text)
{
	if(form.value == Text)
	form.value = "";
}
function fnBlurForm(form, Text)
{
	if(form.value == "")
	form.value = Text;
}

//digitare  solo numeri

function onKeyNumeric(e)
{
	// Accetto solo numeri e backspace <-
	if ( ((e.keyCode >= 48) && (e.keyCode <= 57)) || (e.keyCode == 8) || (e.keyCode == 9) || (e.keyCode == 13) ) {
		return true;
	} else {
		return false;
	}
}

//SHOW DIV

function fnShowDiv(div){
	$(document).ready(function()
	{
		$(div).fadeIn();
		$("#overlay").fadeIn();
	});
}
function fnHideDiv(div){
	$(document).ready(function()
	{
		$(div).hide();
		//$(div).fadeOut();
		$("#overlay").fadeOut();
	});
}

//FUNZIONI CERCA IMMOBILE


function controlloInserimentoDati() {

var metratura_1 = parseInt($('input[name="mtrD"]').val());
var metratura_2 = parseInt($('input[name="mtrA"]').val());

//	var prezzo_1 = $('input[name*="przD"]').val();
//	var prezzo_2 = $('input[name*="przA"]').val();

	
//if (prezzo_1 != "Da:" && prezzo_2 != "A:" || metratura_1 != "Da:" && metratura_2 != "A:") {

	//if (prezzo_2 < prezzo_1 || metratura_2 < metratura_1) {
  if (metratura_1 != "Da:" && metratura_2 != "A:") {
	if (metratura_1 > metratura_2) {
		alert("Attenzione il valore "+metratura_2+" e' maggiore del valore "+metratura_1);
		fnHideDiv('#container_loading');
		return false;
	//}
	}else{
		return true;	
	}
  }
	
}



var valore_tipo;
var nome_prov;

function stampamiValore(id, n) {
		
	valore_tipo = document.getElementsByName(id).item(n).value;
	var nome_prov=$('.cambioZona0').val();
	//alert(nome_prov);
	test_ajax(nome_prov);

}


$("type").change(function() {
});

$('.cambioZona').change(function() {
	$("#subzone_name").val("CIAO");	
});

/* CONTROLLO CAMPI */
function fnCheckForm(arr, div)
{
	var b = false;
	$.each($(div).find('input'),function() {
		if($(this).attr('type') == 'text')
		{
			for(i=0;i<arr.length;i++)
			{
				if (this.value == arr[i] || this.value == "")
				{
					b = true
				};
			}
		}
	});
	if(b)
	{
		alert('Devi inserire tutti i campi!');
		return false;
	}else{
		alert('Mail inviata con successo!');
		return true;
	}
}

///
function test_ajax(dato) {	
fnShowDiv('#container_loading');
$.ajax({
    url : "test2.php?variabile="+valore_tipo+"&nome_provincia="+dato,
	type : "GET",
	dataType: "script",
    success : function (data,stato) {
        $("#risultati1").html(data);
        $("#statoChiamata").text(stato);
    },
    error : function (richiesta,stato,errori) {
        alert("E' evvenuto un errore. Il stato della chiamata: "+stato);
    }
	
});
}	

