var xmlHttp = GetXmlHttpObject();

var xmlHttp2 = GetXmlHttpObject2(); //secondo oggetto per usarli contemporaneamente



/*AJAX*/

//metodo per creare la richiesta
function GetXmlHttpObject()
{  var xmlHttp=null;  
try    {    
	// Firefox, Opera 8.0+, Safari, IE7    
		xmlHttp=new XMLHttpRequest();    
		}  
catch (e)    
{    // Internet Explorer & e precedenti    
try      {      
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      	
		}    
catch (e)      
		{      
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
		}    
}  
return xmlHttp;
}





function GetXmlHttpObject2()
{  var xmlHttp2=null;  
try    {    
	// Firefox, Opera 8.0+, Safari, IE7    
		xmlHttp2=new XMLHttpRequest();    
		}  
catch (e)    
{    // Internet Explorer & e precedenti    
try      {      
			xmlHttp2=new ActiveXObject("Msxml2.XMLHTTP");      	
		}    
catch (e)      
		{      
			xmlHttp2=new ActiveXObject("Microsoft.XMLHTTP");      
		}    
}  
return xmlHttp2;
}




/************************** visualizzatore *****************************/
function cambiaSezione()
{ 				
		if (xmlHttp.readyState==4)
			{ 		
				
					//alert(xmlHttp.responseText);
					if (xmlHttp.responseText!=0)
					document.getElementById("ultima_sezione").innerHTML=xmlHttp.responseText;
					scrolla_ultima_sezione();

			}
			
} 

function mostra_ultima_sezione()
{	
	
if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
	{		
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)  
	{  
		/*alert ("Il tuo browser non supporta AJAX");*/  return;  
	} 	
	xmlHttp.open("GET","ajax.php",true);	
	xmlHttp.onreadystatechange=cambiaSezione;
	xmlHttp.send(null);
	}
	
	
}
/************************** visualizzatore *****************************/	



function cambiaImmagine()
{ 		
		if (xmlHttp2.readyState==4)
			{ 			
					//alert(xmlHttp.responseText);
					if (xmlHttp2.responseText!=0)
					document.getElementById("box_fotogallery").innerHTML=xmlHttp2.responseText;
					setTimeout("cambia_immagine()",20000);							
			}			
} 


function cambia_immagine()
{		
	
if (xmlHttp2.readyState == 4 || xmlHttp2.readyState == 0)
	{		
		
		
		
	xmlHttp2=GetXmlHttpObject2()
	if (xmlHttp2==null)  
	{  
		/*alert ("Il tuo browser non supporta AJAX");*/  return;  
	}

	
	xmlHttp2.open("GET","ajax_img.php",true);
	xmlHttp2.onreadystatechange=cambiaImmagine;				
	xmlHttp2.send(null);	
	} {
	//se la connessione è impegnata riproviamo dopo 1 sec
	//setTimeout('cambia_immagine()',20000);		
	}
}
