function assegnaXMLHttpRequest()
{
	var
		XHR = null,
		browserUtente = navigator.userAgent.toUpperCase();
	if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object")
		XHR = new XMLHttpRequest();
	else if(window.ActiveXObject && browserUtente.indexOf("MSIE 4") < 0) {
		if(browserUtente.indexOf("MSIE 5") < 0)
			XHR = new ActiveXObject("Msxml2.XMLHTTP");
		else
			XHR = new ActiveXObject("Microsoft.XMLHTTP");
	}
	return XHR;
};
               
function getWithAjax(nomefile,contenitore)
{
    return getWithAjax(nomefile,contenitore,"null");
}

function getWithAjax(nomefile,contenitore,loader)
{ 		
        if (loader != "null")
        {
         	showLoader();
        }
		
        var ajax = assegnaXMLHttpRequest(); 
          
        if(ajax)
        {  
            ajax.open("GET",nomefile,true);
            ajax.setRequestHeader('Cache-Control', 'no-cache');	
            ajax.setRequestHeader("connection", "close");
            
            ajax.onreadystatechange = function() 
            {
               if(ajax.readyState === 4)
                {
                    if(ajax.status == 200)
                    {    
		            	document.getElementById(contenitore).innerHTML = ajax.responseText;		
		            }
                    else
                    {
                        document.getElementById(contenitore).innerHTML = "";   
                    }
                    if (loader != "null")
                    {
                        hideLoader();
                    }
                }
            }
            ajax.send(null);
           
        }
}
    
function showLoader(){
	//document.getElementById("carica").style.display="block";
}

function hideLoader(){
	//document.getElementById("carica").style.display="none";
}

function colorizeNews(pos,id)
{
	//devo decolorare le altre notizie!!
	if (pos == "1") {
		document.getElementById("thumb_"+ (id-1) ).style.borderColor = "#2E3238";
		document.getElementById("link_"+  (id-1) ).style.color = "#FF9900";
		document.getElementById("thumb_"+ (id-2) ).style.borderColor = "#2E3238";
		document.getElementById("link_"+ (id-2) ).style.color = "#FF9900";
	}
	
	if (pos == "2") {
		document.getElementById("thumb_"+ (id+1) ).style.borderColor = "#2E3238";
		document.getElementById("link_"+  (id+1) ).style.color = "#FF9900";
		document.getElementById("thumb_"+ (id-1) ).style.borderColor = "#2E3238";
		document.getElementById("link_"+ (id-1) ).style.color = "#FF9900";
	}
	
	if (pos == "3") {
		document.getElementById("thumb_"+ (id+1) ).style.borderColor = "#2E3238";
		document.getElementById("link_"+  (id+1) ).style.color = "#FF9900";
		document.getElementById("thumb_"+ (id+2) ).style.borderColor = "#2E3238";
		document.getElementById("link_"+ (id+2) ).style.color = "#FF9900";
	}
	
	//colora la notizia che l'utente sta "sorvolando" con il mouse
	document.getElementById("thumb_"+id).style.borderColor = "#FFFFFF";
	document.getElementById("link_"+id).style.color = "#FFFFFF";
}