function ajaxNews(section,nomeDiv)
{
		
  var myVal;
  var nomecontenitore=nomeDiv;
  var contenitore;
  var http_request;
  var url;
  var recordXPagina=1;
  var paginaCorrente=1;
  var contLinkPages=null;
  var parametriGET="";
  
  function settaContPages(contenitore){
	  contLinkPages=contenitore;
  }
  
  function settaRecordXPagina(numero){
	  recordXPagina=numero;
  }
  
  function passaValoriGET(parametri){
	  parametriGET=parametri;
  }
    //*********************************************** SET XML *****************************************
	
  function setXML(){
		
		var XMLNews = http_request.responseXML.getElementsByTagName('new');
		
		if (XMLNews.length>0){
			
			var nodo=XMLNews[0];
			
			if(nodo.getElementsByTagName('data')[0].firstChild.data!= null){
				
				
				var idNews=nodo.getElementsByTagName('id')[0].firstChild.data;
				document.getElementById("testoNewsHome").innerHTML=nodo.getElementsByTagName('data')[0].firstChild.data + " <br /> " +  nodo.getElementsByTagName('titolo')[0].firstChild.data + "<br />" + (nodo.getElementsByTagName('descrizione')[0].firstChild.data.substr(0,50)) + "...";
				document.getElementById("immagineNewsHome").setAttribute("src",nodo.getElementsByTagName('foto')[0].firstChild.data);
				
			}
			
			XMLNews=null;
			/*
			var XMLNews = http_request.responseXML.getElementsByTagName('numRec');
			
			var numeroRecord=XMLNews[0].firstChild.data;
			
			if (numeroRecord>1){
			
				var divPagine = document.getElementById('pagineNewsHome');
							
				divPagine.className="linkPagine";
				
				var ul=document.createElement('ul');
				
				divPagine.appendChild(ul);

				for (var i=0;i<numeroRecord;i++){
					
					var li=document.createElement('li');
					
					if ((i+1)!=Number(paginaCorrente)){
						
						var a=document.createElement('a');
	
						a.onclick=function(){
							paginaCorrente=this.innerHTML;
							caricaXML();
						}
							
						a.innerHTML=(i+1).toString();
						a.href="javascript:void 0;";
						li.appendChild(a);
						
					}else{
						
						li.className="currentPage";
						li.innerHTML = (i+1).toString();
						
					}
					ul.appendChild(li);
				}
						
				if (contLinkPages){
					if (typeof(contLinkPages)=="string") {
						contLinkPages=settaContenitore(contLinkPages);
					}else{
						contLinkPages.innerHTML="";
					}
					contLinkPages.appendChild(divPagine);

				}else{
					
					divNews.appendChild(divPagine);
					
				}
			}
			*/
		}else{
			
			//alert("non ci sono record");
			
		}
	}
	  
  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("provlemi con il contenitore div!!!"+nomecontenitore);	
			return null;
		}else{
			return temp;
		}
  }

  function cambiaStato()
  {
	  if (http_request.readyState != 4) {		
		//Carico il flash per il caricamento
		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>';
	}else{ 
		if (http_request.status == 200) {
			setXML();
		}else{
			alert('There was a problem with the request.');
		}
	}   
  }
  
  function caricaXML(){
	  
	  url="functions/loadXML.php?section="+section+"&numeroPagina="+paginaCorrente+"&recordXPagina="+recordXPagina;
	  if (parametriGET.length>0){
		 url+="&"+ parametriGET;
	  }
	  http_request.open('GET', url, true);
	  http_request.onreadystatechange = cambiaStato;
	  http_request.send(null);
		
  }
  
  creaOggetto();
  contenitore=settaContenitore(nomecontenitore);
  
  this.caricaXML=caricaXML;
  this.settaRecordXPagina=settaRecordXPagina;
  this.settaContPages=settaContPages;
  this.passaValoriGET=passaValoriGET;
  
}

