// JavaScript Document
// EN Version ONLY
var ds1 = new Spry.Data.HTMLDataSet("pcntabledata.html", "pcndata", {useCache: false, sortOnLoad: ["PCN_Sort","Notice_Date"], sortOrderOnLoad: "descending", columnNames: ["AMID", "PCN", "PCN_Sort", "PCN_Title", "Notice_Date", "Devices_Packages", "PCN_Category"]});
ds1.setColumnType("Notice_Date", "date");

// filter used for the Search By Title and Device inputs
function FindDeviceFilterFunc(deviceStr){
	return function (ds, row, rowIndex){
		var searchStr = deviceStr.toLowerCase();
		// search for the string passed in within two columns...
		if (row["Devices_Packages"].toLowerCase().indexOf(searchStr) != -1
			|| row["PCN_Title"].toLowerCase().indexOf(searchStr) != -1)
			return row; // Return the row to keep it in the data set.
		return null; // Return null to remove the row from the data set.
	}
}

ds1.filter(null); // default to clearing the filter

// Add a listener that fires after the page is loaded. 
Spry.Utils.addLoadListener(
	function(){
		Spry.$$("#pcnTable").setAttribute("spry:region","ds1");
		Spry.$$("#pcnRepeatRow").setAttribute("spry:repeat","ds1");
		Spry.$$("#pcnIDSort").setAttribute("spry:sort","PCN_Sort");
		Spry.$$("#pcnDateSort").setAttribute("spry:sort","Date_Sort");
		Spry.$$("#pcnRepeatRow").setAttribute("spry:even","evenrow");
		Spry.$$("#pcnNoRows").setAttribute("spry:if","{ds_RowCount}==0");
	}
)

