// 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(argomentazioni, tiporichiesta)
	{

switch (tiporichiesta)
{
	
/*
----------------- PREVENTIVO
*/	

	case "preventivo":

argomentazioni=='cancella'?arrCampi=new Array('email'):arrCampi=new Array('nome', 'cognome', 'email', 'servizi[]', 'finalita');

// per non perdere troppo tempo l'argomento 'cancella' viene passato assieme a quello 'preventivo', altrimenti avrei dovuto creare un altro pezzo di funzione per intero
	
	sbiancamento:	
	for (sbianca=0; sbianca<document.form_gen.elements.length; sbianca++)
					{
					
					if (document.form_gen.elements[sbianca].id=="invio")
						{
							/* 
							non sbianca il pulsante invio 
							*/
							continue sbiancamento;
						}
					document.form_gen.elements[sbianca].style.backgroundColor='#ffffff';	
					document.getElementById('attenzione').innerHTML="";
					document.getElementById('attenzione').style.backgroundColor='';	
					/*document.getElementById('div_privacy').style.backgroundColor='';*/
					document.getElementById('div_servizi').style.backgroundColor='';
					}
		
	verifica_generale:
	for(v=0; v<(arrCampi.length); v++)
		{
		valuta=eval("document.getElementById('"+arrCampi[v]+"')");
		//valuta.style.background="#FFFFFF;";
		
		if(valuta.id=="servizi[]")
				{
				valuta_servizi=document.form_gen.elements['servizi[]'] ;
				/*alert("valuta_servizi.length="+valuta_servizi.length);*/
				
				
				
				flag_servizi=false;
				
				verifica_servizi:
				for(v_a=0; v_a<(valuta_servizi.length); v_a++)
					{
						
						/*alert(v_a+" - "+valuta_servizi[v_a].id+" - "+valuta_servizi[v_a].checked)*/
						
						if(valuta_servizi[v_a].checked || valuta_servizi[7].value!="") 
						{
							flag_servizi=true;
						}
						else
						{
							
							continue verifica_servizi;
							
						}
						
					}
					
					if(!flag_servizi)
					{
						
							document.getElementById('attenzione').style.backgroundColor='#f0f094';
							document.getElementById('attenzione').innerHTML="Attenzione. E'necessario scegliere almeno un servizio";
							document.getElementById('div_servizi').style.backgroundColor='#f0f094';
							
							document.location.href='#compila-preventivo';
							return false;
					}
					else
					{
						continue verifica_generale;
					}
				}
		
		
		if(valuta.value=="" || valuta.value==" ")
				{
				valuta.style.backgroundColor='#f0f094';
				
				//evidenziaDiv=eval("document.getElementById('"+element_id+"').style.backgroundColor='#f0f094'");  
				//focusDiv=eval("document.getElementById('"+element_id+"').focus()");

				
				document.getElementById('attenzione').innerHTML="Attenzione. E'necessario compilare il campo "+arrCampi[v]+"";
				//vuoto=eval("document.getElementById('"+arrCampi[v]+"')")
			 	//valuta.style.background="#FFFFCC;";
				document.getElementById('attenzione').style.backgroundColor='#f0f094';
				document.location.href='#compila-preventivo';
				valuta.focus();	
				return false;
				
				
				
				
				//exit;
				} else 
				{
				continue verifica_generale;
				} 
			}
			
		if(validaEmail(document.getElementById('email').value)===false)
					{
					
					document.getElementById('attenzione').innerHTML="Attenzione: verificare l'indirizzo email inserito.";
					document.getElementById('email').style.backgroundColor='#f0f094';
					
					document.getElementById('attenzione').style.backgroundColor='#f0f094';
					document.location.href='#compila-preventivo';
					document.getElementById('email').focus;
					return false;
					}
		
		
		/*if(document.getElementById('privacy').checked==false)
			{
			
			document.getElementById('div_privacy').style.backgroundColor='#f0f094';
			document.getElementById('attenzione').innerHTML="Attenzione. E'necessario spuntare per accettazione il trattamento dei dati personali.";
						//vuoto=eval("document.getElementById('"+arrCampi[v]+"')")
						//valuta.style.background="#FFFFCC;";
						document.getElementById('attenzione').style.backgroundColor='#f0f094';
						document.location.href='#compila-preventivo';
						return false;
			}*/
		
		break;
		
		
/*
----------------- ORDINE
*/	
	
	case "ordine":
		
		
	arrCampi=new Array('nome', 'cognome', 'email', 'telefono', 'finalita');
	
	
	break;
		
	
		
/*
----------------- INFORMAZIONI
*/	
	
		
	case "informazioni":
	
	arrCampi=new Array('nome', 'cognome', 'email', 'telefono');
	
	break;
		
		
} // ENDOF switch (tiporichiesta)

	
	sbiancamento:	
	for (sbianca=0; sbianca<document.form_ord.elements.length; sbianca++)
					{
					
					if (document.form_ord.elements[sbianca].id=="invio")
						{
							/* 
							non sbianca il pulsante invio 
							*/
							continue sbiancamento;
						}
					document.form_ord.elements[sbianca].style.backgroundColor='#ffffff';	
					document.getElementById('attenzione').innerHTML="";
					document.getElementById('attenzione').style.backgroundColor='';	
					/*document.getElementById('div_privacy').style.backgroundColor='';*/
					document.getElementById('div_prodotti').style.backgroundColor='';
					}
		
	verifica_generale:
	for(v=0; v<(arrCampi.length); v++)
		{
		valuta=eval("document.getElementById('"+arrCampi[v]+"')");
		
		if(valuta.value=="" || valuta.value==" ")
				{
				valuta.style.backgroundColor='#f0f094';
				
	

				
				document.getElementById('attenzione').innerHTML="Attenzione. E'necessario compilare il campo "+arrCampi[v]+""
				document.getElementById('attenzione').style.backgroundColor='#f0f094';
				document.location.href='#compila-preventivo';
				valuta.focus();	
				return false;
				
				
				
				
				//exit;
				} else 
				{
				continue verifica_generale;
				} 
			}
			
		if(validaEmail(document.getElementById('email').value)===false)
					{
					
					document.getElementById('attenzione').innerHTML="Attenzione: verificare l'indirizzo email inserito.";
					document.getElementById('email').style.backgroundColor='#f0f094';
					
					document.getElementById('attenzione').style.backgroundColor='#f0f094';
					document.location.href='#compila-ordine';
					document.getElementById('email').focus;
					return false;
					}
					
		if(checkPhone(document.getElementById('telefono').value)===false)
				{
					document.getElementById('attenzione').innerHTML="Attenzione: utilizzare solo numeri nel campo telefono.";
					document.getElementById('telefono').style.backgroundColor='#f0f094';
					
					document.getElementById('attenzione').style.backgroundColor='#f0f094';
					document.location.href='#compila-ordine';
					document.getElementById('telefono').focus;
					return false;
				}
					
		if(verifiContratti()===false)
					{	
					alert("per proseguire accettare le condizioni contrattuali e l'informativa sui dati personali");
					return false;
					}
		
		
		
	
	} // ENDOF verificampi()
	
	
	
	

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
}


