// global variables
var pic = null;
var popImg = null;
var imgCount = 0;

function winOpen() { return (popImg != null && popImg.closed != true) ? true : false; }

function ImgPopUp(picName,winWidth,winHeight) {
	// if existing pic with same name, pop it up else create new window & pop it up
	if (pic == picName && winOpen()) {
		popImg.focus();
	} else {
		// close any pop up windows now open - do not close if early IE
		if (navigator.appName != "Microsoft Internet Explorer" || parseInt(navigator.appVersion) >=4) {
			if (popImg != null && !popImg.closed) popImg.close();
		}

		pic = picName;						// build new pop up window		
		imgWinName = "popImg" + imgCount++;	// unique name for each pop-up window
		
		popImg = window.open("",imgWinName, "toolbar=no,scrollbars=no,resizable=no,width=" + winWidth + ",height=" + winHeight);
		var htmlString = "<html><head><title></title></head><body background=\"" + pic + "\"></body></html>";

		popImg.document.open();
		popImg.document.write(htmlString);
		popImg.document.close();
	}

	return false;
}


function Form_Validator_It(theForm) {
var strsublista = '';
var typelista = window.document.form1.typelista.value;
for (i=0; i < document.form1.elements.length; i++) {
	    if ((document.form1.elements[i].name=='sublista[]')) {
		 if (document.form1.elements[i].checked)     
		      strsublista+=','+document.form1.elements[i].value;
	    }
}
if ((strsublista=='') && (typelista=='sublista')){
     alert ('Selezionare almeno una sublista');
     return (false);
 }
 if (document.form1.nome.value == ""){
	 alert ("Attenzione!!! Non è stato inserito il campo nome ");
	 return (false);
	 }if (document.form1.email.value == ""){
	 alert ("Attenzione!!! Non è stato inserito il campo email ");
	 return (false);
     }else{ 
	function isValidEmail(addressS){
		emailRegexp = RegExp('^[A-Za-z0-9._-]+[@]([A-Za-z0-9-]+[.])+([A-za-z]{2,4})$', 'i');
		if (emailRegexp.test(addressS)){
		    //return (true);
		}else{
		    alert ("ATTENZIONE!!! Il formato della e-mail non è corretto!!!");
		    return (false);
		} 
	    }
	    return (isValidEmail(theForm.email.value))
     }
}


function Form_Validator_En(theForm) {
var strsublista = '';
var typelista = window.document.form1.typelista.value;
for (i=0; i < document.form1.elements.length; i++) {
	    if ((document.form1.elements[i].name=='sublista[]')) {
		 if (document.form1.elements[i].checked)     
		      strsublista+=','+document.form1.elements[i].value;
	    }
}
if ((strsublista=='') && (typelista=='sublista')){
     alert ('Select one sublist at least');
     return (false);
 }
 if (document.form1.nome.value == ""){
	 alert ("Attention!!!  It has not been inserted the field nome ");
	 return (false);
	 }if (document.form1.email.value == ""){
	 alert ("Attention!!!  It has not been inserted the field email ");
	 return (false);
     }else{ 
	function isValidEmail(addressS){
		emailRegexp = RegExp('^[A-Za-z0-9._-]+[@]([A-Za-z0-9-]+[.])+([A-za-z]{2,4})$', 'i');
		if (emailRegexp.test(addressS)){
		    //return (true);
		}else{
		    alert ("ATTENTION!!!  The format of the email is not corrected!!!");
		    return (false);
		} 
	    }
	    return (isValidEmail(theForm.email.value))
     }
}