function ValidaEmail(stringa)
{ 

  var carrattere=""
  var testo =0
  var vannobene = "abcdefghijklmnopqrstuvwxyz_@.ABCDEFGHIJKLMNOPQRSTUVWXYZƒŠŒšœŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ0123456789";
  var checkStr = stringa;
  var aposto = true;
  var chiocciola = 0
  var punto = 0
  for (i = 0;  i < checkStr.length;  i++)
	{
	    carattere = checkStr.charAt(i);
	    for (j = 0;  j < vannobene.length;  j++)
	      {
		if (carattere == vannobene.charAt(j))
		{
		  if (carattere=="@")
		     {
			if (testo==0)
				aposto=false;
			chiocciola = chiocciola +1;
			testo = -1;
		     }

		  if (carattere==".")
		     {
			if (testo==0)
			aposto=false;
			punto= punto +1
			testo = -1;
		     }
			testo = testo + 1;
		  break;
		}

		if (j == vannobene.length)
		    {
		      aposto = false;
		      break;
		    }
	       }
	  }
if (!aposto || chiocciola !=1 || punto ==0 || testo < 2 || testo >3 )
   {
	return (false);
   }
return (true);
}

function ChangeLanguage(Lingua)
{
	URL = document.location.href
	document.location.href = "../include/lingua.asp?Lingua=" + Lingua +"&URL=" + URL
}

function CheckEmail()
{
	mail = self.document.frmnwlt.Mail_Newsletter.value;
	if (ValidaEmail(mail))
	{
		document.frmnwlt.submit();
	}	
	else
	{
		alert("Mail non valida");
	}		
}

function CheckUser()
{
	document.frmreserved.submit();
}


function open_chat()
{
	ww=650;
	hh=500;
	sbar='no';
	up=(screen.height) ? (screen.height-hh)/2 : 0;
	sx=(screen.width) ? (screen.width-ww)/2 : 0;

	if (self.name=="flash")
	{
		window.open("chat/","chat","width=" + ww  + ",height=" + hh  + ", Top=" + up + ", Left=" + sx + ",scrollbars="+ sbar);
	} else {
		window.open("../chat/","chat","width=" + ww  + ",height=" + hh  + ", Top=" + up + ", Left=" + sx + ",scrollbars="+ sbar);
	}
}


function RicaricaElemento(IdDiv)
{
    if (XMLHTTP.readyState == 4)
    {
        var R = document.getElementById(IdDiv);
        R.innerHTML = XMLHTTP.responseText;        
    }
}


function RicavaBrowser(QualeBrowser)
{
    if (navigator.userAgent.indexOf("MSIE") != (-1))
    {
        var Classe = "Msxml2.XMLHTTP";
        if (navigator.appVersion.indexOf("MSIE 5.5") != (-1));
        {
            Classe = "Microsoft.XMLHTTP";
        } 
        try
        {
            OggettoXMLHTTP = new ActiveXObject(Classe);
            OggettoXMLHTTP.onreadystatechange = QualeBrowser;
            return OggettoXMLHTTP;
        }
        catch(e)
        {
            alert("Errore: l'ActiveX non verrà eseguito!");
        }
    }
    else if (navigator.userAgent.indexOf("Mozilla") != (-1))
    {
        OggettoXMLHTTP = new XMLHttpRequest();
        OggettoXMLHTTP.onload = QualeBrowser;
        OggettoXMLHTTP.onerror = QualeBrowser;
        return OggettoXMLHTTP;
    }
    else
    {
        alert("L'esempio non funziona con altri browser!");
    }
}