function checkPhone(numero) 
{
	var re = RegExp(/^([0-9\+]{1})([0-9])*$/);
	if(!numero.match(re)) return false
	else return true
}



function verifiContratti()
{
	accettaPriv="";
	accettaContr="";
	accettaContr=document.getElementById('accetta_contratto').checked;
	accettaPriv=document.getElementById('accetta_privacy').checked;
	
	if(accettaPriv+accettaContr==2)
	{
		document.getElementById('div_contratti').style.backgroundColor='#fff';
		
		return true;
	}
	else
	{
		document.getElementById('div_contratti').style.backgroundColor='#f0f094';
		
		
		return false;
	}
}


	
function cambiaIMG(img_prodotto)
{
	//----in qualsiasi caso, se è cambiata la scelta del prodotto, deve cambiare il valore dell'input hidden
	if(document.getElementById('hidd_cambia_prodotto'))
	{
	document.getElementById('hidd_cambia_prodotto').value=img_prodotto;
	}
	
	switch(img_prodotto)
	{
		case "promozione-sito":
		document.getElementById('IMG_prodotto').src="img/listino/promozione-sito.png";
		break;
		
		case "identita-web":
		document.getElementById('IMG_prodotto').src="img/listino/identita-web.png";
		break;
		
		case "progetto-sito":
		document.getElementById('IMG_prodotto').src="img/listino/progetto-sito.png";
		break;
		
		case "profilo-web":
		document.getElementById('IMG_prodotto').src="img/listino/profilo-web.png";
		break;
	}
}



