﻿var myXMLDoc = "rss/all.xml";

function loadMostPopularBlogsXML() {
    var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
    var ie = (typeof window.ActiveXObject != 'undefined');

    if (moz) {
        var oParser = new DOMParser();
        xmlDoc = oParser.parseFromString(strmostpopularblogs, "text/xml");
        return xmlDoc;
    }
    else if (ie) {
        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        xmlDoc.async = false;
        xmlDoc.loadXML(strmostpopularblogs);
        return xmlDoc;
    }

}

function loadXMLDoc(dname) {
    if (window.XMLHttpRequest) {
        xhttp = new XMLHttpRequest();
    }
    else {
        xhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xhttp.open("GET", dname, false);
    xhttp.send();
    return xhttp.responseXML;
}

xmlDoc = loadXMLDoc(myXMLDoc);


document.write('<div class="leader"><h4>LATEST ARTICLES <a href="http://feeds.feedburner.com/ImediaConnectionAll" class="rss"><img title="Subscribe to latest articles" src="http://assets.imediaconnection.com/images/global/icon_rss_sm.gif" alt="Subscribe to latest articles" style="border-width:0px;" /></a></h4>');

var displayMax = 10;
var myURL = "http://blogs.imediaconnection.com/BlogDetail.aspx?BlogID=";
var arrURL = "";
var most = xmlDoc.getElementsByTagName("item");
var title;
var pagelink;
var count;

if (most.length < 10)
    displayMax = most.length;
else
    displayMax = 5;

  
for (var i = 0; i < displayMax; i++) {
    title = most[i].getElementsByTagName("title")[0].firstChild.nodeValue;
    pagelink = most[i].getElementsByTagName("link")[0].firstChild.nodeValue;
    //count = most[i].getElementsByTagName("ViewCount")[0].firstChild.nodeValue;  
    // --- display template ---
    document.write("<li>");
    document.write("<a href='" + myURL + pagelink + "'>" + title + "</a>");
    document.write("</li>");
}
document.write('</ul> ');
document.write('</div> ');
