var req;
var visto1=false;
var visto2=false;
var visto3=false;
var visto4=false;
var visto5=false;
var visto6=false;
var visto7=false;
var visto8=false;
var lastclick=0;

/* funzione cross-browser per referenziare gli oggetti in base al nome o all'ID
This function can be called in two ways; to reference an item in the current document:
	MWJ_findObj( NameOrId )
To reference an item in any other document in a frameset, you can choose how 
high in the frame structure to start. WARNING: - cross frame scripting will 
cause errors if your page is in a frameset from a different domain 
	MWJ_findObj( NameOrId, ReferenceToTopMostFrameToSearch )
this function is slightly bigger than the DreamWeaver function but is more 
efficient as it can also find anchors, frames, variables, functions, 
and check through any frame structure. Note that if the name refers to inputs 
in a form that share the same name, this function will return 
the collection of inputs sharing that name.*/
function MWJ_findObj( oName, oFrame, oDoc ) {
	if( !oDoc ) { if( oFrame ) { oDoc = oFrame.document; } else { oDoc = window.document; } }
	if( oDoc[oName] ) { return oDoc[oName]; } if( oDoc.all && oDoc.all[oName] ) { return oDoc.all[oName]; }
	if( oDoc.getElementById && oDoc.getElementById(oName) ) { return oDoc.getElementById(oName); }
	for( var x = 0; x < oDoc.forms.length; x++ ) { if( oDoc.forms[x][oName] ) { return oDoc.forms[x][oName]; } }
	for( var x = 0; x < oDoc.anchors.length; x++ ) { if( oDoc.anchors[x].name == oName ) { return oDoc.anchors[x]; } }
	for( var x = 0; document.layers && x < oDoc.layers.length; x++ ) {
		var theOb = MWJ_findObj( oName, null, oDoc.layers[x].document ); if( theOb ) { return theOb; } }
	if( !oFrame && window[oName] ) { return window[oName]; } if( oFrame && oFrame[oName] ) { return oFrame[oName]; }
	for( var x = 0; oFrame && oFrame.frames && x < oFrame.frames.length; x++ ) {
		var theOb = MWJ_findObj( oName, oFrame.frames[x], oFrame.frames[x].document ); if( theOb ) { return theOb; } }
	return null;
}

function Initialize()
{
	try
	{
		req=new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			req=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			req=null;
		}
	}
	if(!req&&typeof XMLHttpRequest!="undefined")
	{
		req=new XMLHttpRequest();
	}
}

function SendQuery(url,nomediv,eff)
{
	//Effect.Fade(nomediv);
	//Element.hide(nomediv);
	//MWJ_findObj('colonna').style.display="none";
	//if (document.colonna2) {MWJ_findObj('colonna2').style.display="none";}
	Initialize();
	// document.getElementById(nomediv).innerHTML ="Prego attendere...";
	if(req!=null)
	{ 
		tempo = new Date().getTime();
		req.onreadystatechange = Process;
		//chiama l'url con parametro per forzare il refresh
		req.open("GET", url+"?rnd="+tempo, true);
		//si puņ fare anche con requestheader ma su uplinkearth fa casini (400 bad request)
		//req.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
        req.send(null);
	}
	function Process()
	{
		if (req.readyState == 4)
	    {
			if (req.status == 200)
			{
				//ShowDiv(nomediv);
				MWJ_findObj(nomediv).innerHTML =req.responseText;
				//if (eff) new Effect.SlideDown(nomediv);
			}
			else
			{
				//ShowDiv(nomediv);
				MWJ_findObj(nomediv).innerHTML ="<p>Dati non disponibili "+req.status+"</p>";
			}
		}
	}
	//if (eff) new Effect.Grow(nomediv, {direction: 'center'});
}

function ShowDiv(nomediv)
{
   MWJ_findObj(nomediv).style.display="block";
}

function HideMenu()
{
   MWJ_findObj('menu1').style.backgroundPosition='0px 0px';
   MWJ_findObj('menu2').style.backgroundPosition='0px 0px';
   MWJ_findObj('menu3').style.backgroundPosition='0px 0px';
   MWJ_findObj('menu4').style.backgroundPosition='0px 0px';
   MWJ_findObj('menu5').style.backgroundPosition='0px 0px';
   MWJ_findObj('menu6').style.backgroundPosition='0px 0px';
   MWJ_findObj('testo1').style.backgroundPosition='0px 0px';
   MWJ_findObj('testo2').style.backgroundPosition='0px 0px';
   MWJ_findObj('testo3').style.backgroundPosition='0px 0px';
   MWJ_findObj('testo4').style.backgroundPosition='0px 0px';
   MWJ_findObj('testo5').style.backgroundPosition='0px 0px';
   MWJ_findObj('testo6').style.backgroundPosition='0px 0px';
}

//function HideDiv(nascondi)
//{
  // MWJ_findObj(nascondi).style.display="none";
//}



function vistirossi()
{
//MWJ_findObj('colonna').style.display="none";
if (visto1==true) MWJ_findObj("menu1").style.backgroundPosition='0px -132px';
if (visto2==true) MWJ_findObj("menu2").style.backgroundPosition='0px -132px';
if (visto3==true) MWJ_findObj("menu3").style.backgroundPosition='0px -132px';
if (visto4==true) MWJ_findObj("menu4").style.backgroundPosition='0px -132px';
if (visto5==true) MWJ_findObj("menu5").style.backgroundPosition='0px -132px';
if (visto6==true) MWJ_findObj("menu6").style.backgroundPosition='0px -132px';
if (visto7==true) MWJ_findObj("menu7").style.backgroundPosition='0px -132px';
}
