
function change_radio(cod)
{
  var arr = document.hot.elements;  
  for(i = 0; i < arr.length; i++) 
   { 
          var c="radio"+arr[i].id;
          if((c!=cod)&&(arr[i].type=='radio'))
          {
             document.getElementById(c).className="off";
             
          } 
   }
  var radio=document.getElementById(cod);
  radio.className="on";
  return;
}

// funzione per il controllo della regolaritè della mail
function solotesto()
{
 var e=document.getElementById("elementi");
 e.innerHTML=" ";
}

function foto()
{
 var e=document.getElementById("elementi");
 e.innerHTML="<table width=450px align=center style='margin-bottom:11px;'> <tr> <td width=29%><b>CARICA IMMAGINE </b></td><td width=71%><input type='file' name='upfile[]' size=37> <input type='hidden' name='MAX_FILE_SIZE' value='1000000000'></td></tr></table>";
}

function video()
{
 var e=document.getElementById("elementi");
 e.innerHTML="<table width=450px align=center style='margin-bottom:11px;'>    <tr> <td width=29%><b>URL YOUTUBE</b></td><td width=71%><input type='text' id='url' name='url' class='invia_campo' ></td></tr></table>";
}

function ControlloMail()
{
	  var mail = document.getElementById("mail").value;
		if (mail=="")
    {
      alert("E-mail è un campo obbligatiorio");
		}
		else
		{
    var trova = mail.indexOf("@"); // Ricerca un carattere nella stringa
		if (trova==-1)
		{
		alert("E-mail non valida");
		}
		else
		{
			var trova = mail.indexOf("."); // Ricerca un carattere nella stringa
			if (trova==-1)
			{
			alert("E-mail non valida");
			}
		}
    }
}

function ControlloTel()
{
    var tel = document.getElementById("tel").value;
    if (tel.length<5)
    {
      alert("Numero di telefono non valido");
    }
}

function ControlloSegnala()
{
    var mail1 = document.getElementById("mail1").value;
    if (mail1=="")
    {
      alert("E-mail del mittente è campo obbligatorio");
      return false;
    }
    var trova = mail1.indexOf("@"); // Ricerca un carattere nella stringa
		if (trova==-1)
		{
		alert("E-mail mittente non valida");
    return false;
		}
		else
		{
			var trova = mail1.indexOf("."); // Ricerca un carattere nella stringa
			if (trova==-1)
			{
			alert("E-mail mittente non valida");
      return false;
			}
		}
    
    
    
    
        var mail2 = document.getElementById("mail2").value;
        if (mail2=="")
    {
      alert("E-mail del destinatario è campo obbligatorio");
      return false;
    }
    var trova = mail2.indexOf("@"); // Ricerca un carattere nella stringa
		if (trova==-1)
		{
		alert("E-mail destinatario non valida");
		}
		else
		{
			var trova = mail2.indexOf("."); // Ricerca un carattere nella stringa
			if (trova==-1)
			{
			alert("E-mail destinatario non valida");
			}
		}
    
}

function ControlloFiltro()
{
    var pwd = document.getElementById("pwd").value;
    if (pwd=="")
        {
          alert("La password è un campo obbligatorio");
          return false;
        }
}

function Contr_art()
{
  var capt=document.getElementById("input_capt").value;
  if (capt=="")
  {
    alert("Non sono stati inseriti i caratteri della figura");
    return false;
  }
  var mail = document.getElementById("mail").value;
	var trova = mail.indexOf("@"); // Ricerca un carattere nella stringa
  if (mail=="")
  {
    alert("E-mail è un campo obbligatorio");
    return false;
  }
  else
  {  
    if (trova==-1)
   {
        alert("E-mail non valida");
	return false;
    }
    else
   {
	var trova = mail.indexOf("."); // Ricerca un carattere nella stringa
	if (trova==-1)
	{
		alert("E-mail non valida");
		return false;
	}
	var tel = document.getElementById("tel").value;
		if ((tel.length<5)&&(tel.length>0))
		{
			alert("Numero di telefono non valido");
			return false;
		}
		else
		{
			if (document.modulo.accettaz[1].checked)
			{
				alert("Per l'invio degli articoli è necessario accettare le condizioni d'uso");
				return false;
			}
			var nome =document.getElementById("nome").value;
			var tit=document.getElementById("tit").value;
			if (nome=="")
			{
				alert("Nick/Nome è un campo obbligatorio");
				return false;
			}
			if (tit=="")
			{
				alert("Titolo è un campo obbligatorio");
				return false;
			}
		}
              
      
   }
  }
   var arr = document.modulo.elements; 
   var a=0;
   for(i = 0; i < arr.length; i++) 
   { 
      if(arr[i].type == 'checkbox') 
      { 
          if(arr[i].checked) 
          {
             a=1;
          }
      } 
   } 
   if(a==0)
   { 
   alert("Devi selezionare almeno una tag");
   return false; 
   }
}
    

