<?xml version="1.0" encoding="UTF-8" ?> 
 <Module>
  <ModulePrefs 
	title="WrightsVineyard.com RSS Reader" 
	title_url="http://www.wrightsvineyard.com/winepedia/"
	author="WrightsVineyard.com" 
	author_email="winepedia.gadget@googlemail.com" 
	author_location="England" 
	author_affiliation="WrightsVineyard.com"
	author_link="http://www.wrightsvineyard.com"
	description="WrightsVineyard.com - Winepedia RSS Feed. This RSS reader shows you the most recent posts on Winepedia, our wine articles section. Winepedia is for wine lovers to share their wine experiences!" 
	screenshot="http://www.wrightsvineyard.com/winepedia/images/gadget/screenshot_rss_reader.jpg"
	thumbnail="http://www.wrightsvineyard.com/winepedia/images/gadget/thumbnail_rss_reader.jpg"	
	height="240"
	scrolling="true"
	render_inline="never">
	<Require feature="dynamic-height"/>
  </ModulePrefs>
  <UserPref name="feed_url" display_name="RSS Feed URL" default_value="http://www.wrightsvineyard.com/winepedia/rss.php" required="true"/>
  <UserPref name="show_date" display_name="Show Dates?" datatype="bool" default_value="true"/>
  <UserPref name="show_summ" display_name="Show Summaries?" datatype="bool" default_value="true"/>
  <UserPref name="num_entries" display_name="Number of Entries:" default_value="9" />
 <Content type="html">
 <![CDATA[ 
<style> 
#content_div { 
font-family: arial, helvetica, sans-serif;
font-size: 11px;
padding: 5px;
background-color: #FFFFFF;
}

#feedtitle {
font-size: 12px;
color: #5F0400;
background-color: #FAF3D8;
}

#feeddescription {
font-size: 11px;
color: #5F0400;
background-color: #FAF3D8;
}

#itemtitle {
font-size: 12px;
font-weight: bold;
background-color: #FAF3D8;
color: #5F0400;
}

#itemdate {
font-size: 10px;
color: #9F9F9F;
}

#itemsummary {
font-size: 11px;
}

#readmore a {
font-size: 11px;
font-weight: bold;
color: #AC0801;
text-decoration: none;
}
</style>


<div id=content_div></div>

<script type="text/javascript"> 

// Get userprefs
var prefs = new _IG_Prefs(__MODULE_ID__);
var feedurl = prefs.getString("feed_url");
var showdate = prefs.getBool("show_date");
var summary = prefs.getBool("show_summ");
var entries = prefs.getInt("num_entries");

// If user wants to display more than 9 entries, display an error
// and set the value to 9, the max allowed.
if (entries > 9)
{
    alert("You cannot display more than 9 entries.");
    entries = 9;
}

// 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.
_IG_FetchFeedAsJSON(
  feedurl,
  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 += "<div id='feedtitle'><b>" + feed.Title + "</b></div>";
    html += "<div id='feeddescription'>" + feed.Description + "</div><br>";
    
    // Access the data for a given entry
    if (feed.Entry) {
      for (var i = 0; i < feed.Entry.length; i++) {
        html += "<div>"
	      +   "<div id='itemtitle'><a target='_blank' href='" + feed.Entry[i].Link + "' style='color:#5F0400; text-decoration:none; line-height:20px;'>"
	      +      feed.Entry[i].Title
	      +   "</a></div> ";
          if (showdate==true)
          {    
             // The feed entry Date field contains the timestamp in seconds
             // since Jan. 1, 1970. To convert it to the milliseconds needed
             // to initialize the JavaScript Date object with the correct date, 
             // multiply by 1000.
             var milliseconds = (feed.Entry[i].Date) * 1000;   
             var date = new Date(milliseconds);
			 html += "<div id='itemdate'>";
             html += date.toLocaleDateString();
             html += " ";
             html += date.toLocaleTimeString();
			 html += "</div>";
          }          
          if (summary==true) {           
             html += "<div id='itemsummary'><i>" + feed.Entry[i].Summary + "</i></div>";
          }
	      html += "<div id='readmore'><a target='_blank' href='" + feed.Entry[i].Link + "'>Read More &gt;&gt;</a></div></div><br/>";
      }
    }

    _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, summary);

    
</script>

  ]]> 
  </Content>
  </Module>