$(function(){
	$(".carousel").jCarouselLite({
		visible: 3,
		auto: 3000,
		speed: 500,
		hoverPause: true,
		btnNext: "#next",
		btnPrev: "#prev"
	});
});

function validateEmail(email)

{

 var re = /^([\w]+)(.[\w]+)*@([\w]+)(.[\w]{2,3}){1,2}$/;

	return re.test(email);

} 

function check_form() {

	var err=0;

	var cognome=document.contatti.cognome.value;

	var nome=document.contatti.nome.value;

	var email=document.contatti.email.value;

	var richiesta=document.contatti.richiesta.value;

	if (cognome=='' || nome=='' || email=='') {

		err++;

	}

	if(err>0)

	{

		alert("Uno dei campi non e' stato completato correttamente");

	}

	else if(!validateEmail(email)) {

		alert("Indirizzo email incompatibile con il formato email standard, inserire tutti i dati in modo corretto");

		err++;

	}

	else {

		document.contatti.submit();

	}

	

}
function assegnaXMLHttpRequest() {

// lista delle variabili locali
var
 // variabile di ritorno, nulla di default
 XHR = null,
 
 // informazioni sul nome del browser
 browserUtente = navigator.userAgent.toUpperCase();


 // browser standard con supporto nativo
 // non importa il tipo di browser
 if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object")
  XHR = new XMLHttpRequest();

 // browser Internet Explorer
 // è necessario filtrare la versione 4
 else if(
  window.ActiveXObject &&
  browserUtente.indexOf("MSIE 4") < 0
 ) {
 
  // la versione 6 di IE ha un nome differente
  // per il tipo di oggetto ActiveX
  if(browserUtente.indexOf("MSIE 5") < 0)
   XHR = new ActiveXObject("Msxml2.XMLHTTP.3.0");

  // le versioni 5 e 5.5 invece sfruttano lo stesso nome
  else
   XHR = new ActiveXObject("Microsoft.XMLHTTP");
 }

 return XHR;
}

function contenuto_div_post_ajax(url,id,p) {
  if (url.substring(0, 4) != 'http' || 
	  url.substring(0, 5) != 'https' ||
	  url.substring(0, 3) != 'ftp' ||
	  url.substring(0, 3) != 'mms') {
  var ajax = assegnaXMLHttpRequest();
  if(ajax) {
   	ajax.open("POST", url , true);
   	ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
   	ajax.setRequestHeader("Content-length", p.length);
   	ajax.setRequestHeader("connection", "close");
   	ajax.onreadystatechange = function() {
  
      // verifica dello stato
      if(ajax.readyState === 4) {
		  if (ajax.status == 200 || ajax.status == 0) {
			  document.getElementById(id).innerHTML = ajax.responseText;
		  } else { document.getElementById(id).innerHTML= "At the moment, information are not available. Try to refresh the page."; } 
	  }
    } 
   ajax.send(p);
 }
  } else { alert("URL unsafe"); }
}



