function RefreshImage(valImageId) {
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}

function validateG() {
with(document.gb) {
	if(autore.value=="") {
	alert("Attenzione: devi inserire il tuo nome.");
	autore.focus();
        autore.style.backgroundColor = "#ffff99";
	return false;
	}
        else {
        autore.style.backgroundColor = "#f0f0f0";
        }

        if(web.value.indexOf("http://")!=0) {
	alert("Attenzione: l'indirizzo web deve contenere il suffisso http://");
        web.value = "http://";
	web.focus();
	web.select();
        web.style.backgroundColor = "#ffff99";
	return false;
	}
        else {
        web.style.backgroundColor = "#f0f0f0";
        }

	if(email.value!="") {
	var stato=true;
	if(email.value.indexOf(" ")!=-1) {
	stato=false;
	}
	var chiocciola=email.value.indexOf("@");
	if(chiocciola<2) {
	stato=false;
	}
	var punto=email.value.indexOf(".", chiocciola);
	if(punto<chiocciola+3) {
	stato=false;
	}
	var lung=email.value.length;
	if(lung-punto<3) {
	stato=false;
	}

        if(stato==false) {
	alert("Attenzione: indirizzo email non valido.");
        email.focus();
	email.select();
        email.style.backgroundColor = "#ffff99";
	return stato;
	}
        else {
        email.style.backgroundColor = "#f0f0f0";
        }
        }

        if(commento.value=="") {
	alert("Attenzione: devi inserire il commento.");
	commento.focus();
        commento.style.backgroundColor = "#ffff99";
	return false;
	}
        else {
        commento.style.backgroundColor = "#f0f0f0";
        }

        if(commento.value.length>=700) {
	alert("Attenzione: lunghezza del testo non consentita.");
	commento.focus();
        commento.style.backgroundColor = "#ffff99";
	return false;
	}
        else {
        commento.style.backgroundColor = "#f0f0f0";
        }

        if(captchacode.value=="") {
        alert("Attenzione: devi inserire i 7 caratteri visualizzati nell'immagine.");
        captchacode.focus();
        captchacode.style.backgroundColor = "#ffff99";
	return false;
	}
        else {
        captchacode.style.backgroundColor = "#f0f0f0";
        }

}
return true;
}

function validateC() {
with(document.ct) {
	if(nome.value=="") {
	alert("Attenzione: devi inserire il tuo nome.");
	nome.focus();
        nome.style.backgroundColor = "#ffff99";
	return false;
	}
        else {
        nome.style.backgroundColor = "#f0f0f0";
        }
 
	if(email.value=="") {
	alert("Attenzione: devi inserire il tuo indirizzo email.");
	email.focus();
        email.style.backgroundColor = "#ffff99";
	return false;
	}
        else {
        email.style.backgroundColor = "#f0f0f0";
        }

	var stato=true;
	if(email.value.indexOf(" ")!=-1) {
	stato=false;
	}
	var chiocciola=email.value.indexOf("@");
	if(chiocciola<2) {
	stato=false;
	}
	var punto=email.value.indexOf(".", chiocciola);
	if(punto<chiocciola+3) {
	stato=false;
	}
	var lung=email.value.length;
	if(lung-punto<3) {
	stato=false;
	}

        if(stato==false) {
	alert("Attenzione: indirizzo email non valido.");
        email.focus();
	email.select();
        email.style.backgroundColor = "#ffff99";
	return stato;
	}
        else {
        email.style.backgroundColor = "#f0f0f0";
        }

	if(soggetto.value=="") {
	alert("Attenzione: devi inserire il soggetto.");
        soggetto.focus();
        soggetto.style.backgroundColor = "#ffff99";
	return false;
	}
        else {
        soggetto.style.backgroundColor = "#f0f0f0";
        }

        if(messaggio.value=="") {
	alert("Attenzione: devi inserire il messaggio.");
	messaggio.focus();
        messaggio.style.backgroundColor = "#ffff99";
	return false;
	}
        else {
        messaggio.style.backgroundColor = "#f0f0f0";
        }

        if(messaggio.value.length>=600) {
	alert("Attenzione: lunghezza del testo non consentita.");
	messaggio.focus();
        messaggio.style.backgroundColor = "#ffff99";
	return false;
	}
        else {
        messaggio.style.backgroundColor = "#f0f0f0";
        }

        if(captchacode.value=="") {
        alert("Attenzione: devi inserire i 7 caratteri visualizzati nell'immagine.");
        captchacode.focus();
        captchacode.style.backgroundColor = "#ffff99";
	return false;
	}
        else {
        captchacode.style.backgroundColor = "#f0f0f0";
        }
	
}
return true;
}

function placeFocus() {
if (document.forms.length > 0) {
var field = document.forms[0];
for (i = 0; i < field.length; i++) {
if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
document.forms[0].elements[i].focus();
break;
         }
      }
   }
}
