

function isnumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }


var highlightbehavior="TD"

var ns6=document.getElementById&&!document.all
var ie=document.all

function changeto(e,highlightcolor){
source=ie? event.srcElement : e.target
if (source.tagName=="TABLE")
return
while(source.tagName!=highlightbehavior && source.tagName!="HTML")
source=ns6? source.parentNode : source.parentElement
if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
source.style.backgroundColor=highlightcolor
}

function contains_ns6(master, slave) { //check if slave is contained by master
while (slave.parentNode)
if ((slave = slave.parentNode) == master)
return true;
return false;
}

function changeback(e,originalcolor){
if (ie&&(event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")||source.tagName=="TABLE")
return
else if (ns6&&(contains_ns6(source, e.relatedTarget)||source.id=="ignore"))
return
if (ie&&event.toElement!=source||ns6&&e.relatedTarget!=source)
source.style.backgroundColor=originalcolor
}


function submit_on_enter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;
if (keycode == 13)
{
myfield.form.submit();
return false;
}
else
return true;
}

function printon(){self.print();}

function popup(sPicURL) {
window.open("foto.htm?"+sPicURL, "", "resizable=0,HEIGHT=300,WIDTH=200");
}

function popupinvia(sPicURL) {
window.open("fotoinvia.asp?"+sPicURL, "", "resizable=0,HEIGHT=300,WIDTH=200");
}

function centra(page)
{
var w = screen.width; 
var h = screen.height; 
var x = Math.round(w / 2) - Math.round(700/2); 
var y = Math.round(h / 2) - Math.round(450/2); 
newwindow = window.open(page, null, 'scrollbars=1, left=' + x + ', screenX=' + x + ',top=' + y + 'screenY=' + y +',width=700,height=450'); 
window.opener=self
}

function vaisopra() {
window.top.scroll(0,0);
}


function ltrim(s) {return s.replace( /^\s*/, "" );}
function rtrim(s) {return s.replace( /\s*$/, "" );}
function trim (s) {return rtrim(ltrim(s));}

function verify(frm)
{

if (frm.name == 'newsletter')
{

ok = 0;

Ctrl = frm.news_email;
result = false;
space_tokens = Ctrl.value.split(" ");
if (space_tokens.length == 1) {
at_tokens = Ctrl.value.split("@");
if (at_tokens.length == 2) {
if (at_tokens[1].length != 0) {
   right_dot_tokens = at_tokens[1].split(".");
   if (right_dot_tokens.length >= 2) {
   if (right_dot_tokens[1].length != 0) {
   result=true;}}}}}

if (!result){
           errorString = "Inserisci un indirizzo E-MAIL valido";
           alert(errorString);
           Ctrl.focus();
           ok = 1;
           }

if (ok == 0)
   document.newsletter.submit();

}

if (frm.name == 'password')
{

ok = 0;

Ctrl = frm.password_email;
result = false;
space_tokens = Ctrl.value.split(" ");
if (space_tokens.length == 1) {
at_tokens = Ctrl.value.split("@");
if (at_tokens.length == 2) {
if (at_tokens[1].length != 0) {
   right_dot_tokens = at_tokens[1].split(".");
   if (right_dot_tokens.length >= 2) {
   if (right_dot_tokens[1].length != 0) {
   result=true;}}}}}

if (!result){
           errorString = "Inserisci un indirizzo E-MAIL valido";
           alert(errorString);
           Ctrl.focus();
           ok = 1;
           }

if (ok == 0)
   document.password.submit();

}



if (frm.name == 'registra' || frm.name == 'profilo')
{

ok = 0;

Ctrl = frm.emailregistra;
result = false;
space_tokens = Ctrl.value.split(" ");
if (space_tokens.length == 1) {
at_tokens = Ctrl.value.split("@");
if (at_tokens.length == 2) {
if (at_tokens[1].length != 0) {
   right_dot_tokens = at_tokens[1].split(".");
   if (right_dot_tokens.length >= 2) {
   if (right_dot_tokens[1].length != 0) {
   result=true;}}}}}

if (frm.nome.value == "")
    {
     errorString = "Il NOME è obbligatoria";
     alert(errorString);
     frm.nome.focus();
     ok = 1;
    }

else if (frm.giorno.value == "0" && frm.mese.value == "0" && frm.anno.value == "0")
    {
     errorString = "La DATA DI NASCITA è obbligatoria";
     alert(errorString);
     frm.giorno.focus();
     ok = 1;
    }

else if (frm.giorno.value == "0")
    {
     errorString = "La DATA DI NASCITA non è completa, inserisci il GIORNO DI NASCITA";
     alert(errorString);
     frm.giorno.focus();
     ok = 1;
    }

else if (frm.mese.value == "0")
    {
     errorString = "La DATA DI NASCITA non è completa, inserisci il MESE DI NASCITA";
     alert(errorString);
     frm.mese.focus();
     ok = 1;
    }

else if (frm.anno.value == "0")
    {
     errorString = "La DATA DI NASCITA non è completa, inserisci l'ANNO DI NASCITA";
     alert(errorString);
     frm.anno.focus();
     ok = 1;
    }

else if (frm.cellulare_pre.value == "")
    {
     errorString = "Il numero di cellulare NON è completo";
     alert(errorString);
     frm.cellulare_pre.focus();
     ok = 1;
    }

else if (frm.cellulare_num.value == "")
    {
     errorString = "Il numero di cellulare NON è completo";
     alert(errorString);
     frm.cellulare_num.focus();
     ok = 1;
    }

else if (!result){
           errorString = "Inserisci un'indirizzo E-MAIL valido";
           alert(errorString);
           Ctrl.focus();
           ok = 1;
           }

else if (frm.indirizzo.value == "")
    {
     errorString = "L'INDIRIZZO è obbligatorio";
     alert(errorString);
     frm.indirizzo.focus();
     ok = 1;
    }

else if (frm.cap.value == "")
    {
     errorString = "Il Codice Avviamento Postale (CAP) è obbligatorio";
     alert(errorString);
     frm.cap.focus();
     ok = 1;
    }

else if (frm.citta.value == "")
    {
     errorString = "La CITTA' è obbligatoria";
     alert(errorString);
     frm.citta.focus();
     ok = 1;
    }

}


if (frm.name == 'contatti')
{

ok = 0;

Ctrl = frm.emailregistra;
result = false;
space_tokens = Ctrl.value.split(" ");
if (space_tokens.length == 1) {
at_tokens = Ctrl.value.split("@");
if (at_tokens.length == 2) {
if (at_tokens[1].length != 0) {
   right_dot_tokens = at_tokens[1].split(".");
   if (right_dot_tokens.length >= 2) {
   if (right_dot_tokens[1].length != 0) {
   result=true;}}}}}

if (frm.oggetto.value == "")
    {
     errorString = "L'OGGETTO DELLA RICHIESTA è obbligatorio";
     alert(errorString);
     frm.oggetto.focus();
     ok = 1;
    }

else if (frm.testo.value == "")
    {
     errorString = "Il TESTO DELLA RICHIESTA è obbligatorio";
     alert(errorString);
     frm.testo.focus();
     ok = 1;
    }

else if (frm.nome.value == "")
    {
     errorString = "Il NOME è obbligatorio";
     alert(errorString);
     frm.nome.focus();
     ok = 1;
    }

else if (!result){
           errorString = "Inserisci un'indirizzo E-MAIL valido";
           alert(errorString);
           Ctrl.focus();
           ok = 1;
           }

if (ok == 0)
   document.contatti.submit();

}

if (frm.name == 'suggerisci')
{

ok = 0;

Ctrl = frm.emailregistra;
result = false;
space_tokens = Ctrl.value.split(" ");
if (space_tokens.length == 1) {
at_tokens = Ctrl.value.split("@");
if (at_tokens.length == 2) {
if (at_tokens[1].length != 0) {
   right_dot_tokens = at_tokens[1].split(".");
   if (right_dot_tokens.length >= 2) {
   if (right_dot_tokens[1].length != 0) {
   result=true;}}}}}

if (frm.nome.value == "")
    {
     errorString = "Il NOME del mittente è obbligatorio";
     alert(errorString);
     frm.nome.focus();
     ok = 1;
    }

else if (!result){
           errorString = "Inserisci un'indirizzo E-MAIL valido";
           alert(errorString);
           Ctrl.focus();
           ok = 1;
           }

if (ok == 0)
   document.suggerisci.submit();

}


if (frm.name == 'cerca2')
{

ok = 0;

if (frm.codice.value == "" && frm.eta.value == "---" && frm.sesso.value == "---" && frm.citta.value == "" && frm.provincia.value == "---")
    {
     errorString = "E' necessario inserire almeno un criterio di selezione :)"
     alert(errorString);
     frm.codice.focus();
     ok = 1;
    }

if (ok == 0)
   document.cerca2.submit();

}


if (frm.name == 'spedizione')
{
ok = 0;

if (frm.nominativo.value == "")
    {
     errorString = "L'inserimento del NOMINATIVO è obbligatorio";
     frm.nominativo.focus();
     alert(errorString);
     ok = 1;
    }

else if (frm.indirizzo.value == "")
    {
     errorString = "L'inserimento dell'INDIRIZZO è obbligatorio";
     frm.indirizzo.focus();
     alert(errorString);
     ok = 1;
    }

else if (frm.cap.value == "")
    {
     errorString = "L'inserimento del CAP è obbligatorio";
     frm.cap.focus();
     alert(errorString);
     ok = 1;
    }

else if (frm.citta.value == "")
    {
     errorString = "L'inserimento della CITTA' è obbligatorio";
     frm.citta.focus();
     alert(errorString);
     ok = 1;
    }

if (ok == 0)
   document.spedizione.submit();

}

if (frm.name == 'cerca')
{
if (frm.cerca.value == "")
    {
     errorString = "Per effettuare una ricerca in archivio è necessario inserire almeno una parola";
     frm.cerca.focus();
     alert(errorString);
     return false;
    }
}


if (frm.name == 'profilo2')
{

ok=0;

if (ok == 0)
   document.profilo2.submit();

}


if (frm.name == 'registra' && ok == 0)
{

if (frm.regolamento.value == "NO")
    {
     errorString = "Per la registrazione al gioco è necessario accettare il regolamento";
     alert(errorString);
     frm.regolamento.focus();
     ok = 1;
    }

else if (frm.privacy.value == "NO")
    {
     errorString = "Per la registrazione al gioco è necessario prestare consenso all'informativa a tutela della privacy";
     alert(errorString);
     frm.privacy.focus();
     ok = 1;
    }

if (ok == 0)
   document.registra.submit();

}

if (frm.name == 'profilo' && ok == 0)
{

if (frm.password.value == "")
    {
     errorString = "Il campo PASSWORD è obbligatorio";
     alert(errorString);
     frm.password.focus();
     ok = 1;
    }

if (ok == 0)
   document.profilo.submit();

}


}
 
function start(winflash, x, y, bar)
{
window.open(winflash,'','scrollbars='+bar+',screenX=150,screenY=50,left=150,top=50,resizable=0,menubar=0,toolbar=0,status=0,width='+x+',height='+y);
}


function startchat(winflash, x, y, bar)
{
window.open(winflash,'CHAT','scrollbars='+bar+',screenX=150,screenY=50,left=150,top=50,resizable=0,menubar=0,toolbar=0,status=0,width='+x+',height='+y);
}


function openflash(winflash, x, y)
{
ind="immagini/"+winflash;
window.open(ind,'','scrollbars=0,screenX=150,screenY=50,left=150,top=50,resizable=0,menubar=0,toolbar=0,status=0,width='+x+',height='+y);
}
