/*
	The widgets are specifically designed for Ingeniux CMS calendar module
*/

dojo.require("dojo.widget.*");
dojo.require("dojo.io.*");
dojo.require("dojo.widget.HtmlWidget");
dojo.require("dojo.string");
dojo.require("dojo.string.extras");
dojo.require("dojo.html.style");
dojo.require("dojo.event");
dojo.require("dojo.lfx.html");
dojo.require("dojo.widget.ContentPane");
dojo.require("dojo.widget.TitlePane");

///////////////////////////////////////////////////////////////////////////////
//	The special calendar title pane:
//	It allows the title nodes to be anything 
///////////////////////////////////////////////////////////////////////////////
dojo.provide("igx.widget.TitlePaneCustomLabel");

dojo.widget.defineWidget("igx.widget.TitlePaneCustomLabel",
	dojo.widget.TitlePane,
	{
		//the id of it's label node
		labelNodeId: "",
		labelStatusNodeId: "",
		
		labelNodeClass: "",
		containerNodeClass: "",		
		labelStatusNodeClass: "",
		
		postCreate: function() {
		
				if (this.labelNodeId) {		
					this.setLabel();
				}
				
				if (this.labelNodeClass) {
					dojo.html.addClass(this.labelNode, this.labelNodeClass);
				}
				if (this.containerNodeClass) {
					dojo.html.addClass(this.containerNode, this.containerNodeClass);
				}
				if (!this.open) {
					dojo.html.hide(this.containerNode);
				}
			},	
				
		onLabelClick: function() {
				if (this.open) {
					dojo.lfx.wipeOut(this.containerNode,250).play();
					this.open=false;
				}else {
					dojo.lfx.wipeIn(this.containerNode,250).play();
					this.open=true;
				}
				
				this.setStatusNode();
			},
			
		setStatusNode: function(){
		
				//reset text
				this.labelNode.innerHTML = this.labelNodeHTML;
				
				if (this.labelStatusNodeId != "")
				{				

					if (this.open) {
						var statusNodeClone = this.statusOpenNode.cloneNode(true);			
					}
					else {
						var statusNodeClone = this.statusCloseNode.cloneNode(true);
					}
					
					if (this.labelStatusNodeClass != "")
						statusNodeClone.className = this.labelStatusNodeClass;
					
					this.labelNode.appendChild(statusNodeClone);
				}
			},	
			
		setLabel: function() {
				//clone the label node and append in the labelNode
				var labelTemplate = document.getElementById(this.labelNodeId);
				
				labelTemplate = labelTemplate.cloneNode(true);
				
				labelTemplate.style.display = "inline";
				
				this.labelNode.appendChild(labelTemplate);
				this.labelNode.style.cursor = "pointer";
				
				if (this.labelNodeClass != "")
					this.labelNode.className = this.labelNodeClass;
					
				if (this.containerNodeClass != "")
					this.containerNode.className = this.containerNodeClass;
				
				this.labelNodeHTML = this.labelNode.innerHTML;
				
				//open close symbol
				if (this.labelStatusNodeId != "")
				{
					var statusNode = document.getElementById(this.labelStatusNodeId);
					
					if (statusNode != null)
					{
						this.statusOpenNode = statusNode.firstChild;
						this.statusCloseNode = statusNode.lastChild;
					}
					
					this.setStatusNode();			
					
				}
			}
							
	});
	
///////////////////////////////////////////////////////////////////////////////
//	The special calendar content pane:
//	it provide simple a way to change highlighting without
//	doing AJAX refresh, thus lessen network traffic
///////////////////////////////////////////////////////////////////////////////
dojo.provide("igx.widget.CalendarContentPane");

