<?xml version="1.0" encoding="UTF-8" ?> 
<Module>
  <ModulePrefs  
    title="GPSies Tracks" 
    title_url="http://www.gpsies.com"
	directory_title="Lifestyle"
	description="RSS-Feed Anzeige der neuesten Strecken von GPSies.com"
	author="Hanta Seewald"
	author_email="myxococcus@googlemail.com"
	author_affiliation="mark-up"
	author_location="Lich, Germany"
	author_link="http://hantas.blogspot.com/"
	author_photo="http://www.mark-up.de/gadgets/gadgets-profile.jpg"
	screenshot="http://www.mark-up.de/gadgets/gpsies-screenshot.gif"
	scrolling="true"
	 >
	<Require feature="analytics" />
  </ModulePrefs>
  
  <UserPref name="num_entries" display_name="Anzahl der Eintraege:" />
  <UserPref name="username" display_name="GPSies Benutzername:" />
  <UserPref name="country" display_name="Land" default_value="de" datatype="enum"> 
	<EnumValue display_value="Australia" value="au" />
	<EnumValue display_value="Austria" value="at" />
	<EnumValue display_value="Brazil" value="br" />
	<EnumValue display_value="Canada" value="ca" />
	<EnumValue display_value="Denmark" value="dk" />
	<EnumValue display_value="France" value="fr" />
	<EnumValue display_value="Germany" value="de" />
	<EnumValue display_value="Greece" value="gr" />
	<EnumValue display_value="Italy" value="it" />
	<EnumValue display_value="Netherlands" value="nl" />
	<EnumValue display_value="Luxembourg" value="lu" />
	<EnumValue display_value="Portugal" value="pt" />
	<EnumValue display_value="Russia" value="ru" />		
	<EnumValue display_value="Spain" value="es" />
	<EnumValue display_value="Switzerland" value="ch" />
	<EnumValue display_value="United Kingdom" value="gb" />
	<EnumValue display_value="United States" value="us" />
  </UserPref>
  <UserPref name="language" display_name="Sprache" default_value="de" datatype="enum">
	<EnumValue value="de" display_value="Deutsch" />
	<EnumValue value="en" display_value="English" />
	<EnumValue value="es" display_value="Espanol" />
	<EnumValue value="fr" display_value="Francais" />
	<EnumValue value="nl" display_value="Nederlands" />
	<EnumValue value="pl" display_value="Polski" />

	<EnumValue value="pt" display_value="Portugues" />
	<EnumValue value="ru" display_value="Russian" />
  </UserPref>  
  <Content type="html">
  <![CDATA[ 
  	<style type="text/css">
		#content_div {
			font-size: 11px;
		}
		h1 {
			font-size: 12px;
			margin: 3px 5px;
		}
		h2 {
			font-size: 11px;
			font-style: italic;
			color: Grey;
			font-weight: normal;
			margin: 3px 5px;
		}
		#content_div a {
			padding: 1px 5px;
		}
	</style>
     
    <div id=content_div></div>
     <script type="text/javascript">
     // Get userprefs
     var prefs = new _IG_Prefs(__MODULE_ID__);
     var entries = prefs.getInt("num_entries");
     var username = prefs.getString("username");
	 var country = prefs.getString("country");
	 var language = prefs.getString("language");
	 if (language == "") language = "de";

	 var baseurl = 'http://www.gpsies.com/gpsiesFeed.do';
	 var baseurl_country = baseurl + "?country=";
	 var baseurl_user = baseurl + "?username=";

     // If user wants to display more than 100 entries, display an error
     // and set the value to 100, the max allowed.
     if (entries > 100)
     {
         alert("You cannot display more than 100 entries.");
         entries = 100;
     }

     // Use the _IG_FetchFeedAsJSON() function to retrieve core feed data from
     // the specified URL. Then combine the data with HTML markup for display in
     // the gadget.
	 var fetchurl;
	 if (username) {
	 	fetchurl = baseurl_user + username;
	 }else if(country) {
	 	fetchurl = baseurl_country + country;
	 }else{
	 	fetchurl = baseurl;
	 }
     _IG_FetchFeedAsJSON( fetchurl + "&language=" + language,
              function(feed) { 
              if (feed == null){ 
                 alert("There is no data.");
                 return;
              }
     
         // Start building HTML string that will be displayed in gadget.
         var html = "";

         // Access the fields in the feed
         html += '<h1><img src="http://www.gpsies.com/favicon.ico" align="left" alt="" />' + feed.Title + '</h1>';
         html += "<h2>" + feed.Description + "</h2>";
     
         // Access the data for a given entry
         if (feed.Entry) {
             for (var i = 0; i < feed.Entry.length; i++) {
                 html += "<div>"
                 + "<a target='_blank' href='" + feed.Entry[i].Link + "'>"
                 + feed.Entry[i].Title
                 + "</a> ";
                 html += "</div>";
             }
         }
     _gel("content_div").innerHTML = html;

     // The rest of the function parameters, which are optional: the number
     // of entries to return, and whether to return summaries.
     }, entries, false);
	 _IG_Analytics("UA-2548275-1", "/gadgets/gpsies");
 
  </script>
  ]]> 
  </Content>
</Module>
