///////////////////////////////////////////////////
// Based on a script by Daniel Lemire with some  //
// bits from all over the web                    //
// http://www.daniel-lemire.com/                 // 
///////////////////////////////////////////////////
 
function displayRSS(URI) {
var xmlhttp=false;
var mydiv = document.getElementById("blog");
/*@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);
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;
		link=new Array(), title=new Array(), date=new Array()
		for(var i=0; i<items_count; i++) {
			if(items.getElementsByTagName('item')[i].getElementsByTagName('link').length==1)
				link[i]=items.getElementsByTagName('item')[i].getElementsByTagName('link')[0];
				
			if(items.getElementsByTagName('item')[i].getElementsByTagName('title').length==1)
				title[i]=items.getElementsByTagName('item')[i].getElementsByTagName('title')[0];
								
			if(items.getElementsByTagName('item')[i].getElementsByTagName('pubDate').length==1)
				date[i]=items.getElementsByTagName('item')[i].getElementsByTagName('pubDate')[0];	
				
		}
		/*if(title.length==0) return false;
		
		h2=document.createElement("h2");
		h2.appendChild(document.createTextNode(xmlDoc.getElementsByTagName('title')[0].firstChild.nodeValue));
		mydiv.appendChild(h2);
		*/
		
		var ws=/\S/;
				
		
		
		for(var i=0; i<items_count; i++) {
			var title_w, link_w;
			
			title_w=(title.length>0)?title[i].firstChild.nodeValue:"<i>Untitled</i>";
			
			link_w=(link.length>0)?link[i].firstChild.nodeValue:"";
			
			date_w =date[i].firstChild.nodeValue;
			
			date_w=date_w.substring(4, 16);
			
			ptag = document.createElement("p");
			ptag.setAttribute("class","blogPost");
            linktag =document.createElement("a");
                      
                                
            datetag =  document.createElement("span");        
            
            datetag.setAttribute("class","pubDate");
            
            
            
            datetag.appendChild(document.createTextNode("   "+date_w));
            
                        
			linktag.setAttribute("href",link_w);
			linktag.setAttribute("class","blogLink");
			linktag.setAttribute("style","text-decoration:none");
            linktag.setAttribute("target","_blank");
            
			linktag.appendChild(document.createTextNode(title_w));
			
			ptag.appendChild(linktag);
			ptag.appendChild(datetag);
			
			mydiv.appendChild(ptag);
		}
	}
}


