C'era più di un errore. Provo a ordinartela un po'...
codice:
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Pagina vuota</title>
<script type="text/javascript">
var direct = new (function () {
var nBGId = 0, nIntervId = null;
function changeBG() {
document.getElementById("diretta").style.background = (nBGId ^= 1) ? "url(images/menu/diretta1.gif)" : "url(images/menu/diretta2.gif)";
}
this.avvia = function() {
if (nIntervId !== null) { return; }
nIntervId = window.setInterval(changeBG, 1500);
};
this.ferma = function() {
if (nIntervId === null) { return; }
window.clearInterval(nIntervId);
nIntervId = null;
};
})();
</script>
</head>
<body onload="direct.avvia();">
[ <span onclick="direct.avvia();" style="cursor:pointer;text-decoration:underline;color:#0000ff;">Avvia animazione</span> | <span onclick="direct.ferma();" style="cursor:pointer;text-decoration:underline;color:#0000ff;">Interrompi animazione</span> ]
<div style="width:800px;height:800px;" id="diretta"></div>
</body>
</html>