// JavaScript Document
var come=0;

var vSomm="";
var vPos="";
var nPixel=0;

function vediLi(quale)
	{
	//alert(document.body.scrollTop)
	var vLi=document.getElementById(quale);
	var statoLi=vLi.style.display;
	
		if(statoLi=="none")
		{
		vLi.style.display="block";
		
		}
		else
		{
		vLi.style.display="none";
		
		}
	}

function mostra(cosa)
{

var mostrando=document.getElementById(cosa);
var posTop=mostrando.style.marginTop;

//alert(posTop)

if(posTop=="12px"||posTop=="-180px")
{

function apri()
		{
		document.getElementById('btn_Somm').innerHTML="Chiudi Sommario";
		document.getElementById('sommarioOut').style.display="block";
		//alert(nPixel)
		if(nPixel<15)
			{
			vPos=eval("mostrando.style.marginTop='"+nPixel+"px'");
			nPixel+=3;
			}
			else
			{
			clearInterval(vSomm);
			}
				
		}
		
	function chiudi()
		{
		document.getElementById('btn_Somm').innerHTML="Apri Sommario";
		
		if(nPixel>-183)
			{
			vPos=eval("mostrando.style.marginTop='"+nPixel+"px'");
			nPixel-=3;
			}
			else
			{
			document.getElementById('sommarioOut').style.display="none";
			clearInterval(vSomm);
			}
		}


if(come==0)
	{
	//alert(altDiv)
	nPixel=-183;
	/*mostrando.style.display="block";
	mostrando.style.visibility="visible";*/
	vSomm=setInterval(apri, 1);
	//mostrando.style.marginLeft="-20px";
	come=1;
	}
	else
	{
	//alert(altDiv)
	//mostrando.style.height="150px";
	/*mostrando.style.display="none";
	mostrando.style.visibility="hidden";*/
	nPixel=12;
	vSomm=setInterval(chiudi, 1);
	//mostrando.style.marginLeft="-235px";
	come=0;
	}

}
}

function maxAlt(idDiv)
	{
	var altMonitor=0;
	//alert(window.innerHeight)
	window.innerHeight==undefined?altMonitor=document.documentElement.clientHeight:altMonitor=window.innerHeight;
	var vDiv=document.getElementById(idDiv)
	var altcolCt=altMonitor-282;
	//alert(altMonitor+" "+altcolCt)
		if(altcolCt>330)
		{
		vDiv.style.height=altcolCt+"px";
		}
		else
		{
		vDiv.style.height="330px";
		}
	}
	
	
function verificampi()
	{
	
arrCampi=new Array('nome', 'email', 'localita', 'informazioni', 'privacy');
	
		
	for (sbianca=0; sbianca<document.form_gen.elements.length; sbianca++)
					{
					
					
					//colore=eval("document.getElementById('"+arrCampi[v1]+"')");
					document.form_gen.elements[sbianca].style.backgroundColor='#ffffff';	
					document.getElementById('attenzione').innerHTML="";
					document.getElementById('attenzione').style.backgroundColor='';	
					}
		
	if(validaEmail(document.getElementById('email').value)===false)
				{
				document.getElementById('attenzione').style.backgroundColor='#f0f094';	
				document.getElementById('attenzione').innerHTML="Attenzione: verificare l'indirizzo email inserito.";
				document.getElementById('email').style.backgroundColor='#f0f094';
				return false;
				}
	
	for(v=0; v<(arrCampi.length); v++)
		{
		valuta=eval("document.getElementById('"+arrCampi[v]+"')");
		//valuta.style.background="#FFFFFF;";
		if(valuta.value=="")
				{
				valuta.style.backgroundColor='#f0f094';
				valuta.focus();	
				//evidenziaDiv=eval("document.getElementById('"+element_id+"').style.backgroundColor='#f0f094'");  
				//focusDiv=eval("document.getElementById('"+element_id+"').focus()");

				document.getElementById('attenzione').style.backgroundColor='#f0f094';	
				document.getElementById('attenzione').innerHTML="Attenzione. E'necessario compilare il campo "+arrCampi[v]+"";
				//vuoto=eval("document.getElementById('"+arrCampi[v]+"')")
			 	//valuta.style.background="#FFFFCC;";
				return false;
				//exit;
				} else 
				{
				continue;
				} 
			}
	
	
	if(document.getElementById('privacy').checked==false)
		{
		document.getElementById('attenzione').style.backgroundColor='#f0f094';	
				document.getElementById('attenzione').innerHTML="Attenzione: è necessario spuntare per accettazione il trattamento dei dati personali.";
					//vuoto=eval("document.getElementById('"+arrCampi[v]+"')")
					//valuta.style.background="#FFFFCC;";
					return false;
		}
	
	
	}

function validaEmail(e_mail) {
	function check_invalid_char(e_mail) {
		if( ( e_mail.search(/[^a-z,A-Z,0-9,\x22,\x23,\x24,\x25,\x26,\x27,\x2A,\x2D,\x2E,\x3C,\x3E,\x40,\x5F,\x7E]/) ) != -1 ) return false
		else return true
	}

	function check_sign(e_mail) {
		var first_at_sign = e_mail.indexOf("@")
		var last_at_sign = e_mail.lastIndexOf("@")

		if ( last_at_sign == -1 ) return false

		var last_dot_sign = e_mail.lastIndexOf(".")
		if ( (first_at_sign == last_at_sign ) && ( first_at_sign > 0 ) && ( last_at_sign < (e_mail.length - 3) ) && ( last_dot_sign > (first_at_sign + 1) ) && ( last_dot_sign < (e_mail.length - 1) ) ) return true
		else return false
	}

	if (check_invalid_char(e_mail) && check_sign(e_mail) ) return true
	else return false
}
