function controlloInvio(){
	nomeForm=document.contactform;
	if(nomeForm.nome.value==""){
		alert("inserire il nome");
		nomeForm.nome.focus();
		return;
	}
	if(nomeForm.cognome.value==""){
		alert("inserire il cognome");
		nomeForm.cognome.focus();
		return;
	}
	if(!checkEmailAddress(nomeForm.email)) return;
	nomeForm.submit();
}

function controlloInvio2(){
	nomeForm=document.ricettaform;
	if(nomeForm.nome.value==""){
		alert("inserire il nome");
		nomeForm.nome.focus();
		return;
	}
	if(nomeForm.cognome.value==""){
		alert("inserire il cognome");
		nomeForm.cognome.focus();
		return;
	}
	if(!checkEmailAddress(nomeForm.email)) return;
	nomeForm.submit();
}


var indirizzoEmail;
function checkEmailAddress(field) {

     var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
     
     if (goodEmail){
        indirizzoEmail = true
     } 
     else {
        alert('Inserire un indirizzo email valido');
        field.focus();
        field.select();
        indirizzoEmail = false;
        }
  	return indirizzoEmail;
}

function mmenu(mID) {
    var menu = document.getElementById(mID);
	var display = menu.style.display;
    nascondi();
    menu.style.display = (display == "block") ? "none" : "block";
}

function nascondi() {
    var uls= document.getElementsByTagName("ul");
	for (i=0;i<uls.length;i++) {
     	if(uls[i].className=="submenu") uls[i].style.display = "none";
	}
}
   
function azzera(tot) {
    var stato1 = 'images/quadrato_lat.jpg'; 
    for (i=1;i<tot+1;i++) {
        tabella= document.getElementById("n"+i);
        tabella.style.background = 'url('+stato1+')';
    }
}
   
function colour_swap(mID, tot) {
    var stato1 = 'images/quadrato_lat.jpg'; 
    var stato2 = 'images/quadrato_lat_on.jpg'; 
    var tabella = document.getElementById(mID);
    var background = tabella.style.background;
    azzera(tot);
    tabella.style.background = (background == 'url('+stato2+')') ? 'url('+stato1+')' : 'url('+stato2+')';
}

function popupNews(idCat){
	var w=550;
	var h=300;
	var posX=( screen.width - w) /2;
	var posY=( screen.height - h) /2;
	finestraZoom=window.open("popupNews.php?idCat="+idCat, "Dettaglio", "toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=no,copyhistory=yes, width=" + w + ", height=" + h + ", left=" + posX + ", top=" + posY);
	finestraZoom.focus();
}

function popupPremiati(idCat){
	var w=550;
	var h=300;
	var posX=( screen.width - w) /2;
	var posY=( screen.height - h) /2;
	finestraZoom=window.open("popupPremiati.php?idCat="+idCat, "Dettaglio", "toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=no,copyhistory=yes, width=" + w + ", height=" + h + ", left=" + posX + ", top=" + posY);
	finestraZoom.focus();
}

function zoom(img, w, h){
    var posX=( screen.width - w) /2;
	var posY=( screen.height - h) /2;
	finestraZoom=window.open("popupZoom.php?img="+img, "Zoom", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=yes, width=" + w + ", height=" + h + ", left=" + posX + ", top=" + posY);
	finestraZoom.focus();
}

