function adjustLayout() {
	var cHeight = xHeight("center");
	var lHeight = xHeight("sx");
	var rHeight = xHeight("dx");
	
	var maxHeight = Math.max(cHeight, Math.max(lHeight, rHeight));
	
	xHeight("center", maxHeight);
	xHeight("sx", maxHeight);
	xHeight("right", maxHeight);
	maxHeightMod = maxHeight - 30;
	xHeight("box-home", maxHeightMod);
}

function adjustLayoutDettaglio() {
	var cHeight = xHeight("center");
	var lHeight = xHeight("sx");
	
	var maxHeight = Math.max(cHeight, lHeight);
	
	xHeight("center", maxHeight);
	xHeight("sx", maxHeight);
}

window.onload = function() {
	xAddEventListener(window, "resize", adjustLayout, false);
	adjustLayout();
	adjustLayoutDettaglio();
}

function Obbligatori(n) {
	if (n == 1) {
		document.getElementById("p_societa").innerHTML = 'Società *';
		document.getElementById("p_attivita").innerHTML = 'Attività della società *';
	} else {
		document.getElementById("p_societa").innerHTML = 'Società';
		document.getElementById("p_attivita").innerHTML = 'Attività della società';
	}
}

function Convalida() {
	
	if (document.forms[0].tipo_richiesta[0].checked) {
		if (document.forms[0].societa.value  == ""){
			alert("Il campo \"Società\" non può essere vuoto");
			document.forms[0].societa.focus();
			return false;
		}
		
		if (document.forms[0].attivita.value  == ""){
			alert("Il campo \"Attività\" non può essere vuoto");
			document.forms[0].attivita.focus();
			return false;
		}
		
	}
	
	if (document.forms[0].nome.value  == ""){
		alert("Il campo \"Nome\" non può essere vuoto");
		document.forms[0].nome.focus();
		return false;
	}
	
	if (document.forms[0].cognome.value  == ""){
		alert("Il campo \"Cognome\" non può essere vuoto");
		document.forms[0].cognome.focus();
		return false;
	}
	
	if (document.forms[0].indirizzo.value  == ""){
		alert("Il campo \"Indirizzo\" non può essere vuoto");
		document.forms[0].indirizzo.focus();
		return false;
	}
	
	if (document.forms[0].cap.value  == ""){
		alert("Il campo \"Cap\" non può essere vuoto");
		document.forms[0].cap.focus();
		return false;
	}
	
	if (document.forms[0].citta.value  == ""){
		alert("Il campo \"Città\" non può essere vuoto");
		document.forms[0].citta.focus();
		return false;
	}

	if (document.forms[0].provincia.value  == ""){
		alert("Il campo \"Provincia\" non può essere vuoto");
		document.forms[0].provincia.focus();
		return false;
	}

	if (document.forms[0].nazione.value  == ""){
		alert("Il campo \"Nazione\" non può essere vuoto");
		document.forms[0].nazione.focus();
		return false;
	}
	
	if (document.forms[0].telefono.value  == ""){
		alert("Il campo \"Telefono\" non può essere vuoto");
		document.forms[0].telefono.focus();
		return false;
	}
	
	if (document.forms[0].email.value  == ""){
		alert("Il campo \"E-mail\" non può essere vuoto");
		document.forms[0].email.focus();
		return false;
	}
	
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.forms[0].email.value)){
		alert("L\'indirizzo e-mail inserito non è in un formato corretto");
		document.forms[0].email.focus();
		return false;
	}
	
	// set var checkbox_choices to zero
	
	var checkbox_choices = 0;
	
	// Loop from zero to the one minus the number of checkbox button selections
	for (counter = 0; counter < document.forms[0].prodotti_interesse.length; counter++) {
	
		// If a checkbox has been selected it will return true
		// (If not it will return false)
		if (document.forms[0].prodotti_interesse[counter].checked) {
				checkbox_choices = checkbox_choices + 1;
		};	
	}
	
	if (checkbox_choices == 0 )
	{
	// If there were less then selections made display an alert box
	alert("E\' necessario selezionare almeno una casella del campo \"Prodotti di interesse\"")
	return (false);
	}
	
	
	var checkbox_choices = 0;
	
	// Loop from zero to the one minus the number of checkbox button selections
	for (counter = 0; counter < document.forms[0].conosciuto_ditecteam.length; counter++) {
	
		// If a checkbox has been selected it will return true
		// (If not it will return false)
		if (document.forms[0].conosciuto_ditecteam[counter].checked) {
				checkbox_choices = checkbox_choices + 1;
		};	
	}
	
	if (checkbox_choices == 0 )
	{
	// If there were less then selections made display an alert box
	alert("E\' necessario selezionare almeno una casella del campo \"Ho conosciuto Ditec Team:\"")
	return (false);
	}
		
	if (!document.forms[0].check_privacy[0].checked) {
		alert("E\' necessario accettare la clausola sulla privacy");
		document.forms[0].check_privacy[0].focus();
		return false;
	}
	
}