YAHOO.namespace("kqed");
YAHOO.kqed.PgmArchiveCal = function() {
	var Ydom = YAHOO.util.Dom,
		Yds = YAHOO.util.DataSource, 
		YdtMath = YAHOO.widget.DateMath,
		containerId = "audio-archive-calendar",
		detailDivId = "audio-archive-detail",
		detailDivWidth = "400px",
		detailDatelineId = "audio-archive-detail-headline",
		hasAudioHtml = " class=\"listen\"",
		segTitle = "segment-title", epTitle = "episode-title", pgmTitle = "program-title",
		/* formats used in Date.prototype.format (kqed-src/global.js) */
		YYYYMM = "yyyymm", YYYYMMDD = "yyyymmdd", MDY = "m/d/yyyy", WMDY_SHORT = "WMDY-short", HM = "H:Ma";
	
	/* scoping nulls */
	var tooltip = [], cal = null;

	return {
		SEGMENT: 2, EPISODE: 1,
		KQED_ORG: 1, CALREPORT: 2, TWINC: 3,   /* to differentiate siteId fed by pageConfig; default KQED_ORG */
		STAT_NEW: 0, STAT_LOAD: 1, STAT_DONE: -1, STAT_MAX_RETRIES: 3, /* status codes to populate monthStatus */
		monthLoadStatus: {},   /* key YYYYMM, loaded status to determine display on pageChange */
		severalMonthsData: {},    /* local cache of every month's loaded data */
		monthData: {},    /* current month's schedule data, shortcut for tooltips */
		currentPageMonth: null,
		containerDivId: containerId,
		calMaskVisible: false,  // is calendar mask currently visible -- starts life as not visible
		getArchiveUrlBase: function() {
			var pac = YAHOO.kqed.PgmArchiveCal;
			if (pac.site_id == pac.CALREPORT) {
				return "/archive/";
			} else if (pac.site_id == pac.TWINC) {
				return "/tv/programs/thisweek/watch/archive/";
			} else {
				return "/epArchive/";
			}
		},
		getEpUrl: function(epid) {
			var pac = YAHOO.kqed.PgmArchiveCal;
			return pac.getArchiveUrlBase() + epid;
		},
		getSegUrl: function(epid, segid) {
			var pac = YAHOO.kqed.PgmArchiveCal;
			return pac.getArchiveUrlBase() + epid + "/" + segid;
		},
		epidsInDay: function(selDate) { // selDate = actual Date object
			YAHOO.log("starting epidsInDay","BLARG","epidsInDay");
			var pac = YAHOO.kqed.PgmArchiveCal;
			var epsInDay = [];
			var tmpDate = selDate.format(MDY);
			YAHOO.log("vars declared","BLARG","epidsInDay");
			YAHOO.log(YAHOO.lang.dump(pac.monthData[tmpDate]), "epidsInDay", "epidDay");
			for (var seg = 0; seg < pac.monthData[tmpDate].length; seg++) {
				var thisSeg = pac.monthData[tmpDate][seg];
				YAHOO.log(YAHOO.lang.dump(thisSeg), "epidsInDay-tmi", "epidDay");
				if (epsInDay.length == 0 || epsInDay[epsInDay.length - 1] != thisSeg.epid) {
					epsInDay.push(thisSeg.epid);
				}
			};
			YAHOO.log(YAHOO.lang.dump(epsInDay), "epidsInDay", "epidDay");
			YAHOO.log("finishing epidsInDay","BLARG","epidsInDay");
			return epsInDay;
		},
		getTooltipText: function(tmpDate) {
			var pac = YAHOO.kqed.PgmArchiveCal;
			var tooltipText = "";
			if (pac.monthData[tmpDate]) {  // date exists
				if (pac.detail_level == pac.SEGMENT) {
					// segment presentation
					for (var seg = 0; seg < pac.monthData[tmpDate].length; seg++) {
						var thisSeg = pac.monthData[tmpDate][seg];
						tooltipText += thisSeg[segTitle] + "<br/>";
					};
				} else {
					// episode presentation
					for (var ep = 0; ep < pac.monthData[tmpDate].length; ep++) {
						var thisEp = pac.monthData[tmpDate][ep];
						tooltipText += thisEp.airtime.format(HM) + ": " + thisEp.title + "<br/>";
					};
				}
			} else {
				tooltipText += "No archives available for this date.";
			}
			return tooltipText;
		},
		getDetailsHtmlSingleEpisode: function(thisEp) {
			var pac = YAHOO.kqed.PgmArchiveCal;
			return "<li>" + "<a href=\"" + pac.getEpUrl(thisEp.epid) + "\">" +
							thisEp.title + "</a> " +
							((thisEp.airtime) ? " / " + (thisEp.airtime.format(HM)) : "") + 
							"</li>";
		},
		getDetailsHtmlSingleSegment: function(thisSeg) {
			var pac = YAHOO.kqed.PgmArchiveCal;
			return "<li>" + "<a href=\"" + pac.getSegUrl(thisSeg.epid, thisSeg.segid) + "\">" + 
					thisSeg[segTitle] + "</a>" + "</li>";
		},
		getSegmentGroupHeading: function(thisSeg) {
			var pac = YAHOO.kqed.PgmArchiveCal;
			var headText = thisSeg[pgmTitle];
			if (pac.site_id == pac.CALREPORT) {
				// HAAACK
				headText = ((thisSeg[epTitle] == "The California Report") ? "Morning Report" : thisSeg[epTitle]);
			}
			return "<a href=\"" + pac.getEpUrl(thisSeg.epid) + "\">" + headText + "</a>";
		},
		getDetailsHtml: function(forDate) {
			var pac = YAHOO.kqed.PgmArchiveCal;
			var tmpDate = forDate.format(MDY);
			var htmltext = "";
			if (pac.monthData[tmpDate]) {
				if (pac.detail_level == pac.SEGMENT) {
					// segment presentation
					var epids = pac.epidsInDay(forDate);
					if (epids.length == 1) {
						// single episode -- no headers
						htmltext += "<ul>";
						for (var seg = 0; seg < pac.monthData[tmpDate].length; seg++) {
							htmltext += pac.getDetailsHtmlSingleSegment(pac.monthData[tmpDate][seg]);
						};
						htmltext += "</ul>";
					} else {
						// multi episode, include ep headers
						for (var seg = 0, last_epid = "x"; seg < pac.monthData[tmpDate].length; seg++) {
							var thisSeg = pac.monthData[tmpDate][seg];
							if (last_epid != thisSeg.epid) {
								last_epid = thisSeg.epid;
								if (seg > 0) 
									htmltext += "</ul>";
								htmltext += "<h3>" + pac.getSegmentGroupHeading(thisSeg) + "</h3><ul>";
							}
							htmltext += pac.getDetailsHtmlSingleSegment(thisSeg);
						};
						htmltext += "</ul>";
						
					}
				} else {
					// episode presentation
					htmltext += "<ul>";
					for (var ep = 0; ep < pac.monthData[tmpDate].length; ep++) {
						// TODO: replace with getDetailsHtmlSingleEpisode as with segments
						var thisEp = pac.monthData[tmpDate][ep];
						htmltext += "<li>" + "<a href=\"" + pac.getEpUrl(thisEp.epid) + "\">" +
							thisEp.title + "</a> " +
							((thisEp.airtime) ? " / " + (thisEp.airtime.format(HM)) : "") + 
							"</li>";
					};
					htmltext += "</ul>";
				}
			} else {
				htmltext += "<ul><li>No archives are available for this day.</li></ul>";
			}
			return htmltext;
		},
		getPanelHeaderHtml: function(selDate) {
			var pac = YAHOO.kqed.PgmArchiveCal, htmltext = selDate.format(WMDY_SHORT);
			// in most cases this will just be the default htmltext declared above, except...
			if (pac.detail_level == pac.SEGMENT) {
				// segment presentation
				if (pac.monthData[selDate.format(MDY)]) {
					// data exists
					var epids = pac.epidsInDay(selDate);
					if (epids.length == 1) {
						htmltext = "<a href=\"" + pac.getEpUrl(epids[0]) + "\">" + selDate.format(WMDY_SHORT) + "</a>";
					}
				}
			}
			return htmltext;
		},
		monthIsLoaded: function(theMonth) {
			var pac = YAHOO.kqed.PgmArchiveCal;
			if (theMonth == null) {
				theMonth = pac.currentPageMonth;
			}
			return ( typeof pac.severalMonthsData[theMonth] == "object" );
		},
		monthIsLoading: function(theMonth) {
			var pac = YAHOO.kqed.PgmArchiveCal;
			return (null != pac.monthLoadStatus[theMonth] && pac.monthLoadStatus[theMonth] >= pac.STAT_LOAD);
		},
		monthStartLoading: function(theMonth) {
			var pac = YAHOO.kqed.PgmArchiveCal;
			if (pac.monthLoadStatus[theMonth] instanceof int) {
				pac.monthLoadStatus[theMonth] += 1;
			} else {
				pac.monthLoadStatus[theMonth] = pac.STAT_LOAD;
			}
		},
		monthFinishLoading: function(theMonth) {
			var pac = YAHOO.kqed.PgmArchiveCal;
			pac.monthLoadStatus[theMonth] = pac.STAT_DONE;
			pac.decorate();
		},
		monthFailLoading: function(theMonth) {
			var pac = YAHOO.kqed.PgmArchiveCal;
			
		},
		monthIsRetryable: function(theMonth) {
			var pac = YAHOO.kqed.PgmArchiveCal;
		},
		fetchMonthEpisodesRemote: function(pagedate, makeActive, monthDataSource) {
			var pac = YAHOO.kqed.PgmArchiveCal, 
				smd = pac.severalMonthsData,
				fetchedMonth = pagedate.format(YYYYMM);
			if (! smd[fetchedMonth]) {
				if (pac.currentPageMonth == fetchedMonth) {
					pac.showCalMask();
				}
				smd[fetchedMonth] = true;
				monthDataSource.sendRequest(  
					"pgmid=" + pac.pgmid + "&year=" + pagedate.getFullYear() + "&month=" + (pagedate.getMonth() + 1), 
					{
						success: function(oRequest,oResponse,oPayload) {
							YAHOO.log(YAHOO.lang.dump(oRequest), "fetch", "fm-er");
							smd[fetchedMonth] = {};
							for (var epIndex = 0, epArray = oResponse.results; epIndex < epArray.length; epIndex++) {
								var ep = epArray[epIndex];
								var epDay = ep.airtime.format(MDY);
								YAHOO.log(YAHOO.lang.dump(ep), "ep", "fm-er");
								if (smd[fetchedMonth][epDay]) {
									// day already exists, add to it
									smd[fetchedMonth][epDay].push(ep);
								} else {
									// make a new day
									smd[fetchedMonth][epDay] = [ep];
								}
							}
							
							if (makeActive || pac.currentPageMonth == fetchedMonth) {
								pac.monthData = smd[fetchedMonth];
								pac.decorate();
								
								// pre-fetch previous month's data when done, to make loading seem faster on month change
								pac.fetchMonth(YdtMath.subtract(pagedate, YdtMath.MONTH, 1), false);
							}

							pac.decorate();
							if (pac.currentPageMonth == fetchedMonth) {
								pac.hideCalMask();
							}

						},
						failure: function(oRequest,oResponse,oPayload) {
							YAHOO.log(YAHOO.lang.dump(oResponse), "error", "fm-sr");
							smd[fetchedMonth] = null;
						},
						scope: pac
					}
				);
			}
		},
		fetchMonthSegmentsRemote: function(pagedate, makeActive, monthDataSource) {
			var pac = YAHOO.kqed.PgmArchiveCal, 
				smd = pac.severalMonthsData,
				fetchedMonth = pagedate.format(YYYYMM);
			if (! smd[fetchedMonth]) {
				if (pac.currentPageMonth == fetchedMonth) {
					pac.showCalMask();
				}
				smd[fetchedMonth] = true;  // indicate that it's loading, so it doesn't try to load multiple times

				monthDataSource.sendRequest(  
					"baselist=segment&pgmid=" + pac.pgmid + "&year=" + pagedate.getFullYear() + "&month=" + (pagedate.getMonth() + 1), 
					{
						success: function(oRequest,oResponse,oPayload) {
							YAHOO.log(YAHOO.lang.dump(oRequest), "fetch", "fm-sr");
							smd[fetchedMonth] = {};
							for (var segIndex = 0, segArray = oResponse.results; segIndex < segArray.length; segIndex++) {
								var seg = segArray[segIndex];
								var segDay = seg.airtime.format(MDY);
								YAHOO.log(YAHOO.lang.dump(seg), "seg", "fm-sr");
								if (smd[fetchedMonth][segDay]) {
									// day already exists, add to it
									smd[fetchedMonth][segDay].push(seg);
								} else {
									// make a new day
									smd[fetchedMonth][segDay] = [seg];
								}
							}
							
							if (makeActive || pac.currentPageMonth == fetchedMonth) {
								pac.monthData = smd[fetchedMonth];
								pac.decorate();
								
								// pre-fetch previous month's data when done, to make loading seem faster on month change
								pac.fetchMonth(YdtMath.subtract(pagedate, YdtMath.MONTH, 1), false);
							}

							pac.decorate();
							if (pac.currentPageMonth == fetchedMonth) {
								pac.hideCalMask();
							}

						},
						failure: function(oRequest,oResponse,oPayload) {
							YAHOO.log(YAHOO.lang.dump(oResponse), "error", "fm-sr");
							if (smd[fetchedMonth] == true) {
								smd[fetchedMonth] = null;  // since load failed, allow future attempts
							}

						},
						scope: pac
					}
				);
			}
		},
		fetchMonth: function(pagedate, makeActive) {
			YAHOO.log("changing month to " + pagedate.toString(), "info", "fetchMonth");
			var pac = YAHOO.kqed.PgmArchiveCal, 
				smd = pac.severalMonthsData,
				fetchedMonth = pagedate.format(YYYYMM);
			var monthDataSource = new Yds("/webapi/v1/audioArchives?upcoming=2&");
			monthDataSource.responseType = Yds.TYPE_XML;


			if (smd[fetchedMonth]) {
				// this month is already gotten, so use locally cached version
				YAHOO.log("this month is already gotten, so don't fetch it again", "info", "fetchMonth");
				if (makeActive) {
					pac.monthData = smd[fetchedMonth];
					pac.decorate();
				// pre-fetch previous month's data when done, to make loading seem faster on month change
					pac.fetchMonth(YdtMath.subtract(pagedate, YdtMath.MONTH, 1), false);
				}
			} else {
				// we don't already have this month in memory, so fetch the results remotely
				
				// TODO note what's loading to prevent overlaps
				if (pac.detail_level === pac.SEGMENT) {
					// get the month's segments
					monthDataSource.responseSchema = {
						resultNode: "segment",
						fields: [segTitle, "segid", 
							epTitle, "epid", 
							pgmTitle, "pgmid",
							{key: "airtime", parser: Yds.parseDate}
						]
					};
					pac.fetchMonthSegmentsRemote(pagedate, makeActive, monthDataSource);
				} else {
					// get the month's episodes
					monthDataSource.responseSchema = {
						resultNode: "episode",
						fields: ["title", "epid", {key: "airtime", parser: Yds.parseDate}]
					};
					pac.fetchMonthEpisodesRemote(pagedate, makeActive, monthDataSource);
				}
			}
			YAHOO.log("fetchedmonth:" + YAHOO.lang.dump(pac.monthData), "info", "fetchMonth");
		},
		pageDateChangeHandler: function(p_sType, p_aArgs) {
			//scope: Y.k.pac.cal
			var pac = YAHOO.kqed.PgmArchiveCal; 
			var smd = pac.severalMonthsData;
			var newPageDate = p_aArgs[0];
			YAHOO.log("this: " + this, "info", "Y.k.pac.pageDateChangeHandler");
			YAHOO.log("this.cfg: " + this.cfg, "info", "Y.k.pac.pageDateChangeHandler");
			YAHOO.log("p_sType: " + p_sType, "info", "Y.k.pac.pageDateChangeHandler");
			YAHOO.log("p_aArgs[0]: " + p_aArgs[0], "info", "Y.k.pac.pageDateChangeHandler");
			pac.currentPageMonth = newPageDate.format(YYYYMM);

			if (! pac.monthIsLoaded(pac.currentPageMonth)) {
				pac.showCalMask();
			} else {
				pac.hideCalMask();
			}

			pac.fetchMonth(newPageDate, true);
			pac.decorate();

			YAHOO.log("fetchMonth completed", "info", "Y.k.pac.pageDateChangeHandler");
		},
		renderHandler: function(e, args, obj) {
			YAHOO.kqed.PgmArchiveCal.addListeners();
		},
		origSelectHandler: function(type, args, obj) {
			var pac = YAHOO.kqed.PgmArchiveCal;
			var selected = args[0];
			var selDate = pac.cal.toDate(selected[0]);
			var eps = pac.getDayInfo(selDate);
			YAHOO.log("epCount: " + eps.length, "info", "Y.k.pac.origSelectHandler");
			if (eps.length == 1) {
				window.location = pac.getEpUrl(eps[0].epid)
			} else {
				Ydom.setInnerHTML(detailDivId, pac.getDetailsHtml(selDate));
				Ydom.setInnerHTML(detailDatelineId, selDate.format(WMDY_SHORT));
			}
		},
		selectHandler: function(type, args, obj) {
			var pac = YAHOO.kqed.PgmArchiveCal;
			var selected = args[0];
			var selDate = pac.cal.toDate(selected[0]);
			var ovl = pac.getOverlay();
			ovl.setBody(pac.getDetailsHtml(selDate));
			ovl.setHeader(pac.getPanelHeaderHtml(selDate));
			ovl.render("audio-archive-detail-skin");
			ovl.show();
		},
		showOverlayHandler: function() {
			var hps = YAHOO.kqed.PgmArchiveCal.hide_when_panel_shows;
			if (hps) {
				for (var i = 0; i < hps.length; i++) {
					YAHOO.util.Dom.setStyle(hps[i],"visibility", "hidden");
				}
			}
		},
		hideOverlayHandler: function() {
			var hps = YAHOO.kqed.PgmArchiveCal.hide_when_panel_shows;
			if (hps) {
				for (var i = 0; i < hps.length; i++) {
					YAHOO.util.Dom.setStyle(hps[i],"visibility", "visible");
				}
			}
		},
		dateChangeMultiEpsHandler: function(selDate) {
			var pac = YAHOO.kqed.PgmArchiveCal;
			Ydom.setInnerHTML(detailDivId, pac.getDetailsHtml(selDate));
			Ydom.setInnerHTML(detailDatelineId, selDate.format(WMDY_SHORT));
		},
		mouseOverHandler: function(e) {
			var id = "";
			id = (e.target) ? e.target.id : e.srcElement.id;
			var ab = YAHOO.kqed.PgmArchiveCal.cal.getDateFieldsByCellId(id);
		},
		init: function() { 
			YAHOO.log("start init", "debug", "Y.k.pac.init");
			var pac = YAHOO.kqed.PgmArchiveCal;
			if (!pac.showDate) {
				pac.showDate = new Date;
			}
			if (!pac.site_id) {
				pac.site_id = pac.KQED_ORG;
			} else if (pac.site_id == pac.CALREPORT || pac.site_id == pac.TWINC) {
				pac.detail_level = pac.SEGMENT;
			}
			if (!pac.detail_level) {
				pac.detail_level = pac.EPISODE;
			}
			
			var cal = pac.getCal();
			cal.select(pac.showDate);

			cal.renderEvent.subscribe(pac.renderHandler, cal, true);
			cal.selectEvent.subscribe(pac.selectHandler, cal, true);
			cal.cfg.subscribeToConfigEvent("pagedate", pac.pageDateChangeHandler, cal, true);

			pac.currentPageMonth = pac.showDate.format(YYYYMM);
			pac.fetchMonth(pac.showDate, true);
			
			var ovl = pac.getOverlay();
			ovl.hide();
			ovl.showEvent.subscribe(pac.showOverlayHandler, ovl, true);
			ovl.hideEvent.subscribe(pac.hideOverlayHandler, ovl, true);

			pac.decorate();

			var cmsk = pac.getCalMask();
			pac.hideCalMask();
			
			YAHOO.log("finish init", "debug", "Y.k.pac.init");
		},
		decorate: function() {
			YAHOO.log("start decorate", "debug", "Y.k.pac.decorate");
			var pac = YAHOO.kqed.PgmArchiveCal, 
				cal = pac.getCal();
			for (var activeDate in pac.monthData) {
				cal.addRenderer(activeDate, cal.renderCellStyleHighlight1);
			};
			cal.render(); 
			if ( pac.severalMonthsData[pac.currentPageMonth] instanceof Object) {
				pac.hideCalMask();
			}
			YAHOO.log("finish decorate", "debug", "Y.k.pac.decorate");
		},
		getCal: function() {
			var pac = YAHOO.kqed.PgmArchiveCal;
			if (! pac.cal) {
				pac.cal = new YAHOO.widget.Calendar(containerId,{navigator:true});
				// TODO implement pac.showMonth here
			}
			return pac.cal;
		},
		getOverlay: function() {
			var pac = YAHOO.kqed.PgmArchiveCal;
			if (! pac.overlay) {
				pac.overlay = new YAHOO.widget.Panel(
					"audio-archive-detail-container", 
					{ 
						context: ["audio-archive-calendar", "tl", "tr"], 
						visible: false, 
						close: true,
						width: detailDivWidth 
					}
				);
			}
			return pac.overlay;
		},
		getCalMask: function() {
			var pac = YAHOO.kqed.PgmArchiveCal,
				cal = pac.getCal(),
				Ydom = YAHOO.util.Dom;
			if (! pac.calMask) {
				// first get reference element to attach mask to -- MAKE SURE NOT TO DEFINE THIS UNTIL cal IS RENDERED AT LEAST ONCE!
				
				var refElementArray = Ydom.getElementsByClassName( cal.Style.CSS_BODY, "tbody", cal.id ),
					refEl = refElementArray[0];  // should only ever be one, so we only care about the first one
				var refRegion = Ydom.getRegion(refEl);
				
				pac.calMask = new YAHOO.util.Element("audio-archive-calendar-month-loading-mask");
				
				// set up styles
				if (refRegion) {
					Ydom.setStyle( pac.calMask, "height", refRegion.height );
					Ydom.setStyle( pac.calMask, "width", refRegion.width );
					Ydom.setX( pac.calMask, refRegion.top );
					Ydom.setY( pac.calMask, refRegion.left );
				}
			}
			return pac.calMask;
		},
		showCalMask: function() {
			var pac = YAHOO.kqed.PgmArchiveCal, 
				msk = pac.getCalMask();
			if (! pac.calMaskVisible) {
				YAHOO.util.Dom.setStyle( msk, "display", "block" );
				pac.calMaskVisible = true;
			}
		},
		hideCalMask: function() {
			var pac = YAHOO.kqed.PgmArchiveCal, 
				msk = pac.getCalMask();
			if (pac.calMaskVisible) {
				YAHOO.util.Dom.setStyle( msk, "display", "none" );
				pac.calMaskVisible = false;
			}
		},
		getDayInfo: function(inDate) {
			var pac = YAHOO.kqed.PgmArchiveCal;
			return pac.monthData[inDate.format(MDY)] || [];
		},
		addListeners: function() {
			YAHOO.log("start addListeners", "debug", "Y.k.pac.addListeners");
			// adapted from http://blog.davglass.com/files/yui/cal5/
			var pac = YAHOO.kqed.PgmArchiveCal;
			var cal1 = pac.getCal();
			var tds = Ydom.getElementsByClassName('calcell', 'td', cal1.table);
			var tipTds = [];
			if (pac.tooltip) {
				pac.tooltip.destroy();
			};
			for (var i = 0; i < tds.length; i++) {
				//Parse the current date to (m/d/yyyy)
				// var tmpDate1 = cal1.cellDates[i][1] + '/' + cal1.cellDates[i][2] + '/' + cal1.cellDates[i][0];
				// var tmpDate2 = pac.formatMDY(cal1.cellDates[i]);
				// YAHOO.log("tmpdate2: " + pac.formatMDY(cal1.cellDates[i]), "info", "addListeners");
				var tmpDate = cal1.cellDates[i][1] + '/' + cal1.cellDates[i][2] + '/' + cal1.cellDates[i][0];
				if (pac.monthData[tmpDate]) {
					tds[i].title = pac.getTooltipText(tmpDate);
					tipTds[tipTds.length] = tds[i].id;
				};
			};
			YAHOO.log(tipTds.length + " tooltips initialized", "info", "addListeners");
			pac.tooltip = new YAHOO.widget.Tooltip('cal_tooltip', { 
				context: tipTds, 
				showDelay:50 } 
			);
			/* pac.tooltip.contextTriggerEvent.subscribe(
				function(type,args) {
					var context = args[0];
					this.cfg.setProperty("text",pac.)
				}
			); */
			YAHOO.log("finish addListeners", "debug", "Y.k.pac.addListeners");
		}
		
	};
}();


