        <?xml version="1.0" encoding="UTF-8" ?> 
<Module>
  <ModulePrefs 
    title="Top Gadget Authors" 
    scrolling="true" 
    height="400" 
    width="600" 
    author="Adam S"
    author_email="adam.sah@gmail.com" 
    description="Displays the top gadget authors across the world on a map!" 
    thumbnail="http://trigse.cx/gmod/gadauthorscrn_120.png" 
    screenshot="http://trigse.cx/gmod/gadauthorscrn_280.png" 
    author_photo="http://www.google.com/ig/gadgets/file/113224972997380417953/gordy_thumbnail.png">
      <Require feature="sharedmap"/>
  </ModulePrefs> 
  <UserPref name="numAuthors" 
      display_name="Authors to Display"
      datatype="enum"
      default_value="1">
    <EnumValue value="1" display_value="5"/>
    <EnumValue value="2" display_value="40"/>
    <EnumValue value="3" display_value="60"/>
    <EnumValue value="4" display_value="80"/>
  </UserPref>
  <Content type="html">
  <![CDATA[ 

    <script type="text/javascript">      
      var map;
      var geocoder;
      
      function displayFeed(url) {
        _IG_FetchXmlContent(url, function (response) {
          if (response == null || typeof(response) != "object" || response.firstChild == null) {
            return;
          }

          var itemList = response.getElementsByTagName("item");
          for (var i = 0; i < itemList.length ; i++) { 
            var nodeList = itemList.item(i).childNodes;
            for (var j = 0; j < nodeList.length ; j++) {
              var node = nodeList.item(j);
              if (node.nodeName == "title") {
                if (node.childNodes.length > 0) var name = node.firstChild.nodeValue;
                else var name = "";
              } else if (node.nodeName == "description") {
                if (node.childNodes.length > 0) var bio = node.firstChild.nodeValue;
                else var bio = "";
              } else if (node.nodeName == "ghapi:author_photo") {
                if (node.childNodes.length > 0) var photo = node.firstChild.nodeValue;
                else var photo = "";
              } else if (node.nodeName == "ghapi:author_location") {
                if (node.childNodes.length > 0) var loc = node.firstChild.nodeValue;
                else var loc = "";
              }
            }
            addToMap(name, bio, photo, loc);
          }
        });
      }

      function randomOffset(num) {
        return num + (Math.random()/20) - (1/20);
      }
    
      function addToMap(name, bio, photo, loc) {
        geocoder.getLatLngAsync(loc, function(response) {
          if (response) {
            var marker = new GMarker(response);
            GEvent.addListener(marker, "click", function() {
              var html = '<div style="min-height:110px; width:400px;">';
              html += '<img src="http://google.com'+photo+'" alt="" style="float:left; padding-right:10px;"/>';
              html += '<div style="margin-left:80px;">';
              html += '<b>'+name+'</b>';
              html += ': '+bio+'<br/>';
              html += '<i>'+loc+'</i>';
              html += '</div></div>';
              marker.openInfoWindowHtml(html);
              });
            map.addOverlay(marker);
          }
        });
      }
      
      function displayFeeds() {
        map = new GMap2();
          geocoder = new GClientGeocoder();
//        map.addControl(new GSmallMapControl());
//        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(50, 0), 1);

        var prefs = new _IG_Prefs(__MODULE_ID__);
        var numAuthors = prefs.getInt("numAuthors")
        for (var i = 0; i < numAuthors; i++) {
          var feedurl = "http://google.com/ig/authors?output=rss&start="+(20*i);
          displayFeed(feedurl);
        }
      }

      _IG_RegisterOnloadHandler(displayFeeds);
document.write("hello world");
    </script>
  ]]>
  </Content> 
</Module>