dojo.widget.defineWidget("igx.widget.CalendarContentPane", 
	dojo.widget.ContentPane,
	{	
		cacheContent: false,
		refreshOnShow: true,
		loadingMessage:"<img src='PreBuilt/CalendarScripts/ajax-loader.gif'>",	
		
		
		//exposed attributes
		defaultBgColor: "",
		selectedBgColor: "",
		todayBgColor: "",
		
		defaultTextColor: "",
		selectedTextColor: "",
		todayTextColor: "",	
		
		defaultCellIdPrefix: "",
		todayCellIdPrefix: "",
		
		
		//tracking category and month
		lastMonth: "",
		lastYear: "",
		lastCategory: "",
		
		
		//view look up
		views: {
				dayViewTab: "day",
				monthViewTab: "month",
				weekViewTab: "week"
			},
		
		
		//infoManaer object is passed in to retrieve information
		changeDate: function (infoManagerObj, view)
		{
			if ((infoManagerObj.month != this.lastMonth) 
				||(infoManagerObj.category != this.lastCategory)
				|| (infoManagerObj.year != this.lastYear))
			{
				//refresh
				var href = this.href;
				
				href = href.split("?")[0];
				
				var params = "?view=" + this.views[view] +
					"&year=" + infoManagerObj.padNum(infoManagerObj.year) + 
					"&month=" + infoManagerObj.padNum(infoManagerObj.month) + 
					"&date=" + infoManagerObj.padNum(infoManagerObj.date) + 
					"&category=" + infoManagerObj.category;
					
				href += params;
				
				this.setUrl(href);
				
				this.lastMonth = infoManagerObj.month;
				this.lastYear = infoManagerObj.year;
				this.lastCategory = infoManagerObj.category;
			}			
			else {
				//month didn't change, just worry about highlighting changes
				this.changeHighlight(infoManagerObj, view);
			}			
		},
		
		changeHighlight: function (infoManagerObj, view)
		{
			var date = infoManagerObj.date;
			
			//reset all highlights
			var cells = this.domNode.getElementsByTagName("td");
			
			var today = new Date()
			
			for (var i=0; i< cells.length; i++)
			{
				var cell = cells[i];
				var cellIdPrefix = cell.id.split("_")[0];
				
				if (cellIdPrefix == this.defaultCellIdPrefix)
				{
					//reset cell background color and text color
					cell.style.backgroundColor = this.defaultBgColor;
					cell.firstChild.style.color = this.defaultTextColor;
				}
				else if (cellIdPrefix == this.todayCellIdPrefix)
				{
					//today, change it to today's color theme
					cell.style.backgroundColor = this.todayBgColor;
					cell.firstChild.style.color = this.todayTextColor;					
				}
			}
			
			var selectedDays = new Array();
			
			//highlight specific
			if (view == "dayViewTab")
			{
				var selDate = new Date(infoManagerObj.year,
					infoManagerObj.month - 1,
					infoManagerObj.date,
					2, 0, 0)
				selectedDays = [selDate];
			}
			else if (view == "weekViewTab")
			{
				var selectedDays = infoManagerObj.getWeekDates().range;
				
				for (var i=selectedDays.length - 1; i>=0; i--)
				{
					if (selectedDays[i].getMonth() + 1 != this.lastMonth)
						selectedDays.splice(i, 1)
				}

			}
			else if (view == "monthViewTab")
			{		
				var selectedDays = infoManagerObj.getMonthDates().range;
			}	
			
			//cycle through date range and highlight them
			for (var i=0; i<selectedDays.length; i++)
			{
				var cellId = "";
			
				if ((today.getFullYear() == selectedDays[i].getFullYear())
					&& (today.getMonth() == selectedDays[i].getMonth())
					&& (today.getDate() == selectedDays[i].getDate()))				
					cellId = this.todayCellIdPrefix + "_" + today.getDate();
				else
					cellId = this.defaultCellIdPrefix + "_" + selectedDays[i].getDate();
					
				var cell = dojo.byId(cellId);
				
				cell.style.backgroundColor = this.selectedBgColor;
				cell.firstChild.style.color = this.selectedTextColor;						
			}		
		}
		
	});	


///////////////////////////////////////////////////////////////////////////////
//	The special calendar events content pane:
//	Upon refresh, it will produce fading effect 
///////////////////////////////////////////////////////////////////////////////

dojo.provide("igx.widget.CalendarEventsContentPane");

