
function printon(){
	if (document.all) {
        if (navigator.appVersion.indexOf("5.0") == -1) {
            var OLECMDID_PRINT = 6;
            var OLECMDEXECOPT_DONTPROMPTUSER = 2;
            var OLECMDEXECOPT_PROMPTUSER = 1;
            var WebBrowser = "<OBJECT ID=\"WebBrowser1\" WIDTH=0 HEIGHT=0 CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></OBJECT>";
            document.body.insertAdjacentHTML("beforeEnd", WebBrowser);
            WebBrowser1.ExecWB(6, 2);
            WebBrowser1.outerHTML = "";
        } else {
			self.print();
        }
    } else {
		self.print();
    }
}

function popup(sPicURL) {
window.open("foto.htm?"+sPicURL, "", "resizable=1,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')
{
	Ctrl = frm.newsletter;
	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();
	   return (result);
           }
}


if (frm.name == 'segnala')
{
if (frm.nome.value == "")
    {
     errorString = "Il campo NOME è obbligatorio";
     frm.nome.focus();
     alert(errorString);
     return false;
    }
if (frm.cognome.value == "")
    {
     errorString = "Il campo COGNOME è obbligatorio";
     frm.cognome.focus();
     alert(errorString);
     return false;
    }

	Ctrl = frm.emailfrom;
	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();
	   return (result);
           }


	Ctrl = frm.emailto;
	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();
	   return (result);
           }


}

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 == 'inscento' || frm.name == 'modcento')
{

frm.numero.value = trim(frm.numero.value)
frm.titolo.value = trim(frm.titolo.value)
frm.data_edizione.value = trim(frm.data_edizione.value)

if (frm.numero.value == "")
    {
     errorString = "Il campo NUMERO è obbligatorio";
     frm.numero.focus();
     alert(errorString);
     return false;
    }

if (frm.data_edizione.value == "")
    {
     errorString = "Il campo DATA EDIZIONE è obbligatorio";
     frm.data_edizione.focus();
     alert(errorString);
     return false;
    }
if (frm.titolo.value == "")
    {
     errorString = "Il campo TITOLO è obbligatorio";
     frm.titolo.focus();
     alert(errorString);
     return false;
    }
}


if (frm.name == 'inscircola' || frm.name == 'modcircola')
{

frm.numero.value = trim(frm.numero.value)
frm.titolo.value = trim(frm.titolo.value)
frm.data_edizione.value = trim(frm.data_edizione.value)

if (frm.numero.value == "")
    {
     errorString = "Il campo NUMERO è obbligatorio";
     frm.numero.focus();
     alert(errorString);
     return false;
    }

if (frm.data_edizione.value == "")
    {
     errorString = "Il campo DATA EDIZIONE è obbligatorio";
     frm.data_edizione.focus();
     alert(errorString);
     return false;
    }
if (frm.titolo.value == "")
    {
     errorString = "Il campo TITOLO è obbligatorio";
     frm.titolo.focus();
     alert(errorString);
     return false;
    }
}

if (frm.name == 'modnews')
{
if (frm.titolo.value == "")
    {
     errorString = "Il campo TITOLO è obbligatorio";
     frm.titolo.focus();
     alert(errorString);
     return false;
    }

if (frm.testo.value == "")
    {
     errorString = "Il campo TESTO è obbligatorio";
     frm.testo.focus();
     alert(errorString);
     return false;
    }
}


if (frm.name == 'insana')
{
if (frm.nome.value == "")
    {
     errorString = "Il campo NOME è obbligatorio";
     frm.nome.focus();
     alert(errorString);
     return false;
    }
}

if ((frm.name == 'modacc') || (frm.name == 'insass'))
{

if (frm.nome.value == "")
    {
     errorString = "Il campo NOME è obbligatorio";
     frm.nome.focus();
     alert(errorString);
     return false;
    }

if (frm.userid.value == "")
    {
     errorString = "Il campo USERID è obbligatorio";
     frm.userid.focus();
     alert(errorString);
     return false;
    }

if (frm.password.value == "")
    {
     errorString = "Il campo PASSWORD è obbligatorio";
     frm.password.focus();
     alert(errorString);
     return false;
    }

}

if (frm.name == 'contatti')
{
if (frm.richiesta.value == "")
    {
     errorString = "Inserisci il testo della RICHIESTA";
     frm.richiesta.focus();
     alert(errorString);
     return false;
    }


if (frm.nome.value == "")
    {
     errorString = "Inserisci il NOME";
     frm.nome.focus();
     alert(errorString);
     return false;
    }

if (frm.cognome.value == "")
    {
     errorString = "Inserisci il COGNOME";
     frm.cognome.focus();
     alert(errorString);
     return false;
    }


	Ctrl = frm.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();
	   return (result);
           }
}

if (frm.name == 'acquista' || frm.name == 'schedaadesione')
{


if (frm.nome.value == "")
    {
     errorString = "Inserisci il NOME";
     frm.nome.focus();
     alert(errorString);
     return false;
    }

if (frm.cognome.value == "")
    {
     errorString = "Inserisci il COGNOME";
     frm.cognome.focus();
     alert(errorString);
     return false;
    }


	Ctrl = frm.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();
	   return (result);
           }
}

}
 
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);
}
