/*
*
* EventKeeper Javascript (based on their example) for ACLA libraries
* by Michael Fulk
* 6/20/2006
*
* Modified by Matt Blevins for Dormont Public Library
* 10/19/2006
*/

// new variable to handle long event names
		var maxNameLength = 50;
// variable for collecting information
		var events = "";
		var header = "";

	// EventKeeper first returns a javascript variable called fString for FeedString 
	// which tells us what variables are returned. 
	// characters in the string can be: 
	// D : date 
	// T : time 
	// N : name 
	// 1 : keyword 1 
	// 2 : keyword 2 
	
	// EventKeeper has created an javascript array variable called evtArray
	// with fields = evt_date, evt_time, evt_name, evt_ID, evt_Key1 and evtKey2
	
function eventList(OrgName){
	// loop through the array
	for (i=0; i<evtArray.length; i++)
	{
		// Check FeedString.
		events += '<div class="event">';
		if (FeedString.indexOf("D") != -1)
			events += evtArray[i][evt_date];
	
		if (FeedString.indexOf("P") != -1)
			events += evtArray[i][evt_date];
		events += " ";
		if (FeedString.indexOf("T") != -1)
			events += evtArray[i][evt_time];
		events += "<br/>";
		if ((FeedString.indexOf("N") != -1) || (FeedString.indexOf("C") != -1)){
			{
				// handle long event names
				var theName = evtArray[i][evt_name];
				if (theName.length > maxNameLength)
					theName = theName.substring(0,maxNameLength-2) + '...';
					
				// create the hyperlink based on the Event Name and the Event ID
				
				var linkurl = 'http://www.eventkeeper.com/code/events.cfm?curOrg=';
				
				linkurl += OrgName + "#" + evtArray[i][evt_id];
				var namelink = '<a href="' + linkurl + '" title="';
				namelink += evtArray[i][evt_name] + '">' + theName + '</a>';
			//	events += '<em>' + namelink + '</em>';
			    events += namelink;
			}
		}	


		if (FeedString.indexOf("1") != -1)
			events += evtArray[i][evt_key1];

		if (FeedString.indexOf("2") != -1)
			events += evtArray[i][evt_key2];

		events += "<br/></div>";
	}
	
	// Include a link to EventKeeper
	events += '<div class="center"><a href="http://www.eventkeeper.com/code/events.cfm?curOrg=' + OrgName + '">More events...</a></div>';
	events += '<div class="ekLink center">Powered by <strong><a href="http://www.eventkeeper.com">EventKeeper</a></strong></div>';

	document.write(events);
	};