dojo.widget.defineWidget("igx.widget.CalendarEventsContentPane", 
	dojo.widget.ContentPane,
	{		
		cacheContent: false,
		refreshOnShow: true,
		loadingMessage:"<img src='PreBuilt/CalendarScripts/ajax-loader.gif'>",

		
		//transition duration (seconds)
		duration: 300,
	
		//extend the postCreate function to hook up fading effect after the content is loaded
		postCreate: function (args, frag, parentComp) {		
		
				//set opacity to transparent before setContent
				dojo.event.kwConnect({
						type:       "before", 
						srcObj:     this, 
						srcFunc:    "onDownloadEnd", 
						targetObj:  this,
						targetFunc: "hideContainer"
					});
				
				//fadein the container
				
				dojo.event.kwConnect({
						type:       "after", 
						srcObj:     this, 
						srcFunc:    "setContent", 
						targetObj:  this,
						targetFunc: "fadingTransition",
						once: true, // make sure we only ever hear about it once					
						delay: 0.5
					});					

		
				if (this.handler != "") {
					this.setHandler(this.handler);
				}
				if (this.isShowing() || this.preload) {
					this.loadContents();
				}
						
			//igx.widget.CalendarEventsContentPane.superclass.postCreate.call(args, frag, parentComp);
			},
			
		//set opacity to transparent before content is set
		hideContainer: function (e) {
				dojo.html.setOpacity(this.domNode, 0);
			},			
			
		//the fading transition
		fadingTransition: function (e) {
				dojo.lfx.html.fadeIn(this.domNode, this.duration, null, null).play();
			}
			

	}
);