<!--//

// AJAX PRELOADER per gli RSS dal BLOG

// funzione di caricamento testo,
// accetta una stringa contenente
// il nome di un file da leggere
function caricaTesto(nomeFile) {

  // variabili di funzione

    // assegnazione oggetto XMLHttpRequest
    ajax = assegnaXMLHttpRequest(),
    // assegnazione elemento del documento
    elemento = prendiElementoDaId("div_ajax_rss"),
    // risultato booleano di funzione
    usaLink = true;
  
  // se l'oggetto XMLHttpRequest non è nullo
  if(ajax) {
    // il link al file non deve essere usato
    usaLink = false;

    // impostazione richiesta asincrona in GET
    // del file specificato
    ajax.open("get", nomeFile, true);

    // rimozione dell'header "connection" come "keep alive"
    ajax.setRequestHeader("connection", "close");

    // impostazione controllo e stato della richiesta
    ajax.onreadystatechange = function() {
      
      // verifica dello stato
      if(ajax.readyState === readyState.COMPLETATO) {
        // verifica della risposta da parte del server
        if(statusText[ajax.status] === "OK")
          // operazione avvenuta con successo
          elemento.innerHTML = ajax.responseText;
        else {
          // errore di caricamento
          elemento.innerHTML = "Impossibile effettuare l'operazione richiesta.<br />";
          elemento.innerHTML += "Errore riscontrato: " + statusText[ajax.status];
        }
      } 
    }

    // invio richiesta
    ajax.send(null);
  }
   
  return usaLink;
} 

//-->




/*var arr_contratti= new Array(0,0);


	//var come=1;

var vSomm="";
var hSomm="";
var nPixel=0;


	function accettanza (posizione, valore)
	{
		arr_contratti[posizione] = valore;
		
		var vedi =0; 
		
		for(var valida in arr_contratti)
		{
			vedi+=arr_contratti[valida];
		}
		
		if(vedi==2)
				{ 
				//document.getElementById('disattivatore').style.height="auto";
				vSomm=setInterval(apri, 1);
				
				}
			else 
				{
				//document.getElementById('disattivatore').style.height="0px";
				vSomm=setInterval(chiudi, 1);
				
				}
		
	}*/
	
	

/*function apri()
		{
		
		
		//document.getElementById('btn_Somm').innerHTML="Chiudi Sommario";
		//document.getElementById('sommarioOut').style.display="block";
		//alert(nPixel)
		if(nPixel<190)
			{
			
			var mostrando = document.getElementById('div_paypal');
			hSomm=eval("mostrando.style.height='"+nPixel+"px'");
			nPixel+=8;
			}
			else
			{
			clearInterval(vSomm);
			}
				
		}
		
	function chiudi()
		{
		
		//document.getElementById('btn_Somm').innerHTML="Apri Sommario";
		
		if(nPixel>-2)
			{
			
			var mostrando = document.getElementById('div_paypal');
			hSomm=eval("mostrando.style.height='"+nPixel+"px'");
			nPixel-=8;
			}
			else
			{
			//document.getElementById('sommarioOut').style.display="none";
			clearInterval(vSomm);
			}
		}*/

