<?xml version="1.0" encoding="UTF-8" ?>
<Module>
	<ModulePrefs title="TERRA: The Nature of Our World"
		title_url="http://www.lifeonterra.com/"
		description="Browse and search TERRA: The Nature of Our World for nature videos and more."
		screenshot="http://www.lifeonterra.com/meta/images/terra-gadget-screen.jpg"
		thumbnail="http://www.lifeonterra.com/meta/images/terra-gadget-thumb.jpg"
		author="Montana State University Libraries"
		author_location="Bozeman, MT, USA"
		author_email="jaclark@montana.edu"
		>
		<Require feature="tabs" />
		<Require feature="dynamic-height" />
		<Require feature="setprefs"/>
	</ModulePrefs>
	<UserPref name="show_date" display_name="Show Dates?" datatype="bool"/>
	<UserPref name="show_summ" display_name="Show Summaries?" datatype="bool"/>
	<UserPref name="num_entries" display_name="Number of Entries:" />
<Content type="html">
	<![CDATA[
	<script type="text/javascript">
	// Initialize tabs, designate the tab named "TERRA Feed" as
	// the tab selected by default.
	var tabs = new _IG_Tabs(__MODULE_ID__, "TERRA Feed");
	function init() {
	// Create the tab and define a corresponding <div> in the
	// HTML portion of the gadget. Add static content to the <div>.
	tabs.addTab("TERRA Feed", "feed");
	tabs.addTab("TERRA Search", "search");
	
	}
	// Call init function to initialize and display tabs.
	_IG_RegisterOnloadHandler(init);
	</script>
	
	<div id="feed" style="display:none">
	<p><img src="http://www.lib.montana.edu/meta/img/msu_favicon.ico" alt="terra video rss feed" /> <strong>TERRA: The Nature of Our World</strong></p>
	<style> #content_div { font-size: 80%; margin: 5px; background-color: #FFFFBF;} </style>
	
	<div id=content_div></div>
	
	<script type="text/javascript">
	
	// Get userprefs
	var prefs = new _IG_Prefs(__MODULE_ID__);
	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(
	"http://feeds.feedburner.com/Terravideos",
	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><b>" + feed.Title + "</b></div>";
	//html += "<div>" + 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>"
	+ "<a target='_blank' href='" + feed.Entry[i].Link + "'>"
	+ feed.Entry[i].Title
	+ "</a> ";
	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 += date.toLocaleDateString();
	html += " ";
	html += date.toLocaleTimeString();
	}
	if (summary==true) {
	html += "<br><i>" + feed.Entry[i].Summary + "</i>";
	}
	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.
	}, 5, summary);
	
	</script>
	<a href="http://feeds.feedburner.com/Terravideos" target="_blank">+ subscribe</a>
	</div>
	
	<div id="search" style="display:none">
	<p><img src="http://www.lib.montana.edu/meta/img/msu_favicon.ico" alt="terra video search" /> <strong>TERRA: The Nature of Our World</strong></p>
	<form action="http://www.lifeonterra.com/results.php" method="post" target="_blank">
	<input type="hidden" name="max" value="25" />
	<input type="hidden" name="low" value="0" />
	<input class="txt_search" type="text" name="keyword" maxlength="35" size="25" />&nbsp; <input type="submit" id="submit" class="submit" value="Search" />
	</form>
	<a href="http://www.lifeonterra.com/search.php" target="_blank">+ advanced search</a>
	</div>
	]]>
</Content>
</Module>