// JavaScript Document
<!--
// Controllo inserimento dati Richiesta Info
function apri() {
	document.getElementById('comm_text').innerHTML="";
	document.getElementById('comm_text').style.display='none';
	var ie = document.all;
	var moz = document.getElementById && !document.all; 
	
	if(ie) {
		var wh = document.documentElement.scrollHeight;
		var tp = document.documentElement.clientHeight;
		document.getElementById('black_page').style.height = wh+"px";	
		document.getElementById('black_page').style.display='block';
		document.getElementById('dati').style.top = document.documentElement.scrollTop + (tp - 250) / 2+"px";
		document.getElementById('dati').style.display='block';
	}
	
	if(moz) {		
		var wh = document.documentElement.scrollHeight;
		var tp = window.innerHeight;
		document.getElementById('black_page').style.height = wh+"px";	
		document.getElementById('black_page').style.display='block';
		document.getElementById('dati').style.top = window.pageYOffset + (tp - 250) / 2+"px";
		document.getElementById('dati').style.display='block';
	}
}

function close_info(x) {
	var campo = x;
	document.getElementById('black_page').style.display='none';
	document.getElementById('dati').style.display='none';
	document.getElementById(campo).focus();
}

function chiudi() {
	document.getElementById('black_page').style.display='none';
	document.getElementById('dati').style.display='none';
	location.replace("contatti.php");
}

function controll_info(theForm) {
	if (theForm.nome.value == "") {
		apri();
		document.getElementById('dati').style.color="#C00";
		document.getElementById('comm_text').innerHTML="<p>Inserire il proprio Nome, grazie.</p>";
		document.getElementById('cfocus').innerHTML="<input type=\"button\" name=\"okappa\" id=\"okappa\" value=\"     OK     \" onclick=\"close_info(\'nome\');\" />";
		document.getElementById('comm_text').style.display='block';
		return (false);
	}
	
	if (theForm.email.value == "") {
		apri();
		document.getElementById('dati').style.color="#C00";
		document.getElementById('comm_text').innerHTML="<p>Inserire il proprio indirizzo E-mail, grazie.</p>";
		document.getElementById('cfocus').innerHTML="<input type=\"button\" name=\"okappa\" id=\"okappa\" value=\"     OK     \" onclick=\"close_info(\'email\');\" />";
		document.getElementById('comm_text').style.display='block';
		return (false);
	}
	
	var imail=theForm.email.value;
	var poschioccia=imail.indexOf("@");
	var pospunto=imail.lastIndexOf(".");
	var len=imail.length;
	if ((poschioccia < 2)||(pospunto<poschioccia+2)||(pospunto==len-1)) {
		apri();
		document.getElementById('dati').style.color="#C00";
		document.getElementById('comm_text').innerHTML="<p>Inserire un'indirizzo E-mail valido, grazie.</p>";
		document.getElementById('cfocus').innerHTML="<input type=\"button\" name=\"okappa\" id=\"okappa\" value=\"     OK     \" onclick=\"close_info(\'email\');\" />";
		document.getElementById('comm_text').style.display='block';
		return (false);
	}

	if (theForm.prov.value == 0) {
		apri();
		document.getElementById('dati').style.color="#C00";
		document.getElementById('comm_text').innerHTML="<p>Selezionare la Provincia di residenza, grazie.</p>";
		document.getElementById('cfocus').innerHTML="<input type=\"button\" name=\"okappa\" id=\"okappa\" value=\"     OK     \" onclick=\"close_info(\'prov\');\" />";
		document.getElementById('comm_text').style.display='block';
		return (false);
	}

	if (theForm.tipo.value == 0) {
		apri();
		document.getElementById('dati').style.color="#C00";
		document.getElementById('comm_text').innerHTML="<p>Selezionare il tipo di richiesta, grazie.</p>";
		document.getElementById('cfocus').innerHTML="<input type=\"button\" name=\"okappa\" id=\"okappa\" value=\"     OK     \" onclick=\"close_info(\'tipo\');\" />";
		document.getElementById('comm_text').style.display='block';
		return (false);
	}

	if (theForm.richiesta.value == "") {
		apri();
		document.getElementById('dati').style.color="#C00";
		document.getElementById('comm_text').innerHTML="<p>Inserire il testo della richiesta, grazie.</p>";
		document.getElementById('cfocus').innerHTML="<input type=\"button\" name=\"okappa\" id=\"okappa\" value=\"     OK     \" onclick=\"close_info(\'richiesta\');\" />";
		document.getElementById('comm_text').style.display='block';
		return (false);
	}
	
	if(document.getElementById('consenso').checked==false) {
		apri();
		document.getElementById('dati').style.color="#C00";
		document.getElementById('comm_text').innerHTML="<p>Per poter inviare la richiesta di informazioni è necessario accettare il trattamento dei dati.</p>";
		document.getElementById('cfocus').innerHTML="<input type=\"button\" name=\"okappa\" id=\"okappa\" value=\"     OK     \" onclick=\"close_info(\'consenso\');\" />";
		document.getElementById('comm_text').style.display='block';
		return (false);
	}
	return (true);
}
// Fine controllo inserimento dati Richiesta Info

// Gestione campi form
function evid_on(id) {
	document.getElementById(id).style.borderColor="#FFFFFF";
}

function evid_off(id) {
	document.getElementById(id).style.borderColor="#039";
}
// Fine gestione campi form

// Gestione Google Map
	var WINDOW_HTML = '<div align="center"><img src="images/logo_min.jpg" width="150" height="57" border="0" alt="Arredamenti Rossi - Schio (Vicenza)"></div>';

    function load() {

    if (GBrowserIsCompatible()) {
      var map = new GMap2(document.getElementById("map"));
      map.addControl(new GLargeMapControl());
	  map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng(45.720563, 11.361450), 15);
      var marker = new GMarker(new GLatLng(45.720563, 11.361450));
      map.addOverlay(marker);
      GEvent.addListener(marker, "click", function() {
        marker.openInfoWindowHtml(WINDOW_HTML);
      });
      marker.openInfoWindowHtml(WINDOW_HTML);
      }
    }
// Fine gestione Google Map
