function controlla_sel()
{
	if (document.getElementById("tendric").options[document.getElementById("tendric").selectedIndex].value!='sel')
	{
		document.getElementById("ric_form").submit();
	}
	else
	{
		alert("Seleziona una destinazione ...");
	}
}

function WebDate() {
	var now = new Date();
	var year= now.getYear();if (year < 1000) year += 1900;
	nameDay = new Array('Domenica','Lunedi','Martedi','Mercoledi','Giovedi','Venerdi','Sabato');
	nameMth = new Array('Gennaio','Febbraio','Marzo','Aprile','Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre','Dicembre');
	document.write('<p> '+nameDay[now.getDay()]+ ' ' + now.getDate() + " " + nameMth[now.getMonth()] + " " + year+'</p>');
}

function quanto(id)
{
	if(document.getElementById)
	{
		oHeight = document.getElementById(id).offsetHeight;
		oWidth = document.getElementById(id).offsetWidth;
	}
	else if (document.layers)
	{
		oHeight = document.layers[id].clip.height;
		oWidth = document.layers[id].clip.width;
	}
	return oHeight;
	//alert("Altezza: "+ oHeight);
}

function setta() 
{
	var altezza = quanto('tabellona');
	if (altezza < 600) 
	{
		altezza = 600;
	}
	document.getElementById("dx").style.height=altezza;
	document.getElementById("sx").style.height=altezza;
}

function popup (url,larg,alt)
{
	window.open (url,"popup","toolbar=no,directories=no,menubar=no,width="+larg+",height="+alt+",resizable=no,scrollbars=no");
}

function verEmail(stringa)
{
	if (!stringa)
	{
		return false;
	}
	var iChars = "*|,\"<:>[]{}`\';()&$#%";
	for (var i = 0; i < stringa.length; i++)
	{
		if (iChars.indexOf(stringa.charAt(i)) != -1)
		{
			return false;
		}
	}
	return true;
} 	
	
function check(numadulti,numbamb)
{
	var errori=0;
	
	//controllo e-mail
	if (!verEmail(document.form2.email_princ.value)){errori++;}
	
	//cliente principale
	if(document.form2.nome_princ.value=="" || document.form2.cognome_princ.value=="" || document.form2.tel_princ.value=="" || document.form2.email_princ.value=="" || document.form2.n_pers.value=="" ){errori++;}	
	
	//clienti secondari
	for(i=0;i<numadulti;i++)
	{
	 if(eval("document.form2.nome_"+i+".value")=="" || eval("document.form2.cognome_"+i+".value")==""){errori++;}
	}
	
	//bambini secondari
	for(i=0;i<numbamb;i++)
	{
	 if(eval("document.form2.nomeb_"+i+".value")=="" || eval("document.form2.cognomeb_"+i+".value")==""){errori++;}
	}
	
	if (document.form2.privacy.checked==false) 
	{
		alert("Fornire il consenso al trattamento dei dati personali!");
		errori++;
	}
	if (document.form2.condizioni.checked==false) 
	{
		alert("Accettare le condizioni contrattuali indicate nel contratto!");
		errori++;
	}
	if(errori>0)
	{
		alert("Devi completare i campi obbligatori!!");
	}
	else
	{
		document.form2.submit();
	}
}
