var httpRequest;

function Clock ()
{
	var orologio = new Date ();
	var HH = orologio.getHours   ();
	var MM = orologio.getMinutes ();
	var SS = orologio.getSeconds ();
	parseInt ( MM ) < 10 ? MM = "0" + MM : null;
	parseInt ( SS ) < 10 ? SS = "0" + SS : null;
	document.formOrologio.textOrologio.value = HH + ":" + MM + ":" + SS;
	window.setTimeout ( "Clock ()", 1000 );
}

function makeRequest ( url )
{		
	if ( url.indexOf ( "?" ) != -1 )
		url = url + '&Rand=' + Math.random();
	else
		url = url + '?Rand=' + Math.random();
	
	if ( window.ActiveXObject ) // IE
	{
		httpRequest = new ActiveXObject ( "Microsoft.XMLHTTP" );
	}
	else if ( window.XMLHttpRequest ) // Non IE
	{
		httpRequest = new XMLHttpRequest ();
	}
	
	httpRequest.open ( "GET", url, true );
	httpRequest.onreadystatechange = function () { processRequest (); };
	httpRequest.send ( null );
}

function processRequest ()
{
	if ( httpRequest.readyState == 4 )
	{
		if ( httpRequest.status == 200 )
		{
			var content = document.getElementById ( "content" );
			
			content.innerHTML = httpRequest.responseText;
		}
		else
		{
            alert ( "Errore caricamento pagina\n" + httpRequest.status + ":" + httpRequest.statusText );
		}
	}
	else if ( httpRequest.readyState == 1 )
	{
		var content = document.getElementById ( "content" );
		content.innerHTML = "<h1>CARICAMENTO IN CORSO...</h1>";
	}          
}

function Login ()
{
	document.formlogin.submit ();	
}

function TornaIndice()
{
	document.location = "index.php";
}

function TornaIndietro( Indirizzo )
{
	document.location = Indirizzo;
}


/*function InserisciTxtScorr ()
{
	document.forminstxtscorr.submit ();	
}*/