		var months = new Array('January','February','March','April','May',
								'June','July','August','September','October','November','December');
		var submonths = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
		var data;
		articleListing = function (id) {
			log("Entering articleListing");
			alert (data.articles[id].title)
		}
		newsListing = function (type) {
			log("Entering newsListing");
			myObject = TBODY();
			myObject.appendChild( TR(null, TD({"width":"100px"}, 'Date'),TD(null, 'News & Press Releases') ) );
			curMonth = null;
			for (a = 0; a < data.articles.length; a++) {
				var oddOrEven = (1 == a % 2)?"odd":"even";
				theMonth = new Date(data.articles[a].date);
				if (curMonth == null || (theMonth.getMonth() != curMonth.getMonth()) || (theMonth.getYear() != curMonth.getYear())) {
					myObject.appendChild( TR({"class":"month"}, TD( {'colspan':'2'}, months[theMonth.getMonth()] + " " + ((theMonth.getYear()<200)?(1900 + theMonth.getYear()):theMonth.getYear() )) ) );
					curMonth = theMonth;
				}

				if ( data.articles[a].url == undefined ) {
					linkTag = A({'href':'./articleDisplay.html?title='+ escape(data.articles[a].title)+
								'&date='+escape(data.articles[a].date)+
								'&summary='+escape(data.articles[a].summary)+
								'&description='+ escape(data.articles[a].description), 
								'rel':'lyteframe',
								'rev':'width: 500px; height: 500px;'}, data.articles[a].title)
				} else {
					linkTag = A({'href':data.articles[a].url, 'rel':'lyteframe'}, data.articles[a].title)
				}

				myObject.appendChild(
					TR( {"class" : "article "+ oddOrEven},
						TD({}, submonths[curMonth.getMonth()]+" "+ theMonth.getDate()),
						TD( {},
							DIV({"class":"title"}, linkTag),
							DIV({"class":"details"}, data.articles[a].summary)
						)
					)
				);
			}
			swapDOM(getElement('jsonListing'), 
				TABLE({"id":"jsonListing","border" :0, "cellpadding":0, "cellspacing":0, "class":"feed"}, myObject)
			);
		}
		calendarListing = function (type) {

			log("Entering calendarListing");
			myObject = TBODY();
			curMonth = null;
			for (a = 0; a < data.articles.length; a++) {
				var oddOrEven = (1 == a % 2)?"odd":"even";
				theMonth = new Date(data.articles[a].startingDate);
				theEndpoint = new Date(data.articles[a].endingDate);
				if (curMonth == null || (theMonth.getMonth() != curMonth.getMonth()) || (theMonth.getYear() != curMonth.getYear())) {
					myObject.appendChild( TR({"class":"month"}, TD( {'colspan':'2'}, months[theMonth.getMonth()] + " " + (1900 + theMonth.getYear()) ) ) );
					curMonth = theMonth;
				}
				timespan = TD({}, submonths[curMonth.getMonth()]+" "+ theMonth.getDate());
				if (data.articles[a].endingDate != null) {
					timespan.appendChild(SPAN(" - "+submonths[theEndpoint.getMonth()]+" "+ theEndpoint.getDate()))
				}

				myObject.appendChild(
					TR( {"class" : "article "+ oddOrEven},
						timespan,
						TD( {},
							DIV({"class":"title"}, 
								A({'href':'javascript:articleListing('+a+");"}, data.articles[a].title)
							),
							DIV({"class":"details"}, data.articles[a].summary)
						)
					)
				);
			}
			swapDOM(getElement('jsonListing'), 
				TABLE({"id":"jsonListing","border" :0, "cellpadding":0, "cellspacing":0, "class":"feed"}, myObject)
			);
		}
		eventListing = function (type) {
			if (type == "article") {
				articleListing();
			} else if (type == "news") {
				newsListing();
			} else if (type == "event") {
				calendarListing();
			} else {
				alert (type + " is not a valid type.")
			}
			initLytebox();

		}

		useData = function (dt) {
			data = dt;
			eventListing(dt.type);
		}
		errData = function (msg) {
			alert("Message Delivery Failure: "+msg.message);
		}

		populate = function (file) {
			d = loadJSONDoc(file);
			d.addCallback(useData);
			d.addErrback(errData);
		}

		monthFormat = function (t, y, m) {
			log("Entering monthFormat: "+y+","+m)
			return {'class':'month', 'href':'javascript:getMonthData(\''+t+'\', \'year='+y+'&month='+m+'\');'}
		}

		writeMonths = function (d) {
			var replacementBloc = DIV();
			/*
			var monthFormat = {'class':'month', 'href':'javascript:getMonthData();'}
			*/
			for (y =0; y < d.years.length; y++) {
				var mons = d.years[y].months
				log("DEBUG","mons="+mons);
				replacementBloc.appendChild(DIV({}, d.years[y].year))
				if (mons.january   != undefined) { replacementBloc.appendChild(DIV(null, A(monthFormat(d.type, d.years[y].year, months[0]), months[0] )))}
				if (mons.february  != undefined) { replacementBloc.appendChild(DIV(null, A(monthFormat(d.type, d.years[y].year, months[1]), months[1] )))}
				if (mons.march     != undefined) { replacementBloc.appendChild(DIV(null, A(monthFormat(d.type, d.years[y].year, months[2]), months[2] )))}
				if (mons.april     != undefined) { replacementBloc.appendChild(DIV(null, A(monthFormat(d.type, d.years[y].year, months[3]), months[3] )))}
				if (mons.may       != undefined) { replacementBloc.appendChild(DIV(null, A(monthFormat(d.type, d.years[y].year, months[4]), months[4] )))}
				if (mons.june      != undefined) { replacementBloc.appendChild(DIV(null, A(monthFormat(d.type, d.years[y].year, months[5]), months[5] )))}
				if (mons.july      != undefined) { replacementBloc.appendChild(DIV(null, A(monthFormat(d.type, d.years[y].year, months[6]), months[6] )))}
				if (mons.august    != undefined) { replacementBloc.appendChild(DIV(null, A(monthFormat(d.type, d.years[y].year, months[7]), months[7] )))}
				if (mons.september != undefined) { replacementBloc.appendChild(DIV(null, A(monthFormat(d.type, d.years[y].year, months[8]), months[8] )))}
				if (mons.october   != undefined) { replacementBloc.appendChild(DIV(null, A(monthFormat(d.type, d.years[y].year, months[9]), months[9] )))}
				if (mons.november  != undefined) { replacementBloc.appendChild(DIV(null, A(monthFormat(d.type, d.years[y].year, months[10]), months[10] )))}
				if (mons.december  != undefined) { replacementBloc.appendChild(DIV(null, A(monthFormat(d.type, d.years[y].year, months[11]), months[11] )))}
			}
			swapDOM(getElement('monthBloc'),replacementBloc)
		}
		getMonths = function (file) {
			d = loadJSONDoc(file);
			d.addCallback(writeMonths);
			d.addErrback(errData);
		}
		getMonthData = function (type, param) {
			log("Entering getMonthData: this is called on selection of a month");
			if (param.indexOf("2006") != -1)
			{
			d = loadJSONDoc("../../gateway.asp?url="+escape("./Website/"+type+".json?"+param));
			} else {
			d = loadJSONDoc("../../gateway.asp?url="+escape("./Website/"+type+".json?"+param));
			}
			d.addCallback(useData);
			d.addErrback(errData);
		}
