// JavaScript Document
$(document).ready(function(){
// Clearfix & Text Area Resize
	$('<style type="text/css">.clearfix:after {visibility: hidden;display: block;font-size: 0;content: " ";clear: both;height: 0;}* html .clearfix { zoom: 1; }*:first-child+html .clearfix { zoom: 1; }textarea{resize:none;}</style>').appendTo("head");

	if($("p").hasClass("thankYou")){
		setThankYou100();
		$(window).resize(setThankYou100);
	}

});


function setThankYou100(){
	$("p.thankYou").css('height','');
	var winHeight = $(window).height();
	var siteHeight = $('body').height();
	if(winHeight>siteHeight){
		var needHeight = (winHeight-siteHeight)+$("p.thankYou").height();
		$("p.thankYou").css('height',needHeight);
	}
}

function contact_validate()
{
	//alert('common.js');
	var name=document.getElementById('txtfname').value;
	var telephone=document.getElementById('txtftelephone').value;
	var cognome=document.getElementById('txtcog').value;
	var email=document.getElementById('txtemail').value;
	if(name=='' || name=='null' || name=='Nome')
	{
		alert('Inserite il vostro nome');
		document.getElementById('txtfname').focus();
		return false;
	}
	else if(name!="")
	{
	//alert("name not null");
	var Alphabet;
	Alphabet = /^[a-zA-Z][a-zA-Z\\s ]+$/;
	var val=name.search(Alphabet);
	//alert(val);
		if (val==-1)
		{
		alert ("Inserisci il nome valido");
		document.getElementById('txtfname').value='';
		document.getElementById('txtfname').focus();
		return false;
		} 
	}
	if(cognome=='' || cognome=='null' || cognome=='Cognome')
	{
		alert('Inserisci il tuo cognome');
		document.getElementById('txtcog').focus();
		return false;
	}
	if(telephone=='' || telephone=='null' || telephone=='Telefono')
	{
		alert('Inserisci il Numero telefonico');
		document.getElementById('txtftelephone').focus();
		return false;
	}
	if(email=='' || email=='null' || email=='Email')
	{
		alert('Inserisci il tuo indirizzo e-mail');
		document.getElementById('txtemail').focus();
		return false;
	}
		else if(email!="")
	{
		var x=document.forms["myforma"]["email"].value;
		var atpos=x.indexOf("@");
		var dotpos=x.lastIndexOf(".");
		if (!validateEmail(email))
		{
		alert("Prega di inserire indirizzo email valido");
		document.getElementById('txtemail').focus();
		return false;
		}
	}
	else
	{
		
		return true;	
	}

}
function callback_validate()
{
	//alert('enter callback');
	var stelephone=document.getElementById('txtstelephone').value;
	var sname=document.getElementById('txtsname').value;

	if(sname=='' || sname=='null' || sname=='Nome')
	{
		alert('Inserite il vostro nome');
		document.getElementById('txtsname').value='';
		document.getElementById('txtsname').focus();
		return false;
	}
	if(stelephone=='' || stelephone=='null' || stelephone=='Telefono')
	{
		alert('Inserisci il Numero telefonico');
		document.getElementById('txtstelephone').value='';
		document.getElementById('txtstelephone').focus();
		return false;
	}
	else
	{
		return true;
		
	}


}
function validateEmail(elementValue){
   var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
   return emailPattern.test(elementValue);
 }

