// JavaScript Document

function att(){ 
	if (xmlHttp.readyState==4)document.getElementById("att").innerHTML=xmlHttp.responseText;
}

function GetXmlHttpObject(){
	var xmlHttp=null;
	try{xmlHttp=new XMLHttpRequest();}										/* Firefox, Opera 8.0+, Safari*/	
	catch (e){																/* Internet Explorer*/
		try{xmlHttp=new ActiveXObject('Msxml2.XMLHTTP');}
		catch (e){xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');}
  }
	return xmlHttp;
}

function LoadAjax(){
	xmlHttp=GetXmlHttpObject();	
	if (xmlHttp==null){alert ('Your browser does not support AJAX!');return;} 
}

function UseAjax(URL,cont){
	xmlHttp.onreadystatechange=cont;				
	xmlHttp.open("GET",URL,true);
	xmlHttp.send(null);
}

function showatt(page){
	LoadAjax();
	var URL="mostra_att.php";
	URL=URL+"?page="+page;
	UseAjax(URL,att);
}

/********************************************* ANIMATION ***********************************************************************/

function animation(){								   			
	var array_immagini = new Array();	
	array_immagini[0]="img/preview/plaza.jpg";
	array_immagini[1]="img/preview/legambiente.jpg";
	array_immagini[2]="img/preview/robertodegaetano.jpg";
	array_immagini[3]="img/preview/art-net.jpg";
	array_immagini[4]="img/preview/artisti.jpg";
	array_immagini[5]="img/preview/vairoli.jpg";
	
	$("#siti").OptimalFadeImage({
		array_image		 : array_immagini,
		width 		 	 : 212,
		height			 : 133,
		fade_intervall	 : 'fast',
		fade_step        : 'medium',
		pause_change	 : 'medium'		
	});		
}
/*******************************************************************************************************************************/

function mail_no_spam(user,dominio){document.location.href = "mailto:" + user + "@" + dominio;}

/*******************************************************************************************************************************/

function showForm() {
	oDiv = document.getElementById('form_mail');
	oDiv.style.display='block';
	return false;
}

function hideForm() {
	oDiv = document.getElementById('form_mail');
	oDiv.style.display='none';
	return false;
}

/*******************************************************************************************************************************/

function isEmail(string) {
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) != -1)
	return 1;
	else
	return 0;
}

function checkForm(form){
	if ( (form.nome.value == 0) || ( form.cognome.value == 0 ) || ( form.mail.value == 0 ) ) {
		alert('I campi NOME, COGNOME e E-MAIL sono obbligatori');
		return false
	}	
	if ( isEmail(form.mail.value) == 0 ) {
		alert('Inserire un indirizzo e-mail valido - sarà utilizzato per inviare la conferma ordine')
		form.mail.focus();
	return false
	}
}