	/*** APRIRE E CHIUDERE UN DIV CHE CONTIENE CONTENUTO ****/
	var state = 'none'; 
	function show(divId) { 
		document.getElementById(divId).style.display = 'block'; 
	} 
	function hide(divId) { 
		document.getElementById(divId).style.display = 'none'; 
	} 
	
function addEvent(obj, evType, fn) {
	if (obj.addEventListener){ 
		obj.addEventListener(evType, fn, false); 
		return true; 
	} else if (obj.attachEvent){ 
		var r = obj.attachEvent("on"+evType, fn); 
		return r; 
	} else { 
		return false; 
	} 
}


function mostraScheda(rif) {
	location.href = "/index.jsp?section=clienti&subsection=offerte&db_action=carica&rif="+rif;
}

function isEmpty(field) {
	if (field.value == null || field.value == '') {
		return true;
	}
	return false;
}

function isValidEmail(field){if(field.value == null || field.value == ''){return true;}else if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(field.value)){return true;} else {field.value='';field.focus();}}

function validateRequest(form) {
	errors = "";

	if (form.name == 'richiesta_sms') {
		return validateSmsRequest(form);
	} else if (form.name == 'richiesta_info') {
		return validateRequestInfo(form);
	}
	
	document.getElementById('idNome').style.color = "#000033";

	document.getElementById('idCognome').style.color = "#000033";
	document.getElementById('idEmail').style.color = "#000033";
	document.getElementById('idConsenso').style.color = "#000033";
	
	if (isEmpty(form.Nome)) {
		errors += "Campo [Nome] non specificato\n";
		document.getElementById('idNome').style.color = "#990000";
		
	}
	
	
	if (isEmpty(form.Cognome)) {
		errors += "Campo [Cognome] non specificato\n";
		document.getElementById('idCognome').style.color = "#990000";
	}
	if (isEmpty(form.Email) || !isValidEmail(form.Email)) {
		errors += "Campo [Email] invalido\n";
		document.getElementById('idEmail').style.color = "#990000";
	}
	if (!form.Consenso.checked) {
		errors += "Campo [Accetto condizioni] non selezionato\n";
		document.getElementById('idConsenso').style.color = "#990000";
	}
	if (errors != "") {
		alert("Errori di compilazione trovati\n\n"+errors);
		return false;
	}
	
	return true;
}

function validateSmsRequest(form) {
	errors = "";

	document.getElementById('idNome').style.color = "#000033";
	document.getElementById('idNome').style.fontWeight = "bold";
	document.getElementById('idCellulare').style.color = "#000033";
	document.getElementById('idCellulare').style.fontWeight = "bold";
	document.getElementById('idConsenso').style.color = "#000033";
	
	if (isEmpty(form.Nome)) {
		errors += "Campo [Nome] non specificato\n";
		document.getElementById('idNome').style.color = "#990000";
	}
	if (isEmpty(form.Cellulare)) {
		errors += "Campo [Cellulare] invalido\n";
		document.getElementById('idCellulare').style.color = "#990000";
	}
	if (!form.Consenso.checked) {
		errors += "Campo [Accetto condizioni] non selezionato\n";
		document.getElementById('idConsenso').style.color = "#990000";
	}
	if (errors != "") {
		alert("Errori di compilazione trovati\n\n"+errors);
		return false;
	}
	
	return true;
}

function validateRequestInfo(form) {
	errors = "";

	document.getElementById('idNomeCognome').style.color = "#000033";
	document.getElementById('idNomeCognome').style.fontWeight = "bold";
	document.getElementById('idNomeCognome').style.fontSize = "12";
	document.getElementById('idEmail').style.color = "#000033";
	document.getElementById('idEmail').style.fontWeight = "bold";
	document.getElementById('idNomeCognome').style.fontSize = "12";
	document.getElementById('idConsenso').style.color = "#000033";
	
	if (isEmpty(form.Nome)) {
		errors += "Campo [Nome] non specificato\n";
		document.getElementById('idNomeCognome').style.color = "#990000";
	}
	if (isEmpty(form.Email) || !isValidEmail(form.Email)) {
		errors += "Campo [Email] invalido\n";
		document.getElementById('idEmail').style.color = "#990000";
	}
	if (!form.Consenso.checked) {
		errors += "Campo [Accetto condizioni] non selezionato\n";
		document.getElementById('idConsenso').style.color = "#990000";
	}
	if (errors != "") {
		alert("Errori di compilazione trovati\n\n"+errors);
		return false;
	}
	
	return true;
}

function doImmobiliPagination(page) {
	location.href = "/index.jsp?section=clienti&subsection=offerte&page="+page+"&#results";
}

function toggleSendEnable(form) {
	if (form.Consenso.checked)
		form.sendButton.disabled = false;
	else
		form.sendButton.disabled = true;
}

function openPopupVideo(){
	var video = window.open("/common/popups/video.jsp","video","toolbar=no,resizable=no,location=no,width=320,height=310");
	video.focus();
}