function displayRSS(URI,myid,mytag,mynb) {
var xmlhttp=false;
var mydiv = document.getElementById(myid);
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  xmlhttp = new XMLHttpRequest();
}
xmlhttp.open("GET", URI,true);
mytag = document.createElement("p");
mytag.setAttribute('align','center');
image = document.createElement('img');
image.setAttribute('border','0');
image.src = 'img/wait.gif';
mytag.appendChild(image);
mydiv.appendChild(mytag);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {  
  xmlDoc=xmlhttp.responseXML;
  items=xmlDoc;
  formatRSS();
  }
 }
 xmlhttp.send(null);

	function formatRSS() {
		var items_count=items.getElementsByTagName('item').length;
		if(mynb < items_count){items_count = mynb;}
        if(items_count == 0) {
       	ptag = document.createElement("p");
        ptag.appendChild(document.createTextNode("Ce flux ne semble pas être valide ou est actuellement indisponible"));
		mydiv.appendChild(ptag);
		return;
        }
		
		//titre
        b = document.createElement("b");	
		var titre = items.getElementsByTagName('title')[0].firstChild.nodeValue;
		if(titre.length>50) titre = titre.substring(0,50) + '...';
		b.appendChild(document.createTextNode(titre));		
		document.getElementById('titre_'+myid).appendChild(b);
		
		//extra
		if(titre.search(/YouTube/)!=-1){
		 var myform = '<form onSubmit="return(false);"><input onfocus="if(this.value=\'Recherche videos\')this.value=\'\';" id="youtubeform" type="text" onMouseover="this.focus();" value=\"Recherche videos\">';
		 myform += "<input type=\"button\" value=\"OK\" onclick=\"recharge('youtube','12',escape(document.getElementById('youtubeform').value));\"></form>";
		 myform += "<p align='center' id='youtubeplayer'></p>";
		 document.getElementById('tdplus'+myid).innerHTML = myform;
		}
		
		//contenu
		var spantag = '';
		for(var i=0; i<items_count; i++) {
          var itemNodes = items.getElementsByTagName("item")[i].childNodes;                                
          for (var j=0; j < itemNodes.length; j++) {
            var itemNode = itemNodes[j];
            if ("title" == itemNode.tagName) {
                articleTitle = (itemNode.firstChild.nodeValue) ? itemNode.firstChild.nodeValue : itemNode.textContent;
            } else if ("valeur" == itemNode.tagName) {
                articleValeur = (itemNode.firstChild.nodeValue) ? itemNode.firstChild.nodeValue : itemNode.textContent;	articleURL = "";
            } else if ("link" == itemNode.tagName) {
                articleURL = (itemNode.firstChild.nodeValue) ? itemNode.firstChild.nodeValue : itemNode.textContent;
            } else if ("media:content" == itemNode.tagName) {
                articleMediaURL = itemNode.getAttribute("url");    
            } else if ("media:thumbnail" == itemNode.tagName) {
                articleThumb = itemNode.getAttribute("url");    
            } else if ("enclosure" == itemNode.tagName) {
                articleEnclosure = itemNode.getAttribute("url");    
            } else if ("description" == itemNode.tagName) {
                articleDesc = (itemNode.firstChild.nodeValue) ? itemNode.firstChild.nodeValue : itemNode.textContent;    
            } else if ("prix" == itemNode.tagName) {
                articlePrix = (itemNode.firstChild.nodeValue) ? itemNode.firstChild.nodeValue : itemNode.textContent;    
            }			
          }
          if(titre.search(/YouTube/)!=-1){ //RSS Media
            spantag += '<span style="cursor:pointer;margin:1px"><img onclick="lireswf(\''+articleEnclosure+'\');" width="90" height="67" src="'+articleThumb+'" border="0"></span>';		  
		  }		  
          else if(articleURL){ //RSS NORMAL
			//if(articleTitle.length>75) articleTitle = articleTitle.substring(0,75) + '...';
			//var exp=new RegExp("(<!\[CDATA\[)|(\]\]>)","g");
			//articleTitle = articleTitle.replace(exp,'');
			//articleURL = articleURL.replace(exp,'');
			//articleDesc = articleDesc.replace(exp,'');
			linktag = document.createElement("a");			
			linktag.setAttribute("href",articleURL);
			linktag.setAttribute("class","gris_b");
			linktag.setAttribute("className","gris_b");
			linktag.setAttribute("target","_blank");			
			linktag.setAttribute("title","header=["+articleTitle+"] body=["+articleDesc+"]");
			linktag.appendChild(document.createTextNode(articleTitle));
			litag = document.createElement("li");
            litag.appendChild(linktag);		
			mydiv.appendChild(litag);		
		  }
          else if(titre.search(/Bourse de Casablanca/) == 0){ //RSS BOURSE  		    			
			span_t = document.createElement("span");
			span_t.style.color="gray";
			span_t.appendChild(document.createTextNode(articleTitle+' : '));
			span_v = document.createElement("span");
			if(articleValeur.search(/-/)==0) {span_v.style.color="red";}
			else if(articleValeur.search(/-/)==-1 && articleValeur!='0,00%') {span_v.style.color="green";}
			span_v.appendChild(document.createTextNode(articleValeur));	
			litag = document.createElement("li");
			litag.style.cursor = "default";
			litag.style.cssFloat = litag.style.styleFloat = "left";
			litag.style.width="45%";
	        litag.onmouseover = function(){this.style.fontWeight='bold'};
	        litag.onmouseout = function(){this.style.fontWeight='normal'};
			litag.appendChild(span_t);
			if(articlePrix){
			span_p = document.createElement("span");
			span_p.appendChild(document.createTextNode('  '+articlePrix+' Dh  '));
            litag.appendChild(span_p);			
			}			
			litag.appendChild(span_v);
			mydiv.appendChild(litag);		
		  }
          else if(titre.search(/Programme 2M/)==0 || titre.search(/Programme TVM/)==0){ //RSS 2M	  		  
			span_t = document.createElement("span");
			span_t.style.color="gray";
			span_t.appendChild(document.createTextNode(articleTitle+' : '));
			span_v = document.createElement("span");
			span_v.appendChild(document.createTextNode(articleValeur));	
			litag = document.createElement("li");
			litag.style.cursor = "default";
			litag.style.cssFloat = litag.style.styleFloat = "left";
			litag.style.width="45%";
	        litag.onmouseover = function(){this.style.fontWeight='bold'};
	        litag.onmouseout = function(){this.style.fontWeight='normal'};
			litag.appendChild(span_t);
			litag.appendChild(span_v);
			mydiv.appendChild(litag);			
          }		
		}
        if(titre.search(/YouTube/)!=-1){mydiv.innerHTML = spantag;}		
		else {mydiv.removeChild(mytag);}
	}
}