///////////////////////////////////////////////////////////////////////////////
//	The calendar date manipulation class,
//	contains all date functions being used be tab manager
///////////////////////////////////////////////////////////////////////////////
dojo.declare("igx.Calendar.InfoManager",
	null,
	{
		year: "",
		month:"",
		date: "",
		category: "",
		
		//track if the date cause month to change or not
		monthChanged: false,		
	
		//initializer: constructor of the class. 
		//in this case: set the date
		initializer: function (year, month, date, category)
		{
		
			if (year != "")
			{
				this.year = parseInt(year, 10);
				this.month = parseInt(month, 10);
				this.date = parseInt(date, 10);
			}
			else
			{
				var now = new Date();
				if (this.year != "")		
					this.year = parseInt(this.year, 10);
				else
					this.year = now.getFullYear();
					
				if (this.month != "")
					this.month = parseInt(this.month, 10);
				else
					this.month = now.getMonth();
					
				this.month += 1;
				
				this.monthChanged = true;
					
				if (this.date != "")
					this.date = parseInt(this.date, 10);	
				else
					this.date = now.getDate();	
			}	
			
			if (category != null)
				this.category = category;	

		},	
		getWeekDates: function()
		{
			
			var now = new Date(this.year, this.month-1, this.date, 2, 0, 0);		 
			var weekDay = now.getDay();
			
			var sunday = new Date(now.getTime() + (0-weekDay)*24*60*60*1000);	
			var saturday = new Date(now.getTime() + (6-weekDay)*24*60*60*1000);	
			
			//array of date objects

			var days = {
					sunday:	sunday,
					saturday: saturday,
					range: this.getDateRange(sunday, saturday)
				};
				
			return days;
		},
		
		getMonthDates: function()
		{
			var firstDay = new Date(this.year, this.month-1, 1, 2, 0, 0);
			var lastDay = new Date((new Date(this.year, this.month, 1, 2, 0, 0)).getTime() - 24*60*60*1000 );
			
			var days = {
					firstDay: firstDay,
					lastDay: lastDay,
					range: this.getDateRange(firstDay, lastDay)				
				};
			return days;
		},
		
		getDateRange: function(sDate, eDate)
		{
			var range = new Array();
			
			var tDate = sDate;
			
			while (tDate < new Date(eDate.getTime() + 24*60*60*1000))
			{
				range.push(tDate);
				tDate = new Date(tDate.getTime() + 24*60*60*1000);
			}
			
			return range;
		},		
		
		LZ: function(x)
		{
			return(x<0||x>9?"":"0")+x;	
		},
		
		formatDate: function (date, format) 
		{
		
			var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
			var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
		
			format=format+"";
			var result="";
			var i_format=0;
			var c="";
			var token="";
			var y=date.getYear()+"";
			var M=date.getMonth()+1;
			var d=date.getDate();
			var E=date.getDay();
			var H=date.getHours();
			var m=date.getMinutes();
			var s=date.getSeconds();
			var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
			// Convert real date parts into formatted versions
			var value=new Object();
			if (y.length < 4) {y=""+(y-0+1900);}
			value["y"]=""+y;
			value["yyyy"]=y;
			value["yy"]=y.substring(2,4);
			value["M"]=M;
			value["MM"]=this.LZ(M);
			value["MMM"]=MONTH_NAMES[M-1];
			value["NNN"]=MONTH_NAMES[M+11];
			value["d"]=d;
			value["dd"]=this.LZ(d);
			value["E"]=DAY_NAMES[E+7];
			value["EE"]=DAY_NAMES[E];
			value["H"]=H;
			value["HH"]=this.LZ(H);
			if (H==0){value["h"]=12;}
			else if (H>12){value["h"]=H-12;}
			else {value["h"]=H;}
			value["hh"]=this.LZ(value["h"]);
			if (H>11){value["K"]=H-12;} else {value["K"]=H;}
			value["k"]=H+1;
			value["KK"]=this.LZ(value["K"]);
			value["kk"]=this.LZ(value["k"]);
			if (H > 11) { value["a"]="PM"; }
			else { value["a"]="AM"; }
			value["m"]=m;
			value["mm"]=this.LZ(m);
			value["s"]=s;
			value["ss"]=this.LZ(s);
			while (i_format < format.length) {
				c=format.charAt(i_format);
				token="";
				while ((format.charAt(i_format)==c) && (i_format < format.length)) {
					token += format.charAt(i_format++);
					}
				if (value[token] != null) { result=result + value[token]; }
				else { result=result + token; }
				}
			return result;
		},
		
		flipMonth: function (curDate, offSet)
		{

			var month = curDate.getMonth()
			var year =  curDate.getFullYear();
			var date = curDate.getDate();
			
			month += offSet;
			
			
			if (month > 11)
			{
				month = 0;
				year += 1;
			}
			else if (month < 0)
			{
				month =11;
				year -= 1;
			}
			
			var newDate = new Date(year, month, date);

			if (newDate.getMonth() != month)
			{
				//if the this specific day of the month doesn't exist,
				//javascript always go to the end of intended month
				newDate = new Date(year, month+1, 1, 2, 0, 0);			
				
				newDate = new Date(newDate.getTime() - 24*60*60*1000);
			}
			
			return newDate;
				
		},	
			
		flipDates: function (offsetInt, selectedView)
		{
			//add 2 hours to avoid daylight saving conflicts
			var date = new Date(this.year, this.month-1, this.date, 2, 0, 0);
			
			if (selectedView == "dayViewTab")
			{
				date = new Date(date.getTime() + offsetInt*24*60*60*1000);
				
				this.initializer( date.getFullYear(), date.getMonth()+1, date.getDate());
			}
			else if (selectedView == "weekViewTab")
			{
				var thisWeekSunday = this.getWeekDates().sunday;
				var thisWeekSaturday = this.getWeekDates().saturday;
			
				var nextWeekSunday = new Date(thisWeekSunday.getTime() + 7*offsetInt*24*60*60*1000);
				var nextWeekSaturday = new Date(thisWeekSaturday.getTime() + 7*offsetInt*24*60*60*1000);
				
				if (thisWeekSunday.getMonth() == nextWeekSunday.getMonth()) {
					if ((thisWeekSaturday.getMonth() != nextWeekSaturday.getMonth()) 
						&&(this.month != nextWeekSunday.getMonth() + 1))
						date = thisWeekSunday;

					else
						date = nextWeekSunday;
				}
				else {
					if ((thisWeekSaturday.getMonth() != nextWeekSaturday.getMonth())
						|| (this.month != thisWeekSunday.getMonth() + 1))
						date = nextWeekSunday;
					else {
						if (offsetInt > 0)
							date = new Date(nextWeekSunday.getFullYear(), nextWeekSunday.getMonth(), 1, 2, 0, 0);
						else
							date = new Date(nextWeekSunday.getFullYear(), thisWeekSunday.getMonth(), 1, 2, 0, 0);
					}
				}
				
				this.initializer( date.getFullYear(), date.getMonth()+1, date.getDate());

			}
			else if (selectedView == "monthViewTab")
			{		
				date = this.flipMonth(date, offsetInt);
				
				this.initializer( date.getFullYear(), date.getMonth()+1, date.getDate());			
			}		
		},
		padNum: function(num, digits)
		{
			num = num + "";
			
			while(num.length < digits)
			{
				num = "0" + num;
			}
			
			return num;
		}			
	});

	
///////////////////////////////////////////////////////////////////////////////
//	The tab container for igx calendar:
//	It contains only 1 content pane and use the tab
//	simple as way to set url and refresh the content pane
//	it will use the "CalendarContentPane" widget to render content
/*
	The tabs and the content can be completely seperated to different
	locations.
	
	The tabsNodes should have children nodes serve as the tabs to click on. They don't have
	to look like tabs. But they do need to have "href" references, otherwise, it will not be 
	recognized as a clickable tab
*/
///////////////////////////////////////////////////////////////////////////////

