function loadXMLFromURL (feedTitle, feedItem) {
  var httpRequest = null;
  if (typeof XMLHttpRequest != 'undefined') {
    httpRequest = new XMLHttpRequest();
  }
  else if (typeof ActiveXObject != 'undefined') {
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
    try {
      httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        httpRequest = null;
      }
    }
    @end @*/
  }
	  
  // now that we have an XMLHttpRequest object let's try and use it
  if (httpRequest != null) {
    // we'll open with the GET method (the last parameter makes sure we handle
    // the transaction asynchronously, which prevents 'hanging' of the browser
    // when using a slow connection
    try {
      httpRequest.open('GET', "feed.xml", true);
      httpRequest.onreadystatechange = function () {
        // the ready state tells us about the state of the XMLHttpRequest:
        //   0 = uninitialized
        //   1 = loading
        //   2 = loaded
        //   3 = interactive
        //   4 = complete
        // while the status shows us the numeric code returned by the server
        // so when the object is complete and the server returns status OK we
        // use the loadHandler to deal with the returned stuff
        if (httpRequest.readyState == 4) {
          feedLoadHandler(httpRequest.responseXML, feedTitle, feedItem);
        }
      };
      httpRequest.send(null);
    } catch (e) {
      alert('Error ' + e.message + ' occurred.');
    }
  }
}

function feedLoadHandler(rssDoc, feedTitle, feedItem) {
  var itemArray = new Array();
  var itemLinkArray = new Array();
  var itemTitleArray = new Array();

  // try and get the title and the link of our RSS feed
  var rssLinkTag = rssDoc.getElementsByTagName('link');
  var rssTitleTag = rssDoc.getElementsByTagName('title');
  if (rssLinkTag.length >= 1 && rssTitleTag.length >= 1) {
    //document.getElementById(feedTitle).target = "_parent";
    //document.getElementById(feedTitle).href = rssLinkTag[0].firstChild.nodeValue;
    document.getElementById(feedTitle).innerHTML = rssTitleTag[0].firstChild.nodeValue;
  }

  // try and walk all the different RSS items and store them in the table
  var rssElements = rssDoc.getElementsByTagName('item');
  for (var i=0; i < rssElements.length; i++) {
    var children=rssElements[i].childNodes;
    for (var j=0; j < children.length ; j++) {
      tag=children[j];
      if (tag.tagName == "title") {
        itemTitleArray.push(tag.firstChild.nodeValue);    
      }
      if (tag.tagName == "link") {
        itemLinkArray.push(tag.firstChild.nodeValue);
      }
    }
  }

  // for all the items we found let's setup our item array
  for (var i=0; i < itemTitleArray.length; i++) {
    itemArray.push(new Array(itemTitleArray[i], itemLinkArray[i]));
  }	

  initItemCycler(itemArray, feedItem);

  startItemCycler();	
}

function initFeedLoader(feedTitle, feedItem) {
  loadXMLFromURL(feedTitle, feedItem);
}

