// Fly of the Month Javascript

// This file assumes that SpryData.js and SpryHTMLDataset.js have been loaded

// Create the HTML Dataset

var dsFotmdb = new Spry.Data.HTMLDataSet("fotm_db_frag.html", "dsFotm", {sortOnLoad:"Name"});


// Filter function for the dsFotmdb.  This filter limits the view of the dataset according to the Pictype
// setting for each row of the dataset

function FilterData(pictype)
{
	var tf = pictype;
	if (!tf)
	{
		// If the text field is empty, remove any filter
		// that is set on the data set.

		dsFotmdb.filter(null);
		return;
	}

	// Set a filter on the data set that matches any row
	// that begins with the string in the text field.

	
	var filterFunc = function(ds, row, rowNumber)
	{
		var str = row["Pictype"];
		if (str == tf)
			return row;
		return null;
	};

	dsFotmdb.filter(filterFunc);
}

// Function to invoke the dsFotmdb filter function
function StartFilterTimer(pictype)
{
	if (StartFilterTimer.timerID)
		clearTimeout(StartFilterTimer.timerID);
	StartFilterTimer.timerID = setTimeout(function() { StartFilterTimer.timerID = null; FilterData(pictype); }, 100);
}

// Invoke the dsFotmdb filter to set an initial view

StartFilterTimer('dryfly');