//}


function Stampa(id)
{
  var w = 800;
  var h = 800;
  var l = Math.floor((screen.width-w)/2);
  var t = Math.floor((screen.height-h)/2);
  window.open("stampa.php?id="+id,"","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l);
}
function Mail(id)
{
  var w = 400;
  var h = 200;
  var l = Math.floor((screen.width-w)/2);
  var t = Math.floor((screen.height-h)/2);
  window.open("mail.php?id="+id,"","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l);
}

function ControlloEMail()
{
  var mitt= document.getElementById("mitt").value;
  var mail = document.getElementById("mail").value;
  if (mail=="")
  {
    alert("E-mail è un campo obbligatorio");
    return false;
  }
  else
  {  
    if (trova==-1)
		{
		alert("E-mail non valida");
    return false;
		}
		else
		{
			var trova = mail.indexOf("."); // Ricerca un carattere nella stringa
			if (trova==-1)
			{
        alert("E-mail non valida");
        return false;
			}
    }
  }
  if (mitt=="")
  {
    alert("Mittente è un campo obbligatorio");
    return false;
  }
}



function change_radio2(cod)
{
 if(cod!='lrisp1')
 {
    document.getElementById('lrisp1').className="off";
 } 
if(cod!='lrisp2')
 {
    document.getElementById('lrisp2').className="off";
 } 
 
  var radio=document.getElementById(cod);
  radio.className="on";
  if (cod=='lrisp1')
  {
    document.forms['merchandise'].action='paypal.php';
  }
  else
  {
    document.forms['merchandise'].action='postapay.php';
    
  }  
  return;
}


function change_radio3(cod)
{
 if(cod!='radio1')
 {
    document.getElementById('radio1').className="off";
 } 
if(cod!='radio2')
 {
    document.getElementById('radio2').className="off";
 } 
 
  var radio=document.getElementById(cod);
  radio.className="on"; 
  return;
}

function change_radio4(cod)
{
 if(cod!='radio1')
 {
    document.getElementById('radio1').className="off";
 } 
if(cod!='radio2')
 {
    document.getElementById('radio2').className="off";
 } 
if(cod!='radio3')
 {
    document.getElementById('radio3').className="off";
 } 

  var radio=document.getElementById(cod);
  radio.className="on"; 
  return;
}

function change_radio5(cod)
{
 if(cod!='r1')
 {
    document.getElementById('r1').className="off";
 } 
if(cod!='r2')
 {
    document.getElementById('r2').className="off";
 } 
if(cod!='r3')
 {
    document.getElementById('r3').className="off";
 } 
if(cod!='r4')
 {
    document.getElementById('r4').className="off";
 } 
if(cod!='r5')
 {
    document.getElementById('r5').className="off";
 } 

  var radio=document.getElementById(cod);
  radio.className="on"; 
  return;
}


function change_check(cod)
{
  var check=document.getElementById(cod);
  if(check.className=="on")
  {
  check.className="off"; 
  }
  else
  {
  check.className="on"; 
  }
  return;
}

function anno(i,a,min)
{
  var id='anno'+i;
  document.getElementById(id).className="archivio_annosl";
    for(k = min; k <= a; k++) 
   { 
          if(k!=i)
          {
             document.getElementById('anno'&k).className="archivio_anno";
          } 
   }
}


function Contr_invia()
{
    var mittente = document.getElementById("mittente").value;
    if (mittente=="")
    {
      alert("E-mail del mittente è un campo obbligatiorio");
      return false;
    }
    else
    {
      var trova = mittente.indexOf("@"); // Ricerca un carattere nella stringa
      if (trova==-1)
      {
	alert("E-mail del mittente non valida");
        return false;
      }
      else
      {
	var trova = mittente.indexOf("."); // Ricerca un carattere nella stringa
	if (trova==-1)
	{
          alert("E-mail del mittente non valida");
          return false;
	}
      }
    }
    var destinatario = document.getElementById("destinatario").value;
    if (destinatario=="")
    {
      alert("E-mail del destinatario è un campo obbligatiorio");
      return false;
    }
    else
    {
      var trova = destinatario.indexOf("@"); // Ricerca un carattere nella stringa
      if (trova==-1)
      {
	alert("E-mail del destinatario non valida");
        return false;
      }
      else
      {
	var trova = destinatario.indexOf("."); // Ricerca un carattere nella stringa
	if (trova==-1)
	{
          alert("E-mail del destinatario non valida");
          return false;
	}
      }
    }
}


function imp_homepage() { 
if(document.all)
document.body.style.behavior='url(#default#homepage)';
document.body.setHomePage('http://www.ilprincipe.eu');
} 

function imp_agenda() { 
if(document.all)
document.body.style.behavior='url(#default#homepage)';
document.body.setHomePage('http://www.ilprincipe.eu/moduli/agenda.php');
} 

 function Popupchat1() {
   var w = 450;
   var h = 585;
   var l = Math.floor((screen.width-w-25)/2);
   var t = Math.floor((screen.height-h)/2);
      window.open("moduli/chat.htm","","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l);
 }

 function Popupchat2() {
   var w = 450;
   var h = 585;
   var l = Math.floor((screen.width-w-25)/2);
   var t = Math.floor((screen.height-h)/2);
      window.open("chat.htm","","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l);
 }


 function PopupCommenti(art) {
   var w = 488;
   var h = 500;
   var l = Math.floor((screen.width-w-32)/2);
   var t = Math.floor((screen.height-h)/2);
      window.open("inserisci_commento.php?id="+art,"","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l);
 }
 
 function PopupFacebook(art) {
   var w = 450;
   var h = 400;
   var l = Math.floor((screen.width-w-25)/2);
   var t = Math.floor((screen.height-h)/2);
      window.open("condividi_fb.php?id="+art,"","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l);
 }

function Contr_ordine_merch()
{
    var mex = document.getElementById("ordine").value;
    var mail=document.getElementById("mail").value;
    if ((mex=="")||(mex=="inserisci il tuo ordine...")||(mail=""))
    {
      alert("Attenzione! Non sono stati compilati i campi necessari");
      return false;
    }
}


function Contr_reg()
{
 
  var mail = document.getElementById("mail").value;
	var trova = mail.indexOf("@"); // Ricerca un carattere nella stringa
  if (mail=="")
  {
    alert("E-mail è un campo obbligatorio");
    return false;
  }
  else
  {  
    if (trova==-1)
   {
        alert("E-mail non valida");
	return false;
    }
    else
   {
	var trova = mail.indexOf("."); // Ricerca un carattere nella stringa
	if (trova==-1)
	{
		alert("E-mail non valida");
		return false;
	}
   }
 }
 var nome = document.getElementById("nome").value;
if (nome=="")
{
   alert("Nick o nome è un campo obbligatorio");
   return false;
}
 var pwd = document.getElementById("pwd").value;
if (pwd=="")
{
   alert("Password è un campo obbligatorio");
   return false;
}
var pwd2 = document.getElementById("pwd2").value;
if (pwd2=="")
{
   alert("Ripeti Password è un campo obbligatorio");
   return false;
}
if (pwd2!=pwd)
{
   alert("Password e Ripeti Password non coincidono");
   return false;
}

 var tel = document.getElementById("tel").value;
if ((tel.length<5)&&(tel.length>0))
{
   alert("Numero di telefono non valido");
   return false;
}
}		
