function ajaxDipnet(section,nomeDiv,idP)
{
	var nomecontenitore=nomeDiv;
	var http_request;
	var contenitore;
	
	this.percorso="";
	this.statica=0;
	this.idCorrente=-1;
	this.section=section;
	this.url;
	this.id=idP;
	this.caricaPrimoRecord=false;
  
	function settaSection(nome){
	  this.section=nome;
	}
	
	function settaId(numero){	
	  this.id=numero;
	}
	
	function getId(){
	  return this.id;
	}
	
	function getContenitore(){
	  return contenitore;
	}
	
	function setContenitore(nome){
	  contenitore=settaContenitore(nome);
	}
	 //*********************************************** SET XML *****************************************
	function setXML(){
			
		contenitore.innerHTML=http_request.responseText;
		
	}
	function creaOggetto()
	{
		if (window.XMLHttpRequest){ 
			http_request = new XMLHttpRequest();
			if (http_request.overrideMimeType){	
				http_request.overrideMimeType('text/xml');
			}		
		}else if(window.ActiveXObject){ 
			try{
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			}catch(e){
				try{
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
				}catch(e){}
			}
		}
		if (!http_request) {
			alert('Cannot create an XMLHTTP instance');
			return false;
		}	
	}
	function settaContenitore(nomecontenitore)
	{
		var temp;
		if (document.getElementById){		
		  temp=document.getElementById(nomecontenitore);
		}else if (document.all){
			temp=document.all[nomecontenitore];
		}else{
			temp=document.layers[nomecontenitore];
		}
		if (!temp){
			alert("Contenitore DIV non esistente !");	
			return null;
		}else{
			return temp;
		}
	}
	function cambiaStato()
	{	
		if (http_request.readyState != 4) {		
			
			contenitore.innerHTML = '<object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" height="25" width="25"><param name="movie" value="templates/immagini/preloadnews.swf"> <param name="quality" value="high"> <param name="wmode" value="transparent"> <embed src="templates/immagini/preloadnews.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" type="application/x-shockwave-flash" height="25" width="25"></object> caricamento in corso...';
		}else{ 
			if (http_request.status == 200) {
				contenitore.innerHTML = "";
				setXML();
			}else{
				alert('Ci sono problemi nella richiesta !');
			}
		}   
	}
	function caricaXML()
	{	
		var carica=true;
		this.url="functions/loadXML.php?section="+this.section
		if (this.statica==1){
			this.url+="&statica=1";
	  	}
		
		if (this.id!=0){
			if (this.idCorrente!=this.id)	{
				this.url+="&id="+this.id;
				this.idCorrente=this.id;
			}else{
				carica=false;	
			}
		}
		
		if (this.caricaPrimoRecord){
			this.url+="&caricaPrimoRecord=1";	
			this.caricaPrimoRecord=false;
		}
		
		if (carica){
			http_request.open('GET', this.url, true);
			http_request.onreadystatechange = cambiaStato;
			http_request.send(null);   
		}
		
	}
  
   creaOggetto();
	if (nomeDiv){
  		contenitore=settaContenitore(nomecontenitore);
  	}
  
  	this.caricaXML=caricaXML;
  	this.settaId=settaId;
  	this.getId=getId;
  	this.settaSection=settaSection;
  	this.setContenitore=setContenitore;
  	this.getContenitore=getContenitore;
}