dojo.provide("igx.widget.CalendarTabManager");

dojo.widget.defineWidget("igx.widget.CalendarTabManager", 
	dojo.widget.HtmlWidget, 
	function () {
		this.eventsPane = null;
		this.calendarPane = null;
		this.tabNodes = [];
		this.selectedTabNode = null;
	},
	
	{
		//exposed attributes
		tabsNodeId: "",
		navigatorBarId: "",
		calendarPaneWidgetId: "",
		eventsPaneWidgetId: "",
		fadingDuration: 300,
		defaultTabId: "",
		
		//capture year, month, date, category from querystrings
		year: "",
		month: "",
		date: "",
		category: "",
		
		view: "",
		
		//internal properties
		infoManager: null,
		
		create: function(args)
		{
		    //check to see if exists already, if not, then create it.
		    //This is work around the strange IE issue of widget double creation causing double event connection.
		    
		    var existingWidget = dojo.widget.byId(args.id);
		    
		    if (existingWidget == null)
		    {
		        return igx.widget.CalendarTabManager.superclass.create.apply(this, arguments);
		    }
		    else
		        return null;
		},
		
		//functions
		postCreate: function (args, frag, parentComp) {
		
		        
				//initialize the info manager
				this.infoManager = new igx.Calendar.InfoManager(this.year,
					this.month, this.date, this.category);
		
				this.domNode.style.display = "none";
		
				var tabNodesContainer = dojo.byId(this.tabsNodeId);	
				
				for (var i=0; i<tabNodesContainer.childNodes.length; i++)
				{
					var isCalTab = dojo.html.getAttribute(tabNodesContainer.childNodes[i], "isCalendarTab");
					var href = dojo.html.getAttribute(tabNodesContainer.childNodes[i], "href");
					
					if ((isCalTab == "true")					
						&& (href != ""))
					{
						tabNodesContainer.childNodes[i].style.cursor = "pointer";
						this.tabNodes.push(tabNodesContainer.childNodes[i]);
					}
				}	
				
							
				this.eventsPane = dojo.widget.byId(this.eventsPaneWidgetId);	
								
				this.eventsPane.duration = this.fadingDuration;				
				
				//initialize calendar node
				this.calendarPane = dojo.widget.byId(this.calendarPaneWidgetId);
				
				
				if (this.calendarPane == null)
				{
					var calendarNode = dojo.byId(this.calendarPaneWidgetId);
				
					this.calendarPane = dojo.widget.createWidget("igx:CalendarContentPane",
							{
								cacheContent: false,
								href: calendarNode.getAttribute("href"),
								
								defaultBgColor: calendarNode.getAttribute("defaultBgColor"),
								selectedBgColor: calendarNode.getAttribute("selectedBgColor"),
								todayBgColor: calendarNode.getAttribute("todayBgColor"),
								
								defaultTextColor: calendarNode.getAttribute("defaultTextColor"),
								selectedTextColor: calendarNode.getAttribute("selectedTextColor"),
								todayTextColor: calendarNode.getAttribute("todayTextColor"),
								
								defaultCellIdPrefix : calendarNode.getAttribute("defaultCellIdPrefix"),
								todayCellIdPrefix : calendarNode.getAttribute("todayCellIdPrefix")						
							},							
							calendarNode						
						);
				}
				
				if (this.view != "")
					this.selectedTabNode = dojo.byId(this.view + "ViewTab");
				else if (this.defaultTabId != "")
					this.selectedTabNode = dojo.byId(this.defaultTabId);
				else
					this.selectedTabNode = this.tabNodes[0];
					
				//assign tab clicking events
				for (var i=0; i<this.tabNodes.length; i++)
				{
					var tab = this.tabNodes[i];
					dojo.event.connect(this.tabNodes[i],
						"onclick",
						this,
						"selectTab");			
				}
				
				//load default tab
				this.selectTab();
				
				//assign the flipping events
				var leftFlip = document.getElementById("leftFlip");
				var rightFlip = document.getElementById("rightFlip");
				
				var self = this;
				dojo.event.connect(leftFlip, "onclick", function(){	self.dateFlip(-1); });
				dojo.event.connect(rightFlip, "onclick", function(){ self.dateFlip(1); });				
			},
			
		destroy: function()
		{
			for (var i=0; i<this.tabNodes.length; i++)
			{
				var tab = this.tabNodes[i];
				dojo.event.disconnect(this.tabNodes[i],
					"onclick",
					this,
					"selectTab");					
			}
			igx.widget.CalendarTabManager.superclass.destroy.apply(this, arguments);			
		},
			
		dateChange: function (year, month, date, calClick){
				this.infoManager.initializer(year, month, date);
				
				//reconstruct the events view widget				
				this.selectTab(null, calClick);				
				//reconstruct the calendar view widget

			},
	    
		dateFlip: function (offset, selectedTabView)	{
			
				if (!selectedTabView)
					selectedTabView = this.selectedTabNode.id;
				
				this.infoManager.flipDates(offset, selectedTabView);
				this.selectTab(null);
			},
	    
		categoryChange: function (category)	{
				this.infoManager.category = category;
				this.selectTab(null);
			},  		
		
		//accept either node or null	
		selectTab: function (e, calClick)
		{
			var clickNode = null;
			
			if (e)
			{
				if (e.target) 
					clickNode = e.target;
				else if (e.srcElement) 
					clickNode = e.srcElement;
					
				while (clickNode.nodeName != "body")
				{
					clickNode = clickNode.parentNode;
					if (clickNode.getAttribute("isCalendarTab") == "true")
					{
						this.selectedTabNode = clickNode;
						break;
					} 
				}					
			}	
			
			
			
			//if month view and date click, go to dayView
			if (calClick == true)
				this.selectedTabNode = dojo.byId("dayViewTab");
			
			//turn all tabs view to inactive
			for (var i=0; i<this.tabNodes.length; i++)
			{
				this.tabNodes[i].childNodes[0].style.display = "inline";
				this.tabNodes[i].childNodes[1].style.display = "none";
			}			
			
			//set the active tab to visiable
			this.selectedTabNode.childNodes[0].style.display = "none";
			this.selectedTabNode.childNodes[1].style.display = "inline";
			
			this.setupDateDisp(); 
			
			//load tab content
			this.loadTabContent();
			
			//manipulate calendar
			
			this.changeCalendarDate();
			
			if (e)
			    dojo.event.browser.stopEvent(e);
		},
		
		timeOut: null,
		
		changeCalendarDate: function()
		{
			if (this.calendarPane) {
				clearTimeout(this.timeOut);
				this.calendarPane.changeDate(this.infoManager, this.selectedTabNode.id);
			}
			else
			{
				this.timeOut = setTimeout(dojo.lang.hitch(this, "changeCalendarDate"), 100);
			}
		},
		
		//change display of the event banner
		setupDateDisp: function() 	{				
				
				var dateDisp = document.getElementById("datesDisp");
				
				var dateText = "";
				
				if (dateDisp != null)
				{
					var formatText = dateDisp.getAttribute("dateFormat");
					
					var selectedTabType = this.selectedTabNode.id;
				
					if (selectedTabType == "dayViewTab") {
						dateText = this.infoManager.formatDate(
							new Date(this.infoManager.year, 
								this.infoManager.month-1, 
								this.infoManager.date, 2, 0, 0), 
						formatText);
					}	
					else if (selectedTabType == "weekViewTab")
					{
						var days = this.infoManager.getWeekDates();
						dateText = this.infoManager.formatDate(days.sunday, formatText) + " to " + this.infoManager.formatDate(days.saturday, formatText);
					}
					else if (selectedTabType == "monthViewTab")
					{
						var days = this.infoManager.getMonthDates();
						dateText = this.infoManager.formatDate(days.firstDay, formatText) + " to " + this.infoManager.formatDate(days.lastDay, formatText);
					}
						
					dateDisp.innerHTML = dateText;
				}	
			},		
			
		//accept either node or null
		loadTabContent: function ()
		{		
			//depending on the tab selected, change the href of the tab
			//append the year, month, date to the href of the tab
			var params = "&year=" + this.infoManager.padNum(this.infoManager.year, 4) +
				"&month=" + this.infoManager.padNum(this.infoManager.month, 2) +
				"&date=" + this.infoManager.padNum(this.infoManager.date, 2) +
				"&category=" + this.infoManager.category;				
					
			//get href attribute
			var href = this.selectedTabNode.getAttribute("href");
			
			href += params;
			
			//refresh the content pane
			this.eventsPane.setUrl(href);
			
			//
		}
	}
);

	
