[Jifty-commit] r2311 - in jifty/trunk: share/web/static/js/yui

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sun Dec 3 21:49:47 EST 2006


Author: trs
Date: Sun Dec  3 21:49:46 2006
New Revision: 2311

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/share/web/static/js/yui/calendar.js
   jifty/trunk/share/web/static/js/yui/dom.js
   jifty/trunk/share/web/static/js/yui/event.js
   jifty/trunk/share/web/static/js/yui/yahoo.js

Log:
 r17856 at zot:  tom | 2006-12-03 14:44:34 -0500
 Update YUI to 0.12 -- local changes have NOT been ported back yet


Modified: jifty/trunk/share/web/static/js/yui/calendar.js
==============================================================================
--- jifty/trunk/share/web/static/js/yui/calendar.js	(original)
+++ jifty/trunk/share/web/static/js/yui/calendar.js	Sun Dec  3 21:49:46 2006
@@ -2,83 +2,555 @@
 Copyright (c) 2006, Yahoo! Inc. All rights reserved.
 Code licensed under the BSD License:
 http://developer.yahoo.net/yui/license.txt
-version: 0.10.0
+version 0.12.0
+*/
+
+/**
+* Config is a utility used within an Object to allow the implementer to maintain a list of local configuration properties and listen for changes to those properties dynamically using CustomEvent. The initial values are also maintained so that the configuration can be reset at any given point to its initial state.
+* @class YAHOO.util.Config
+* @constructor
+* @param {Object}	owner	The owner Object to which this Config Object belongs
+*/
+YAHOO.util.Config = function(owner) {
+	if (owner) {
+		this.init(owner);
+	}
+};
+
+YAHOO.util.Config.prototype = {
 
-WARNING THIS IS NOT A STOCK RELEASE.  IT HAS BEEN MODIFED FROM ITS ORIGINAL FORM:
+	/**
+	* Object reference to the owner of this Config Object
+	* @property owner
+	* @type Object
+	*/
+	owner : null,
 
-    
-            renderCellNotThisMonth:
-            THIS FUNCTION MODIFIED BY JESSE VINCENT on 2006-11-29 TO MAKE OUT OF MONTH DATES CLICKABLE
-            ALL RIGHTS DISCLAIMED.
+	/**
+	* Boolean flag that specifies whether a queue is currently being executed
+	* @property queueInProgress
+	* @type Boolean
+	*/
+	queueInProgress : false,
+
+
+	/**
+	* Validates that the value passed in is a Boolean.
+	* @method checkBoolean
+	* @param	{Object}	val	The value to validate
+	* @return	{Boolean}	true, if the value is valid
+	*/
+	checkBoolean: function(val) {
+		if (typeof val == 'boolean') {
+			return true;
+		} else {
+			return false;
+		}
+	},
+
+	/**
+	* Validates that the value passed in is a number.
+	* @method checkNumber
+	* @param	{Object}	val	The value to validate
+	* @return	{Boolean}	true, if the value is valid
+	*/
+	checkNumber: function(val) {
+		if (isNaN(val)) {
+			return false;
+		} else {
+			return true;
+		}
+	}
+};
 
 
-*/
 /**
-* @class
-* <p>YAHOO.widget.DateMath is used for simple date manipulation. The class is a static utility
-* used for adding, subtracting, and comparing dates.</p>
+* Initializes the configuration Object and all of its local members.
+* @method init
+* @param {Object}	owner	The owner Object to which this Config Object belongs
 */
-YAHOO.widget.DateMath = new function() {
+YAHOO.util.Config.prototype.init = function(owner) {
+
+	this.owner = owner;
+
+	/**
+	* Object reference to the owner of this Config Object
+	* @event configChangedEvent
+	*/
+	this.configChangedEvent = new YAHOO.util.CustomEvent("configChanged");
+
+	this.queueInProgress = false;
+
+	/* Private Members */
+
+	/**
+	* Maintains the local collection of configuration property objects and their specified values
+	* @property config
+	* @private
+	* @type Object
+	*/
+	var config = {};
+
+	/**
+	* Maintains the local collection of configuration property objects as they were initially applied.
+	* This object is used when resetting a property.
+	* @property initialConfig
+	* @private
+	* @type Object
+	*/
+	var initialConfig = {};
+
+	/**
+	* Maintains the local, normalized CustomEvent queue
+	* @property eventQueue
+	* @private
+	* @type Object
+	*/
+	var eventQueue = [];
+
+	/**
+	* Fires a configuration property event using the specified value.
+	* @method fireEvent
+	* @private
+	* @param {String}	key			The configuration property's name
+	* @param {value}	Object		The value of the correct type for the property
+	*/
+	var fireEvent = function( key, value ) {
+		key = key.toLowerCase();
+
+		var property = config[key];
+
+		if (typeof property != 'undefined' && property.event) {
+			property.event.fire(value);
+		}
+	};
+	/* End Private Members */
+
+	/**
+	* Adds a property to the Config Object's private config hash.
+	* @method addProperty
+	* @param {String}	key	The configuration property's name
+	* @param {Object}	propertyObject	The Object containing all of this property's arguments
+	*/
+	this.addProperty = function( key, propertyObject ) {
+		key = key.toLowerCase();
+
+		config[key] = propertyObject;
+
+		propertyObject.event = new YAHOO.util.CustomEvent(key);
+		propertyObject.key = key;
+
+		if (propertyObject.handler) {
+			propertyObject.event.subscribe(propertyObject.handler, this.owner, true);
+		}
+
+		this.setProperty(key, propertyObject.value, true);
+
+		if (! propertyObject.suppressEvent) {
+			this.queueProperty(key, propertyObject.value);
+		}
+	};
+
+	/**
+	* Returns a key-value configuration map of the values currently set in the Config Object.
+	* @method getConfig
+	* @return {Object} The current config, represented in a key-value map
+	*/
+	this.getConfig = function() {
+		var cfg = {};
+
+		for (var prop in config) {
+			var property = config[prop];
+			if (typeof property != 'undefined' && property.event) {
+				cfg[prop] = property.value;
+			}
+		}
+
+		return cfg;
+	};
+
+	/**
+	* Returns the value of specified property.
+	* @method getProperty
+	* @param {String} key	The name of the property
+	* @return {Object}		The value of the specified property
+	*/
+	this.getProperty = function(key) {
+		key = key.toLowerCase();
+
+		var property = config[key];
+		if (typeof property != 'undefined' && property.event) {
+			return property.value;
+		} else {
+			return undefined;
+		}
+	};
+
+	/**
+	* Resets the specified property's value to its initial value.
+	* @method resetProperty
+	* @param {String} key	The name of the property
+	* @return {Boolean} True is the property was reset, false if not
+	*/
+	this.resetProperty = function(key) {
+		key = key.toLowerCase();
+
+		var property = config[key];
+		if (typeof property != 'undefined' && property.event) {
+			if (initialConfig[key] && initialConfig[key] != 'undefined')	{
+				this.setProperty(key, initialConfig[key]);
+			}
+			return true;
+		} else {
+			return false;
+		}
+	};
+
+	/**
+	* Sets the value of a property. If the silent property is passed as true, the property's event will not be fired.
+	* @method setProperty
+	* @param {String} key		The name of the property
+	* @param {String} value		The value to set the property to
+	* @param {Boolean} silent	Whether the value should be set silently, without firing the property event.
+	* @return {Boolean}			True, if the set was successful, false if it failed.
+	*/
+	this.setProperty = function(key, value, silent) {
+		key = key.toLowerCase();
+
+		if (this.queueInProgress && ! silent) {
+			this.queueProperty(key,value); // Currently running through a queue...
+			return true;
+		} else {
+			var property = config[key];
+			if (typeof property != 'undefined' && property.event) {
+				if (property.validator && ! property.validator(value)) { // validator
+					return false;
+				} else {
+					property.value = value;
+					if (! silent) {
+						fireEvent(key, value);
+						this.configChangedEvent.fire([key, value]);
+					}
+					return true;
+				}
+			} else {
+				return false;
+			}
+		}
+	};
+
+	/**
+	* Sets the value of a property and queues its event to execute. If the event is already scheduled to execute, it is
+	* moved from its current position to the end of the queue.
+	* @method queueProperty
+	* @param {String} key	The name of the property
+	* @param {String} value	The value to set the property to
+	* @return {Boolean}		true, if the set was successful, false if it failed.
+	*/
+	this.queueProperty = function(key, value) {
+		key = key.toLowerCase();
+
+		var property = config[key];
+
+		if (typeof property != 'undefined' && property.event) {
+			if (typeof value != 'undefined' && property.validator && ! property.validator(value)) { // validator
+				return false;
+			} else {
+
+				if (typeof value != 'undefined') {
+					property.value = value;
+				} else {
+					value = property.value;
+				}
+
+				var foundDuplicate = false;
+
+				for (var i=0;i<eventQueue.length;i++) {
+					var queueItem = eventQueue[i];
+
+					if (queueItem) {
+						var queueItemKey = queueItem[0];
+						var queueItemValue = queueItem[1];
+
+						if (queueItemKey.toLowerCase() == key) {
+							// found a dupe... push to end of queue, null current item, and break
+							eventQueue[i] = null;
+							eventQueue.push([key, (typeof value != 'undefined' ? value : queueItemValue)]);
+							foundDuplicate = true;
+							break;
+						}
+					}
+				}
+
+				if (! foundDuplicate && typeof value != 'undefined') { // this is a refire, or a new property in the queue
+					eventQueue.push([key, value]);
+				}
+			}
 
+			if (property.supercedes) {
+				for (var s=0;s<property.supercedes.length;s++) {
+					var supercedesCheck = property.supercedes[s];
+
+					for (var q=0;q<eventQueue.length;q++) {
+						var queueItemCheck = eventQueue[q];
+
+						if (queueItemCheck) {
+							var queueItemCheckKey = queueItemCheck[0];
+							var queueItemCheckValue = queueItemCheck[1];
+
+							if ( queueItemCheckKey.toLowerCase() == supercedesCheck.toLowerCase() ) {
+								eventQueue.push([queueItemCheckKey, queueItemCheckValue]);
+								eventQueue[q] = null;
+								break;
+							}
+						}
+					}
+				}
+			}
+
+			return true;
+		} else {
+			return false;
+		}
+	};
+
+	/**
+	* Fires the event for a property using the property's current value.
+	* @method refireEvent
+	* @param {String} key	The name of the property
+	*/
+	this.refireEvent = function(key) {
+		key = key.toLowerCase();
+
+		var property = config[key];
+		if (typeof property != 'undefined' && property.event && typeof property.value != 'undefined') {
+			if (this.queueInProgress) {
+				this.queueProperty(key);
+			} else {
+				fireEvent(key, property.value);
+			}
+		}
+	};
+
+	/**
+	* Applies a key-value Object literal to the configuration, replacing any existing values, and queueing the property events.
+	* Although the values will be set, fireQueue() must be called for their associated events to execute.
+	* @method applyConfig
+	* @param {Object}	userConfig	The configuration Object literal
+	* @param {Boolean}	init		When set to true, the initialConfig will be set to the userConfig passed in, so that calling a reset will reset the properties to the passed values.
+	*/
+	this.applyConfig = function(userConfig, init) {
+		if (init) {
+			initialConfig = userConfig;
+		}
+		for (var prop in userConfig) {
+			this.queueProperty(prop, userConfig[prop]);
+		}
+	};
+
+	/**
+	* Refires the events for all configuration properties using their current values.
+	* @method refresh
+	*/
+	this.refresh = function() {
+		for (var prop in config) {
+			this.refireEvent(prop);
+		}
+	};
+
+	/**
+	* Fires the normalized list of queued property change events
+	* @method fireQueue
+	*/
+	this.fireQueue = function() {
+		this.queueInProgress = true;
+		for (var i=0;i<eventQueue.length;i++) {
+			var queueItem = eventQueue[i];
+			if (queueItem) {
+				var key = queueItem[0];
+				var value = queueItem[1];
+
+				var property = config[key];
+				property.value = value;
+
+				fireEvent(key,value);
+			}
+		}
+
+		this.queueInProgress = false;
+		eventQueue = [];
+	};
+
+	/**
+	* Subscribes an external handler to the change event for any given property.
+	* @method subscribeToConfigEvent
+	* @param {String}	key			The property name
+	* @param {Function}	handler		The handler function to use subscribe to the property's event
+	* @param {Object}	obj			The Object to use for scoping the event handler (see CustomEvent documentation)
+	* @param {Boolean}	override	Optional. If true, will override "this" within the handler to map to the scope Object passed into the method.
+	* @return {Boolean}				True, if the subscription was successful, otherwise false.
+	*/
+	this.subscribeToConfigEvent = function(key, handler, obj, override) {
+		key = key.toLowerCase();
+
+		var property = config[key];
+		if (typeof property != 'undefined' && property.event) {
+			if (! YAHOO.util.Config.alreadySubscribed(property.event, handler, obj)) {
+				property.event.subscribe(handler, obj, override);
+			}
+			return true;
+		} else {
+			return false;
+		}
+	};
+
+	/**
+	* Unsubscribes an external handler from the change event for any given property.
+	* @method unsubscribeFromConfigEvent
+	* @param {String}	key			The property name
+	* @param {Function}	handler		The handler function to use subscribe to the property's event
+	* @param {Object}	obj			The Object to use for scoping the event handler (see CustomEvent documentation)
+	* @return {Boolean}				True, if the unsubscription was successful, otherwise false.
+	*/
+	this.unsubscribeFromConfigEvent = function(key, handler, obj) {
+		key = key.toLowerCase();
+
+		var property = config[key];
+		if (typeof property != 'undefined' && property.event) {
+			return property.event.unsubscribe(handler, obj);
+		} else {
+			return false;
+		}
+	};
+
+	/**
+	* Returns a string representation of the Config object
+	* @method toString
+	* @return {String}	The Config object in string format.
+	*/
+	this.toString = function() {
+		var output = "Config";
+		if (this.owner) {
+			output += " [" + this.owner.toString() + "]";
+		}
+		return output;
+	};
+
+	/**
+	* Returns a string representation of the Config object's current CustomEvent queue
+	* @method outputEventQueue
+	* @return {String}	The string list of CustomEvents currently queued for execution
+	*/
+	this.outputEventQueue = function() {
+		var output = "";
+		for (var q=0;q<eventQueue.length;q++) {
+			var queueItem = eventQueue[q];
+			if (queueItem) {
+				output += queueItem[0] + "=" + queueItem[1] + ", ";
+			}
+		}
+		return output;
+	};
+};
+
+/**
+* Checks to determine if a particular function/Object pair are already subscribed to the specified CustomEvent
+* @method YAHOO.util.Config.alreadySubscribed
+* @static
+* @param {YAHOO.util.CustomEvent} evt	The CustomEvent for which to check the subscriptions
+* @param {Function}	fn	The function to look for in the subscribers list
+* @param {Object}	obj	The execution scope Object for the subscription
+* @return {Boolean}	true, if the function/Object pair is already subscribed to the CustomEvent passed in
+*/
+YAHOO.util.Config.alreadySubscribed = function(evt, fn, obj) {
+	for (var e=0;e<evt.subscribers.length;e++) {
+		var subsc = evt.subscribers[e];
+		if (subsc && subsc.obj == obj && subsc.fn == fn) {
+			return true;
+		}
+	}
+	return false;
+};
+
+/**
+* YAHOO.widget.DateMath is used for simple date manipulation. The class is a static utility
+* used for adding, subtracting, and comparing dates.
+* @class YAHOO.widget.DateMath
+*/
+YAHOO.widget.DateMath = {
 	/**
 	* Constant field representing Day
+	* @property DAY
+	* @static
+	* @final
 	* @type String
 	*/
-	this.DAY = "D";
+	DAY : "D",
 
 	/**
 	* Constant field representing Week
+	* @property WEEK
+	* @static
+	* @final
 	* @type String
 	*/
-	this.WEEK = "W";
+	WEEK : "W",
 
 	/**
 	* Constant field representing Year
+	* @property YEAR
+	* @static
+	* @final
 	* @type String
 	*/
-	this.YEAR = "Y";
+	YEAR : "Y",
 
 	/**
 	* Constant field representing Month
+	* @property MONTH
+	* @static
+	* @final
 	* @type String
 	*/
-	this.MONTH = "M";
+	MONTH : "M",
 
 	/**
 	* Constant field representing one day, in milliseconds
-	* @type Integer
+	* @property ONE_DAY_MS
+	* @static
+	* @final
+	* @type Number
 	*/
-	this.ONE_DAY_MS = 1000*60*60*24;
+	ONE_DAY_MS : 1000*60*60*24,
 
 	/**
 	* Adds the specified amount of time to the this instance.
+	* @method add
 	* @param {Date} date	The JavaScript Date object to perform addition on
-	* @param {string} field	The this field constant to be used for performing addition.
-	* @param {Integer} amount	The number of units (measured in the field constant) to add to the date.
+	* @param {String} field	The field constant to be used for performing addition.
+	* @param {Number} amount	The number of units (measured in the field constant) to add to the date.
+	* @return {Date} The resulting Date object
 	*/
-	this.add = function(date, field, amount) {
+	add : function(date, field, amount) {
 		var d = new Date(date.getTime());
-		switch (field)
-		{
+		switch (field) {
 			case this.MONTH:
 				var newMonth = date.getMonth() + amount;
 				var years = 0;
 
 
 				if (newMonth < 0) {
-					while (newMonth < 0)
-					{
+					while (newMonth < 0) {
 						newMonth += 12;
 						years -= 1;
 					}
 				} else if (newMonth > 11) {
-					while (newMonth > 11)
-					{
+					while (newMonth > 11) {
 						newMonth -= 12;
 						years += 1;
 					}
 				}
-				
+
 				d.setMonth(newMonth);
 				d.setFullYear(date.getFullYear() + years);
 				break;
@@ -89,75 +561,97 @@
 				d.setFullYear(date.getFullYear() + amount);
 				break;
 			case this.WEEK:
-				d.setDate(date.getDate() + 7);
+				d.setDate(date.getDate() + (amount * 7));
 				break;
 		}
 		return d;
-	};
+	},
 
 	/**
 	* Subtracts the specified amount of time from the this instance.
+	* @method subtract
 	* @param {Date} date	The JavaScript Date object to perform subtraction on
-	* @param {Integer} field	The this field constant to be used for performing subtraction.
-	* @param {Integer} amount	The number of units (measured in the field constant) to subtract from the date.
+	* @param {Number} field	The this field constant to be used for performing subtraction.
+	* @param {Number} amount	The number of units (measured in the field constant) to subtract from the date.
+	* @return {Date} The resulting Date object
 	*/
-	this.subtract = function(date, field, amount) {
+	subtract : function(date, field, amount) {
 		return this.add(date, field, (amount*-1));
-	};
+	},
 
 	/**
 	* Determines whether a given date is before another date on the calendar.
+	* @method before
 	* @param {Date} date		The Date object to compare with the compare argument
 	* @param {Date} compareTo	The Date object to use for the comparison
 	* @return {Boolean} true if the date occurs before the compared date; false if not.
 	*/
-	this.before = function(date, compareTo) {
+	before : function(date, compareTo) {
 		var ms = compareTo.getTime();
 		if (date.getTime() < ms) {
 			return true;
 		} else {
 			return false;
 		}
-	};
+	},
 
 	/**
 	* Determines whether a given date is after another date on the calendar.
+	* @method after
 	* @param {Date} date		The Date object to compare with the compare argument
 	* @param {Date} compareTo	The Date object to use for the comparison
 	* @return {Boolean} true if the date occurs after the compared date; false if not.
 	*/
-	this.after = function(date, compareTo) {
+	after : function(date, compareTo) {
 		var ms = compareTo.getTime();
 		if (date.getTime() > ms) {
 			return true;
 		} else {
 			return false;
 		}
-	};
+	},
+
+	/**
+	* Determines whether a given date is between two other dates on the calendar.
+	* @method between
+	* @param {Date} date		The date to check for
+	* @param {Date} dateBegin	The start of the range
+	* @param {Date} dateEnd		The end of the range
+	* @return {Boolean} true if the date occurs between the compared dates; false if not.
+	*/
+	between : function(date, dateBegin, dateEnd) {
+		if (this.after(date, dateBegin) && this.before(date, dateEnd)) {
+			return true;
+		} else {
+			return false;
+		}
+	},
 
 	/**
 	* Retrieves a JavaScript Date object representing January 1 of any given year.
-	* @param {Integer} calendarYear		The calendar year for which to retrieve January 1
+	* @method getJan1
+	* @param {Number} calendarYear		The calendar year for which to retrieve January 1
 	* @return {Date}	January 1 of the calendar year specified.
 	*/
-	this.getJan1 = function(calendarYear) {
-		return new Date(calendarYear,0,1); 
-	};
+	getJan1 : function(calendarYear) {
+		return new Date(calendarYear,0,1);
+	},
 
 	/**
 	* Calculates the number of days the specified date is from January 1 of the specified calendar year.
 	* Passing January 1 to this function would return an offset value of zero.
+	* @method getDayOffset
 	* @param {Date}	date	The JavaScript date for which to find the offset
-	* @param {Integer} calendarYear	The calendar year to use for determining the offset
-	* @return {Integer}	The number of days since January 1 of the given year
+	* @param {Number} calendarYear	The calendar year to use for determining the offset
+	* @return {Number}	The number of days since January 1 of the given year
 	*/
-	this.getDayOffset = function(date, calendarYear) {
+	getDayOffset : function(date, calendarYear) {
 		var beginYear = this.getJan1(calendarYear); // Find the start of the year. This will be in week 1.
-		
+
 		// Find the number of days the passed in date is away from the calendar year start
 		var dayOffset = Math.ceil((date.getTime()-beginYear.getTime()) / this.ONE_DAY_MS);
 		return dayOffset;
-	};
+	},
 
 	/**
 	* Calculates the week number for the given date. This function assumes that week 1 is the
@@ -166,112 +660,103 @@
 	* date if the date overlaps years. For instance, a week may be considered week 1 of 2005, or
 	* week 53 of 2004. Specifying the optional calendarYear allows one to make this distinction
 	* easily.
+	* @method getWeekNumber
 	* @param {Date}	date	The JavaScript date for which to find the week number
-	* @param {Integer} calendarYear	OPTIONAL - The calendar year to use for determining the week number. Default is
+	* @param {Number} calendarYear	OPTIONAL - The calendar year to use for determining the week number. Default is
 	*											the calendar year of parameter "date".
-	* @param {Integer} weekStartsOn	OPTIONAL - The integer (0-6) representing which day a week begins on. Default is 0 (for Sunday).
-	* @return {Integer}	The week number of the given date.
+	* @param {Number} weekStartsOn	OPTIONAL - The integer (0-6) representing which day a week begins on. Default is 0 (for Sunday).
+	* @return {Number}	The week number of the given date.
 	*/
-	this.getWeekNumber = function(date, calendarYear, weekStartsOn) {
-		if (! weekStartsOn) {
-			weekStartsOn = 0;
-		}
-		if (! calendarYear) {
-			calendarYear = date.getFullYear();
-		}
-		var weekNum = -1;
-		
-		var jan1 = this.getJan1(calendarYear);
-		var jan1DayOfWeek = jan1.getDay();
-		
-		var month = date.getMonth();
-		var day = date.getDate();
-		var year = date.getFullYear();
-		
-		var dayOffset = this.getDayOffset(date, calendarYear); // Days since Jan 1, Calendar Year
-			
-		if (dayOffset < 0 && dayOffset >= (-1 * jan1DayOfWeek)) {
-			weekNum = 1;
-		} else {
-			weekNum = 1;
-			var testDate = this.getJan1(calendarYear);
-			
-			while (testDate.getTime() < date.getTime() && testDate.getFullYear() == calendarYear) {
-				weekNum += 1;
-				testDate = this.add(testDate, this.WEEK, 1);
-			}
-		}
-		
+	getWeekNumber : function(date, calendarYear) {
+		date = this.clearTime(date);
+		var nearestThurs = new Date(date.getTime() + (4 * this.ONE_DAY_MS) - ((date.getDay()) * this.ONE_DAY_MS));
+
+		var jan1 = new Date(nearestThurs.getFullYear(),0,1);
+		var dayOfYear = ((nearestThurs.getTime() - jan1.getTime()) / this.ONE_DAY_MS) - 1;
+
+		var weekNum = Math.ceil((dayOfYear)/ 7);
 		return weekNum;
-	};
+	},
 
 	/**
 	* Determines if a given week overlaps two different years.
+	* @method isYearOverlapWeek
 	* @param {Date}	weekBeginDate	The JavaScript Date representing the first day of the week.
 	* @return {Boolean}	true if the date overlaps two different years.
 	*/
-	this.isYearOverlapWeek = function(weekBeginDate) {
+	isYearOverlapWeek : function(weekBeginDate) {
 		var overlaps = false;
 		var nextWeek = this.add(weekBeginDate, this.DAY, 6);
 		if (nextWeek.getFullYear() != weekBeginDate.getFullYear()) {
 			overlaps = true;
 		}
 		return overlaps;
-	};
+	},
 
 	/**
 	* Determines if a given week overlaps two different months.
+	* @method isMonthOverlapWeek
 	* @param {Date}	weekBeginDate	The JavaScript Date representing the first day of the week.
 	* @return {Boolean}	true if the date overlaps two different months.
 	*/
-	this.isMonthOverlapWeek = function(weekBeginDate) {
+	isMonthOverlapWeek : function(weekBeginDate) {
 		var overlaps = false;
 		var nextWeek = this.add(weekBeginDate, this.DAY, 6);
 		if (nextWeek.getMonth() != weekBeginDate.getMonth()) {
 			overlaps = true;
 		}
 		return overlaps;
-	};
+	},
 
 	/**
 	* Gets the first day of a month containing a given date.
+	* @method findMonthStart
 	* @param {Date}	date	The JavaScript Date used to calculate the month start
 	* @return {Date}		The JavaScript Date representing the first day of the month
 	*/
-	this.findMonthStart = function(date) {
+	findMonthStart : function(date) {
 		var start = new Date(date.getFullYear(), date.getMonth(), 1);
 		return start;
-	};
+	},
 
 	/**
 	* Gets the last day of a month containing a given date.
+	* @method findMonthEnd
 	* @param {Date}	date	The JavaScript Date used to calculate the month end
 	* @return {Date}		The JavaScript Date representing the last day of the month
 	*/
-	this.findMonthEnd = function(date) {
+	findMonthEnd : function(date) {
 		var start = this.findMonthStart(date);
 		var nextMonth = this.add(start, this.MONTH, 1);
 		var end = this.subtract(nextMonth, this.DAY, 1);
 		return end;
-	};
+	},
 
 	/**
 	* Clears the time fields from a given date, effectively setting the time to midnight.
+	* @method clearTime
 	* @param {Date}	date	The JavaScript Date for which the time fields will be cleared
 	* @return {Date}		The JavaScript Date cleared of all time fields
 	*/
-	this.clearTime = function(date) {
-		date.setHours(0,0,0,0);
+	clearTime : function(date) {
+		date.setHours(12,0,0,0);
 		return date;
-	};
-}
+	}
+};
+
+/**
+* The Calendar component is a UI control that enables users to choose one or more dates from a graphical calendar presented in a one-month ("one-up") or two-month ("two-up") interface. Calendars are generated entirely via script and can be navigated without any page refreshes.
+* @module    Calendar
+* @title     Calendar Widget
+* @namespace YAHOO.widget
+* @requires  yahoo,dom,event
+*/
 
 /**
-* @class
-* <p>Calendar_Core is the base class for the Calendar widget. In its most basic
+* Calendar is the base class for the Calendar widget. In its most basic
 * implementation, it has the ability to render a calendar widget on the page
 * that can be manipulated to select a single date, move back and forth between
-* months and years.</p>
+* months and years.
 * <p>To construct the placeholder for the calendar widget, the code is as
 * follows:
 *	<xmp>
@@ -279,1270 +764,1835 @@
 *	</xmp>
 * Note that the table can be replaced with any kind of element.
 * </p>
+* @namespace YAHOO.widget
+* @class Calendar
 * @constructor
 * @param {String}	id			The id of the table element that will represent the calendar widget
-* @param {String}	containerId	The id of the container element that will contain the calendar table
-* @param {String}	monthyear	The month/year string used to set the current calendar page
-* @param {String}	selected	A string of date values formatted using the date parser. The built-in
-								default date format is MM/DD/YYYY. Ranges are defined using
-								MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
-								Any combination of these can be combined by delimiting the string with
-								commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
-*/
-YAHOO.widget.Calendar_Core = function(id, containerId, monthyear, selected) {
-	if (arguments.length > 0)
-	{
-		this.init(id, containerId, monthyear, selected);
-	}
-}
+* @param {String}	containerId	The id of the container div element that will wrap the calendar table
+* @param {Object}	config		The configuration object containing the Calendar's arguments
+*/
+YAHOO.widget.Calendar = function(id, containerId, config) {
+	this.init(id, containerId, config);
+};
 
-YAHOO.widget.Calendar_Core.IMG_ROOT = (window.location.href.toLowerCase().indexOf("https") == 0 ? "https://a248.e.akamai.net/sec.yimg.com/i/" : "http://us.i1.yimg.com/us.yimg.com/i/");
+/**
+* The path to be used for images loaded for the Calendar
+* @property YAHOO.widget.Calendar.IMG_ROOT
+* @static
+* @type String
+*/
+YAHOO.widget.Calendar.IMG_ROOT = (window.location.href.toLowerCase().indexOf("https") === 0 ? "https://a248.e.akamai.net/sec.yimg.com/i/" : "http://us.i1.yimg.com/us.yimg.com/i/");
 
 /**
 * Type constant used for renderers to represent an individual date (M/D/Y)
+* @property YAHOO.widget.Calendar.DATE
+* @static
 * @final
 * @type String
 */
-YAHOO.widget.Calendar_Core.DATE = "D";
+YAHOO.widget.Calendar.DATE = "D";
 
 /**
 * Type constant used for renderers to represent an individual date across any year (M/D)
+* @property YAHOO.widget.Calendar.MONTH_DAY
+* @static
 * @final
 * @type String
 */
-YAHOO.widget.Calendar_Core.MONTH_DAY = "MD";
+YAHOO.widget.Calendar.MONTH_DAY = "MD";
 
 /**
 * Type constant used for renderers to represent a weekday
+* @property YAHOO.widget.Calendar.WEEKDAY
+* @static
 * @final
 * @type String
 */
-YAHOO.widget.Calendar_Core.WEEKDAY = "WD";
+YAHOO.widget.Calendar.WEEKDAY = "WD";
 
 /**
 * Type constant used for renderers to represent a range of individual dates (M/D/Y-M/D/Y)
+* @property YAHOO.widget.Calendar.RANGE
+* @static
 * @final
 * @type String
 */
-YAHOO.widget.Calendar_Core.RANGE = "R";
+YAHOO.widget.Calendar.RANGE = "R";
 
 /**
 * Type constant used for renderers to represent a month across any year
+* @property YAHOO.widget.Calendar.MONTH
+* @static
 * @final
 * @type String
 */
-YAHOO.widget.Calendar_Core.MONTH = "M";
+YAHOO.widget.Calendar.MONTH = "M";
 
 /**
 * Constant that represents the total number of date cells that are displayed in a given month
-* including 
+* @property YAHOO.widget.Calendar.DISPLAY_DAYS
+* @static
 * @final
-* @type Integer
+* @type Number
 */
-YAHOO.widget.Calendar_Core.DISPLAY_DAYS = 42;
+YAHOO.widget.Calendar.DISPLAY_DAYS = 42;
 
 /**
 * Constant used for halting the execution of the remainder of the render stack
+* @property YAHOO.widget.Calendar.STOP_RENDER
+* @static
 * @final
 * @type String
 */
-YAHOO.widget.Calendar_Core.STOP_RENDER = "S";
+YAHOO.widget.Calendar.STOP_RENDER = "S";
 
-YAHOO.widget.Calendar_Core.prototype = {
+YAHOO.widget.Calendar.prototype = {
 
 	/**
 	* The configuration object used to set up the calendars various locale and style options.
+	* @property Config
+	* @private
+	* @deprecated Configuration properties should be set by calling Calendar.cfg.setProperty.
 	* @type Object
 	*/
 	Config : null,
 
 	/**
 	* The parent CalendarGroup, only to be set explicitly by the parent group
+	* @property parent
 	* @type CalendarGroup
-	*/	
+	*/
 	parent : null,
 
 	/**
 	* The index of this item in the parent group
-	* @type Integer
+	* @property index
+	* @type Number
 	*/
 	index : -1,
 
 	/**
 	* The collection of calendar table cells
+	* @property cells
 	* @type HTMLTableCellElement[]
 	*/
 	cells : null,
 
 	/**
-	* The collection of calendar week header cells
-	* @type HTMLTableCellElement[]
-	*/
-	weekHeaderCells : null,
-
-	/**
-	* The collection of calendar week footer cells
-	* @type HTMLTableCellElement[]
-	*/
-	weekFooterCells : null,
-	
-	/**
 	* The collection of calendar cell dates that is parallel to the cells collection. The array contains dates field arrays in the format of [YYYY, M, D].
-	* @type Array[](Integer[])
+	* @property cellDates
+	* @type Array[](Number[])
 	*/
 	cellDates : null,
 
 	/**
 	* The id that uniquely identifies this calendar. This id should match the id of the placeholder element on the page.
+	* @property id
 	* @type String
 	*/
 	id : null,
 
 	/**
 	* The DOM element reference that points to this calendar's container element. The calendar will be inserted into this element when the shell is rendered.
+	* @property oDomContainer
 	* @type HTMLElement
 	*/
 	oDomContainer : null,
 
 	/**
 	* A Date object representing today's date.
+	* @property today
 	* @type Date
 	*/
 	today : null,
 
 	/**
-	* The list of render functions, along with required parameters, used to render cells. 
+	* The list of render functions, along with required parameters, used to render cells.
+	* @property renderStack
 	* @type Array[]
 	*/
 	renderStack : null,
 
 	/**
 	* A copy of the initial render functions created before rendering.
-	* @type Array
+	* @property _renderStack
 	* @private
+	* @type Array
 	*/
 	_renderStack : null,
 
 	/**
-	* A Date object representing the month/year that the calendar is currently set to
+	* A Date object representing the month/year that the calendar is initially set to
+	* @property _pageDate
+	* @private
 	* @type Date
 	*/
-	pageDate : null,
+	_pageDate : null,
 
 	/**
-	* A Date object representing the month/year that the calendar is initially set to
-	* @type Date
+	* The private list of initially selected dates.
+	* @property _selectedDates
 	* @private
+	* @type Array
 	*/
-	_pageDate : null,
-	
+	_selectedDates : null,
+
 	/**
-	* A Date object representing the minimum selectable date
-	* @type Date
+	* A map of DOM event handlers to attach to cells associated with specific CSS class names
+	* @property domEventMap
+	* @type Object
 	*/
-	minDate : null,
-	
+	domEventMap : null
+};
+
+
+
+/**
+* Initializes the Calendar widget.
+* @method init
+* @param {String}	id			The id of the table element that will represent the calendar widget
+* @param {String}	containerId	The id of the container div element that will wrap the calendar table
+* @param {Object}	config		The configuration object containing the Calendar's arguments
+*/
+YAHOO.widget.Calendar.prototype.init = function(id, containerId, config) {
+	this.initEvents();
+	this.today = new Date();
+	YAHOO.widget.DateMath.clearTime(this.today);
+
+	this.id = id;
+	this.oDomContainer = document.getElementById(containerId);
+
 	/**
-	* A Date object representing the maximum selectable date
-	* @type Date
+	* The Config object used to hold the configuration variables for the Calendar
+	* @property cfg
+	* @type YAHOO.util.Config
 	*/
-	maxDate : null,
-	
+	this.cfg = new YAHOO.util.Config(this);
+
 	/**
-	* The list of currently selected dates. The data format for this local collection is 
-	* an array of date field arrays, e.g:
-	* [
-	*	[2004,5,25],
-	*	[2004,5,26]
-	* ]
-	* @type Array[](Integer[])
+	* The local object which contains the Calendar's options
+	* @property Options
+	* @type Object
 	*/
-	selectedDates : null,
+	this.Options = {};
 
 	/**
-	* The private list of initially selected dates.
-	* @type Array
-	* @private
+	* The local object which contains the Calendar's locale settings
+	* @property Locale
+	* @type Object
 	*/
-	_selectedDates : null,
+	this.Locale = {};
+
+	this.initStyles();
+
+	YAHOO.util.Dom.addClass(this.oDomContainer, this.Style.CSS_CONTAINER);
+	YAHOO.util.Dom.addClass(this.oDomContainer, this.Style.CSS_SINGLE);
+
+	this.cellDates = [];
+	this.cells = [];
+	this.renderStack = [];
+	this._renderStack = [];
+
+	this.setupConfig();
+
+	if (config) {
+		this.cfg.applyConfig(config, true);
+	}
+
+	this.cfg.fireQueue();
+};
+
+/**
+* Renders the built-in IFRAME shim for the IE6 and below
+* @method configIframe
+*/
+YAHOO.widget.Calendar.prototype.configIframe = function(type, args, obj) {
+	var useIframe = args[0];
+
+	if (YAHOO.util.Dom.inDocument(this.oDomContainer)) {
+		if (useIframe) {
+			var pos = YAHOO.util.Dom.getStyle(this.oDomContainer, "position");
+
+			if (this.browser == "ie" && (pos == "absolute" || pos == "relative")) {
+				if (! YAHOO.util.Dom.inDocument(this.iframe)) {
+					this.iframe = document.createElement("iframe");
+					this.iframe.src = "javascript:false;";
+					YAHOO.util.Dom.setStyle(this.iframe, "opacity", "0");
+					this.oDomContainer.insertBefore(this.iframe, this.oDomContainer.firstChild);
+				}
+			}
+		} else {
+			if (this.iframe) {
+				if (this.iframe.parentNode) {
+					this.iframe.parentNode.removeChild(this.iframe);
+				}
+				this.iframe = null;
+			}
+		}
+	}
+};
+
+/**
+* Default handler for the "title" property
+* @method configTitle
+*/
+YAHOO.widget.Calendar.prototype.configTitle = function(type, args, obj) {
+	var title = args[0];
+	var close = this.cfg.getProperty("close");
+
+	var titleDiv;
+
+	if (title && title !== "") {
+		titleDiv = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE, "div", this.oDomContainer)[0] || document.createElement("div");
+		titleDiv.className = YAHOO.widget.CalendarGroup.CSS_2UPTITLE;
+		titleDiv.innerHTML = title;
+		this.oDomContainer.insertBefore(titleDiv, this.oDomContainer.firstChild);
+		YAHOO.util.Dom.addClass(this.oDomContainer, "withtitle");
+	} else {
+		titleDiv = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE, "div", this.oDomContainer)[0] || null;
+
+		if (titleDiv) {
+			YAHOO.util.Event.purgeElement(titleDiv);
+			this.oDomContainer.removeChild(titleDiv);
+		}
+		if (! close) {
+			YAHOO.util.Dom.removeClass(this.oDomContainer, "withtitle");
+		}
+	}
+};
+
+/**
+* Default handler for the "close" property
+* @method configClose
+*/
+YAHOO.widget.Calendar.prototype.configClose = function(type, args, obj) {
+	var close = args[0];
+	var title = this.cfg.getProperty("title");
+
+	var linkClose;
+
+	if (close === true) {
+		linkClose = YAHOO.util.Dom.getElementsByClassName("link-close", "a", this.oDomContainer)[0] || document.createElement("a");
+		linkClose.href = "javascript:void(null);";
+		linkClose.className = "link-close";
+		YAHOO.util.Event.addListener(linkClose, "click", this.hide, this, true);
+		var imgClose = document.createElement("img");
+		imgClose.src = YAHOO.widget.Calendar.IMG_ROOT + "us/my/bn/x_d.gif";
+		imgClose.className = YAHOO.widget.CalendarGroup.CSS_2UPCLOSE;
+		linkClose.appendChild(imgClose);
+		this.oDomContainer.appendChild(linkClose);
+		YAHOO.util.Dom.addClass(this.oDomContainer, "withtitle");
+	} else {
+		linkClose = YAHOO.util.Dom.getElementsByClassName("link-close", "a", this.oDomContainer)[0] || null;
+
+		if (linkClose) {
+			YAHOO.util.Event.purgeElement(linkClose);
+			this.oDomContainer.removeChild(linkClose);
+		}
+		if (! title || title === "") {
+			YAHOO.util.Dom.removeClass(this.oDomContainer, "withtitle");
+		}
+	}
+};
+
+/**
+* Initializes Calendar's built-in CustomEvents
+* @method initEvents
+*/
+YAHOO.widget.Calendar.prototype.initEvents = function() {
+
+	/**
+	* Fired before a selection is made
+	* @event beforeSelectEvent
+	*/
+	this.beforeSelectEvent = new YAHOO.util.CustomEvent("beforeSelect");
+
+	/**
+	* Fired when a selection is made
+	* @event selectEvent
+	* @param {Array}	Array of Date field arrays in the format [YYYY, MM, DD].
+	*/
+	this.selectEvent = new YAHOO.util.CustomEvent("select");
+
+	/**
+	* Fired before a selection is made
+	* @event beforeDeselectEvent
+	*/
+	this.beforeDeselectEvent = new YAHOO.util.CustomEvent("beforeDeselect");
+
+	/**
+	* Fired when a selection is made
+	* @event deselectEvent
+	* @param {Array}	Array of Date field arrays in the format [YYYY, MM, DD].
+	*/
+	this.deselectEvent = new YAHOO.util.CustomEvent("deselect");
+
+	/**
+	* Fired when the Calendar page is changed
+	* @event changePageEvent
+	*/
+	this.changePageEvent = new YAHOO.util.CustomEvent("changePage");
+
+	/**
+	* Fired before the Calendar is rendered
+	* @event beforeRenderEvent
+	*/
+	this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender");
+
+	/**
+	* Fired when the Calendar is rendered
+	* @event renderEvent
+	*/
+	this.renderEvent = new YAHOO.util.CustomEvent("render");
+
+	/**
+	* Fired when the Calendar is reset
+	* @event resetEvent
+	*/
+	this.resetEvent = new YAHOO.util.CustomEvent("reset");
+
+	/**
+	* Fired when the Calendar is cleared
+	* @event clearEvent
+	*/
+	this.clearEvent = new YAHOO.util.CustomEvent("clear");
+
+	this.beforeSelectEvent.subscribe(this.onBeforeSelect, this, true);
+	this.selectEvent.subscribe(this.onSelect, this, true);
+	this.beforeDeselectEvent.subscribe(this.onBeforeDeselect, this, true);
+	this.deselectEvent.subscribe(this.onDeselect, this, true);
+	this.changePageEvent.subscribe(this.onChangePage, this, true);
+	this.renderEvent.subscribe(this.onRender, this, true);
+	this.resetEvent.subscribe(this.onReset, this, true);
+	this.clearEvent.subscribe(this.onClear, this, true);
+};
+
+
+/**
+* The default event function that is attached to a date link within a calendar cell
+* when the calendar is rendered.
+* @method doSelectCell
+* @param {DOMEvent} e	The event
+* @param {Calendar} cal	A reference to the calendar passed by the Event utility
+*/
+YAHOO.widget.Calendar.prototype.doSelectCell = function(e, cal) {
+	var target = YAHOO.util.Event.getTarget(e);
+
+	var cell,index,d,date;
+
+	while (target.tagName.toLowerCase() != "td" && ! YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) {
+		target = target.parentNode;
+		if (target.tagName.toLowerCase() == "html") {
+			return;
+		}
+	}
+
+	cell = target;
+
+	if (YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_SELECTABLE)) {
+		index = cell.id.split("cell")[1];
+		d = cal.cellDates[index];
+		date = new Date(d[0],d[1]-1,d[2]);
+
+		var link;
+
+		if (cal.Options.MULTI_SELECT) {
+			link = cell.getElementsByTagName("a")[0];
+			if (link) {
+				link.blur();
+			}
+
+			var cellDate = cal.cellDates[index];
+			var cellDateIndex = cal._indexOfSelectedFieldArray(cellDate);
+
+			if (cellDateIndex > -1) {
+				cal.deselectCell(index);
+			} else {
+				cal.selectCell(index);
+			}
+
+		} else {
+			link = cell.getElementsByTagName("a")[0];
+			if (link) {
+				link.blur();
+			}
+			cal.selectCell(index);
+		}
+	}
+};
+
+/**
+* The event that is executed when the user hovers over a cell
+* @method doCellMouseOver
+* @param {DOMEvent} e	The event
+* @param {Calendar} cal	A reference to the calendar passed by the Event utility
+*/
+YAHOO.widget.Calendar.prototype.doCellMouseOver = function(e, cal) {
+	var target;
+	if (e) {
+		target = YAHOO.util.Event.getTarget(e);
+	} else {
+		target = this;
+	}
+
+	while (target.tagName.toLowerCase() != "td") {
+		target = target.parentNode;
+		if (target.tagName.toLowerCase() == "html") {
+			return;
+		}
+	}
+
+	if (YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) {
+		YAHOO.util.Dom.addClass(target, cal.Style.CSS_CELL_HOVER);
+	}
+};
+
+/**
+* The event that is executed when the user moves the mouse out of a cell
+* @method doCellMouseOut
+* @param {DOMEvent} e	The event
+* @param {Calendar} cal	A reference to the calendar passed by the Event utility
+*/
+YAHOO.widget.Calendar.prototype.doCellMouseOut = function(e, cal) {
+	var target;
+	if (e) {
+		target = YAHOO.util.Event.getTarget(e);
+	} else {
+		target = this;
+	}
+
+	while (target.tagName.toLowerCase() != "td") {
+		target = target.parentNode;
+		if (target.tagName.toLowerCase() == "html") {
+			return;
+		}
+	}
+
+	if (YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) {
+		YAHOO.util.Dom.removeClass(target, cal.Style.CSS_CELL_HOVER);
+	}
+};
+
+YAHOO.widget.Calendar.prototype.setupConfig = function() {
+
+	/**
+	* The month/year representing the current visible Calendar date (mm/yyyy)
+	* @config pagedate
+	* @type String
+	* @default today's date
+	*/
+	this.cfg.addProperty("pagedate", { value:new Date(), handler:this.configPageDate } );
+
+	/**
+	* The date or range of dates representing the current Calendar selection
+	* @config selected
+	* @type String
+	* @default []
+	*/
+	this.cfg.addProperty("selected", { value:[], handler:this.configSelected } );
+
+	/**
+	* The title to display above the Calendar's month header
+	* @config title
+	* @type String
+	* @default ""
+	*/
+	this.cfg.addProperty("title", { value:"", handler:this.configTitle } );
+
+	/**
+	* Whether or not a close button should be displayed for this Calendar
+	* @config close
+	* @type Boolean
+	* @default false
+	*/
+	this.cfg.addProperty("close", { value:false, handler:this.configClose } );
+
+	/**
+	* Whether or not an iframe shim should be placed under the Calendar to prevent select boxes from bleeding through in Internet Explorer 6 and below.
+	* @config iframe
+	* @type Boolean
+	* @default true
+	*/
+	this.cfg.addProperty("iframe", { value:true, handler:this.configIframe, validator:this.cfg.checkBoolean } );
+
+	/**
+	* The minimum selectable date in the current Calendar (mm/dd/yyyy)
+	* @config mindate
+	* @type String
+	* @default null
+	*/
+	this.cfg.addProperty("mindate", { value:null, handler:this.configMinDate } );
 
 	/**
-	* A boolean indicating whether the shell of the calendar has already been rendered to the page
+	* The maximum selectable date in the current Calendar (mm/dd/yyyy)
+	* @config maxdate
+	* @type String
+	* @default null
+	*/
+	this.cfg.addProperty("maxdate", { value:null, handler:this.configMaxDate } );
+
+
+	// Options properties
+
+	/**
+	* True if the Calendar should allow multiple selections. False by default.
+	* @config MULTI_SELECT
 	* @type Boolean
-	*/	
-	shellRendered : false,
+	* @default false
+	*/
+	this.cfg.addProperty("MULTI_SELECT",	{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
 
 	/**
-	* The HTML table element that represents this calendar
-	* @type HTMLTableElement
-	*/	
-	table : null,
+	* The weekday the week begins on. Default is 0 (Sunday).
+	* @config START_WEEKDAY
+	* @type number
+	* @default 0
+	*/
+	this.cfg.addProperty("START_WEEKDAY",	{ value:0, handler:this.configOptions, validator:this.cfg.checkNumber  } );
 
 	/**
-	* The HTML cell element that represents the main header cell TH used in the calendar table
-	* @type HTMLTableCellElement
-	*/	
-	headerCell : null
+	* True if the Calendar should show weekday labels. True by default.
+	* @config SHOW_WEEKDAYS
+	* @type Boolean
+	* @default true
+	*/
+	this.cfg.addProperty("SHOW_WEEKDAYS",	{ value:true, handler:this.configOptions, validator:this.cfg.checkBoolean  } );
+
+	/**
+	* True if the Calendar should show week row headers. False by default.
+	* @config SHOW_WEEK_HEADER
+	* @type Boolean
+	* @default false
+	*/
+	this.cfg.addProperty("SHOW_WEEK_HEADER",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
+
+	/**
+	* True if the Calendar should show week row footers. False by default.
+	* @config SHOW_WEEK_FOOTER
+	* @type Boolean
+	* @default false
+	*/
+	this.cfg.addProperty("SHOW_WEEK_FOOTER",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
+
+	/**
+	* True if the Calendar should suppress weeks that are not a part of the current month. False by default.
+	* @config HIDE_BLANK_WEEKS
+	* @type Boolean
+	* @default false
+	*/
+	this.cfg.addProperty("HIDE_BLANK_WEEKS",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
+
+	/**
+	* The image that should be used for the left navigation arrow.
+	* @config NAV_ARROW_LEFT
+	* @type String
+	* @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif"
+	*/
+	this.cfg.addProperty("NAV_ARROW_LEFT",	{ value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif", handler:this.configOptions } );
+
+	/**
+	* The image that should be used for the left navigation arrow.
+	* @config NAV_ARROW_RIGHT
+	* @type String
+	* @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif"
+	*/
+	this.cfg.addProperty("NAV_ARROW_RIGHT",	{ value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif", handler:this.configOptions } );
+
+	// Locale properties
+
+	/**
+	* The short month labels for the current locale.
+	* @config MONTHS_SHORT
+	* @type String[]
+	* @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
+	*/
+	this.cfg.addProperty("MONTHS_SHORT",	{ value:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], handler:this.configLocale } );
+
+	/**
+	* The long month labels for the current locale.
+	* @config MONTHS_LONG
+	* @type String[]
+	* @default ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
+	*/
+	this.cfg.addProperty("MONTHS_LONG",		{ value:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], handler:this.configLocale } );
+
+	/**
+	* The 1-character weekday labels for the current locale.
+	* @config WEEKDAYS_1CHAR
+	* @type String[]
+	* @default ["S", "M", "T", "W", "T", "F", "S"]
+	*/
+	this.cfg.addProperty("WEEKDAYS_1CHAR",	{ value:["S", "M", "T", "W", "T", "F", "S"], handler:this.configLocale } );
+
+	/**
+	* The short weekday labels for the current locale.
+	* @config WEEKDAYS_SHORT
+	* @type String[]
+	* @default ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]
+	*/
+	this.cfg.addProperty("WEEKDAYS_SHORT",	{ value:["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], handler:this.configLocale } );
+
+	/**
+	* The medium weekday labels for the current locale.
+	* @config WEEKDAYS_MEDIUM
+	* @type String[]
+	* @default ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
+	*/
+	this.cfg.addProperty("WEEKDAYS_MEDIUM",	{ value:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], handler:this.configLocale } );
+
+	/**
+	* The long weekday labels for the current locale.
+	* @config WEEKDAYS_LONG
+	* @type String[]
+	* @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
+	*/
+	this.cfg.addProperty("WEEKDAYS_LONG",	{ value:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], handler:this.configLocale } );
+
+	/**
+	* Refreshes the locale values used to build the Calendar.
+	* @method refreshLocale
+	* @private
+	*/
+	var refreshLocale = function() {
+		this.cfg.refireEvent("LOCALE_MONTHS");
+		this.cfg.refireEvent("LOCALE_WEEKDAYS");
+	};
+
+	this.cfg.subscribeToConfigEvent("START_WEEKDAY", refreshLocale, this, true);
+	this.cfg.subscribeToConfigEvent("MONTHS_SHORT", refreshLocale, this, true);
+	this.cfg.subscribeToConfigEvent("MONTHS_LONG", refreshLocale, this, true);
+	this.cfg.subscribeToConfigEvent("WEEKDAYS_1CHAR", refreshLocale, this, true);
+	this.cfg.subscribeToConfigEvent("WEEKDAYS_SHORT", refreshLocale, this, true);
+	this.cfg.subscribeToConfigEvent("WEEKDAYS_MEDIUM", refreshLocale, this, true);
+	this.cfg.subscribeToConfigEvent("WEEKDAYS_LONG", refreshLocale, this, true);
+
+	/**
+	* The setting that determines which length of month labels should be used. Possible values are "short" and "long".
+	* @config LOCALE_MONTHS
+	* @type String
+	* @default "long"
+	*/
+	this.cfg.addProperty("LOCALE_MONTHS",	{ value:"long", handler:this.configLocaleValues } );
+
+	/**
+	* The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long".
+	* @config LOCALE_WEEKDAYS
+	* @type String
+	* @default "short"
+	*/
+	this.cfg.addProperty("LOCALE_WEEKDAYS",	{ value:"short", handler:this.configLocaleValues } );
+
+	/**
+	* The value used to delimit individual dates in a date string passed to various Calendar functions.
+	* @config DATE_DELIMITER
+	* @type String
+	* @default ","
+	*/
+	this.cfg.addProperty("DATE_DELIMITER",		{ value:",", handler:this.configLocale } );
+
+	/**
+	* The value used to delimit date fields in a date string passed to various Calendar functions.
+	* @config DATE_FIELD_DELIMITER
+	* @type String
+	* @default "/"
+	*/
+	this.cfg.addProperty("DATE_FIELD_DELIMITER",{ value:"/", handler:this.configLocale } );
+
+	/**
+	* The value used to delimit date ranges in a date string passed to various Calendar functions.
+	* @config DATE_RANGE_DELIMITER
+	* @type String
+	* @default "-"
+	*/
+	this.cfg.addProperty("DATE_RANGE_DELIMITER",{ value:"-", handler:this.configLocale } );
+
+	/**
+	* The position of the month in a month/year date string
+	* @config MY_MONTH_POSITION
+	* @type Number
+	* @default 1
+	*/
+	this.cfg.addProperty("MY_MONTH_POSITION",	{ value:1, handler:this.configLocale, validator:this.cfg.checkNumber } );
+
+	/**
+	* The position of the year in a month/year date string
+	* @config MY_YEAR_POSITION
+	* @type Number
+	* @default 2
+	*/
+	this.cfg.addProperty("MY_YEAR_POSITION",	{ value:2, handler:this.configLocale, validator:this.cfg.checkNumber } );
+
+	/**
+	* The position of the month in a month/day date string
+	* @config MD_MONTH_POSITION
+	* @type Number
+	* @default 1
+	*/
+	this.cfg.addProperty("MD_MONTH_POSITION",	{ value:1, handler:this.configLocale, validator:this.cfg.checkNumber } );
+
+	/**
+	* The position of the day in a month/year date string
+	* @config MD_DAY_POSITION
+	* @type Number
+	* @default 2
+	*/
+	this.cfg.addProperty("MD_DAY_POSITION",		{ value:2, handler:this.configLocale, validator:this.cfg.checkNumber } );
+
+	/**
+	* The position of the month in a month/day/year date string
+	* @config MDY_MONTH_POSITION
+	* @type Number
+	* @default 1
+	*/
+	this.cfg.addProperty("MDY_MONTH_POSITION",	{ value:1, handler:this.configLocale, validator:this.cfg.checkNumber } );
+
+	/**
+	* The position of the day in a month/day/year date string
+	* @config MDY_DAY_POSITION
+	* @type Number
+	* @default 2
+	*/
+	this.cfg.addProperty("MDY_DAY_POSITION",	{ value:2, handler:this.configLocale, validator:this.cfg.checkNumber } );
+
+	/**
+	* The position of the year in a month/day/year date string
+	* @config MDY_YEAR_POSITION
+	* @type Number
+	* @default 3
+	*/
+	this.cfg.addProperty("MDY_YEAR_POSITION",	{ value:3, handler:this.configLocale, validator:this.cfg.checkNumber } );
 };
 
+/**
+* The default handler for the "pagedate" property
+* @method configPageDate
+*/
+YAHOO.widget.Calendar.prototype.configPageDate = function(type, args, obj) {
+	var val = args[0];
+	var month, year, aMonthYear;
+
+	if (val) {
+		if (val instanceof Date) {
+			val = YAHOO.widget.DateMath.findMonthStart(val);
+			this.cfg.setProperty("pagedate", val, true);
+			if (! this._pageDate) {
+				this._pageDate = this.cfg.getProperty("pagedate");
+			}
+			return;
+		} else {
+			aMonthYear = val.split(this.cfg.getProperty("DATE_FIELD_DELIMITER"));
+			month = parseInt(aMonthYear[this.cfg.getProperty("MY_MONTH_POSITION")-1], 10)-1;
+			year = parseInt(aMonthYear[this.cfg.getProperty("MY_YEAR_POSITION")-1], 10);
+		}
+	} else {
+		month = this.today.getMonth();
+		year = this.today.getFullYear();
+	}
 
+	this.cfg.setProperty("pagedate", new Date(year, month, 1), true);
+	if (! this._pageDate) {
+		this._pageDate = this.cfg.getProperty("pagedate");
+	}
+};
 
 /**
-* Initializes the calendar widget. This method must be called by all subclass constructors.
-* @param {String}	id			The id of the table element that will represent the calendar widget
-* @param {String}	containerId	The id of the container element that will contain the calendar table
-* @param {String}	monthyear	The month/year string used to set the current calendar page
-* @param {String}	selected	A string of date values formatted using the date parser. The built-in
-								default date format is MM/DD/YYYY. Ranges are defined using
-								MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
-								Any combination of these can be combined by delimiting the string with
-								commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
+* The default handler for the "mindate" property
+* @method configMinDate
 */
-YAHOO.widget.Calendar_Core.prototype.init = function(id, containerId, monthyear, selected) {
-	this.setupConfig();
+YAHOO.widget.Calendar.prototype.configMinDate = function(type, args, obj) {
+	var val = args[0];
+	if (typeof val == 'string') {
+		val = this._parseDate(val);
+		this.cfg.setProperty("mindate", new Date(val[0],(val[1]-1),val[2]));
+	}
+};
 
-	this.id = id;
+/**
+* The default handler for the "maxdate" property
+* @method configMaxDate
+*/
+YAHOO.widget.Calendar.prototype.configMaxDate = function(type, args, obj) {
+	var val = args[0];
+	if (typeof val == 'string') {
+		val = this._parseDate(val);
+		this.cfg.setProperty("maxdate", new Date(val[0],(val[1]-1),val[2]));
+	}
+};
+
+/**
+* The default handler for the "selected" property
+* @method configSelected
+*/
+YAHOO.widget.Calendar.prototype.configSelected = function(type, args, obj) {
+	var selected = args[0];
+
+	if (selected) {
+		if (typeof selected == 'string') {
+			this.cfg.setProperty("selected", this._parseDates(selected), true);
+		}
+	}
+	if (! this._selectedDates) {
+		this._selectedDates = this.cfg.getProperty("selected");
+	}
+};
+
+/**
+* The default handler for all configuration options properties
+* @method configOptions
+*/
+YAHOO.widget.Calendar.prototype.configOptions = function(type, args, obj) {
+	type = type.toUpperCase();
+	var val = args[0];
+	this.Options[type] = val;
+};
+
+/**
+* The default handler for all configuration locale properties
+* @method configLocale
+*/
+YAHOO.widget.Calendar.prototype.configLocale = function(type, args, obj) {
+	type = type.toUpperCase();
+	var val = args[0];
+	this.Locale[type] = val;
+
+	this.cfg.refireEvent("LOCALE_MONTHS");
+	this.cfg.refireEvent("LOCALE_WEEKDAYS");
+
+};
+
+/**
+* The default handler for all configuration locale field length properties
+* @method configLocaleValues
+*/
+YAHOO.widget.Calendar.prototype.configLocaleValues = function(type, args, obj) {
+	type = type.toUpperCase();
+	var val = args[0];
+
+	switch (type) {
+		case "LOCALE_MONTHS":
+			switch (val) {
+				case "short":
+					this.Locale.LOCALE_MONTHS = this.cfg.getProperty("MONTHS_SHORT").concat();
+					break;
+				case "long":
+					this.Locale.LOCALE_MONTHS = this.cfg.getProperty("MONTHS_LONG").concat();
+					break;
+			}
+			break;
+		case "LOCALE_WEEKDAYS":
+			switch (val) {
+				case "1char":
+					this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_1CHAR").concat();
+					break;
+				case "short":
+					this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_SHORT").concat();
+					break;
+				case "medium":
+					this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_MEDIUM").concat();
+					break;
+				case "long":
+					this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_LONG").concat();
+					break;
+			}
+
+			var START_WEEKDAY = this.cfg.getProperty("START_WEEKDAY");
+
+			if (START_WEEKDAY > 0) {
+				for (var w=0;w<START_WEEKDAY;++w) {
+					this.Locale.LOCALE_WEEKDAYS.push(this.Locale.LOCALE_WEEKDAYS.shift());
+				}
+			}
+			break;
+	}
+};
+
+/**
+* Defines the style constants for the Calendar
+* @method initStyles
+*/
+YAHOO.widget.Calendar.prototype.initStyles = function() {
+
+	/**
+	* Collection of Style constants for the Calendar
+	* @property Style
+	*/
+	this.Style = {
+		/**
+		* @property Style.CSS_ROW_HEADER
+		*/
+		CSS_ROW_HEADER: "calrowhead",
+		/**
+		* @property Style.CSS_ROW_FOOTER
+		*/
+		CSS_ROW_FOOTER: "calrowfoot",
+		/**
+		* @property Style.CSS_CELL
+		*/
+		CSS_CELL : "calcell",
+		/**
+		* @property Style.CSS_CELL_SELECTED
+		*/
+		CSS_CELL_SELECTED : "selected",
+		/**
+		* @property Style.CSS_CELL_SELECTABLE
+		*/
+		CSS_CELL_SELECTABLE : "selectable",
+		/**
+		* @property Style.CSS_CELL_RESTRICTED
+		*/
+		CSS_CELL_RESTRICTED : "restricted",
+		/**
+		* @property Style.CSS_CELL_TODAY
+		*/
+		CSS_CELL_TODAY : "today",
+		/**
+		* @property Style.CSS_CELL_OOM
+		*/
+		CSS_CELL_OOM : "oom",
+		/**
+		* @property Style.CSS_CELL_OOB
+		*/
+		CSS_CELL_OOB : "previous",
+		/**
+		* @property Style.CSS_HEADER
+		*/
+		CSS_HEADER : "calheader",
+		/**
+		* @property Style.CSS_HEADER_TEXT
+		*/
+		CSS_HEADER_TEXT : "calhead",
+		/**
+		* @property Style.CSS_WEEKDAY_CELL
+		*/
+		CSS_WEEKDAY_CELL : "calweekdaycell",
+		/**
+		* @property Style.CSS_WEEKDAY_ROW
+		*/
+		CSS_WEEKDAY_ROW : "calweekdayrow",
+		/**
+		* @property Style.CSS_FOOTER
+		*/
+		CSS_FOOTER : "calfoot",
+		/**
+		* @property Style.CSS_CALENDAR
+		*/
+		CSS_CALENDAR : "yui-calendar",
+		/**
+		* @property Style.CSS_SINGLE
+		*/
+		CSS_SINGLE : "single",
+		/**
+		* @property Style.CSS_CONTAINER
+		*/
+		CSS_CONTAINER : "yui-calcontainer",
+		/**
+		* @property Style.CSS_NAV_LEFT
+		*/
+		CSS_NAV_LEFT : "calnavleft",
+		/**
+		* @property Style.CSS_NAV_RIGHT
+		*/
+		CSS_NAV_RIGHT : "calnavright",
+		/**
+		* @property Style.CSS_CELL_TOP
+		*/
+		CSS_CELL_TOP : "calcelltop",
+		/**
+		* @property Style.CSS_CELL_LEFT
+		*/
+		CSS_CELL_LEFT : "calcellleft",
+		/**
+		* @property Style.CSS_CELL_RIGHT
+		*/
+		CSS_CELL_RIGHT : "calcellright",
+		/**
+		* @property Style.CSS_CELL_BOTTOM
+		*/
+		CSS_CELL_BOTTOM : "calcellbottom",
+		/**
+		* @property Style.CSS_CELL_HOVER
+		*/
+		CSS_CELL_HOVER : "calcellhover",
+		/**
+		* @property Style.CSS_CELL_HIGHLIGHT1
+		*/
+		CSS_CELL_HIGHLIGHT1 : "highlight1",
+		/**
+		* @property Style.CSS_CELL_HIGHLIGHT2
+		*/
+		CSS_CELL_HIGHLIGHT2 : "highlight2",
+		/**
+		* @property Style.CSS_CELL_HIGHLIGHT3
+		*/
+		CSS_CELL_HIGHLIGHT3 : "highlight3",
+		/**
+		* @property Style.CSS_CELL_HIGHLIGHT4
+		*/
+		CSS_CELL_HIGHLIGHT4 : "highlight4"
+	};
+};
+
+/**
+* Builds the date label that will be displayed in the calendar header or
+* footer, depending on configuration.
+* @method buildMonthLabel
+* @return	{String}	The formatted calendar month label
+*/
+YAHOO.widget.Calendar.prototype.buildMonthLabel = function() {
+	var text = this.Locale.LOCALE_MONTHS[this.cfg.getProperty("pagedate").getMonth()] + " " + this.cfg.getProperty("pagedate").getFullYear();
+	return text;
+};
+
+/**
+* Builds the date digit that will be displayed in calendar cells
+* @method buildDayLabel
+* @param {Date}	workingDate	The current working date
+* @return	{String}	The formatted day label
+*/
+YAHOO.widget.Calendar.prototype.buildDayLabel = function(workingDate) {
+	var day = workingDate.getDate();
+	return day;
+};
+
+/**
+* Renders the calendar header.
+* @method renderHeader
+* @param {Array}	html	The current working HTML array
+* @return {Array} The current working HTML array
+*/
+YAHOO.widget.Calendar.prototype.renderHeader = function(html) {
+	var colSpan = 7;
+
+	if (this.cfg.getProperty("SHOW_WEEK_HEADER")) {
+		colSpan += 1;
+	}
+
+	if (this.cfg.getProperty("SHOW_WEEK_FOOTER")) {
+		colSpan += 1;
+	}
+
+	html[html.length] = "<thead>";
+	html[html.length] =		"<tr>";
+	html[html.length] =			'<th colspan="' + colSpan + '" class="' + this.Style.CSS_HEADER_TEXT + '">';
+	html[html.length] =				'<div class="' + this.Style.CSS_HEADER + '">';
+
+		var renderLeft, renderRight = false;
+
+		if (this.parent) {
+			if (this.index === 0) {
+				renderLeft = true;
+			}
+			if (this.index == (this.parent.cfg.getProperty("pages") -1)) {
+				renderRight = true;
+			}
+		} else {
+			renderLeft = true;
+			renderRight = true;
+		}
+
+		var cal = this.parent || this;
+
+		if (renderLeft) {
+			html[html.length] = '<a class="' + this.Style.CSS_NAV_LEFT + '" style="background-image:url(' + this.cfg.getProperty("NAV_ARROW_LEFT") + ')">&#160;</a>';
+		}
+
+		html[html.length] = this.buildMonthLabel();
+
+		if (renderRight) {
+			html[html.length] = '<a class="' + this.Style.CSS_NAV_RIGHT + '" style="background-image:url(' + this.cfg.getProperty("NAV_ARROW_RIGHT") + ')">&#160;</a>';
+		}
+
+
+	html[html.length] =				'</div>';
+	html[html.length] =			'</th>';
+	html[html.length] =		'</tr>';
+
+	if (this.cfg.getProperty("SHOW_WEEKDAYS")) {
+		html = this.buildWeekdays(html);
+	}
+
+	html[html.length] = '</thead>';
+
+	return html;
+};
+
+/**
+* Renders the Calendar's weekday headers.
+* @method buildWeekdays
+* @param {Array}	html	The current working HTML array
+* @return {Array} The current working HTML array
+*/
+YAHOO.widget.Calendar.prototype.buildWeekdays = function(html) {
+
+	html[html.length] = '<tr class="' + this.Style.CSS_WEEKDAY_ROW + '">';
+
+	if (this.cfg.getProperty("SHOW_WEEK_HEADER")) {
+		html[html.length] = '<th>&#160;</th>';
+	}
+
+	for(var i=0;i<this.Locale.LOCALE_WEEKDAYS.length;++i) {
+		html[html.length] = '<th class="calweekdaycell">' + this.Locale.LOCALE_WEEKDAYS[i] + '</th>';
+	}
+
+	if (this.cfg.getProperty("SHOW_WEEK_FOOTER")) {
+		html[html.length] = '<th>&#160;</th>';
+	}
+
+	html[html.length] = '</tr>';
+
+	return html;
+};
+
+/**
+* Renders the calendar body.
+* @method renderBody
+* @param {Date}	workingDate	The current working Date being used for the render process
+* @param {Array}	html	The current working HTML array
+* @return {Array} The current working HTML array
+*/
+YAHOO.widget.Calendar.prototype.renderBody = function(workingDate, html) {
+
+	var startDay = this.cfg.getProperty("START_WEEKDAY");
+
+	this.preMonthDays = workingDate.getDay();
+	if (startDay > 0) {
+		this.preMonthDays -= startDay;
+	}
+	if (this.preMonthDays < 0) {
+		this.preMonthDays += 7;
+	}
+
+	this.monthDays = YAHOO.widget.DateMath.findMonthEnd(workingDate).getDate();
+	this.postMonthDays = YAHOO.widget.Calendar.DISPLAY_DAYS-this.preMonthDays-this.monthDays;
+
+	workingDate = YAHOO.widget.DateMath.subtract(workingDate, YAHOO.widget.DateMath.DAY, this.preMonthDays);
+
+	var useDate,weekNum,weekClass;
+	useDate = this.cfg.getProperty("pagedate");
+
+	html[html.length] = '<tbody class="m' + (useDate.getMonth()+1) + '">';
+
+	var i = 0;
+
+	var tempDiv = document.createElement("div");
+	var cell = document.createElement("td");
+	tempDiv.appendChild(cell);
+
+	var jan1 = new Date(useDate.getFullYear(),0,1);
+
+	var cal = this.parent || this;
+
+	for (var r=0;r<6;r++) {
+
+		weekNum = YAHOO.widget.DateMath.getWeekNumber(workingDate, useDate.getFullYear(), startDay);
+
+		weekClass = "w" + weekNum;
+
+		if (r !== 0 && this.isDateOOM(workingDate) && this.cfg.getProperty("HIDE_BLANK_WEEKS") === true) {
+			break;
+		} else {
 
-	this.cellDates = new Array();
-	
-	this.cells = new Array();
-	
-	this.renderStack = new Array();
-	this._renderStack = new Array();
+			html[html.length] = '<tr class="' + weekClass + '">';
 
-	this.oDomContainer = document.getElementById(containerId);
-	
-	this.today = new Date();
-	YAHOO.widget.DateMath.clearTime(this.today);
+			if (this.cfg.getProperty("SHOW_WEEK_HEADER")) { html = this.renderRowHeader(weekNum, html); }
 
-	var month;
-	var year;
+			for (var d=0;d<7;d++){ // Render actual days
 
-	if (monthyear)
-	{
-		var aMonthYear = monthyear.split(this.Locale.DATE_FIELD_DELIMITER);
-        /* The following two calls to parseInt had an explicit radix added
-           so dates with leading zeros aren't parsed as octal. */
-		month = parseInt(aMonthYear[this.Locale.MY_MONTH_POSITION-1], 10);
-		year = parseInt(aMonthYear[this.Locale.MY_YEAR_POSITION-1], 10);
-	} else {
-		month = this.today.getMonth()+1;
-		year = this.today.getFullYear();
-	}
+				var cellRenderers = [];
 
-	this.pageDate = new Date(year, month-1, 1);
-	this._pageDate = new Date(this.pageDate.getTime());
+				this.clearElement(cell);
 
-	if (selected)
-	{
-		this.selectedDates = this._parseDates(selected);
-		this._selectedDates = this.selectedDates.concat();
-	} else {
-		this.selectedDates = new Array();
-		this._selectedDates = new Array();
-	}
+				YAHOO.util.Dom.addClass(cell, "calcell");
 
-	this.wireDefaultEvents();
-	this.wireCustomEvents();
-};
+				cell.id = this.id + "_cell" + i;
 
+				cell.innerHTML = i;
 
-/**
-* Wires the local DOM events for the Calendar, including cell selection, hover, and
-* default navigation that is used for moving back and forth between calendar pages.
-*/
-YAHOO.widget.Calendar_Core.prototype.wireDefaultEvents = function() {
-	
-	/**
-	* The default event function that is attached to a date link within a calendar cell
-	* when the calendar is rendered. 
-	* @param	e		The event
-	* @param	cal		A reference to the calendar passed by the Event utility
-	*/
-	this.doSelectCell = function(e, cal) {		
-		var cell = this;
-		var index = cell.index;
-		var d = cal.cellDates[index];
-		var date = new Date(d[0],d[1]-1,d[2]);
-		
-		/* if (! cal.isDateOOM(date) && ! YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_RESTRICTED) && ! YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_OOB)) { */
-        /* MODIFIED BY JESSE VINCENT ON 2006-11-29 TO ALLOW OOM DATES TO BE CLICKABLE*/
+				var renderer = null;
 
-		if ( ! YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_RESTRICTED) && ! YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_OOB)) {
-			if (cal.Options.MULTI_SELECT) {
-				var link = cell.getElementsByTagName("A")[0];
-				link.blur();
-				
-				var cellDate = cal.cellDates[index];
-				var cellDateIndex = cal._indexOfSelectedFieldArray(cellDate);
-				
-				if (cellDateIndex > -1)
-				{	
-					cal.deselectCell(index);
-				} else {
-					cal.selectCell(index);
-				}	
-				
-			} else {
-				var link = cell.getElementsByTagName("A")[0];
-				link.blur()
-				cal.selectCell(index);
-			}
-		}
-	}
+				if (workingDate.getFullYear()	== this.today.getFullYear() &&
+					workingDate.getMonth()		== this.today.getMonth() &&
+					workingDate.getDate()		== this.today.getDate()) {
+					cellRenderers[cellRenderers.length]=cal.renderCellStyleToday;
+				}
 
-	/**
-	* The event that is executed when the user hovers over a cell
-	* @param	e		The event
-	* @param	cal		A reference to the calendar passed by the Event utility
-	* @private
-	*/
-	this.doCellMouseOver = function(e, cal) {
-		var cell = this;
-		var index = cell.index;
-		var d = cal.cellDates[index];
-		var date = new Date(d[0],d[1]-1,d[2]);
+				this.cellDates[this.cellDates.length]=[workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()]; // Add this date to cellDates
 
-		if (! cal.isDateOOM(date) && ! YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_RESTRICTED) && ! YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_OOB)) {
-			YAHOO.widget.Calendar_Core.prependCssClass(cell, cal.Style.CSS_CELL_HOVER);
-		}
-	}
+				if (this.isDateOOM(workingDate)) {
+					cellRenderers[cellRenderers.length]=cal.renderCellNotThisMonth;
+				} else {
 
-	/**
-	* The event that is executed when the user moves the mouse out of a cell
-	* @param	e		The event
-	* @param	cal		A reference to the calendar passed by the Event utility
-	* @private
-	*/
-	this.doCellMouseOut = function(e, cal) {
-		YAHOO.widget.Calendar_Core.removeCssClass(this, cal.Style.CSS_CELL_HOVER);
-	}
-	
-	/**
-	* A wrapper event that executes the nextMonth method through a DOM event
-	* @param	e		The event
-	* @param	cal		A reference to the calendar passed by the Event utility
-	* @private
-	*/	
-	this.doNextMonth = function(e, cal) {
-		cal.nextMonth();
-	}
+					YAHOO.util.Dom.addClass(cell, "wd" + workingDate.getDay());
+					YAHOO.util.Dom.addClass(cell, "d" + workingDate.getDate());
 
-	/**
-	* A wrapper event that executes the previousMonth method through a DOM event
-	* @param	e		The event
-	* @param	cal		A reference to the calendar passed by the Event utility
-	* @private
-	*/		
-	this.doPreviousMonth = function(e, cal) {
-		cal.previousMonth();
-	}
-}
+					for (var s=0;s<this.renderStack.length;++s) {
 
-/**
-* This function can be extended by subclasses to attach additional DOM events to
-* the calendar. By default, this method is unimplemented.
-*/
-YAHOO.widget.Calendar_Core.prototype.wireCustomEvents = function() { }
+						var rArray = this.renderStack[s];
+						var type = rArray[0];
 
-/**
-This method is called to initialize the widget configuration variables, including
-style, localization, and other display and behavioral options.
-<p>Config: Container for the CSS style configuration variables.</p>
-<p><strong>Config.Style</strong> - Defines the CSS classes used for different calendar elements</p>
-<blockquote>
-	<div><em>CSS_CALENDAR</em> : Container table</div>
-	<div><em>CSS_HEADER</em> : </div>
-	<div><em>CSS_HEADER_TEXT</em> : Calendar header</div>
-	<div><em>CSS_FOOTER</em> : Calendar footer</div>
-	<div><em>CSS_CELL</em> : Calendar day cell</div>
-	<div><em>CSS_CELL_OOM</em> : Calendar OOM (out of month) cell</div>
-	<div><em>CSS_CELL_SELECTED</em> : Calendar selected cell</div>
-	<div><em>CSS_CELL_RESTRICTED</em> : Calendar restricted cell</div>
-	<div><em>CSS_CELL_TODAY</em> : Calendar cell for today's date</div>
-	<div><em>CSS_ROW_HEADER</em> : The cell preceding a row (used for week number by default)</div>
-	<div><em>CSS_ROW_FOOTER</em> : The cell following a row (not implemented by default)</div>
-	<div><em>CSS_WEEKDAY_CELL</em> : The cells used for labeling weekdays</div>
-	<div><em>CSS_WEEKDAY_ROW</em> : The row containing the weekday label cells</div>
-	<div><em>CSS_BORDER</em> : The border style used for the default UED rendering</div>
-	<div><em>CSS_CONTAINER</em> : Special container class used to properly adjust the sizing and float</div>
-	<div><em>CSS_NAV_LEFT</em> : Left navigation arrow</div>
-	<div><em>CSS_NAV_RIGHT</em> : Right navigation arrow</div>
-	<div><em>CSS_CELL_TOP</em> : Outlying cell along the top row</div>
-	<div><em>CSS_CELL_LEFT</em> : Outlying cell along the left row</div>
-	<div><em>CSS_CELL_RIGHT</em> : Outlying cell along the right row</div>
-	<div><em>CSS_CELL_BOTTOM</em> : Outlying cell along the bottom row</div>
-	<div><em>CSS_CELL_HOVER</em> : Cell hover style</div>
-	<div><em>CSS_CELL_HIGHLIGHT1</em> : Highlight color 1 for styling cells</div>
-	<div><em>CSS_CELL_HIGHLIGHT2</em> : Highlight color 2 for styling cells</div>
-	<div><em>CSS_CELL_HIGHLIGHT3</em> : Highlight color 3 for styling cells</div>
-	<div><em>CSS_CELL_HIGHLIGHT4</em> : Highlight color 4 for styling cells</div>
-
-</blockquote>
-<p><strong>Config.Locale</strong> - Defines the locale string arrays used for localization</p>
-<blockquote>
-	<div><em>MONTHS_SHORT</em> : Array of 12 months in short format ("Jan", "Feb", etc.)</div>
-	<div><em>MONTHS_LONG</em> : Array of 12 months in short format ("Jan", "Feb", etc.)</div>
-	<div><em>WEEKDAYS_1CHAR</em> : Array of 7 days in 1-character format ("S", "M", etc.)</div>
-	<div><em>WEEKDAYS_SHORT</em> : Array of 7 days in short format ("Su", "Mo", etc.)</div>
-	<div><em>WEEKDAYS_MEDIUM</em> : Array of 7 days in medium format ("Sun", "Mon", etc.)</div>
-	<div><em>WEEKDAYS_LONG</em> : Array of 7 days in long format ("Sunday", "Monday", etc.)</div>
-	<div><em>DATE_DELIMITER</em> : The value used to delimit series of multiple dates (Default: ",")</div>
-	<div><em>DATE_FIELD_DELIMITER</em> : The value used to delimit date fields (Default: "/")</div>
-	<div><em>DATE_RANGE_DELIMITER</em> : The value used to delimit date fields (Default: "-")</div>
-	<div><em>MY_MONTH_POSITION</em> : The value used to determine the position of the month in a month/year combo (e.g. 12/2005) (Default: 1)</div>
-	<div><em>MY_YEAR_POSITION</em> : The value used to determine the position of the year in a month/year combo (e.g. 12/2005) (Default: 2)</div>	
-	<div><em>MD_MONTH_POSITION</em> : The value used to determine the position of the month in a month/day combo (e.g. 12/25) (Default: 1)</div>
-	<div><em>MD_DAY_POSITION</em> : The value used to determine the position of the day in a month/day combo (e.g. 12/25) (Default: 2)</div>
-	<div><em>MDY_MONTH_POSITION</em> : The value used to determine the position of the month in a month/day/year combo (e.g. 12/25/2005) (Default: 1)</div>
-	<div><em>MDY_DAY_POSITION</em> : The value used to determine the position of the day in a month/day/year combo (e.g. 12/25/2005) (Default: 2)</div>
-	<div><em>MDY_YEAR_POSITION</em> : The value used to determine the position of the year in a month/day/year combo (e.g. 12/25/2005) (Default: 3)</div>
-</blockquote>
-<p><strong>Config.Options</strong> - Defines other configurable calendar widget options</p>
-<blockquote>
-	<div><em>SHOW_WEEKDAYS</em> : Boolean, determines whether to display the weekday headers (defaults to true)</div>
-	<div><em>LOCALE_MONTHS</em> : Array, points to the desired Config.Locale array (defaults to Config.Locale.MONTHS_LONG)</div>
-	<div><em>LOCALE_WEEKDAYS</em> : Array, points to the desired Config.Locale array (defaults to Config.Locale.WEEKDAYS_SHORT)</div>
-	<div><em>START_WEEKDAY</em> : Integer, 0-6, representing the day that a week begins on</div>
-	<div><em>SHOW_WEEK_HEADER</em> : Boolean, determines whether to display row headers</div>
-	<div><em>SHOW_WEEK_FOOTER</em> : Boolean, determines whether to display row footers</div>
-	<div><em>HIDE_BLANK_WEEKS</em> : Boolean, determines whether to hide extra weeks that are completely OOM</div>
-	<div><em>NAV_ARROW_LEFT</em> : String, the image path used for the left navigation arrow</div>
-	<div><em>NAV_ARROW_RIGHT</em> : String, the image path used for the right navigation arrow</div>
-</blockquote>
-*/
-YAHOO.widget.Calendar_Core.prototype.setupConfig = function() {
-	/**
-	* Container for the CSS style configuration variables.
-	*/
-	this.Config = new Object();
-	
-	this.Config.Style = {
-		// Style variables
-		CSS_ROW_HEADER: "calrowhead",
-		CSS_ROW_FOOTER: "calrowfoot",
-		CSS_CELL : "calcell",
-		CSS_CELL_SELECTED : "selected",
-		CSS_CELL_RESTRICTED : "restricted",
-		CSS_CELL_TODAY : "today",
-		CSS_CELL_OOM : "oom",
-		CSS_CELL_OOB : "previous",
-		CSS_HEADER : "calheader",
-		CSS_HEADER_TEXT : "calhead",
-		CSS_WEEKDAY_CELL : "calweekdaycell",
-		CSS_WEEKDAY_ROW : "calweekdayrow",
-		CSS_FOOTER : "calfoot",
-		CSS_CALENDAR : "calendar",
-		CSS_BORDER : "calbordered",
-		CSS_CONTAINER : "calcontainer", 
-		CSS_NAV_LEFT : "calnavleft",
-		CSS_NAV_RIGHT : "calnavright",
-		CSS_CELL_TOP : "calcelltop",
-		CSS_CELL_LEFT : "calcellleft",
-		CSS_CELL_RIGHT : "calcellright",
-		CSS_CELL_BOTTOM : "calcellbottom",
-		CSS_CELL_HOVER : "calcellhover",
-		CSS_CELL_HIGHLIGHT1 : "highlight1",
-		CSS_CELL_HIGHLIGHT2 : "highlight2",
-		CSS_CELL_HIGHLIGHT3 : "highlight3",
-		CSS_CELL_HIGHLIGHT4 : "highlight4"
-	};
+						var month;
+						var day;
+						var year;
+
+						switch (type) {
+							case YAHOO.widget.Calendar.DATE:
+								month = rArray[1][1];
+								day = rArray[1][2];
+								year = rArray[1][0];
+
+								if (workingDate.getMonth()+1 == month && workingDate.getDate() == day && workingDate.getFullYear() == year) {
+									renderer = rArray[2];
+									this.renderStack.splice(s,1);
+								}
+								break;
+							case YAHOO.widget.Calendar.MONTH_DAY:
+								month = rArray[1][0];
+								day = rArray[1][1];
+
+								if (workingDate.getMonth()+1 == month && workingDate.getDate() == day) {
+									renderer = rArray[2];
+									this.renderStack.splice(s,1);
+								}
+								break;
+							case YAHOO.widget.Calendar.RANGE:
+								var date1 = rArray[1][0];
+								var date2 = rArray[1][1];
+
+								var d1month = date1[1];
+								var d1day = date1[2];
+								var d1year = date1[0];
+
+								var d1 = new Date(d1year, d1month-1, d1day);
+
+								var d2month = date2[1];
+								var d2day = date2[2];
+								var d2year = date2[0];
+
+								var d2 = new Date(d2year, d2month-1, d2day);
+
+								if (workingDate.getTime() >= d1.getTime() && workingDate.getTime() <= d2.getTime()) {
+									renderer = rArray[2];
+
+									if (workingDate.getTime()==d2.getTime()) {
+										this.renderStack.splice(s,1);
+									}
+								}
+								break;
+							case YAHOO.widget.Calendar.WEEKDAY:
+
+								var weekday = rArray[1][0];
+								if (workingDate.getDay()+1 == weekday) {
+									renderer = rArray[2];
+								}
+								break;
+							case YAHOO.widget.Calendar.MONTH:
+
+								month = rArray[1][0];
+								if (workingDate.getMonth()+1 == month) {
+									renderer = rArray[2];
+								}
+								break;
+						}
 
-	this.Style = this.Config.Style;
+						if (renderer) {
+							cellRenderers[cellRenderers.length]=renderer;
+						}
+					}
 
-	this.Config.Locale = {
-		// Locale definition
-		MONTHS_SHORT : ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
-		MONTHS_LONG : ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
-		WEEKDAYS_1CHAR : ["S", "M", "T", "W", "T", "F", "S"],
-		WEEKDAYS_SHORT : ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
-		WEEKDAYS_MEDIUM : ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
-		WEEKDAYS_LONG : ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
-		DATE_DELIMITER : ",",
-		DATE_FIELD_DELIMITER : "/",
-		DATE_RANGE_DELIMITER : "-",
-		MY_MONTH_POSITION : 1,
-		MY_YEAR_POSITION : 2,
-		MD_MONTH_POSITION : 1,
-		MD_DAY_POSITION : 2,
-		MDY_MONTH_POSITION : 1,
-		MDY_DAY_POSITION : 2,
-		MDY_YEAR_POSITION : 3
-	};
+				}
 
-	this.Locale = this.Config.Locale;
+				if (this._indexOfSelectedFieldArray([workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()]) > -1) {
+					cellRenderers[cellRenderers.length]=cal.renderCellStyleSelected;
+				}
 
-	this.Config.Options = {
-		// Configuration variables
-		MULTI_SELECT : false,
-		SHOW_WEEKDAYS : true,
-		START_WEEKDAY : 0,
-		SHOW_WEEK_HEADER : false,
-		SHOW_WEEK_FOOTER : false,
-		HIDE_BLANK_WEEKS : false,
-		NAV_ARROW_LEFT : YAHOO.widget.Calendar_Core.IMG_ROOT + "us/tr/callt.gif",
-		NAV_ARROW_RIGHT : YAHOO.widget.Calendar_Core.IMG_ROOT + "us/tr/calrt.gif"
-	};
+				var mindate = this.cfg.getProperty("mindate");
+				var maxdate = this.cfg.getProperty("maxdate");
 
-	this.Options = this.Config.Options;
+				if (mindate) {
+					mindate = YAHOO.widget.DateMath.clearTime(mindate);
+				}
+				if (maxdate) {
+					maxdate = YAHOO.widget.DateMath.clearTime(maxdate);
+				}
 
-	this.customConfig();
+				if (
+					(mindate && (workingDate.getTime() < mindate.getTime())) ||
+					(maxdate && (workingDate.getTime() > maxdate.getTime()))
+				) {
+					cellRenderers[cellRenderers.length]=cal.renderOutOfBoundsDate;
+				} else {
+					cellRenderers[cellRenderers.length]=cal.styleCellDefault;
+					cellRenderers[cellRenderers.length]=cal.renderCellDefault;
+				}
 
-	if (! this.Options.LOCALE_MONTHS) {
-		this.Options.LOCALE_MONTHS=this.Locale.MONTHS_LONG;
-	}
-	if (! this.Options.LOCALE_WEEKDAYS) {
-		this.Options.LOCALE_WEEKDAYS=this.Locale.WEEKDAYS_SHORT;
-	}
 
-	// If true, reconfigure weekday arrays to place Mondays first
-	if (this.Options.START_WEEKDAY > 0)
-	{
-		for (var w=0;w<this.Options.START_WEEKDAY;++w) {
-			this.Locale.WEEKDAYS_SHORT.push(this.Locale.WEEKDAYS_SHORT.shift());
-			this.Locale.WEEKDAYS_MEDIUM.push(this.Locale.WEEKDAYS_MEDIUM.shift());
-			this.Locale.WEEKDAYS_LONG.push(this.Locale.WEEKDAYS_LONG.shift());		
-		}
-	}
-};
 
-/**
-* This method is called when subclasses need to override configuration variables
-* or create new ones. Values can be explicitly set as follows:
-* <blockquote><code>
-*	this.Config.Style.CSS_CELL = "newcalcell";
-*	this.Config.Locale.MONTHS_SHORT = ["Jan", "Fv", "Mars", "Avr", "Mai", "Juin", "Juil", "Aot", "Sept", "Oct", "Nov", "Dc"];
-* </code></blockquote>
-*/
-YAHOO.widget.Calendar_Core.prototype.customConfig = function() { };
+				for (var x=0;x<cellRenderers.length;++x) {
+					var ren = cellRenderers[x];
+					if (ren.call((this.parent || this),workingDate,cell) == YAHOO.widget.Calendar.STOP_RENDER) {
+						break;
+					}
+				}
 
-/**
-* Builds the date label that will be displayed in the calendar header or
-* footer, depending on configuration.
-* @return	The formatted calendar month label
-* @type String
-*/
-YAHOO.widget.Calendar_Core.prototype.buildMonthLabel = function() {
-	var text = this.Options.LOCALE_MONTHS[this.pageDate.getMonth()] + " " + this.pageDate.getFullYear();
-	return text;
-};
+				workingDate.setTime(workingDate.getTime() + YAHOO.widget.DateMath.ONE_DAY_MS);
 
-/**
-* Builds the date digit that will be displayed in calendar cells
-* @return	The formatted day label
-* @type	String
-*/
-YAHOO.widget.Calendar_Core.prototype.buildDayLabel = function(workingDate) {
-	var day = workingDate.getDate();
-	return day;
-};
+				if (i >= 0 && i <= 6) {
+					YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_TOP);
+				}
+				if ((i % 7) === 0) {
+					YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_LEFT);
+				}
+				if (((i+1) % 7) === 0) {
+					YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_RIGHT);
+				}
 
+				var postDays = this.postMonthDays;
+				if (postDays >= 7 && this.cfg.getProperty("HIDE_BLANK_WEEKS")) {
+					var blankWeeks = Math.floor(postDays/7);
+					for (var p=0;p<blankWeeks;++p) {
+						postDays -= 7;
+					}
+				}
 
+				if (i >= ((this.preMonthDays+postDays+this.monthDays)-7)) {
+					YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_BOTTOM);
+				}
 
-/**
-* Builds the calendar table shell that will be filled in with dates and formatting.
-* This method calls buildShellHeader, buildShellBody, and buildShellFooter (in that order) 
-* to construct the pieces of the calendar table. The construction of the shell should
-* only happen one time when the calendar is initialized.
-*/
-YAHOO.widget.Calendar_Core.prototype.buildShell = function() {
-	
-	this.table = document.createElement("TABLE");
-	this.table.cellSpacing = 0;	
-	YAHOO.widget.Calendar_Core.setCssClasses(this.table, [this.Style.CSS_CALENDAR]);
-
-	this.table.id = this.id;
-	
-	this.buildShellHeader();
-	this.buildShellBody();
-	this.buildShellFooter();
-	
-	YAHOO.util.Event.addListener(window, "unload", this._unload, this);
-};
+				html[html.length] = tempDiv.innerHTML;
 
-/**
-* Builds the calendar shell header by inserting a THEAD into the local calendar table.
-*/
-YAHOO.widget.Calendar_Core.prototype.buildShellHeader = function() {
-	var head = document.createElement("THEAD");
-	var headRow = document.createElement("TR");
+				i++;
+			}
 
-	var headerCell = document.createElement("TH");
-	
-	var colSpan = 7;
-	if (this.Config.Options.SHOW_WEEK_HEADER) {
-		this.weekHeaderCells = new Array();
-		colSpan += 1;
-	}
-	if (this.Config.Options.SHOW_WEEK_FOOTER) {
-		this.weekFooterCells = new Array();
-		colSpan += 1;
-	}	
-	
-	headerCell.colSpan = colSpan;
-	
-	YAHOO.widget.Calendar_Core.setCssClasses(headerCell,[this.Style.CSS_HEADER_TEXT]);
-
-	this.headerCell = headerCell;
-
-	headRow.appendChild(headerCell);
-	head.appendChild(headRow);
-
-	// Append day labels, if needed
-	if (this.Options.SHOW_WEEKDAYS)
-	{
-		var row = document.createElement("TR");
-		var fillerCell;
-
-		YAHOO.widget.Calendar_Core.setCssClasses(row,[this.Style.CSS_WEEKDAY_ROW]);
-		
-		if (this.Config.Options.SHOW_WEEK_HEADER) {
-			fillerCell = document.createElement("TH");
-			YAHOO.widget.Calendar_Core.setCssClasses(fillerCell,[this.Style.CSS_WEEKDAY_CELL]);
-			row.appendChild(fillerCell);
-		}
-		
-		for(var i=0;i<this.Options.LOCALE_WEEKDAYS.length;++i)
-		{
-			var cell = document.createElement("TH");
-			YAHOO.widget.Calendar_Core.setCssClasses(cell,[this.Style.CSS_WEEKDAY_CELL]);
-			cell.innerHTML=this.Options.LOCALE_WEEKDAYS[i];
-			row.appendChild(cell);
-		}
-
-		if (this.Config.Options.SHOW_WEEK_FOOTER) {
-			fillerCell = document.createElement("TH");
-			YAHOO.widget.Calendar_Core.setCssClasses(fillerCell,[this.Style.CSS_WEEKDAY_CELL]);
-			row.appendChild(fillerCell);
-		}
-				
-		head.appendChild(row);
-	}
-
-	this.table.appendChild(head);
-};
-
-/**
-* Builds the calendar shell body (6 weeks by 7 days)
-*/
-YAHOO.widget.Calendar_Core.prototype.buildShellBody = function() {
-	// This should only get executed once
-	this.tbody = document.createElement("TBODY");
-
-	for (var r=0;r<6;++r)
-	{
-		var row = document.createElement("TR");
-		
-		for (var c=0;c<this.headerCell.colSpan;++c)
-		{
-			var cell;
-			if (this.Config.Options.SHOW_WEEK_HEADER && c===0) { // Row header
-				cell = document.createElement("TH");
-				this.weekHeaderCells[this.weekHeaderCells.length] = cell;
-			} else if (this.Config.Options.SHOW_WEEK_FOOTER && c==(this.headerCell.colSpan-1)){ // Row footer
-				cell = document.createElement("TH");
-				this.weekFooterCells[this.weekFooterCells.length] = cell;
-			} else {
-				cell = document.createElement("TD");
-				this.cells[this.cells.length] = cell;
-				YAHOO.widget.Calendar_Core.setCssClasses(cell, [this.Style.CSS_CELL]);
-				YAHOO.util.Event.addListener(cell, "click", this.doSelectCell, this);
+			if (this.cfg.getProperty("SHOW_WEEK_FOOTER")) { html = this.renderRowFooter(weekNum, html); }
 
-				YAHOO.util.Event.addListener(cell, "mouseover", this.doCellMouseOver, this);
-				YAHOO.util.Event.addListener(cell, "mouseout", this.doCellMouseOut, this);
-			}
-			row.appendChild(cell);
+			html[html.length] = '</tr>';
 		}
-		this.tbody.appendChild(row);
 	}
-	
-	this.table.appendChild(this.tbody);
+
+	html[html.length] = '</tbody>';
+
+	return html;
 };
 
 /**
-* Builds the calendar shell footer. In the default implementation, there is
+* Renders the calendar footer. In the default implementation, there is
 * no footer.
+* @method renderFooter
+* @param {Array}	html	The current working HTML array
+* @return {Array} The current working HTML array
 */
-YAHOO.widget.Calendar_Core.prototype.buildShellFooter = function() { };
-
-/**
-* Outputs the calendar shell to the DOM, inserting it into the placeholder element.
-*/
-YAHOO.widget.Calendar_Core.prototype.renderShell = function() {
-	this.oDomContainer.appendChild(this.table);
-	this.shellRendered = true;
-};
+YAHOO.widget.Calendar.prototype.renderFooter = function(html) { return html; };
 
 /**
 * Renders the calendar after it has been configured. The render() method has a specific call chain that will execute
 * when the method is called: renderHeader, renderBody, renderFooter.
-* Refer to the documentation for those methods for information on 
+* Refer to the documentation for those methods for information on
 * individual render tasks.
+* @method render
 */
-YAHOO.widget.Calendar_Core.prototype.render = function() {
-	if (! this.shellRendered)
-	{
-		this.buildShell();
-		this.renderShell();
-	}
+YAHOO.widget.Calendar.prototype.render = function() {
+	this.beforeRenderEvent.fire();
 
-	this.resetRenderers();
+	// Find starting day of the current month
+	var workingDate = YAHOO.widget.DateMath.findMonthStart(this.cfg.getProperty("pagedate"));
 
+	this.resetRenderers();
 	this.cellDates.length = 0;
 
-	// Find starting day of the current month
-	var workingDate = YAHOO.widget.DateMath.findMonthStart(this.pageDate);
+	YAHOO.util.Event.purgeElement(this.oDomContainer, true);
 
-	this.renderHeader();
-	this.renderBody(workingDate);
-	this.renderFooter();
+	var html = [];
 
-	this.onRender();
-};
+	html[html.length] = '<table cellSpacing="0" class="' + this.Style.CSS_CALENDAR + ' y' + workingDate.getFullYear() + '" id="' + this.id + '">';
+	html = this.renderHeader(html);
+	html = this.renderBody(workingDate, html);
+	html = this.renderFooter(html);
+	html[html.length] = '</table>';
 
+	this.oDomContainer.innerHTML = html.join("\n");
 
+	this.applyListeners();
+	this.cells = this.oDomContainer.getElementsByTagName("td");
 
-/**
-* Appends the header contents into the widget header.
-*/
-YAHOO.widget.Calendar_Core.prototype.renderHeader = function() {
-	this.headerCell.innerHTML = "";
-	
-	var headerContainer = document.createElement("DIV");
-	headerContainer.className = this.Style.CSS_HEADER;
-	
-	headerContainer.appendChild(document.createTextNode(this.buildMonthLabel()));
-	
-	this.headerCell.appendChild(headerContainer);
+	this.cfg.refireEvent("title");
+	this.cfg.refireEvent("close");
+	this.cfg.refireEvent("iframe");
+
+	this.renderEvent.fire();
 };
 
 /**
-* Appends the calendar body. The default implementation calculates the number of
-* OOM (out of month) cells that need to be rendered at the start of the month, renders those, 
-* and renders all the day cells using the built-in cell rendering methods.
-*
-* While iterating through all of the cells, the calendar checks for renderers in the
-* local render stack that match the date of the current cell, and then applies styles
-* as necessary.
-* 
-* @param {Date}	workingDate	The current working Date object being used to generate the calendar
+* Applies the Calendar's DOM listeners to applicable elements.
+* @method applyListeners
 */
-YAHOO.widget.Calendar_Core.prototype.renderBody = function(workingDate) {
-
-	this.preMonthDays = workingDate.getDay();
-	if (this.Options.START_WEEKDAY > 0) {
-		this.preMonthDays -= this.Options.START_WEEKDAY;
-	}
-	if (this.preMonthDays < 0) {
-		this.preMonthDays += 7;
-	}
-	
-	this.monthDays = YAHOO.widget.DateMath.findMonthEnd(workingDate).getDate();
-	this.postMonthDays = YAHOO.widget.Calendar_Core.DISPLAY_DAYS-this.preMonthDays-this.monthDays;
-	
-	workingDate = YAHOO.widget.DateMath.subtract(workingDate, YAHOO.widget.DateMath.DAY, this.preMonthDays);
-	
-	var weekRowIndex = 0;
-	
-	for (var c=0;c<this.cells.length;++c)
-	{
-		var cellRenderers = new Array();
-		
-		var cell = this.cells[c];
-		this.clearElement(cell);
-
-		cell.index = c;
-		cell.id = this.id + "_cell" + c;
-		
-		this.cellDates[this.cellDates.length]=[workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()]; // Add this date to cellDates
-
-		if (workingDate.getDay() == this.Options.START_WEEKDAY) {
-			var rowHeaderCell = null;
-			var rowFooterCell = null;
-			
-			if (this.Options.SHOW_WEEK_HEADER) {
-				rowHeaderCell = this.weekHeaderCells[weekRowIndex];
-				this.clearElement(rowHeaderCell);
-			}
-			
-			if (this.Options.SHOW_WEEK_FOOTER) {
-				rowFooterCell = this.weekFooterCells[weekRowIndex];
-				this.clearElement(rowFooterCell);
-			}			
-			
-			if (this.Options.HIDE_BLANK_WEEKS && this.isDateOOM(workingDate) && ! YAHOO.widget.DateMath.isMonthOverlapWeek(workingDate)) {
-				// The first day of the week is not in this month, and it's not an overlap week
-				continue;
-			} else {
-				if (rowHeaderCell) {
-					this.renderRowHeader(workingDate, rowHeaderCell);
-				}
-				if (rowFooterCell) {
-					this.renderRowFooter(workingDate, rowFooterCell);
-				}	
-			}
-		}
+YAHOO.widget.Calendar.prototype.applyListeners = function() {
 
-		
+	var root = this.oDomContainer;
+	var cal = this.parent || this;
 
-		var renderer = null;
-		
-		if (workingDate.getFullYear()	== this.today.getFullYear() &&
-			workingDate.getMonth()		== this.today.getMonth() &&
-			workingDate.getDate()		== this.today.getDate())
-		{
-			cellRenderers[cellRenderers.length]=this.renderCellStyleToday;
-		}
-		
-		if (this.isDateOOM(workingDate))
-		{
-			cellRenderers[cellRenderers.length]=this.renderCellNotThisMonth;
-		} else {
-			for (var r=0;r<this.renderStack.length;++r)
-			{
-				var rArray = this.renderStack[r];
-				var type = rArray[0];
-				
-				var month;
-				var day;
-				var year;
-
-				switch (type) {
-					case YAHOO.widget.Calendar_Core.DATE:
-						month = rArray[1][1];
-						day = rArray[1][2];
-						year = rArray[1][0];
-
-						if (workingDate.getMonth()+1 == month && workingDate.getDate() == day && workingDate.getFullYear() == year)
-						{
-							renderer = rArray[2];
-							this.renderStack.splice(r,1);
-						}
-						break;
-					case YAHOO.widget.Calendar_Core.MONTH_DAY:
-						month = rArray[1][0];
-						day = rArray[1][1];
-						
-						if (workingDate.getMonth()+1 == month && workingDate.getDate() == day)
-						{
-							renderer = rArray[2];
-							this.renderStack.splice(r,1);
-						}
-						break;
-					case YAHOO.widget.Calendar_Core.RANGE:
-						var date1 = rArray[1][0];
-						var date2 = rArray[1][1];
-
-						var d1month = date1[1];
-						var d1day = date1[2];
-						var d1year = date1[0];
-						
-						var d1 = new Date(d1year, d1month-1, d1day);
-
-						var d2month = date2[1];
-						var d2day = date2[2];
-						var d2year = date2[0];
-
-						var d2 = new Date(d2year, d2month-1, d2day);
-
-						if (workingDate.getTime() >= d1.getTime() && workingDate.getTime() <= d2.getTime())
-						{
-							renderer = rArray[2];
+	var linkLeft, linkRight;
 
-							if (workingDate.getTime()==d2.getTime()) { 
-								this.renderStack.splice(r,1);
-							}
-						}
-						break;
-					case YAHOO.widget.Calendar_Core.WEEKDAY:
-						
-						var weekday = rArray[1][0];
-						if (workingDate.getDay()+1 == weekday)
-						{
-							renderer = rArray[2];
-						}
-						break;
-					case YAHOO.widget.Calendar_Core.MONTH:
-						
-						month = rArray[1][0];
-						if (workingDate.getMonth()+1 == month)
-						{
-							renderer = rArray[2];
-						}
-						break;
-				}
-				
-				if (renderer) {
-					cellRenderers[cellRenderers.length]=renderer;
-				}
-			}
+	linkLeft = YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_LEFT, "a", root);
+	linkRight = YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_RIGHT, "a", root);
 
-		}
+	if (linkLeft) {
+		this.linkLeft = linkLeft[0];
+		YAHOO.util.Event.addListener(this.linkLeft, "mousedown", cal.previousMonth, cal, true);
+	}
 
-		if (this._indexOfSelectedFieldArray([workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()]) > -1)
-		{
-			cellRenderers[cellRenderers.length]=this.renderCellStyleSelected; 
-		}
+	if (linkRight) {
+		this.linkRight = linkRight[0];
+		YAHOO.util.Event.addListener(this.linkRight, "mousedown", cal.nextMonth, cal, true);
+	}
 
-		if (this.minDate)
-		{
-			this.minDate = YAHOO.widget.DateMath.clearTime(this.minDate);
-		}
-		if (this.maxDate)
-		{
-			this.maxDate = YAHOO.widget.DateMath.clearTime(this.maxDate);
-		}
+	if (this.domEventMap) {
+		var el,elements;
+		for (var cls in this.domEventMap) {
+			if (this.domEventMap.hasOwnProperty(cls)) {
+				var items = this.domEventMap[cls];
 
-		if (
-			(this.minDate && (workingDate.getTime() < this.minDate.getTime())) ||
-			(this.maxDate && (workingDate.getTime() > this.maxDate.getTime()))
-		) {
-			cellRenderers[cellRenderers.length]=this.renderOutOfBoundsDate;
-		} else {
-			cellRenderers[cellRenderers.length]=this.renderCellDefault;	
-		}
-		
-		for (var x=0;x<cellRenderers.length;++x)
-		{
-			var ren = cellRenderers[x];
-			if (ren.call(this,workingDate,cell) == YAHOO.widget.Calendar_Core.STOP_RENDER) {
-				break;
-			}
-		}
-		
-		workingDate = YAHOO.widget.DateMath.add(workingDate, YAHOO.widget.DateMath.DAY, 1); // Go to the next day
-		if (workingDate.getDay() == this.Options.START_WEEKDAY) {
-			weekRowIndex += 1;
-		}
+				if (! (items instanceof Array)) {
+					items = [items];
+				}
 
-		YAHOO.widget.Calendar_Core.addCssClass(cell, this.Style.CSS_CELL);
-		if (c >= 0 && c <= 6) {
-			YAHOO.widget.Calendar_Core.addCssClass(cell, this.Style.CSS_CELL_TOP);
-		}
-		if ((c % 7) == 0) {
-			YAHOO.widget.Calendar_Core.addCssClass(cell, this.Style.CSS_CELL_LEFT);
-		}
-		if (((c+1) % 7) == 0) {
-			YAHOO.widget.Calendar_Core.addCssClass(cell, this.Style.CSS_CELL_RIGHT);
-		}
-		
-		var postDays = this.postMonthDays; 
-		if (postDays >= 7 && this.Options.HIDE_BLANK_WEEKS) {
-			var blankWeeks = Math.floor(postDays/7);
-			for (var p=0;p<blankWeeks;++p) {
-				postDays -= 7;
+				for (var i=0;i<items.length;i++)	{
+					var item = items[i];
+					elements = YAHOO.util.Dom.getElementsByClassName(cls, item.tag, this.oDomContainer);
+
+					for (var c=0;c<elements.length;c++) {
+						el = elements[c];
+						 YAHOO.util.Event.addListener(el, item.event, item.handler, item.scope, item.correct );
+					}
+				}
 			}
 		}
-		
-		if (c >= ((this.preMonthDays+postDays+this.monthDays)-7)) {
-			YAHOO.widget.Calendar_Core.addCssClass(cell, this.Style.CSS_CELL_BOTTOM);
-		}
 	}
-		
+
+	YAHOO.util.Event.addListener(this.oDomContainer, "click", this.doSelectCell, this);
+	YAHOO.util.Event.addListener(this.oDomContainer, "mouseover", this.doCellMouseOver, this);
+	YAHOO.util.Event.addListener(this.oDomContainer, "mouseout", this.doCellMouseOut, this);
 };
 
 /**
-* Appends the contents of the calendar widget footer into the shell. By default, 
-* the calendar does not contain a footer, and this method must be implemented by 
-* subclassing the widget.
+* Retrieves the Date object for the specified Calendar cell
+* @method getDateByCellId
+* @param {String}	id	The id of the cell
+* @return {Date} The Date object for the specified Calendar cell
 */
-YAHOO.widget.Calendar_Core.prototype.renderFooter = function() { };
+YAHOO.widget.Calendar.prototype.getDateByCellId = function(id) {
+	var date = this.getDateFieldsByCellId(id);
+	return new Date(date[0],date[1]-1,date[2]);
+};
 
 /**
-* @private
+* Retrieves the Date object for the specified Calendar cell
+* @method getDateFieldsByCellId
+* @param {String}	id	The id of the cell
+* @return {Array}	The array of Date fields for the specified Calendar cell
 */
-YAHOO.widget.Calendar_Core.prototype._unload = function(e, cal) {
-	for (var c in cal.cells) {
-		c = null;
-	}
-	
-	cal.cells = null;
-	
-	cal.tbody = null;
-	cal.oDomContainer = null;
-	cal.table = null;
-	cal.headerCell = null;
-	
-	cal = null;
-};
-												  
-												  
-/****************** BEGIN BUILT-IN TABLE CELL RENDERERS ************************************/
+YAHOO.widget.Calendar.prototype.getDateFieldsByCellId = function(id) {
+	id = id.toLowerCase().split("_cell")[1];
+	id = parseInt(id, 10);
+	return this.cellDates[id];
+};
 
-YAHOO.widget.Calendar_Core.prototype.renderOutOfBoundsDate = function(workingDate, cell) {
-	YAHOO.widget.Calendar_Core.addCssClass(cell, this.Style.CSS_CELL_OOB);
-	cell.innerHTML = workingDate.getDate();
-	return YAHOO.widget.Calendar_Core.STOP_RENDER;
-}
+// BEGIN BUILT-IN TABLE CELL RENDERERS
 
 /**
-* Renders the row header for a week. The date passed in should be
-* the first date of the given week.
-* @param {Date}					workingDate		The current working Date object (beginning of the week) being used to generate the calendar
+* Renders a cell that falls before the minimum date or after the maximum date.
+* widget class.
+* @method renderOutOfBoundsDate
+* @param {Date}					workingDate		The current working Date object being used to generate the calendar
 * @param {HTMLTableCellElement}	cell			The current working cell in the calendar
+* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+*			should not be terminated
 */
-YAHOO.widget.Calendar_Core.prototype.renderRowHeader = function(workingDate, cell) {
-	YAHOO.widget.Calendar_Core.addCssClass(cell, this.Style.CSS_ROW_HEADER);
-	
-	var useYear = this.pageDate.getFullYear();
-	
-	if (! YAHOO.widget.DateMath.isYearOverlapWeek(workingDate)) {
-		useYear = workingDate.getFullYear();
-	}
-	
-	var weekNum = YAHOO.widget.DateMath.getWeekNumber(workingDate, useYear, this.Options.START_WEEKDAY);
-	cell.innerHTML = weekNum;
-	
-	if (this.isDateOOM(workingDate) && ! YAHOO.widget.DateMath.isMonthOverlapWeek(workingDate)) {
-		YAHOO.widget.Calendar_Core.addCssClass(cell, this.Style.CSS_CELL_OOM);	
-	}
+YAHOO.widget.Calendar.prototype.renderOutOfBoundsDate = function(workingDate, cell) {
+	YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_OOB);
+	cell.innerHTML = workingDate.getDate();
+	return YAHOO.widget.Calendar.STOP_RENDER;
 };
 
 /**
-* Renders the row footer for a week. The date passed in should be
-* the first date of the given week.
-* @param {Date}					workingDate		The current working Date object (beginning of the week) being used to generate the calendar
-* @param {HTMLTableCellElement}	cell			The current working cell in the calendar
+* Renders the row header for a week.
+* @method renderRowHeader
+* @param {Number}	weekNum	The week number of the current row
+* @param {Array}	cell	The current working HTML array
 */
-YAHOO.widget.Calendar_Core.prototype.renderRowFooter = function(workingDate, cell) {
-	YAHOO.widget.Calendar_Core.addCssClass(cell, this.Style.CSS_ROW_FOOTER);
-	
-	if (this.isDateOOM(workingDate) && ! YAHOO.widget.DateMath.isMonthOverlapWeek(workingDate)) {
-		YAHOO.widget.Calendar_Core.addCssClass(cell, this.Style.CSS_CELL_OOM);	
-	}
+YAHOO.widget.Calendar.prototype.renderRowHeader = function(weekNum, html) {
+	html[html.length] = '<th class="calrowhead">' + weekNum + '</th>';
+	return html;
+};
+
+/**
+* Renders the row footer for a week.
+* @method renderRowFooter
+* @param {Number}	weekNum	The week number of the current row
+* @param {Array}	cell	The current working HTML array
+*/
+YAHOO.widget.Calendar.prototype.renderRowFooter = function(weekNum, html) {
+	html[html.length] = '<th class="calrowfoot">' + weekNum + '</th>';
+	return html;
 };
 
 /**
 * Renders a single standard calendar cell in the calendar widget table.
-* All logic for determining how a standard default cell will be rendered is 
+* All logic for determining how a standard default cell will be rendered is
 * encapsulated in this method, and must be accounted for when extending the
 * widget class.
+* @method renderCellDefault
 * @param {Date}					workingDate		The current working Date object being used to generate the calendar
 * @param {HTMLTableCellElement}	cell			The current working cell in the calendar
-* @return YAHOO.widget.Calendar_Core.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
-*			should not be terminated
-* @type String
 */
-YAHOO.widget.Calendar_Core.prototype.renderCellDefault = function(workingDate, cell) {
-	cell.innerHTML = "";
-	var link = document.createElement("a");
-
-	link.href="javascript:void(null);";
-	link.name=this.id+"__"+workingDate.getFullYear()+"_"+(workingDate.getMonth()+1)+"_"+workingDate.getDate();
+YAHOO.widget.Calendar.prototype.renderCellDefault = function(workingDate, cell) {
+	cell.innerHTML = '<a href="javascript:void(null);" >' + this.buildDayLabel(workingDate) + "</a>";
+};
 
-	link.appendChild(document.createTextNode(this.buildDayLabel(workingDate)));
-	cell.appendChild(link);
+/**
+* Styles a selectable cell.
+* @method styleCellDefault
+* @param {Date}					workingDate		The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement}	cell			The current working cell in the calendar
+*/
+YAHOO.widget.Calendar.prototype.styleCellDefault = function(workingDate, cell) {
+	YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_SELECTABLE);
 };
 
-YAHOO.widget.Calendar_Core.prototype.renderCellStyleHighlight1 = function(workingDate, cell) {
-	YAHOO.widget.Calendar_Core.addCssClass(cell, this.Style.CSS_CELL_HIGHLIGHT1);
+
+/**
+* Renders a single standard calendar cell using the CSS hightlight1 style
+* @method renderCellStyleHighlight1
+* @param {Date}					workingDate		The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement}	cell			The current working cell in the calendar
+*/
+YAHOO.widget.Calendar.prototype.renderCellStyleHighlight1 = function(workingDate, cell) {
+	YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT1);
 };
-YAHOO.widget.Calendar_Core.prototype.renderCellStyleHighlight2 = function(workingDate, cell) {
-	YAHOO.widget.Calendar_Core.addCssClass(cell, this.Style.CSS_CELL_HIGHLIGHT2);
+
+/**
+* Renders a single standard calendar cell using the CSS hightlight2 style
+* @method renderCellStyleHighlight2
+* @param {Date}					workingDate		The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement}	cell			The current working cell in the calendar
+*/
+YAHOO.widget.Calendar.prototype.renderCellStyleHighlight2 = function(workingDate, cell) {
+	YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT2);
 };
-YAHOO.widget.Calendar_Core.prototype.renderCellStyleHighlight3 = function(workingDate, cell) {
-	YAHOO.widget.Calendar_Core.addCssClass(cell, this.Style.CSS_CELL_HIGHLIGHT3);
+
+/**
+* Renders a single standard calendar cell using the CSS hightlight3 style
+* @method renderCellStyleHighlight3
+* @param {Date}					workingDate		The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement}	cell			The current working cell in the calendar
+*/
+YAHOO.widget.Calendar.prototype.renderCellStyleHighlight3 = function(workingDate, cell) {
+	YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT3);
 };
-YAHOO.widget.Calendar_Core.prototype.renderCellStyleHighlight4 = function(workingDate, cell) {
-	YAHOO.widget.Calendar_Core.addCssClass(cell, this.Style.CSS_CELL_HIGHLIGHT4);
+
+/**
+* Renders a single standard calendar cell using the CSS hightlight4 style
+* @method renderCellStyleHighlight4
+* @param {Date}					workingDate		The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement}	cell			The current working cell in the calendar
+*/
+YAHOO.widget.Calendar.prototype.renderCellStyleHighlight4 = function(workingDate, cell) {
+	YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT4);
 };
 
 /**
 * Applies the default style used for rendering today's date to the current calendar cell
+* @method renderCellStyleToday
 * @param {Date}					workingDate		The current working Date object being used to generate the calendar
 * @param {HTMLTableCellElement}	cell			The current working cell in the calendar
-* @return	YAHOO.widget.Calendar_Core.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
-*			should not be terminated
-* @type String
 */
-YAHOO.widget.Calendar_Core.prototype.renderCellStyleToday = function(workingDate, cell) {
-	YAHOO.widget.Calendar_Core.addCssClass(cell, this.Style.CSS_CELL_TODAY);
+YAHOO.widget.Calendar.prototype.renderCellStyleToday = function(workingDate, cell) {
+	YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_TODAY);
 };
 
 /**
 * Applies the default style used for rendering selected dates to the current calendar cell
+* @method renderCellStyleSelected
 * @param {Date}					workingDate		The current working Date object being used to generate the calendar
 * @param {HTMLTableCellElement}	cell			The current working cell in the calendar
-* @return	YAHOO.widget.Calendar_Core.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
 *			should not be terminated
-* @type String
 */
-YAHOO.widget.Calendar_Core.prototype.renderCellStyleSelected = function(workingDate, cell) {
-	YAHOO.widget.Calendar_Core.addCssClass(cell, this.Style.CSS_CELL_SELECTED);
+YAHOO.widget.Calendar.prototype.renderCellStyleSelected = function(workingDate, cell) {
+	YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_SELECTED);
 };
 
 /**
 * Applies the default style used for rendering dates that are not a part of the current
 * month (preceding or trailing the cells for the current month)
+* @method renderCellNotThisMonth
 * @param {Date}					workingDate		The current working Date object being used to generate the calendar
 * @param {HTMLTableCellElement}	cell			The current working cell in the calendar
-* @return	YAHOO.widget.Calendar_Core.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
 *			should not be terminated
-* @type String
 */
-YAHOO.widget.Calendar_Core.prototype.renderCellNotThisMonth = function(workingDate, cell) {
-
-
-    /****   THIS FUNCTION MODIFIED BY JESSE VINCENT on 2006-11-29 TO MAKE OUT OF MONTH DATES CLICKABLE
-            ALL RIGHTS DISCLAIMED.
-     ****/
-	YAHOO.widget.Calendar_Core.addCssClass(cell, this.Style.CSS_CELL_OOM);
-	cell.innerHTML = "";
-	var link = document.createElement("a");
-
-	link.href="javascript:void(null);";
-	link.name=this.id+"__"+workingDate.getFullYear()+"_"+(workingDate.getMonth()+1)+"_"+workingDate.getDate();
-
-	link.appendChild(document.createTextNode(this.buildDayLabel(workingDate)));
-	cell.appendChild(link);
-	return YAHOO.widget.Calendar_Core.STOP_RENDER;
+YAHOO.widget.Calendar.prototype.renderCellNotThisMonth = function(workingDate, cell) {
+	YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_OOM);
+	cell.innerHTML=workingDate.getDate();
+	return YAHOO.widget.Calendar.STOP_RENDER;
 };
 
 /**
 * Renders the current calendar cell as a non-selectable "black-out" date using the default
 * restricted style.
+* @method renderBodyCellRestricted
 * @param {Date}					workingDate		The current working Date object being used to generate the calendar
 * @param {HTMLTableCellElement}	cell			The current working cell in the calendar
-* @return	YAHOO.widget.Calendar_Core.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
 *			should not be terminated
-* @type String
 */
-YAHOO.widget.Calendar_Core.prototype.renderBodyCellRestricted = function(workingDate, cell) {
-	YAHOO.widget.Calendar_Core.setCssClasses(cell, [this.Style.CSS_CELL,this.Style.CSS_CELL_RESTRICTED]);
+YAHOO.widget.Calendar.prototype.renderBodyCellRestricted = function(workingDate, cell) {
+	YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL);
+	YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_RESTRICTED);
 	cell.innerHTML=workingDate.getDate();
-	return YAHOO.widget.Calendar_Core.STOP_RENDER;
+	return YAHOO.widget.Calendar.STOP_RENDER;
 };
-/******************** END BUILT-IN TABLE CELL RENDERERS ************************************/
 
-/******************** BEGIN MONTH NAVIGATION METHODS ************************************/
+// END BUILT-IN TABLE CELL RENDERERS
+
+// BEGIN MONTH NAVIGATION METHODS
+
 /**
 * Adds the designated number of months to the current calendar month, and sets the current
 * calendar page date to the new month.
-* @param {Integer}	count	The number of months to add to the current calendar
+* @method addMonths
+* @param {Number}	count	The number of months to add to the current calendar
 */
-YAHOO.widget.Calendar_Core.prototype.addMonths = function(count) {
-	this.pageDate = YAHOO.widget.DateMath.add(this.pageDate, YAHOO.widget.DateMath.MONTH, count);
+YAHOO.widget.Calendar.prototype.addMonths = function(count) {
+	this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.add(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.MONTH, count));
 	this.resetRenderers();
-	this.onChangePage();
+	this.changePageEvent.fire();
 };
 
 /**
 * Subtracts the designated number of months from the current calendar month, and sets the current
 * calendar page date to the new month.
-* @param {Integer}	count	The number of months to subtract from the current calendar
+* @method subtractMonths
+* @param {Number}	count	The number of months to subtract from the current calendar
 */
-YAHOO.widget.Calendar_Core.prototype.subtractMonths = function(count) {
-	this.pageDate = YAHOO.widget.DateMath.subtract(this.pageDate, YAHOO.widget.DateMath.MONTH, count);
+YAHOO.widget.Calendar.prototype.subtractMonths = function(count) {
+	this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.subtract(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.MONTH, count));
 	this.resetRenderers();
-	this.onChangePage();
+	this.changePageEvent.fire();
 };
 
 /**
 * Adds the designated number of years to the current calendar, and sets the current
 * calendar page date to the new month.
-* @param {Integer}	count	The number of years to add to the current calendar
+* @method addYears
+* @param {Number}	count	The number of years to add to the current calendar
 */
-YAHOO.widget.Calendar_Core.prototype.addYears = function(count) {
-	this.pageDate = YAHOO.widget.DateMath.add(this.pageDate, YAHOO.widget.DateMath.YEAR, count);
+YAHOO.widget.Calendar.prototype.addYears = function(count) {
+	this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.add(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.YEAR, count));
 	this.resetRenderers();
-	this.onChangePage();
+	this.changePageEvent.fire();
 };
 
 /**
 * Subtcats the designated number of years from the current calendar, and sets the current
 * calendar page date to the new month.
-* @param {Integer}	count	The number of years to subtract from the current calendar
+* @method subtractYears
+* @param {Number}	count	The number of years to subtract from the current calendar
 */
-YAHOO.widget.Calendar_Core.prototype.subtractYears = function(count) {
-	this.pageDate = YAHOO.widget.DateMath.subtract(this.pageDate, YAHOO.widget.DateMath.YEAR, count);
+YAHOO.widget.Calendar.prototype.subtractYears = function(count) {
+	this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.subtract(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.YEAR, count));
 	this.resetRenderers();
-	this.onChangePage();
+	this.changePageEvent.fire();
 };
 
 /**
 * Navigates to the next month page in the calendar widget.
+* @method nextMonth
 */
-YAHOO.widget.Calendar_Core.prototype.nextMonth = function() {
+YAHOO.widget.Calendar.prototype.nextMonth = function() {
 	this.addMonths(1);
 };
 
 /**
 * Navigates to the previous month page in the calendar widget.
+* @method previousMonth
 */
-YAHOO.widget.Calendar_Core.prototype.previousMonth = function() {
+YAHOO.widget.Calendar.prototype.previousMonth = function() {
 	this.subtractMonths(1);
 };
 
 /**
 * Navigates to the next year in the currently selected month in the calendar widget.
+* @method nextYear
 */
-YAHOO.widget.Calendar_Core.prototype.nextYear = function() {
+YAHOO.widget.Calendar.prototype.nextYear = function() {
 	this.addYears(1);
 };
 
 /**
 * Navigates to the previous year in the currently selected month in the calendar widget.
+* @method previousYear
 */
-YAHOO.widget.Calendar_Core.prototype.previousYear = function() {
+YAHOO.widget.Calendar.prototype.previousYear = function() {
 	this.subtractYears(1);
 };
 
-/****************** END MONTH NAVIGATION METHODS ************************************/
+// END MONTH NAVIGATION METHODS
 
-/************* BEGIN SELECTION METHODS *************************************************************/
+// BEGIN SELECTION METHODS
 
 /**
-* Resets the calendar widget to the originally selected month and year, and 
+* Resets the calendar widget to the originally selected month and year, and
 * sets the calendar to the initial selection(s).
+* @method reset
 */
-YAHOO.widget.Calendar_Core.prototype.reset = function() {
-	this.selectedDates.length = 0;
-	this.selectedDates = this._selectedDates.concat();
-
-	this.pageDate = new Date(this._pageDate.getTime());
-	this.onReset();
+YAHOO.widget.Calendar.prototype.reset = function() {
+	this.cfg.resetProperty("selected");
+	this.cfg.resetProperty("pagedate");
+	this.resetEvent.fire();
 };
 
 /**
 * Clears the selected dates in the current calendar widget and sets the calendar
 * to the current month and year.
+* @method clear
 */
-YAHOO.widget.Calendar_Core.prototype.clear = function() {
-	this.selectedDates.length = 0;
-	this.pageDate = new Date(this.today.getTime());
-	this.onClear();
+YAHOO.widget.Calendar.prototype.clear = function() {
+	this.cfg.setProperty("selected", []);
+	this.cfg.setProperty("pagedate", new Date(this.today.getTime()));
+	this.clearEvent.fire();
 };
 
 /**
 * Selects a date or a collection of dates on the current calendar. This method, by default,
-* does not call the render method explicitly. Once selection has completed, render must be 
+* does not call the render method explicitly. Once selection has completed, render must be
 * called for the changes to be reflected visually.
+* @method select
 * @param	{String/Date/Date[]}	date	The date string of dates to select in the current calendar. Valid formats are
 *								individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006).
 *								Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005).
 *								This method can also take a JavaScript Date object or an array of Date objects.
-* @return						Array of JavaScript Date objects representing all individual dates that are currently selected.
-* @type Date[]
+* @return	{Date[]}			Array of JavaScript Date objects representing all individual dates that are currently selected.
 */
-YAHOO.widget.Calendar_Core.prototype.select = function(date) {
-	this.onBeforeSelect();
+YAHOO.widget.Calendar.prototype.select = function(date) {
+	this.beforeSelectEvent.fire();
 
+	var selected = this.cfg.getProperty("selected");
 	var aToBeSelected = this._toFieldArray(date);
 
-	for (var a=0;a<aToBeSelected.length;++a)
-	{
+	for (var a=0;a<aToBeSelected.length;++a) {
 		var toSelect = aToBeSelected[a]; // For each date item in the list of dates we're trying to select
-		if (this._indexOfSelectedFieldArray(toSelect) == -1) // not already selected?
-		{	
-			this.selectedDates[this.selectedDates.length]=toSelect;
+		if (this._indexOfSelectedFieldArray(toSelect) == -1) { // not already selected?
+			selected[selected.length]=toSelect;
 		}
 	}
-	
+
 	if (this.parent) {
-		this.parent.sync(this);
+		this.parent.cfg.setProperty("selected", selected);
+	} else {
+		this.cfg.setProperty("selected", selected);
 	}
 
-	this.onSelect();
+	this.selectEvent.fire(aToBeSelected);
 
 	return this.getSelectedDates();
 };
@@ -1551,14 +2601,14 @@
 * Selects a date on the current calendar by referencing the index of the cell that should be selected.
 * This method is used to easily select a single cell (usually with a mouse click) without having to do
 * a full render. The selected style is applied to the cell directly.
-* @param	{Integer}	cellIndex	The index of the cell to select in the current calendar. 
-* @return							Array of JavaScript Date objects representing all individual dates that are currently selected.
-* @type Date[]
+* @method selectCell
+* @param	{Number}	cellIndex	The index of the cell to select in the current calendar.
+* @return	{Date[]}	Array of JavaScript Date objects representing all individual dates that are currently selected.
 */
-YAHOO.widget.Calendar_Core.prototype.selectCell = function(cellIndex) {
-	this.onBeforeSelect();
+YAHOO.widget.Calendar.prototype.selectCell = function(cellIndex) {
+	this.beforeSelectEvent.fire();
 
-	this.cells = this.tbody.getElementsByTagName("TD");
+	var selected = this.cfg.getProperty("selected");
 
 	var cell = this.cells[cellIndex];
 	var cellDate = this.cellDates[cellIndex];
@@ -1567,15 +2617,18 @@
 
 	var selectDate = cellDate.concat();
 
-	this.selectedDates.push(selectDate);
-	
+	selected[selected.length] = selectDate;
+
 	if (this.parent) {
-		this.parent.sync(this);
+		this.parent.cfg.setProperty("selected", selected);
+	} else {
+		this.cfg.setProperty("selected", selected);
 	}
 
 	this.renderCellStyleSelected(dCellDate,cell);
 
-	this.onSelect();
+	this.selectEvent.fire([selectDate]);
+
 	this.doCellMouseOut.call(cell, null, this);
 
 	return this.getSelectedDates();
@@ -1583,36 +2636,39 @@
 
 /**
 * Deselects a date or a collection of dates on the current calendar. This method, by default,
-* does not call the render method explicitly. Once deselection has completed, render must be 
+* does not call the render method explicitly. Once deselection has completed, render must be
 * called for the changes to be reflected visually.
+* @method deselect
 * @param	{String/Date/Date[]}	date	The date string of dates to deselect in the current calendar. Valid formats are
 *								individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006).
 *								Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005).
-*								This method can also take a JavaScript Date object or an array of Date objects.	
-* @return						Array of JavaScript Date objects representing all individual dates that are currently selected.
-* @type Date[]
+*								This method can also take a JavaScript Date object or an array of Date objects.
+* @return	{Date[]}			Array of JavaScript Date objects representing all individual dates that are currently selected.
 */
-YAHOO.widget.Calendar_Core.prototype.deselect = function(date) {
-	this.onBeforeDeselect();
+YAHOO.widget.Calendar.prototype.deselect = function(date) {
+	this.beforeDeselectEvent.fire();
+
+	var selected = this.cfg.getProperty("selected");
 
 	var aToBeSelected = this._toFieldArray(date);
 
-	for (var a=0;a<aToBeSelected.length;++a)
-	{
+	for (var a=0;a<aToBeSelected.length;++a) {
 		var toSelect = aToBeSelected[a]; // For each date item in the list of dates we're trying to select
 		var index = this._indexOfSelectedFieldArray(toSelect);
-	
-		if (index != -1)
-		{	
-			this.selectedDates.splice(index,1);
+
+		if (index != -1) {
+			selected.splice(index,1);
 		}
 	}
 
 	if (this.parent) {
-		this.parent.sync(this);
-	} 
+		this.parent.cfg.setProperty("selected", selected);
+	} else {
+		this.cfg.setProperty("selected", selected);
+	}
+
+	this.deselectEvent.fire(aToBeSelected);
 
-	this.onDeselect();
 	return this.getSelectedDates();
 };
 
@@ -1620,13 +2676,14 @@
 * Deselects a date on the current calendar by referencing the index of the cell that should be deselected.
 * This method is used to easily deselect a single cell (usually with a mouse click) without having to do
 * a full render. The selected style is removed from the cell directly.
-* @param	{Integer}	cellIndex	The index of the cell to deselect in the current calendar. 
-* @return							Array of JavaScript Date objects representing all individual dates that are currently selected.
-* @type Date[]
+* @method deselectCell
+* @param	{Number}	cellIndex	The index of the cell to deselect in the current calendar.
+* @return	{Date[]}	Array of JavaScript Date objects representing all individual dates that are currently selected.
 */
-YAHOO.widget.Calendar_Core.prototype.deselectCell = function(i) {
-	this.onBeforeDeselect();
-	this.cells = this.tbody.getElementsByTagName("TD");
+YAHOO.widget.Calendar.prototype.deselectCell = function(i) {
+	this.beforeDeselectEvent.fire();
+
+	var selected = this.cfg.getProperty("selected");
 
 	var cell = this.cells[i];
 	var cellDate = this.cellDates[i];
@@ -1636,122 +2693,118 @@
 
 	var selectDate = cellDate.concat();
 
-	if (cellDateIndex > -1)
-	{
-		if (this.pageDate.getMonth() == dCellDate.getMonth() &&
-			this.pageDate.getFullYear() == dCellDate.getFullYear())
-		{
-			YAHOO.widget.Calendar_Core.removeCssClass(cell, this.Style.CSS_CELL_SELECTED);
+	if (cellDateIndex > -1) {
+		if (this.cfg.getProperty("pagedate").getMonth() == dCellDate.getMonth() &&
+			this.cfg.getProperty("pagedate").getFullYear() == dCellDate.getFullYear()) {
+			YAHOO.util.Dom.removeClass(cell, this.Style.CSS_CELL_SELECTED);
 		}
 
-		this.selectedDates.splice(cellDateIndex, 1);
+		selected.splice(cellDateIndex, 1);
 	}
 
 
 	if (this.parent) {
-		this.parent.sync(this);
+		this.parent.cfg.setProperty("selected", selected);
+	} else {
+		this.cfg.setProperty("selected", selected);
 	}
 
-	this.onDeselect();
+	this.deselectEvent.fire(selectDate);
 	return this.getSelectedDates();
 };
 
 /**
 * Deselects all dates on the current calendar.
-* @return				Array of JavaScript Date objects representing all individual dates that are currently selected.
+* @method deselectAll
+* @return {Date[]}		Array of JavaScript Date objects representing all individual dates that are currently selected.
 *						Assuming that this function executes properly, the return value should be an empty array.
 *						However, the empty array is returned for the sake of being able to check the selection status
 *						of the calendar.
-* @type Date[]
 */
-YAHOO.widget.Calendar_Core.prototype.deselectAll = function() {
-	this.onBeforeDeselect();
-	var count = this.selectedDates.length;
-	this.selectedDates.length = 0;
+YAHOO.widget.Calendar.prototype.deselectAll = function() {
+	this.beforeDeselectEvent.fire();
+
+	var selected = this.cfg.getProperty("selected");
+	var count = selected.length;
+	var sel = selected.concat();
 
 	if (this.parent) {
-		this.parent.sync(this);
+		this.parent.cfg.setProperty("selected", []);
+	} else {
+		this.cfg.setProperty("selected", []);
 	}
-	
+
 	if (count > 0) {
-		this.onDeselect();
+		this.deselectEvent.fire(sel);
 	}
 
 	return this.getSelectedDates();
 };
-/************* END SELECTION METHODS *************************************************************/
 
+// END SELECTION METHODS
 
-/************* BEGIN TYPE CONVERSION METHODS ****************************************************/
+// BEGIN TYPE CONVERSION METHODS
 
 /**
 * Converts a date (either a JavaScript Date object, or a date string) to the internal data structure
 * used to represent dates: [[yyyy,mm,dd],[yyyy,mm,dd]].
+* @method _toFieldArray
 * @private
 * @param	{String/Date/Date[]}	date	The date string of dates to deselect in the current calendar. Valid formats are
 *								individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006).
 *								Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005).
-*								This method can also take a JavaScript Date object or an array of Date objects.	
-* @return						Array of date field arrays
-* @type Array[](Integer[])
+*								This method can also take a JavaScript Date object or an array of Date objects.
+* @return {Array[](Number[])}	Array of date field arrays
 */
-YAHOO.widget.Calendar_Core.prototype._toFieldArray = function(date) {
-	var returnDate = new Array();
+YAHOO.widget.Calendar.prototype._toFieldArray = function(date) {
+	var returnDate = [];
 
-	if (date instanceof Date)
-	{
+	if (date instanceof Date) {
 		returnDate = [[date.getFullYear(), date.getMonth()+1, date.getDate()]];
-	} 
-	else if (typeof date == 'string')
-	{
+	} else if (typeof date == 'string') {
 		returnDate = this._parseDates(date);
-	}
-	else if (date instanceof Array)
-	{
-		for (var i=0;i<date.length;++i)
-		{
+	} else if (date instanceof Array) {
+		for (var i=0;i<date.length;++i) {
 			var d = date[i];
 			returnDate[returnDate.length] = [d.getFullYear(),d.getMonth()+1,d.getDate()];
 		}
 	}
-	
+
 	return returnDate;
 };
 
 /**
 * Converts a date field array [yyyy,mm,dd] to a JavaScript Date object.
+* @method _toDate
 * @private
-* @param	{Integer[]}		dateFieldArray	The date field array to convert to a JavaScript Date.
-* @return					JavaScript Date object representing the date field array
-* @type Date
-*/
-YAHOO.widget.Calendar_Core.prototype._toDate = function(dateFieldArray) {
-	if (dateFieldArray instanceof Date)
-	{
+* @param	{Number[]}		dateFieldArray	The date field array to convert to a JavaScript Date.
+* @return	{Date}	JavaScript Date object representing the date field array
+*/
+YAHOO.widget.Calendar.prototype._toDate = function(dateFieldArray) {
+	if (dateFieldArray instanceof Date) {
 		return dateFieldArray;
-	} else 	
-	{
+	} else {
 		return new Date(dateFieldArray[0],dateFieldArray[1]-1,dateFieldArray[2]);
 	}
 };
-/************* END TYPE CONVERSION METHODS ******************************************************/
 
+// END TYPE CONVERSION METHODS
+
+// BEGIN UTILITY METHODS
 
-/************* BEGIN UTILITY METHODS ****************************************************/
 /**
 * Converts a date field array [yyyy,mm,dd] to a JavaScript Date object.
+* @method _fieldArraysAreEqual
 * @private
-* @param	{Integer[]}	array1	The first date field array to compare
-* @param	{Integer[]}	array2	The first date field array to compare
-* @return						The boolean that represents the equality of the two arrays
-* @type Boolean
+* @param	{Number[]}	array1	The first date field array to compare
+* @param	{Number[]}	array2	The first date field array to compare
+* @return	{Boolean}	The boolean that represents the equality of the two arrays
 */
-YAHOO.widget.Calendar_Core.prototype._fieldArraysAreEqual = function(array1, array2) {
+YAHOO.widget.Calendar.prototype._fieldArraysAreEqual = function(array1, array2) {
 	var match = false;
 
-	if (array1[0]==array2[0]&&array1[1]==array2[1]&&array1[2]==array2[2])
-	{
-		match=true;	
+	if (array1[0]==array2[0]&&array1[1]==array2[1]&&array1[2]==array2[2]) {
+		match=true;
 	}
 
 	return match;
@@ -1759,20 +2812,19 @@
 
 /**
 * Gets the index of a date field array [yyyy,mm,dd] in the current list of selected dates.
+* @method	_indexOfSelectedFieldArray
 * @private
-* @param	{Integer[]}		find	The date field array to search for
-* @return					The index of the date field array within the collection of selected dates.
+* @param	{Number[]}		find	The date field array to search for
+* @return	{Number}			The index of the date field array within the collection of selected dates.
 *								-1 will be returned if the date is not found.
-* @type Integer
 */
-YAHOO.widget.Calendar_Core.prototype._indexOfSelectedFieldArray = function(find) {
+YAHOO.widget.Calendar.prototype._indexOfSelectedFieldArray = function(find) {
 	var selected = -1;
+	var seldates = this.cfg.getProperty("selected");
 
-	for (var s=0;s<this.selectedDates.length;++s)
-	{
-		var sArray = this.selectedDates[s];
-		if (find[0]==sArray[0]&&find[1]==sArray[1]&&find[2]==sArray[2])
-		{
+	for (var s=0;s<seldates.length;++s) {
+		var sArray = seldates[s];
+		if (find[0]==sArray[0]&&find[1]==sArray[1]&&find[2]==sArray[2]) {
 			selected = s;
 			break;
 		}
@@ -1783,76 +2835,83 @@
 
 /**
 * Determines whether a given date is OOM (out of month).
+* @method	isDateOOM
 * @param	{Date}	date	The JavaScript Date object for which to check the OOM status
 * @return	{Boolean}	true if the date is OOM
 */
-YAHOO.widget.Calendar_Core.prototype.isDateOOM = function(date) {
+YAHOO.widget.Calendar.prototype.isDateOOM = function(date) {
 	var isOOM = false;
-	if (date.getMonth() != this.pageDate.getMonth()) {
+	if (date.getMonth() != this.cfg.getProperty("pagedate").getMonth()) {
 		isOOM = true;
 	}
 	return isOOM;
 };
 
-/************* END UTILITY METHODS *******************************************************/
+// END UTILITY METHODS
 
-/************* BEGIN EVENT HANDLERS ******************************************************/
+// BEGIN EVENT HANDLERS
 
 /**
 * Event executed before a date is selected in the calendar widget.
+* @deprecated Event handlers for this event should be susbcribed to beforeSelectEvent.
 */
-YAHOO.widget.Calendar_Core.prototype.onBeforeSelect = function() {
-	if (! this.Options.MULTI_SELECT) {
-		this.clearAllBodyCellStyles(this.Style.CSS_CELL_SELECTED);
-		this.deselectAll();
+YAHOO.widget.Calendar.prototype.onBeforeSelect = function() {
+	if (this.cfg.getProperty("MULTI_SELECT") === false) {
+		if (this.parent) {
+			this.parent.callChildFunction("clearAllBodyCellStyles", this.Style.CSS_CELL_SELECTED);
+			this.parent.deselectAll();
+		} else {
+			this.clearAllBodyCellStyles(this.Style.CSS_CELL_SELECTED);
+			this.deselectAll();
+		}
 	}
 };
 
 /**
 * Event executed when a date is selected in the calendar widget.
+* @param	{Array}	selected	An array of date field arrays representing which date or dates were selected. Example: [ [2006,8,6],[2006,8,7],[2006,8,8] ]
+* @deprecated Event handlers for this event should be susbcribed to selectEvent.
 */
-YAHOO.widget.Calendar_Core.prototype.onSelect = function() { };
+YAHOO.widget.Calendar.prototype.onSelect = function(selected) { };
 
 /**
 * Event executed before a date is deselected in the calendar widget.
+* @deprecated Event handlers for this event should be susbcribed to beforeDeselectEvent.
 */
-YAHOO.widget.Calendar_Core.prototype.onBeforeDeselect = function() { };
+YAHOO.widget.Calendar.prototype.onBeforeDeselect = function() { };
 
 /**
 * Event executed when a date is deselected in the calendar widget.
+* @param	{Array}	selected	An array of date field arrays representing which date or dates were deselected. Example: [ [2006,8,6],[2006,8,7],[2006,8,8] ]
+* @deprecated Event handlers for this event should be susbcribed to deselectEvent.
 */
-YAHOO.widget.Calendar_Core.prototype.onDeselect = function() { };
+YAHOO.widget.Calendar.prototype.onDeselect = function(deselected) { };
 
 /**
 * Event executed when the user navigates to a different calendar page.
+* @deprecated Event handlers for this event should be susbcribed to changePageEvent.
 */
-YAHOO.widget.Calendar_Core.prototype.onChangePage = function() {
-		var me = this;
-
-		this.renderHeader();
-		if (this.renderProcId) {
-			clearTimeout(this.renderProcId);
-		}
-		this.renderProcId = setTimeout(function() {
-											me.render();
-											me.renderProcId = null;
-										}, 1);
+YAHOO.widget.Calendar.prototype.onChangePage = function() {
+	this.render();
 };
 
 /**
 * Event executed when the calendar widget is rendered.
+* @deprecated Event handlers for this event should be susbcribed to renderEvent.
 */
-YAHOO.widget.Calendar_Core.prototype.onRender = function() { };
+YAHOO.widget.Calendar.prototype.onRender = function() { };
 
 /**
 * Event executed when the calendar widget is reset to its original state.
+* @deprecated Event handlers for this event should be susbcribed to resetEvemt.
 */
-YAHOO.widget.Calendar_Core.prototype.onReset = function() { this.render(); };
+YAHOO.widget.Calendar.prototype.onReset = function() { this.render(); };
 
 /**
 * Event executed when the calendar widget is completely cleared to the current month with no selections.
+* @deprecated Event handlers for this event should be susbcribed to clearEvent.
 */
-YAHOO.widget.Calendar_Core.prototype.onClear = function() { this.render(); };
+YAHOO.widget.Calendar.prototype.onClear = function() { this.render(); };
 
 /**
 * Validates the calendar widget. This method has no default implementation
@@ -1861,33 +2920,35 @@
 * it doesn't.
 * @type Boolean
 */
-YAHOO.widget.Calendar_Core.prototype.validate = function() { return true; };
-
-/************* END EVENT HANDLERS *********************************************************/
+YAHOO.widget.Calendar.prototype.validate = function() { return true; };
 
+// END EVENT HANDLERS
 
-/************* BEGIN DATE PARSE METHODS ***************************************************/
-
+// BEGIN DATE PARSE METHODS
 
 /**
 * Converts a date string to a date field array
 * @private
 * @param	{String}	sDate			Date string. Valid formats are mm/dd and mm/dd/yyyy.
 * @return				A date field array representing the string passed to the method
-* @type Array[](Integer[])
+* @type Array[](Number[])
 */
-YAHOO.widget.Calendar_Core.prototype._parseDate = function(sDate) {
+YAHOO.widget.Calendar.prototype._parseDate = function(sDate) {
 	var aDate = sDate.split(this.Locale.DATE_FIELD_DELIMITER);
 	var rArray;
 
-	if (aDate.length == 2)
-	{
+	if (aDate.length == 2) {
 		rArray = [aDate[this.Locale.MD_MONTH_POSITION-1],aDate[this.Locale.MD_DAY_POSITION-1]];
-		rArray.type = YAHOO.widget.Calendar_Core.MONTH_DAY;
+		rArray.type = YAHOO.widget.Calendar.MONTH_DAY;
 	} else {
 		rArray = [aDate[this.Locale.MDY_YEAR_POSITION-1],aDate[this.Locale.MDY_MONTH_POSITION-1],aDate[this.Locale.MDY_DAY_POSITION-1]];
-		rArray.type = YAHOO.widget.Calendar_Core.DATE;
+		rArray.type = YAHOO.widget.Calendar.DATE;
+	}
+
+	for (var i=0;i<rArray.length;i++) {
+		rArray[i] = parseInt(rArray[i], 10);
 	}
+
 	return rArray;
 };
 
@@ -1896,15 +2957,14 @@
 * @private
 * @param	{String}	sDates		Date string with one or more comma-delimited dates. Valid formats are mm/dd, mm/dd/yyyy, mm/dd/yyyy-mm/dd/yyyy
 * @return							An array of date field arrays
-* @type Array[](Integer[])
+* @type Array[](Number[])
 */
-YAHOO.widget.Calendar_Core.prototype._parseDates = function(sDates) {
-	var aReturn = new Array();
+YAHOO.widget.Calendar.prototype._parseDates = function(sDates) {
+	var aReturn = [];
 
 	var aDates = sDates.split(this.Locale.DATE_DELIMITER);
-	
-	for (var d=0;d<aDates.length;++d)
-	{
+
+	for (var d=0;d<aDates.length;++d) {
 		var sDate = aDates[d];
 
 		if (sDate.indexOf(this.Locale.DATE_RANGE_DELIMITER) != -1) {
@@ -1928,70 +2988,67 @@
 /**
 * Converts a date range to the full list of included dates
 * @private
-* @param	{Integer[]}	startDate	Date field array representing the first date in the range
-* @param	{Integer[]}	endDate		Date field array representing the last date in the range
+* @param	{Number[]}	startDate	Date field array representing the first date in the range
+* @param	{Number[]}	endDate		Date field array representing the last date in the range
 * @return							An array of date field arrays
-* @type Array[](Integer[])
+* @type Array[](Number[])
 */
-YAHOO.widget.Calendar_Core.prototype._parseRange = function(startDate, endDate) {
+YAHOO.widget.Calendar.prototype._parseRange = function(startDate, endDate) {
 	var dStart   = new Date(startDate[0],startDate[1]-1,startDate[2]);
 	var dCurrent = YAHOO.widget.DateMath.add(new Date(startDate[0],startDate[1]-1,startDate[2]),YAHOO.widget.DateMath.DAY,1);
 	var dEnd     = new Date(endDate[0],  endDate[1]-1,  endDate[2]);
 
-	var results = new Array();
+	var results = [];
 	results.push(startDate);
-	while (dCurrent.getTime() <= dEnd.getTime())
-	{
+	while (dCurrent.getTime() <= dEnd.getTime()) {
 		results.push([dCurrent.getFullYear(),dCurrent.getMonth()+1,dCurrent.getDate()]);
 		dCurrent = YAHOO.widget.DateMath.add(dCurrent,YAHOO.widget.DateMath.DAY,1);
 	}
 	return results;
 };
 
-/************* END DATE PARSE METHODS *****************************************************/
+// END DATE PARSE METHODS
 
-/************* BEGIN RENDERER METHODS *****************************************************/
+// BEGIN RENDERER METHODS
 
 /**
 * Resets the render stack of the current calendar to its original pre-render value.
 */
-YAHOO.widget.Calendar_Core.prototype.resetRenderers = function() {
+YAHOO.widget.Calendar.prototype.resetRenderers = function() {
 	this.renderStack = this._renderStack.concat();
 };
 
 /**
 * Clears the inner HTML, CSS class and style information from the specified cell.
+* @method clearElement
 * @param	{HTMLTableCellElement}	The cell to clear
-*/ 
-YAHOO.widget.Calendar_Core.prototype.clearElement = function(cell) {
-	cell.innerHTML = "&nbsp;";
+*/
+YAHOO.widget.Calendar.prototype.clearElement = function(cell) {
+	cell.innerHTML = "&#160;";
 	cell.className="";
 };
 
 /**
 * Adds a renderer to the render stack. The function reference passed to this method will be executed
 * when a date cell matches the conditions specified in the date string for this renderer.
+* @method addRenderer
 * @param	{String}	sDates		A date string to associate with the specified renderer. Valid formats
 *									include date (12/24/2005), month/day (12/24), and range (12/1/2004-1/1/2005)
 * @param	{Function}	fnRender	The function executed to render cells that match the render rules for this renderer.
 */
-YAHOO.widget.Calendar_Core.prototype.addRenderer = function(sDates, fnRender) {
+YAHOO.widget.Calendar.prototype.addRenderer = function(sDates, fnRender) {
 	var aDates = this._parseDates(sDates);
-	for (var i=0;i<aDates.length;++i)
-	{
+	for (var i=0;i<aDates.length;++i) {
 		var aDate = aDates[i];
-	
-		if (aDate.length == 2) // this is either a range or a month/day combo
-		{
-			if (aDate[0] instanceof Array) // this is a range
-			{
-				this._addRenderer(YAHOO.widget.Calendar_Core.RANGE,aDate,fnRender);
+
+		if (aDate.length == 2) { // this is either a range or a month/day combo
+			if (aDate[0] instanceof Array) { // this is a range
+				this._addRenderer(YAHOO.widget.Calendar.RANGE,aDate,fnRender);
 			} else { // this is a month/day combo
-				this._addRenderer(YAHOO.widget.Calendar_Core.MONTH_DAY,aDate,fnRender);
+				this._addRenderer(YAHOO.widget.Calendar.MONTH_DAY,aDate,fnRender);
 			}
-		} else if (aDate.length == 3)
-		{
-			this._addRenderer(YAHOO.widget.Calendar_Core.DATE,aDate,fnRender);
+		} else if (aDate.length == 3) {
+			this._addRenderer(YAHOO.widget.Calendar.DATE,aDate,fnRender);
 		}
 	}
 };
@@ -1999,370 +3056,796 @@
 /**
 * The private method used for adding cell renderers to the local render stack.
 * This method is called by other methods that set the renderer type prior to the method call.
+* @method _addRenderer
 * @private
 * @param	{String}	type		The type string that indicates the type of date renderer being added.
-*									Values are YAHOO.widget.Calendar_Core.DATE, YAHOO.widget.Calendar_Core.MONTH_DAY, YAHOO.widget.Calendar_Core.WEEKDAY,
-*									YAHOO.widget.Calendar_Core.RANGE, YAHOO.widget.Calendar_Core.MONTH
+*									Values are YAHOO.widget.Calendar.DATE, YAHOO.widget.Calendar.MONTH_DAY, YAHOO.widget.Calendar.WEEKDAY,
+*									YAHOO.widget.Calendar.RANGE, YAHOO.widget.Calendar.MONTH
 * @param	{Array}		aDates		An array of dates used to construct the renderer. The format varies based
 *									on the renderer type
 * @param	{Function}	fnRender	The function executed to render cells that match the render rules for this renderer.
 */
-YAHOO.widget.Calendar_Core.prototype._addRenderer = function(type, aDates, fnRender) {
+YAHOO.widget.Calendar.prototype._addRenderer = function(type, aDates, fnRender) {
 	var add = [type,aDates,fnRender];
-	this.renderStack.unshift(add);	
-	
+	this.renderStack.unshift(add);
 	this._renderStack = this.renderStack.concat();
 };
 
-/**
-* Adds a month to the render stack. The function reference passed to this method will be executed
-* when a date cell matches the month passed to this method.
-* @param	{Integer}	month		The month (1-12) to associate with this renderer
-* @param	{Function}	fnRender	The function executed to render cells that match the render rules for this renderer.
-*/
-YAHOO.widget.Calendar_Core.prototype.addMonthRenderer = function(month, fnRender) {
-	this._addRenderer(YAHOO.widget.Calendar_Core.MONTH,[month],fnRender);
-};
+/**
+* Adds a month to the render stack. The function reference passed to this method will be executed
+* when a date cell matches the month passed to this method.
+* @method addMonthRenderer
+* @param	{Number}	month		The month (1-12) to associate with this renderer
+* @param	{Function}	fnRender	The function executed to render cells that match the render rules for this renderer.
+*/
+YAHOO.widget.Calendar.prototype.addMonthRenderer = function(month, fnRender) {
+	this._addRenderer(YAHOO.widget.Calendar.MONTH,[month],fnRender);
+};
+
+/**
+* Adds a weekday to the render stack. The function reference passed to this method will be executed
+* when a date cell matches the weekday passed to this method.
+* @method addWeekdayRenderer
+* @param	{Number}	weekday		The weekday (0-6) to associate with this renderer
+* @param	{Function}	fnRender	The function executed to render cells that match the render rules for this renderer.
+*/
+YAHOO.widget.Calendar.prototype.addWeekdayRenderer = function(weekday, fnRender) {
+	this._addRenderer(YAHOO.widget.Calendar.WEEKDAY,[weekday],fnRender);
+};
+
+// END RENDERER METHODS
+
+// BEGIN CSS METHODS
+
+/**
+* Removes all styles from all body cells in the current calendar table.
+* @method clearAllBodyCellStyles
+* @param	{style}		The CSS class name to remove from all calendar body cells
+*/
+YAHOO.widget.Calendar.prototype.clearAllBodyCellStyles = function(style) {
+	for (var c=0;c<this.cells.length;++c) {
+		YAHOO.util.Dom.removeClass(this.cells[c],style);
+	}
+};
+
+// END CSS METHODS
+
+// BEGIN GETTER/SETTER METHODS
+/**
+* Sets the calendar's month explicitly
+* @method setMonth
+* @param {Number}	month		The numeric month, from 0 (January) to 11 (December)
+*/
+YAHOO.widget.Calendar.prototype.setMonth = function(month) {
+	var current = this.cfg.getProperty("pagedate");
+	current.setMonth(month);
+	this.cfg.setProperty("pagedate", current);
+};
+
+/**
+* Sets the calendar's year explicitly.
+* @method setYear
+* @param {Number}	year		The numeric 4-digit year
+*/
+YAHOO.widget.Calendar.prototype.setYear = function(year) {
+	var current = this.cfg.getProperty("pagedate");
+	current.setFullYear(year);
+	this.cfg.setProperty("pagedate", current);
+};
+
+/**
+* Gets the list of currently selected dates from the calendar.
+* @method getSelectedDates
+* @return {Date[]} An array of currently selected JavaScript Date objects.
+*/
+YAHOO.widget.Calendar.prototype.getSelectedDates = function() {
+	var returnDates = [];
+	var selected = this.cfg.getProperty("selected");
+
+	for (var d=0;d<selected.length;++d) {
+		var dateArray = selected[d];
+
+		var date = new Date(dateArray[0],dateArray[1]-1,dateArray[2]);
+		returnDates.push(date);
+	}
+
+	returnDates.sort( function(a,b) { return a-b; } );
+	return returnDates;
+};
+
+/// END GETTER/SETTER METHODS ///
+
+/**
+* Hides the Calendar's outer container from view.
+* @method hide
+*/
+YAHOO.widget.Calendar.prototype.hide = function() {
+	this.oDomContainer.style.display = "none";
+};
+
+/**
+* Shows the Calendar's outer container.
+* @method show
+*/
+YAHOO.widget.Calendar.prototype.show = function() {
+	this.oDomContainer.style.display = "block";
+};
+
+/**
+* Returns a string representing the current browser.
+* @property browser
+* @type String
+*/
+YAHOO.widget.Calendar.prototype.browser = function() {
+			var ua = navigator.userAgent.toLowerCase();
+				  if (ua.indexOf('opera')!=-1) { // Opera (check first in case of spoof)
+					 return 'opera';
+				  } else if (ua.indexOf('msie 7')!=-1) { // IE7
+					 return 'ie7';
+				  } else if (ua.indexOf('msie') !=-1) { // IE
+					 return 'ie';
+				  } else if (ua.indexOf('safari')!=-1) { // Safari (check before Gecko because it includes "like Gecko")
+					 return 'safari';
+				  } else if (ua.indexOf('gecko') != -1) { // Gecko
+					 return 'gecko';
+				  } else {
+					 return false;
+				  }
+			}();
+/**
+* Returns a string representation of the object.
+* @method toString
+* @return {String}	A string representation of the Calendar object.
+*/
+YAHOO.widget.Calendar.prototype.toString = function() {
+	return "Calendar " + this.id;
+};
+
+/**
+* @namespace YAHOO.widget
+* @class Calendar_Core
+* @extends YAHOO.widget.Calendar
+* @deprecated The old Calendar_Core class is no longer necessary.
+*/
+YAHOO.widget.Calendar_Core = YAHOO.widget.Calendar;
+
+YAHOO.widget.Cal_Core = YAHOO.widget.Calendar;
+
+/**
+* YAHOO.widget.CalendarGroup is a special container class for YAHOO.widget.Calendar. This class facilitates
+* the ability to have multi-page calendar views that share a single dataset and are
+* dependent on each other.
+*
+* The calendar group instance will refer to each of its elements using a 0-based index.
+* For example, to construct the placeholder for a calendar group widget with id "cal1" and
+* containerId of "cal1Container", the markup would be as follows:
+*	<xmp>
+*		<div id="cal1Container_0"></div>
+*		<div id="cal1Container_1"></div>
+*	</xmp>
+* The tables for the calendars ("cal1_0" and "cal1_1") will be inserted into those containers.
+* @namespace YAHOO.widget
+* @class CalendarGroup
+* @constructor
+* @param {String}	id			The id of the table element that will represent the calendar widget
+* @param {String}	containerId	The id of the container div element that will wrap the calendar table
+* @param {Object}	config		The configuration object containing the Calendar's arguments
+*/
+YAHOO.widget.CalendarGroup = function(id, containerId, config) {
+	if (arguments.length > 0) {
+		this.init(id, containerId, config);
+	}
+};
+
+/**
+* Initializes the calendar group. All subclasses must call this method in order for the
+* group to be initialized properly.
+* @method init
+* @param {String}	id			The id of the table element that will represent the calendar widget
+* @param {String}	containerId	The id of the container div element that will wrap the calendar table
+* @param {Object}	config		The configuration object containing the Calendar's arguments
+*/
+YAHOO.widget.CalendarGroup.prototype.init = function(id, containerId, config) {
+	this.initEvents();
+	this.initStyles();
+
+	/**
+	* The collection of Calendar pages contained within the CalendarGroup
+	* @property pages
+	* @type YAHOO.widget.Calendar[]
+	*/
+	this.pages = [];
+
+	/**
+	* The unique id associated with the CalendarGroup
+	* @property id
+	* @type String
+	*/
+	this.id = id;
+
+	/**
+	* The unique id associated with the CalendarGroup container
+	* @property containerId
+	* @type String
+	*/
+	this.containerId = containerId;
+
+	/**
+	* The outer containing element for the CalendarGroup
+	* @property oDomContainer
+	* @type HTMLElement
+	*/
+	this.oDomContainer = document.getElementById(containerId);
+
+	YAHOO.util.Dom.addClass(this.oDomContainer, YAHOO.widget.CalendarGroup.CSS_CONTAINER);
+	YAHOO.util.Dom.addClass(this.oDomContainer, YAHOO.widget.CalendarGroup.CSS_MULTI_UP);
+
+	/**
+	* The Config object used to hold the configuration variables for the CalendarGroup
+	* @property cfg
+	* @type YAHOO.util.Config
+	*/
+	this.cfg = new YAHOO.util.Config(this);
+
+	/**
+	* The local object which contains the CalendarGroup's options
+	* @property Options
+	* @type Object
+	*/
+	this.Options = {};
+
+	/**
+	* The local object which contains the CalendarGroup's locale settings
+	* @property Locale
+	* @type Object
+	*/
+	this.Locale = {};
+
+	this.setupConfig();
+
+	if (config) {
+		this.cfg.applyConfig(config, true);
+	}
+
+	this.cfg.fireQueue();
+
+	// OPERA HACK FOR MISWRAPPED FLOATS
+	if (this.browser == "opera"){
+		var fixWidth = function() {
+			var startW = this.oDomContainer.offsetWidth;
+			var w = 0;
+			for (var p=0;p<this.pages.length;++p) {
+				var cal = this.pages[p];
+				w += cal.oDomContainer.offsetWidth;
+			}
+			if (w > 0) {
+				this.oDomContainer.style.width = w + "px";
+			}
+		};
+		this.renderEvent.subscribe(fixWidth,this,true);
+	}
+};
+
+
+YAHOO.widget.CalendarGroup.prototype.setupConfig = function() {
+	/**
+	* The number of pages to include in the CalendarGroup. This value can only be set once, in the CalendarGroup's constructor arguments.
+	* @config pages
+	* @type Number
+	* @default 2
+	*/
+	this.cfg.addProperty("pages", { value:2, validator:this.cfg.checkNumber, handler:this.configPages } );
+
+	/**
+	* The month/year representing the current visible Calendar date (mm/yyyy)
+	* @config pagedate
+	* @type String
+	* @default today's date
+	*/
+	this.cfg.addProperty("pagedate", { value:new Date(), handler:this.configPageDate } );
+
+	/**
+	* The date or range of dates representing the current Calendar selection
+	* @config selected
+	* @type String
+	* @default []
+	*/
+	this.cfg.addProperty("selected", { value:[], handler:this.delegateConfig } );
+
+	/**
+	* The title to display above the CalendarGroup's month header
+	* @config title
+	* @type String
+	* @default ""
+	*/
+	this.cfg.addProperty("title", { value:"", handler:this.configTitle } );
+
+	/**
+	* Whether or not a close button should be displayed for this CalendarGroup
+	* @config close
+	* @type Boolean
+	* @default false
+	*/
+	this.cfg.addProperty("close", { value:false, handler:this.configClose } );
+
+	/**
+	* Whether or not an iframe shim should be placed under the Calendar to prevent select boxes from bleeding through in Internet Explorer 6 and below.
+	* @config iframe
+	* @type Boolean
+	* @default true
+	*/
+	this.cfg.addProperty("iframe", { value:true, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
+
+	/**
+	* The minimum selectable date in the current Calendar (mm/dd/yyyy)
+	* @config mindate
+	* @type String
+	* @default null
+	*/
+	this.cfg.addProperty("mindate", { value:null, handler:this.delegateConfig } );
+
+	/**
+	* The maximum selectable date in the current Calendar (mm/dd/yyyy)
+	* @config maxdate
+	* @type String
+	* @default null
+	*/
+	this.cfg.addProperty("maxdate", { value:null, handler:this.delegateConfig  } );
+
+	// Options properties
+
+	/**
+	* True if the Calendar should allow multiple selections. False by default.
+	* @config MULTI_SELECT
+	* @type Boolean
+	* @default false
+	*/
+	this.cfg.addProperty("MULTI_SELECT",	{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
+
+	/**
+	* The weekday the week begins on. Default is 0 (Sunday).
+	* @config START_WEEKDAY
+	* @type number
+	* @default 0
+	*/
+	this.cfg.addProperty("START_WEEKDAY",	{ value:0, handler:this.delegateConfig, validator:this.cfg.checkNumber  } );
+
+	/**
+	* True if the Calendar should show weekday labels. True by default.
+	* @config SHOW_WEEKDAYS
+	* @type Boolean
+	* @default true
+	*/
+	this.cfg.addProperty("SHOW_WEEKDAYS",	{ value:true, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
+
+	/**
+	* True if the Calendar should show week row headers. False by default.
+	* @config SHOW_WEEK_HEADER
+	* @type Boolean
+	* @default false
+	*/
+	this.cfg.addProperty("SHOW_WEEK_HEADER",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
+
+	/**
+	* True if the Calendar should show week row footers. False by default.
+	* @config SHOW_WEEK_FOOTER
+	* @type Boolean
+	* @default false
+	*/
+	this.cfg.addProperty("SHOW_WEEK_FOOTER",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
+
+	/**
+	* True if the Calendar should suppress weeks that are not a part of the current month. False by default.
+	* @config HIDE_BLANK_WEEKS
+	* @type Boolean
+	* @default false
+	*/
+	this.cfg.addProperty("HIDE_BLANK_WEEKS",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
+
+	/**
+	* The image that should be used for the left navigation arrow.
+	* @config NAV_ARROW_LEFT
+	* @type String
+	* @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif"
+	*/
+	this.cfg.addProperty("NAV_ARROW_LEFT",	{ value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif", handler:this.delegateConfig } );
+
+	/**
+	* The image that should be used for the left navigation arrow.
+	* @config NAV_ARROW_RIGHT
+	* @type String
+	* @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif"
+	*/
+	this.cfg.addProperty("NAV_ARROW_RIGHT",	{ value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif", handler:this.delegateConfig } );
+
+	// Locale properties
+
+	/**
+	* The short month labels for the current locale.
+	* @config MONTHS_SHORT
+	* @type String[]
+	* @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
+	*/
+	this.cfg.addProperty("MONTHS_SHORT",	{ value:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], handler:this.delegateConfig } );
+
+	/**
+	* The long month labels for the current locale.
+	* @config MONTHS_LONG
+	* @type String[]
+	* @default ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
+	*/
+	this.cfg.addProperty("MONTHS_LONG",		{ value:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], handler:this.delegateConfig } );
+
+	/**
+	* The 1-character weekday labels for the current locale.
+	* @config WEEKDAYS_1CHAR
+	* @type String[]
+	* @default ["S", "M", "T", "W", "T", "F", "S"]
+	*/
+	this.cfg.addProperty("WEEKDAYS_1CHAR",	{ value:["S", "M", "T", "W", "T", "F", "S"], handler:this.delegateConfig } );
+
+	/**
+	* The short weekday labels for the current locale.
+	* @config WEEKDAYS_SHORT
+	* @type String[]
+	* @default ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]
+	*/
+	this.cfg.addProperty("WEEKDAYS_SHORT",	{ value:["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], handler:this.delegateConfig } );
+
+	/**
+	* The medium weekday labels for the current locale.
+	* @config WEEKDAYS_MEDIUM
+	* @type String[]
+	* @default ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
+	*/
+	this.cfg.addProperty("WEEKDAYS_MEDIUM",	{ value:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], handler:this.delegateConfig } );
+
+	/**
+	* The long weekday labels for the current locale.
+	* @config WEEKDAYS_LONG
+	* @type String[]
+	* @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
+	*/
+	this.cfg.addProperty("WEEKDAYS_LONG",	{ value:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], handler:this.delegateConfig } );
+
+	/**
+	* The setting that determines which length of month labels should be used. Possible values are "short" and "long".
+	* @config LOCALE_MONTHS
+	* @type String
+	* @default "long"
+	*/
+	this.cfg.addProperty("LOCALE_MONTHS",	{ value:"long", handler:this.delegateConfig } );
+
+	/**
+	* The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long".
+	* @config LOCALE_WEEKDAYS
+	* @type String
+	* @default "short"
+	*/
+	this.cfg.addProperty("LOCALE_WEEKDAYS",	{ value:"short", handler:this.delegateConfig } );
+
+	/**
+	* The value used to delimit individual dates in a date string passed to various Calendar functions.
+	* @config DATE_DELIMITER
+	* @type String
+	* @default ","
+	*/
+	this.cfg.addProperty("DATE_DELIMITER",		{ value:",", handler:this.delegateConfig } );
+
+	/**
+	* The value used to delimit date fields in a date string passed to various Calendar functions.
+	* @config DATE_FIELD_DELIMITER
+	* @type String
+	* @default "/"
+	*/
+	this.cfg.addProperty("DATE_FIELD_DELIMITER",{ value:"/", handler:this.delegateConfig } );
+
+	/**
+	* The value used to delimit date ranges in a date string passed to various Calendar functions.
+	* @config DATE_RANGE_DELIMITER
+	* @type String
+	* @default "-"
+	*/
+	this.cfg.addProperty("DATE_RANGE_DELIMITER",{ value:"-", handler:this.delegateConfig } );
+
+	/**
+	* The position of the month in a month/year date string
+	* @config MY_MONTH_POSITION
+	* @type Number
+	* @default 1
+	*/
+	this.cfg.addProperty("MY_MONTH_POSITION",	{ value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
+
+	/**
+	* The position of the year in a month/year date string
+	* @config MY_YEAR_POSITION
+	* @type Number
+	* @default 2
+	*/
+	this.cfg.addProperty("MY_YEAR_POSITION",	{ value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
+
+	/**
+	* The position of the month in a month/day date string
+	* @config MD_MONTH_POSITION
+	* @type Number
+	* @default 1
+	*/
+	this.cfg.addProperty("MD_MONTH_POSITION",	{ value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
+
+	/**
+	* The position of the day in a month/year date string
+	* @config MD_DAY_POSITION
+	* @type Number
+	* @default 2
+	*/
+	this.cfg.addProperty("MD_DAY_POSITION",		{ value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
+
+	/**
+	* The position of the month in a month/day/year date string
+	* @config MDY_MONTH_POSITION
+	* @type Number
+	* @default 1
+	*/
+	this.cfg.addProperty("MDY_MONTH_POSITION",	{ value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
+
+	/**
+	* The position of the day in a month/day/year date string
+	* @config MDY_DAY_POSITION
+	* @type Number
+	* @default 2
+	*/
+	this.cfg.addProperty("MDY_DAY_POSITION",	{ value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
+
+	/**
+	* The position of the year in a month/day/year date string
+	* @config MDY_YEAR_POSITION
+	* @type Number
+	* @default 3
+	*/
+	this.cfg.addProperty("MDY_YEAR_POSITION",	{ value:3, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
 
-/**
-* Adds a weekday to the render stack. The function reference passed to this method will be executed
-* when a date cell matches the weekday passed to this method.
-* @param	{Integer}	weekay		The weekday (1-7) to associate with this renderer
-* @param	{Function}	fnRender	The function executed to render cells that match the render rules for this renderer.
-*/
-YAHOO.widget.Calendar_Core.prototype.addWeekdayRenderer = function(weekday, fnRender) {
-	this._addRenderer(YAHOO.widget.Calendar_Core.WEEKDAY,[weekday],fnRender);
 };
-/************* END RENDERER METHODS *******************************************************/
 
-/***************** BEGIN CSS METHODS *******************************************/
 /**
-* Adds the specified CSS class to the element passed to this method.
-* @param	{HTMLElement}	element		The element to which the CSS class should be applied
-* @param	{String}	style		The CSS class name to add to the referenced element
+* Initializes CalendarGroup's built-in CustomEvents
+* @method initEvents
 */
-YAHOO.widget.Calendar_Core.addCssClass = function(element, style) {
-	if (element.className.length === 0)
-	{
-		element.className += style;
-	} else {
-		element.className += " " + style;
-	}
-};
+YAHOO.widget.CalendarGroup.prototype.initEvents = function() {
+	var me = this;
 
-YAHOO.widget.Calendar_Core.prependCssClass = function(element, style) {
-	element.className = style + " " + element.className;
-}
+	/**
+	* Proxy subscriber to subscribe to the CalendarGroup's child Calendars' CustomEvents
+	* @method sub
+	* @private
+	* @param {Function} fn	The function to subscribe to this CustomEvent
+	* @param {Object}	obj	The CustomEvent's scope object
+	* @param {Boolean}	bOverride	Whether or not to apply scope correction
+	*/
+	var sub = function(fn, obj, bOverride) {
+		for (var p=0;p<me.pages.length;++p) {
+			var cal = me.pages[p];
+			cal[this.type + "Event"].subscribe(fn, obj, bOverride);
+		}
+	};
 
-/**
-* Removed the specified CSS class from the element passed to this method.
-* @param	{HTMLElement}	element		The element from which the CSS class should be removed
-* @param	{String}	style		The CSS class name to remove from the referenced element
-*/
-YAHOO.widget.Calendar_Core.removeCssClass = function(element, style) {
-	var aStyles = element.className.split(" ");
-	for (var s=0;s<aStyles.length;++s)
-	{
-		if (aStyles[s] == style)
-		{
-			aStyles.splice(s,1);
-			break;
+	/**
+	* Proxy unsubscriber to unsubscribe from the CalendarGroup's child Calendars' CustomEvents
+	* @method unsub
+	* @private
+	* @param {Function} fn	The function to subscribe to this CustomEvent
+	* @param {Object}	obj	The CustomEvent's scope object
+	*/
+	var unsub = function(fn, obj) {
+		for (var p=0;p<me.pages.length;++p) {
+			var cal = me.pages[p];
+			cal[this.type + "Event"].unsubscribe(fn, obj);
 		}
-	}
-	YAHOO.widget.Calendar_Core.setCssClasses(element, aStyles);
-};
+	};
 
-/**
-* Sets the specified array of CSS classes into the referenced element
-* @param	{HTMLElement}	element		The element to set the CSS classes into
-* @param	{String[]}		aStyles		An array of CSS class names
-*/
-YAHOO.widget.Calendar_Core.setCssClasses = function(element, aStyles) {
-	element.className = "";
-	var className = aStyles.join(" ");
-	element.className = className;
-};
+	/**
+	* Fired before a selection is made
+	* @event beforeSelectEvent
+	*/
+	this.beforeSelectEvent = new YAHOO.util.CustomEvent("beforeSelect");
+	this.beforeSelectEvent.subscribe = sub; this.beforeSelectEvent.unsubscribe = unsub;
 
-/**
-* Removes all styles from all body cells in the current calendar table.
-* @param	{style}		The CSS class name to remove from all calendar body cells
-*/
-YAHOO.widget.Calendar_Core.prototype.clearAllBodyCellStyles = function(style) {
-	for (var c=0;c<this.cells.length;++c)
-	{
-		YAHOO.widget.Calendar_Core.removeCssClass(this.cells[c],style);
-	}
-};
+	/**
+	* Fired when a selection is made
+	* @event selectEvent
+	* @param {Array}	Array of Date field arrays in the format [YYYY, MM, DD].
+	*/
+	this.selectEvent = new YAHOO.util.CustomEvent("select");
+	this.selectEvent.subscribe = sub; this.selectEvent.unsubscribe = unsub;
 
-/***************** END CSS METHODS *********************************************/
+	/**
+	* Fired before a selection is made
+	* @event beforeDeselectEvent
+	*/
+	this.beforeDeselectEvent = new YAHOO.util.CustomEvent("beforeDeselect");
+	this.beforeDeselectEvent.subscribe = sub; this.beforeDeselectEvent.unsubscribe = unsub;
 
-/***************** BEGIN GETTER/SETTER METHODS *********************************/
-/**
-* Sets the calendar's month explicitly.
-* @param {Integer}	month		The numeric month, from 1 (January) to 12 (December)
-*/
-YAHOO.widget.Calendar_Core.prototype.setMonth = function(month) {
-	this.pageDate.setMonth(month);
-};
+	/**
+	* Fired when a selection is made
+	* @event deselectEvent
+	* @param {Array}	Array of Date field arrays in the format [YYYY, MM, DD].
+	*/
+	this.deselectEvent = new YAHOO.util.CustomEvent("deselect");
+	this.deselectEvent.subscribe = sub; this.deselectEvent.unsubscribe = unsub;
+
+	/**
+	* Fired when the Calendar page is changed
+	* @event changePageEvent
+	*/
+	this.changePageEvent = new YAHOO.util.CustomEvent("changePage");
+	this.changePageEvent.subscribe = sub; this.changePageEvent.unsubscribe = unsub;
+
+	/**
+	* Fired before the Calendar is rendered
+	* @event beforeRenderEvent
+	*/
+	this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender");
+	this.beforeRenderEvent.subscribe = sub; this.beforeRenderEvent.unsubscribe = unsub;
+
+	/**
+	* Fired when the Calendar is rendered
+	* @event renderEvent
+	*/
+	this.renderEvent = new YAHOO.util.CustomEvent("render");
+	this.renderEvent.subscribe = sub; this.renderEvent.unsubscribe = unsub;
+
+	/**
+	* Fired when the Calendar is reset
+	* @event resetEvent
+	*/
+	this.resetEvent = new YAHOO.util.CustomEvent("reset");
+	this.resetEvent.subscribe = sub; this.resetEvent.unsubscribe = unsub;
+
+	/**
+	* Fired when the Calendar is cleared
+	* @event clearEvent
+	*/
+	this.clearEvent = new YAHOO.util.CustomEvent("clear");
+	this.clearEvent.subscribe = sub; this.clearEvent.unsubscribe = unsub;
 
-/**
-* Sets the calendar's year explicitly.
-* @param {Integer}	year		The numeric 4-digit year
-*/
-YAHOO.widget.Calendar_Core.prototype.setYear = function(year) {
-	this.pageDate.setFullYear(year);
 };
 
 /**
-* Gets the list of currently selected dates from the calendar.
-* @return	An array of currently selected JavaScript Date objects.
-* @type Date[]
+* The default Config handler for the "pages" property
+* @method configPages
+* @param {String} type	The CustomEvent type (usually the property name)
+* @param {Object[]}	args	The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+* @param {Object} obj	The scope object. For configuration handlers, this will usually equal the owner.
 */
-YAHOO.widget.Calendar_Core.prototype.getSelectedDates = function() {
-	var returnDates = new Array();
+YAHOO.widget.CalendarGroup.prototype.configPages = function(type, args, obj) {
+	var pageCount = args[0];
 
-	for (var d=0;d<this.selectedDates.length;++d)
-	{
-		var dateArray = this.selectedDates[d];
+	for (var p=0;p<pageCount;++p) {
+		var calId = this.id + "_" + p;
+		var calContainerId = this.containerId + "_" + p;
 
-		var date = new Date(dateArray[0],dateArray[1]-1,dateArray[2]);
-		returnDates.push(date);
-	}
+		var childConfig = this.cfg.getConfig();
+		childConfig.close = false;
+		childConfig.title = false;
 
-	returnDates.sort();
-	return returnDates;
-};
+		var cal = this.constructChild(calId, calContainerId, childConfig);
+		var caldate = cal.cfg.getProperty("pagedate");
+		caldate.setMonth(caldate.getMonth()+p);
+		cal.cfg.setProperty("pagedate", caldate);
 
-/***************** END GETTER/SETTER METHODS *********************************/
+		YAHOO.util.Dom.removeClass(cal.oDomContainer, this.Style.CSS_SINGLE);
+		YAHOO.util.Dom.addClass(cal.oDomContainer, "groupcal");
 
-YAHOO.widget.Calendar_Core._getBrowser = function()
-{
-  /**
-   * UserAgent
-   * @private
-   * @type String
-   */
-  var ua = navigator.userAgent.toLowerCase();
-  
-  if (ua.indexOf('opera')!=-1) // Opera (check first in case of spoof)
-	 return 'opera';
-  else if (ua.indexOf('msie')!=-1) // IE
-	 return 'ie';
-  else if (ua.indexOf('safari')!=-1) // Safari (check before Gecko because it includes "like Gecko")
-	 return 'safari';
-  else if (ua.indexOf('gecko') != -1) // Gecko
-	 return 'gecko';
- else
-  return false;
-}
-
-
-YAHOO.widget.Cal_Core = YAHOO.widget.Calendar_Core;
-
-/**
-* @class
-* Calendar is the default implementation of the YAHOO.widget.Calendar_Core base class.
-* This class is the UED-approved version of the calendar selector widget. For all documentation
-* on the implemented methods listed here, see the documentation for YAHOO.widget.Calendar_Core.
-* @constructor
-* @param {String}	id			The id of the table element that will represent the calendar widget
-* @param {String}	containerId	The id of the container element that will contain the calendar table
-* @param {String}	monthyear	The month/year string used to set the current calendar page
-* @param {String}	selected	A string of date values formatted using the date parser. The built-in
-								default date format is MM/DD/YYYY. Ranges are defined using
-								MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
-								Any combination of these can be combined by delimiting the string with
-								commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
-*/
-YAHOO.widget.Calendar = function(id, containerId, monthyear, selected) {
-	if (arguments.length > 0)
-	{
-		this.init(id, containerId, monthyear, selected);
-	}
-}
-
-YAHOO.widget.Calendar.prototype = new YAHOO.widget.Calendar_Core();
-
-YAHOO.widget.Calendar.prototype.buildShell = function() {
-	this.border = document.createElement("DIV");
-	this.border.className =  this.Style.CSS_BORDER;
-	
-	this.table = document.createElement("TABLE");
-	this.table.cellSpacing = 0;	
-	
-	YAHOO.widget.Calendar_Core.setCssClasses(this.table, [this.Style.CSS_CALENDAR]);
-
-	this.border.id = this.id;
-	
-	this.buildShellHeader();
-	this.buildShellBody();
-	this.buildShellFooter();
-};
-
-YAHOO.widget.Calendar.prototype.renderShell = function() {
-	this.border.appendChild(this.table);
-	this.oDomContainer.appendChild(this.border);
-	this.shellRendered = true;
-};
-
-YAHOO.widget.Calendar.prototype.renderHeader = function() {
-	this.headerCell.innerHTML = "";
-	
-	var headerContainer = document.createElement("DIV");
-	headerContainer.className = this.Style.CSS_HEADER;
-	
-    var ourthis = this;
-    
-    /* So, Yahoo hooked into previous/nextMonth() via a javascript: "URL",
-       but they did it in a way that didn't work (!).  So I swapped that out
-       for an onclick. */
-	var linkLeft = document.createElement("A");
-    linkLeft.href = "#";
-    linkLeft.onclick = function(ev) { ourthis.previousMonth(); return false; }; 
-	var imgLeft = document.createElement("IMG");
-	imgLeft.src = this.Options.NAV_ARROW_LEFT;
-	imgLeft.className = this.Style.CSS_NAV_LEFT;
-	linkLeft.appendChild(imgLeft);
-	
-	var linkRight = document.createElement("A");
-    linkRight.href = "#";
-    linkRight.onclick = function(ev) { ourthis.nextMonth(); return false; };
-	var imgRight = document.createElement("IMG");
-	imgRight.src = this.Options.NAV_ARROW_RIGHT;
-	imgRight.className = this.Style.CSS_NAV_RIGHT;
-	linkRight.appendChild(imgRight);
-	
-	headerContainer.appendChild(linkLeft);
-	headerContainer.appendChild(document.createTextNode(this.buildMonthLabel()));
-	headerContainer.appendChild(linkRight);
-	
-	this.headerCell.appendChild(headerContainer);
-};
+		if (p===0) {
+			YAHOO.util.Dom.addClass(cal.oDomContainer, "first");
+		}
 
-YAHOO.widget.Cal = YAHOO.widget.Calendar;
+		if (p==(pageCount-1)) {
+			YAHOO.util.Dom.addClass(cal.oDomContainer, "last");
+		}
 
-/**
-* @class
-* <p>YAHOO.widget.CalendarGroup is a special container class for YAHOO.widget.Calendar_Core. This class facilitates
-* the ability to have multi-page calendar views that share a single dataset and are
-* dependent on each other.</p>
-* 
-* <p>The calendar group instance will refer to each of its elements using a 0-based index.
-* For example, to construct the placeholder for a calendar group widget with id "cal1" and
-* containerId of "cal1Container", the markup would be as follows:
-*	<xmp>
-*		<div id="cal1Container_0"></div>
-*		<div id="cal1Container_1"></div>
-*	</xmp>
-* The tables for the calendars ("cal1_0" and "cal1_1") will be inserted into those containers.
-* </p>
-* @constructor
-* @param {Integer}		pageCount	The number of pages that this calendar should display.
-* @param {String}		id			The id of the element that will be inserted into the DOM.
-* @param {String}	containerId	The id of the container element that the calendar will be inserted into.
-* @param {String}		monthyear	The month/year string used to set the current calendar page
-* @param {String}		selected	A string of date values formatted using the date parser. The built-in
-									default date format is MM/DD/YYYY. Ranges are defined using
-									MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
-									Any combination of these can be combined by delimiting the string with
-									commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
-*/
-YAHOO.widget.CalendarGroup = function(pageCount, id, containerId, monthyear, selected) {
-	if (arguments.length > 0)
-	{
-		this.init(pageCount, id, containerId, monthyear, selected);
+		cal.parent = this;
+		cal.index = p;
+
+		this.pages[this.pages.length] = cal;
 	}
-}
+};
 
 /**
-* Initializes the calendar group. All subclasses must call this method in order for the
-* group to be initialized properly.
-* @param {Integer}		pageCount	The number of pages that this calendar should display.
-* @param {String}		id			The id of the element that will be inserted into the DOM.
-* @param {String}		containerId	The id of the container element that the calendar will be inserted into.
-* @param {String}		monthyear	The month/year string used to set the current calendar page
-* @param {String}		selected	A string of date values formatted using the date parser. The built-in
-									default date format is MM/DD/YYYY. Ranges are defined using
-									MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
-									Any combination of these can be combined by delimiting the string with
-									commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
-*/
-YAHOO.widget.CalendarGroup.prototype.init = function(pageCount, id, containerId, monthyear, selected) {
-	//var self=this;
-	
-	this.id = id;
-	this.selectedDates = new Array();
-	this.containerId = containerId;
-	
-	this.pageCount = pageCount;
+* The default Config handler for the "pagedate" property
+* @method configPageDate
+* @param {String} type	The CustomEvent type (usually the property name)
+* @param {Object[]}	args	The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+* @param {Object} obj	The scope object. For configuration handlers, this will usually equal the owner.
+*/
+YAHOO.widget.CalendarGroup.prototype.configPageDate = function(type, args, obj) {
+	var val = args[0];
 
-	this.pages = new Array();
+	for (var p=0;p<this.pages.length;++p) {
+		var cal = this.pages[p];
+		cal.cfg.setProperty("pagedate", val);
+		var calDate = cal.cfg.getProperty("pagedate");
+		calDate.setMonth(calDate.getMonth()+p);
+	}
+};
 
-	for (var p=0;p<pageCount;++p)
-	{
-		var cal = this.constructChild(id + "_" + p, this.containerId + "_" + p , monthyear, selected);
-				
-		cal.parent = this;
-		
-		cal.index = p;
+/**
+* Delegates a configuration property to the CustomEvents associated with the CalendarGroup's children
+* @method delegateConfig
+* @param {String} type	The CustomEvent type (usually the property name)
+* @param {Object[]}	args	The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+* @param {Object} obj	The scope object. For configuration handlers, this will usually equal the owner.
+*/
+YAHOO.widget.CalendarGroup.prototype.delegateConfig = function(type, args, obj) {
+	var val = args[0];
+	var cal;
 
-		cal.pageDate.setMonth(cal.pageDate.getMonth()+p);
-		cal._pageDate = new Date(cal.pageDate.getFullYear(),cal.pageDate.getMonth(),cal.pageDate.getDate());
-		this.pages.push(cal);
-	}
-	
-	this.doNextMonth = function(e, calGroup) {
-		calGroup.nextMonth();
-	}
-	
-	this.doPreviousMonth = function(e, calGroup) {
-		calGroup.previousMonth();
+	for (var p=0;p<this.pages.length;p++) {
+		cal = this.pages[p];
+		cal.cfg.setProperty(type, val);
 	}
 };
 
+
+/**
+* Adds a function to all child Calendars within this CalendarGroup.
+* @method setChildFunction
+* @param {String}		fnName		The name of the function
+* @param {Function}		fn			The function to apply to each Calendar page object
+*/
 YAHOO.widget.CalendarGroup.prototype.setChildFunction = function(fnName, fn) {
-	for (var p=0;p<this.pageCount;++p) {
+	var pageCount = this.cfg.getProperty("pages");
+
+	for (var p=0;p<pageCount;++p) {
 		this.pages[p][fnName] = fn;
 	}
-}
+};
 
+/**
+* Calls a function within all child Calendars within this CalendarGroup.
+* @method callChildFunction
+* @param {String}		fnName		The name of the function
+* @param {Array}		args		The arguments to pass to the function
+*/
 YAHOO.widget.CalendarGroup.prototype.callChildFunction = function(fnName, args) {
-	for (var p=0;p<this.pageCount;++p) {
+	var pageCount = this.cfg.getProperty("pages");
+
+	for (var p=0;p<pageCount;++p) {
 		var page = this.pages[p];
 		if (page[fnName]) {
 			var fn = page[fnName];
 			fn.call(page, args);
 		}
-	}	
-}
+	}
+};
 
 /**
 * Constructs a child calendar. This method can be overridden if a subclassed version of the default
 * calendar is to be used.
-* @param {String}		id			The id of the element that will be inserted into the DOM.
-* @param {String}		containerId	The id of the container element that the calendar will be inserted into.
-* @param {String}		monthyear	The month/year string used to set the current calendar page
-* @param {String}		selected	A string of date values formatted using the date parser. The built-in
-									default date format is MM/DD/YYYY. Ranges are defined using
-									MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
-									Any combination of these can be combined by delimiting the string with
-									commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
-* @return							The YAHOO.widget.Calendar_Core instance that is constructed
-* @type YAHOO.widget.Calendar_Core
-*/
-YAHOO.widget.CalendarGroup.prototype.constructChild = function(id,containerId,monthyear,selected) {
-	return new YAHOO.widget.Calendar_Core(id,containerId,monthyear,selected);
+* @method constructChild
+* @param {String}	id			The id of the table element that will represent the calendar widget
+* @param {String}	containerId	The id of the container div element that will wrap the calendar table
+* @param {Object}	config		The configuration object containing the Calendar's arguments
+* @return {YAHOO.widget.Calendar}	The YAHOO.widget.Calendar instance that is constructed
+*/
+YAHOO.widget.CalendarGroup.prototype.constructChild = function(id,containerId,config) {
+	var container = document.getElementById(containerId);
+	if (! container) {
+		container = document.createElement("div");
+		container.id = containerId;
+		this.oDomContainer.appendChild(container);
+	}
+	return new YAHOO.widget.Calendar(id,containerId,config);
 };
 
 
 /**
 * Sets the calendar group's month explicitly. This month will be set into the first
+* @method setMonth
 * page of the multi-page calendar, and all other months will be iterated appropriately.
-* @param {Integer}	month		The numeric month, from 1 (January) to 12 (December)
+* @param {Number}	month		The numeric month, from 0 (January) to 11 (December)
 */
 YAHOO.widget.CalendarGroup.prototype.setMonth = function(month) {
-	for (var p=0;p<this.pages.length;++p)
-	{
+	for (var p=0;p<this.pages.length;++p) {
 		var cal = this.pages[p];
 		cal.setMonth(month+p);
 	}
@@ -2370,90 +3853,114 @@
 
 /**
 * Sets the calendar group's year explicitly. This year will be set into the first
+* @method setYear
 * page of the multi-page calendar, and all other months will be iterated appropriately.
-* @param {Integer}	year		The numeric 4-digit year
+* @param {Number}	year		The numeric 4-digit year
 */
 YAHOO.widget.CalendarGroup.prototype.setYear = function(year) {
-	for (var p=0;p<this.pages.length;++p)
-	{
+	for (var p=0;p<this.pages.length;++p) {
 		var cal = this.pages[p];
-		if ((cal.pageDate.getMonth()+1) == 1 && p>0)
-		{
+		var pageDate = cal.cfg.getProperty("pageDate");
+
+		if ((pageDate.getMonth()+1) == 1 && p>0) {
 			year+=1;
 		}
 		cal.setYear(year);
 	}
 };
-
 /**
 * Calls the render function of all child calendars within the group.
+* @method render
 */
 YAHOO.widget.CalendarGroup.prototype.render = function() {
-	for (var p=0;p<this.pages.length;++p)
-	{
+	this.renderHeader();
+	for (var p=0;p<this.pages.length;++p) {
 		var cal = this.pages[p];
 		cal.render();
 	}
+	this.renderFooter();
 };
 
 /**
-* Calls the select function of all child calendars within the group.
+* Selects a date or a collection of dates on the current calendar. This method, by default,
+* does not call the render method explicitly. Once selection has completed, render must be
+* called for the changes to be reflected visually.
+* @method select
+* @param	{String/Date/Date[]}	date	The date string of dates to select in the current calendar. Valid formats are
+*								individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006).
+*								Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005).
+*								This method can also take a JavaScript Date object or an array of Date objects.
+* @return	{Date[]}			Array of JavaScript Date objects representing all individual dates that are currently selected.
 */
 YAHOO.widget.CalendarGroup.prototype.select = function(date) {
-	var ret;
-	for (var p=0;p<this.pages.length;++p)
-	{
+	for (var p=0;p<this.pages.length;++p) {
 		var cal = this.pages[p];
-		ret = cal.select(date);
+		cal.select(date);
 	}
-	return ret;
+	return this.getSelectedDates();
 };
 
 /**
-* Calls the selectCell function of all child calendars within the group.
+* Selects a date on the current calendar by referencing the index of the cell that should be selected.
+* This method is used to easily select a single cell (usually with a mouse click) without having to do
+* a full render. The selected style is applied to the cell directly.
+* @method selectCell
+* @param	{Number}	cellIndex	The index of the cell to select in the current calendar.
+* @return	{Date[]}	Array of JavaScript Date objects representing all individual dates that are currently selected.
 */
 YAHOO.widget.CalendarGroup.prototype.selectCell = function(cellIndex) {
-	var ret;
-	for (var p=0;p<this.pages.length;++p)
-	{
+	for (var p=0;p<this.pages.length;++p) {
 		var cal = this.pages[p];
-		ret = cal.selectCell(cellIndex);
+		cal.selectCell(cellIndex);
 	}
-	return ret;
+	return this.getSelectedDates();
 };
 
 /**
-* Calls the deselect function of all child calendars within the group.
+* Deselects a date or a collection of dates on the current calendar. This method, by default,
+* does not call the render method explicitly. Once deselection has completed, render must be
+* called for the changes to be reflected visually.
+* @method deselect
+* @param	{String/Date/Date[]}	date	The date string of dates to deselect in the current calendar. Valid formats are
+*								individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006).
+*								Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005).
+*								This method can also take a JavaScript Date object or an array of Date objects.
+* @return	{Date[]}			Array of JavaScript Date objects representing all individual dates that are currently selected.
 */
 YAHOO.widget.CalendarGroup.prototype.deselect = function(date) {
-	var ret;
-	for (var p=0;p<this.pages.length;++p)
-	{
+	for (var p=0;p<this.pages.length;++p) {
 		var cal = this.pages[p];
-		ret = cal.deselect(date);
+		cal.deselect(date);
 	}
-	return ret;
+	return this.getSelectedDates();
 };
 
 /**
-* Calls the deselectAll function of all child calendars within the group.
+* Deselects all dates on the current calendar.
+* @method deselectAll
+* @return {Date[]}		Array of JavaScript Date objects representing all individual dates that are currently selected.
+*						Assuming that this function executes properly, the return value should be an empty array.
+*						However, the empty array is returned for the sake of being able to check the selection status
+*						of the calendar.
 */
 YAHOO.widget.CalendarGroup.prototype.deselectAll = function() {
-	var ret;
-	for (var p=0;p<this.pages.length;++p)
-	{
+	for (var p=0;p<this.pages.length;++p) {
 		var cal = this.pages[p];
-		ret = cal.deselectAll();
+		cal.deselectAll();
 	}
-	return ret;
+	return this.getSelectedDates();
 };
 
 /**
-* Calls the deselectAll function of all child calendars within the group.
+* Deselects a date on the current calendar by referencing the index of the cell that should be deselected.
+* This method is used to easily deselect a single cell (usually with a mouse click) without having to do
+* a full render. The selected style is removed from the cell directly.
+* @method deselectCell
+* @param	{Number}	cellIndex	The index of the cell to deselect in the current calendar.
+* @return	{Date[]}	Array of JavaScript Date objects representing all individual dates that are currently selected.
 */
 YAHOO.widget.CalendarGroup.prototype.deselectCell = function(cellIndex) {
-	for (var p=0;p<this.pages.length;++p)
-	{
+	for (var p=0;p<this.pages.length;++p) {
 		var cal = this.pages[p];
 		cal.deselectCell(cellIndex);
 	}
@@ -2461,391 +3968,272 @@
 };
 
 /**
-* Calls the reset function of all child calendars within the group.
+* Resets the calendar widget to the originally selected month and year, and
+* sets the calendar to the initial selection(s).
+* @method reset
 */
 YAHOO.widget.CalendarGroup.prototype.reset = function() {
-	for (var p=0;p<this.pages.length;++p)
-	{
+	for (var p=0;p<this.pages.length;++p) {
 		var cal = this.pages[p];
 		cal.reset();
 	}
 };
 
 /**
-* Calls the clear function of all child calendars within the group.
+* Clears the selected dates in the current calendar widget and sets the calendar
+* to the current month and year.
+* @method clear
 */
 YAHOO.widget.CalendarGroup.prototype.clear = function() {
-	for (var p=0;p<this.pages.length;++p)
-	{
+	for (var p=0;p<this.pages.length;++p) {
 		var cal = this.pages[p];
 		cal.clear();
 	}
 };
 
 /**
-* Calls the nextMonth function of all child calendars within the group.
+* Navigates to the next month page in the calendar widget.
+* @method nextMonth
 */
 YAHOO.widget.CalendarGroup.prototype.nextMonth = function() {
-	for (var p=0;p<this.pages.length;++p)
-	{
+	for (var p=0;p<this.pages.length;++p) {
 		var cal = this.pages[p];
 		cal.nextMonth();
 	}
 };
 
 /**
-* Calls the previousMonth function of all child calendars within the group.
+* Navigates to the previous month page in the calendar widget.
+* @method previousMonth
 */
 YAHOO.widget.CalendarGroup.prototype.previousMonth = function() {
-	for (var p=this.pages.length-1;p>=0;--p)
-	{
+	for (var p=this.pages.length-1;p>=0;--p) {
 		var cal = this.pages[p];
 		cal.previousMonth();
 	}
 };
 
 /**
-* Calls the nextYear function of all child calendars within the group.
+* Navigates to the next year in the currently selected month in the calendar widget.
+* @method nextYear
 */
 YAHOO.widget.CalendarGroup.prototype.nextYear = function() {
-	for (var p=0;p<this.pages.length;++p)
-	{
+	for (var p=0;p<this.pages.length;++p) {
 		var cal = this.pages[p];
 		cal.nextYear();
 	}
 };
 
 /**
-* Calls the previousYear function of all child calendars within the group.
+* Navigates to the previous year in the currently selected month in the calendar widget.
+* @method previousYear
 */
 YAHOO.widget.CalendarGroup.prototype.previousYear = function() {
-	for (var p=0;p<this.pages.length;++p)
-	{
+	for (var p=0;p<this.pages.length;++p) {
 		var cal = this.pages[p];
 		cal.previousYear();
 	}
 };
 
-/**
-* Synchronizes the data values for all child calendars within the group. If the sync
-* method is called passing in the caller object, the values of all children will be set
-* to the values of the caller. If the argument is ommitted, the values from all children
-* will be combined into one distinct list and set into each child.
-* @param	{YAHOO.widget.Calendar_Core}	caller		The YAHOO.widget.Calendar_Core that is initiating the call to sync().
-* @return								Array of selected dates, in JavaScript Date object form.
-* @type Date[]
-*/
-YAHOO.widget.CalendarGroup.prototype.sync = function(caller) {
-	var calendar;
-
-	if (caller)
-	{
-		this.selectedDates = caller.selectedDates.concat();
-	} else {
-		var hash = new Object();
-		var combinedDates = new Array();
-
-		for (var p=0;p<this.pages.length;++p)
-		{
-			calendar = this.pages[p];
-
-			var values = calendar.selectedDates;
-
-			for (var v=0;v<values.length;++v)
-			{
-				var valueArray = values[v];
-				hash[valueArray.toString()] = valueArray;
-			}
-		}
-
-		for (var val in hash)
-		{
-			combinedDates[combinedDates.length]=hash[val];
-		}
-		
-		this.selectedDates = combinedDates.concat();
-	}
-
-	// Set all the values into the children
-	for (p=0;p<this.pages.length;++p)
-	{
-		calendar = this.pages[p];
-		if (! calendar.Options.MULTI_SELECT) {
-			calendar.clearAllBodyCellStyles(calendar.Config.Style.CSS_CELL_SELECTED);
-		}
-		calendar.selectedDates = this.selectedDates.concat();
-		
-	}
-	
-	return this.getSelectedDates();
-};
 
 /**
 * Gets the list of currently selected dates from the calendar.
 * @return			An array of currently selected JavaScript Date objects.
 * @type Date[]
 */
-YAHOO.widget.CalendarGroup.prototype.getSelectedDates = function() { 
-	var returnDates = new Array();
+YAHOO.widget.CalendarGroup.prototype.getSelectedDates = function() {
+	var returnDates = [];
+	var selected = this.cfg.getProperty("selected");
 
-	for (var d=0;d<this.selectedDates.length;++d)
-	{
-		var dateArray = this.selectedDates[d];
+	for (var d=0;d<selected.length;++d) {
+		var dateArray = selected[d];
 
 		var date = new Date(dateArray[0],dateArray[1]-1,dateArray[2]);
 		returnDates.push(date);
 	}
 
-	returnDates.sort();
+	returnDates.sort( function(a,b) { return a-b; } );
 	return returnDates;
 };
 
 /**
-* Calls the addRenderer function of all child calendars within the group.
+* Adds a renderer to the render stack. The function reference passed to this method will be executed
+* when a date cell matches the conditions specified in the date string for this renderer.
+* @method addRenderer
+* @param	{String}	sDates		A date string to associate with the specified renderer. Valid formats
+*									include date (12/24/2005), month/day (12/24), and range (12/1/2004-1/1/2005)
+* @param	{Function}	fnRender	The function executed to render cells that match the render rules for this renderer.
 */
 YAHOO.widget.CalendarGroup.prototype.addRenderer = function(sDates, fnRender) {
-	for (var p=0;p<this.pages.length;++p)
-	{
+	for (var p=0;p<this.pages.length;++p) {
 		var cal = this.pages[p];
 		cal.addRenderer(sDates, fnRender);
 	}
 };
 
 /**
-* Calls the addMonthRenderer function of all child calendars within the group.
+* Adds a month to the render stack. The function reference passed to this method will be executed
+* when a date cell matches the month passed to this method.
+* @method addMonthRenderer
+* @param	{Number}	month		The month (1-12) to associate with this renderer
+* @param	{Function}	fnRender	The function executed to render cells that match the render rules for this renderer.
 */
 YAHOO.widget.CalendarGroup.prototype.addMonthRenderer = function(month, fnRender) {
-	for (var p=0;p<this.pages.length;++p)
-	{
+	for (var p=0;p<this.pages.length;++p) {
 		var cal = this.pages[p];
 		cal.addMonthRenderer(month, fnRender);
 	}
 };
 
 /**
-* Calls the addWeekdayRenderer function of all child calendars within the group.
+* Adds a weekday to the render stack. The function reference passed to this method will be executed
+* when a date cell matches the weekday passed to this method.
+* @method addWeekdayRenderer
+* @param	{Number}	weekday		The weekday (0-6) to associate with this renderer
+* @param	{Function}	fnRender	The function executed to render cells that match the render rules for this renderer.
 */
 YAHOO.widget.CalendarGroup.prototype.addWeekdayRenderer = function(weekday, fnRender) {
-	for (var p=0;p<this.pages.length;++p)
-	{
+	for (var p=0;p<this.pages.length;++p) {
 		var cal = this.pages[p];
 		cal.addWeekdayRenderer(weekday, fnRender);
 	}
 };
 
 /**
-* Sets an event handler universally across all child calendars within the group. For instance,
-* to set the onSelect handler for all child calendars to a function called fnSelect, the call would be:
-* <code>
-* calGroup.wireEvent("onSelect", fnSelect);
-* </code>
-* @param	{String}	eventName	The name of the event to handler to set within all child calendars.
-* @param	{Function}	fn			The function to set into the specified event handler.
-*/
-YAHOO.widget.CalendarGroup.prototype.wireEvent = function(eventName, fn) {
-	for (var p=0;p<this.pages.length;++p)
-	{
-		var cal = this.pages[p];
-		cal[eventName] = fn;
-	}
-};
+* Renders the header for the CalendarGroup.
+* @method renderHeader
+*/
+YAHOO.widget.CalendarGroup.prototype.renderHeader = function() {};
 
-YAHOO.widget.CalGrp = YAHOO.widget.CalendarGroup;
+/**
+* Renders a footer for the 2-up calendar container. By default, this method is
+* unimplemented.
+* @method renderFooter
+*/
+YAHOO.widget.CalendarGroup.prototype.renderFooter = function() {};
 
 /**
-* @class
-* Calendar2up_Cal is the default implementation of the Calendar_Core base class, when used
-* in a 2-up view. This class is the UED-approved version of the calendar selector widget. For all documentation
-* on the implemented methods listed here, see the documentation for Calendar_Core. This class
-* has some special attributes that only apply to calendars rendered within the calendar group implementation. 
-* There should be no reason to instantiate this class directly.
-* @constructor
-* @param {String}	id			The id of the table element that will represent the calendar widget
-* @param {String}	containerId	The id of the container element that will contain the calendar table
-* @param {String}	monthyear	The month/year string used to set the current calendar page
-* @param {String}	selected	A string of date values formatted using the date parser. The built-in
-								default date format is MM/DD/YYYY. Ranges are defined using
-								MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
-								Any combination of these can be combined by delimiting the string with
-								commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
-*/
-YAHOO.widget.Calendar2up_Cal = function(id, containerId, monthyear, selected) {
-	if (arguments.length > 0)
-	{
-		this.init(id, containerId, monthyear, selected);
-	}
-}
-
-YAHOO.widget.Calendar2up_Cal.prototype = new YAHOO.widget.Calendar_Core();
-
-/**
-* Renders the header for each individual calendar in the 2-up view. More
-* specifically, this method handles the placement of left and right arrows for
-* navigating between calendar pages.
-*/
-YAHOO.widget.Calendar2up_Cal.prototype.renderHeader = function() {
-	this.headerCell.innerHTML = "";
-	
-	var headerContainer = document.createElement("DIV");
-	headerContainer.className = this.Style.CSS_HEADER;
-	
-	if (this.index == 0) {
-		var linkLeft = document.createElement("A");
-		linkLeft.href = "javascript:void(null)";
-		YAHOO.util.Event.addListener(linkLeft, "click", this.parent.doPreviousMonth, this.parent);
-		var imgLeft = document.createElement("IMG");
-		imgLeft.src = this.Options.NAV_ARROW_LEFT;
-		imgLeft.className = this.Style.CSS_NAV_LEFT;
-		linkLeft.appendChild(imgLeft);
-		headerContainer.appendChild(linkLeft);
-	}
-	
-	headerContainer.appendChild(document.createTextNode(this.buildMonthLabel()));
-	
-	if (this.index == 1) {
-		var linkRight = document.createElement("A");
-		linkRight.href = "javascript:void(null)";
-		YAHOO.util.Event.addListener(linkRight, "click", this.parent.doNextMonth, this.parent);
-		var imgRight = document.createElement("IMG");
-		imgRight.src = this.Options.NAV_ARROW_RIGHT;
-		imgRight.className = this.Style.CSS_NAV_RIGHT;
-		linkRight.appendChild(imgRight);
-		headerContainer.appendChild(linkRight);
-	}
-	
-	this.headerCell.appendChild(headerContainer);
+* Adds the designated number of months to the current calendar month, and sets the current
+* calendar page date to the new month.
+* @method addMonths
+* @param {Number}	count	The number of months to add to the current calendar
+*/
+YAHOO.widget.CalendarGroup.prototype.addMonths = function(count) {
+	this.callChildFunction("addMonths", count);
 };
 
 
-
-
 /**
-* @class
-* Calendar2up is the default implementation of the CalendarGroup base class, when used
-* in a 2-up view. This class is the UED-approved version of the 2-up calendar selector widget. For all documentation
-* on the implemented methods listed here, see the documentation for CalendarGroup. 
-* @constructor
-* @param {String}	id			The id of the table element that will represent the calendar widget
-* @param {String}	containerId	The id of the container element that will contain the calendar table
-* @param {String}	monthyear	The month/year string used to set the current calendar page
-* @param {String}	selected	A string of date values formatted using the date parser. The built-in
-								default date format is MM/DD/YYYY. Ranges are defined using
-								MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
-								Any combination of these can be combined by delimiting the string with
-								commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
-*/
-YAHOO.widget.Calendar2up = function(id, containerId, monthyear, selected) {
-	if (arguments.length > 0)
-	{	
-		this.buildWrapper(containerId);
-		this.init(2, id, containerId, monthyear, selected);
-	}
-}
-
-YAHOO.widget.Calendar2up.prototype = new YAHOO.widget.CalendarGroup();
-
-/**
-* Implementation of CalendarGroup.constructChild that ensures that child calendars of 
-* Calendar2up will be of type Calendar2up_Cal.
-*/
-YAHOO.widget.Calendar2up.prototype.constructChild = function(id,containerId,monthyear,selected) {
-	var cal = new YAHOO.widget.Calendar2up_Cal(id,containerId,monthyear,selected);
-	return cal;
+* Subtracts the designated number of months from the current calendar month, and sets the current
+* calendar page date to the new month.
+* @method subtractMonths
+* @param {Number}	count	The number of months to subtract from the current calendar
+*/
+YAHOO.widget.CalendarGroup.prototype.subtractMonths = function(count) {
+	this.callChildFunction("subtractMonths", count);
 };
 
 /**
-* Builds the wrapper container for the 2-up calendar.
-* @param {String} containerId	The id of the outer container element.
-*/
-YAHOO.widget.Calendar2up.prototype.buildWrapper = function(containerId) {
-	var outerContainer = document.getElementById(containerId);
-	
-	outerContainer.className = "calcontainer";
-	
-	var innerContainer = document.createElement("DIV");
-	innerContainer.className = "calbordered";
-	innerContainer.id = containerId + "_inner";
-	
-	var cal1Container = document.createElement("DIV");
-	cal1Container.id = containerId + "_0";
-	cal1Container.className = "cal2up";
-	cal1Container.style.marginRight = "10px";
-	
-	var cal2Container = document.createElement("DIV");
-	cal2Container.id = containerId + "_1"; 
-	cal2Container.className = "cal2up";
-	
-	outerContainer.appendChild(innerContainer);
-	innerContainer.appendChild(cal1Container);
-	innerContainer.appendChild(cal2Container);
-	
-	this.innerContainer = innerContainer;
-	this.outerContainer = outerContainer;
-}
+* Adds the designated number of years to the current calendar, and sets the current
+* calendar page date to the new month.
+* @method addYears
+* @param {Number}	count	The number of years to add to the current calendar
+*/
+YAHOO.widget.CalendarGroup.prototype.addYears = function(count) {
+	this.callChildFunction("addYears", count);
+};
 
 /**
-* Renders the 2-up calendar.
+* Subtcats the designated number of years from the current calendar, and sets the current
+* calendar page date to the new month.
+* @method subtractYears
+* @param {Number}	count	The number of years to subtract from the current calendar
 */
-YAHOO.widget.Calendar2up.prototype.render = function() {
-	this.renderHeader();
-	YAHOO.widget.CalendarGroup.prototype.render.call(this);
-	this.renderFooter();
+YAHOO.widget.CalendarGroup.prototype.subtractYears = function(count) {
+	this.callChildFunction("subtractYears", count);
 };
 
 /**
-* Renders the header located at the top of the container for the 2-up calendar.
+* CSS class representing the container for the calendar
+* @property YAHOO.widget.CalendarGroup.CSS_CONTAINER
+* @static
+* @final
+* @type String
 */
-YAHOO.widget.Calendar2up.prototype.renderHeader = function() {
-	if (! this.title) {
-		this.title = "";
-	}
-	if (! this.titleDiv)
-	{
-		this.titleDiv = document.createElement("DIV");
-		if (this.title == "")
-		{
-			this.titleDiv.style.display="none";
-		}
-	}
-
-	this.titleDiv.className = "title";
-	this.titleDiv.innerHTML = this.title;
+YAHOO.widget.CalendarGroup.CSS_CONTAINER = "yui-calcontainer";
 
-	if (this.outerContainer.style.position == "absolute")
-	{
-		var linkClose = document.createElement("A");
-		linkClose.href = "javascript:void(null)";
-		YAHOO.util.Event.addListener(linkClose, "click", this.hide, this);
-
-		var imgClose = document.createElement("IMG");
-		imgClose.src = YAHOO.widget.Calendar_Core.IMG_ROOT + "us/my/bn/x_d.gif";
-		imgClose.className = "close-icon";
+/**
+* CSS class representing the container for the calendar
+* @property YAHOO.widget.CalendarGroup.CSS_MULTI_UP
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.CalendarGroup.CSS_MULTI_UP = "multi";
 
-		linkClose.appendChild(imgClose);
+/**
+* CSS class representing the title for the 2-up calendar
+* @property YAHOO.widget.CalendarGroup.CSS_2UPTITLE
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.CalendarGroup.CSS_2UPTITLE = "title";
 
-		this.linkClose = linkClose;
+/**
+* CSS class representing the close icon for the 2-up calendar
+* @property YAHOO.widget.CalendarGroup.CSS_2UPCLOSE
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.CalendarGroup.CSS_2UPCLOSE = "close-icon";
 
-		this.titleDiv.appendChild(linkClose);
-	}
+YAHOO.augment(YAHOO.widget.CalendarGroup, YAHOO.widget.Calendar, "buildDayLabel",
+																 "buildMonthLabel",
+																 "renderOutOfBoundsDate",
+																 "renderRowHeader",
+																 "renderRowFooter",
+																 "renderCellDefault",
+																 "styleCellDefault",
+																 "renderCellStyleHighlight1",
+																 "renderCellStyleHighlight2",
+																 "renderCellStyleHighlight3",
+																 "renderCellStyleHighlight4",
+																 "renderCellStyleToday",
+																 "renderCellStyleSelected",
+																 "renderCellNotThisMonth",
+																 "renderBodyCellRestricted",
+																 "initStyles",
+																 "configTitle",
+																 "configClose",
+																 "hide",
+																 "show",
+																 "browser");
+
+/**
+* Returns a string representation of the object.
+* @method toString
+* @return {String}	A string representation of the CalendarGroup object.
+*/
+YAHOO.widget.CalendarGroup.prototype.toString = function() {
+	return "CalendarGroup " + this.id;
+};
 
-	this.innerContainer.insertBefore(this.titleDiv, this.innerContainer.firstChild);
-}
+YAHOO.widget.CalGrp = YAHOO.widget.CalendarGroup;
 
 /**
-* Hides the 2-up calendar's outer container from view.
+* @class YAHOO.widget.Calendar2up
+* @extends YAHOO.widget.CalendarGroup
+* @deprecated The old Calendar2up class is no longer necessary, since CalendarGroup renders in a 2up view by default.
 */
-YAHOO.widget.Calendar2up.prototype.hide = function(e, cal) {
-	if (! cal)
-	{
-		cal = this;
-	}
-	cal.outerContainer.style.display = "none";
-}
+YAHOO.widget.Calendar2up = function(id, containerId, config) {
+	this.init(id, containerId, config);
+};
+
+YAHOO.extend(YAHOO.widget.Calendar2up, YAHOO.widget.CalendarGroup);
 
 /**
-* Renders a footer for the 2-up calendar container. By default, this method is
-* unimplemented.
+* @deprecated The old Calendar2up class is no longer necessary, since CalendarGroup renders in a 2up view by default.
 */
-YAHOO.widget.Calendar2up.prototype.renderFooter = function() {}
-
-YAHOO.widget.Cal2up = YAHOO.widget.Calendar2up;
+YAHOO.widget.Cal2up = YAHOO.widget.Calendar2up;
\ No newline at end of file

Modified: jifty/trunk/share/web/static/js/yui/dom.js
==============================================================================
--- jifty/trunk/share/web/static/js/yui/dom.js	(original)
+++ jifty/trunk/share/web/static/js/yui/dom.js	Sun Dec  3 21:49:46 2006
@@ -2,721 +2,775 @@
 Copyright (c) 2006, Yahoo! Inc. All rights reserved.
 Code licensed under the BSD License:
 http://developer.yahoo.net/yui/license.txt
+version: 0.12.0
 */
 
 /**
- * @class Provides helper methods for DOM elements.
+ * The dom module provides helper methods for manipulating Dom elements.
+ * @module dom
+ *
  */
-YAHOO.util.Dom = function() {
-   var ua = navigator.userAgent.toLowerCase();
-   var isOpera = (ua.indexOf('opera') != -1);
-   var isIE = (ua.indexOf('msie') != -1 && !isOpera); // not opera spoof
-   var id_counter = 0;
-   
-   return {
-      /**
-       * Returns an HTMLElement reference
-       * @param {String/HTMLElement/Array} el Accepts a string to use as an ID for getting a DOM reference, an actual DOM reference, or an Array of IDs and/or HTMLElements.
-       * @return {HTMLElement/Array} A DOM reference to an HTML element or an array of HTMLElements.
-       */
-      get: function(el) {
-         if (typeof el != 'string' && !(el instanceof Array) )
-         { // assuming HTMLElement or HTMLCollection, so pass back as is
-            return el;
-         }
-         
-         if (typeof el == 'string') 
-         { // ID
-            return document.getElementById(el);
-         }
-         else
-         { // array of ID's and/or elements
-            var collection = [];
-            for (var i = 0, len = el.length; i < len; ++i)
-            {
-               collection[collection.length] = this.get(el[i]);
-            }
-            
-            return collection;
-         }
 
-         return null; // safety, should never happen
-      },
-   
-      /**
-       * Normalizes currentStyle and ComputedStyle.
-       * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
-       * @param {String} property The style property whose value is returned.
-       * @return {String/Array} The current value of the style property for the element(s).
-       */
-      getStyle: function(el, property) {
-         var f = function(el) {
+(function() {
+    var Y = YAHOO.util,     // internal shorthand
+        getStyle,           // for load time browser branching
+        setStyle,           // ditto
+        id_counter = 0,     // for use with generateId
+        propertyCache = {}; // for faster hyphen converts
+
+    // brower detection
+    var ua = navigator.userAgent.toLowerCase(),
+        isOpera = (ua.indexOf('opera') > -1),
+        isSafari = (ua.indexOf('safari') > -1),
+        isGecko = (!isOpera && !isSafari && ua.indexOf('gecko') > -1),
+        isIE = (!isOpera && ua.indexOf('msie') > -1);
+
+    // regex cache
+    var patterns = {
+        HYPHEN: /(-[a-z])/i
+    };
+
+
+    var toCamel = function(property) {
+        if ( !patterns.HYPHEN.test(property) ) {
+            return property; // no hyphens
+        }
+
+        if (propertyCache[property]) { // already converted
+            return propertyCache[property];
+        }
+
+        while( patterns.HYPHEN.exec(property) ) {
+            property = property.replace(RegExp.$1,
+                    RegExp.$1.substr(1).toUpperCase());
+        }
+
+        propertyCache[property] = property;
+        return property;
+        //return property.replace(/-([a-z])/gi, function(m0, m1) {return m1.toUpperCase()}) // cant use function as 2nd arg yet due to safari bug
+    };
+
+    // branching at load instead of runtime
+    if (document.defaultView && document.defaultView.getComputedStyle) { // W3C DOM method
+        getStyle = function(el, property) {
             var value = null;
-            var dv = document.defaultView;
-            
-            if (property == 'opacity' && el.filters) 
-            {// IE opacity
-               value = 1;
-               try {
-                  value = el.filters.item('DXImageTransform.Microsoft.Alpha').opacity / 100;
-               } catch(e) {
-                  try {
-                     value = el.filters.item('alpha').opacity / 100;
-                  } catch(e) {}
-               }
-            }
-            else if (el.style[property]) 
-            {
-               value = el.style[property];
-            }
-            else if (el.currentStyle && el.currentStyle[property]) {
-               value = el.currentStyle[property];
-            }
-            else if ( dv && dv.getComputedStyle )
-            {  // convert camelCase to hyphen-case
-               
-               var converted = '';
-               for(var i = 0, len = property.length;i < len; ++i) {
-                  if (property.charAt(i) == property.charAt(i).toUpperCase()) 
-                  {
-                     converted = converted + '-' + property.charAt(i).toLowerCase();
-                  } else {
-                     converted = converted + property.charAt(i);
-                  }
-               }
-               
-               if (dv.getComputedStyle(el, '') && dv.getComputedStyle(el, '').getPropertyValue(converted)) {
-                  value = dv.getComputedStyle(el, '').getPropertyValue(converted);
-               }
-            }
-      
-            return value;
-         };
-         
-         return this.batch(el, f, this, true);
-      },
-   
-      /**
-       * Wrapper for setting style properties of HTMLElements.  Normalizes "opacity" across modern browsers.
-       * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
-       * @param {String} property The style property to be set.
-       * @param {String} val The value to apply to the given property.
-       */
-      setStyle: function(el, property, val) {
-         var f = function(el) {
-            switch(property) {
-               case 'opacity' :
-                  if (isIE && typeof el.style.filter == 'string') { // in case not appended
-                     el.style.filter = 'alpha(opacity=' + val * 100 + ')';
-                     
-                     if (!el.currentStyle || !el.currentStyle.hasLayout) {
-                        el.style.zoom = 1; // when no layout or cant tell
-                     }
-                  } else {
-                     el.style.opacity = val;
-                     el.style['-moz-opacity'] = val;
-                     el.style['-khtml-opacity'] = val;
-                  }
-
-                  break;
-               default :
-                  el.style[property] = val;
-            }
-            
-         };
-         
-         this.batch(el, f, this, true);
-      },
-      
-      /**
-       * Gets the current position of an element based on page coordinates.  Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
-       * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
-       @ return {Array} The XY position of the element(s)
-       */
-      getXY: function(el) {
-         var f = function(el) {
-   
-         // has to be part of document to have pageXY
-            if (el.parentNode === null || this.getStyle(el, 'display') == 'none') {
-               return false;
-            }
-            
-            var parent = null;
-            var pos = [];
-            var box;
-            
-            if (el.getBoundingClientRect) { // IE
-               box = el.getBoundingClientRect();
-               var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
-               var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
-               
-               return [box.left + scrollLeft, box.top + scrollTop];
-            }
-            else if (document.getBoxObjectFor) { // gecko
-               box = document.getBoxObjectFor(el);
-               
-               var borderLeft = parseInt(this.getStyle(el, 'borderLeftWidth'));
-               var borderTop = parseInt(this.getStyle(el, 'borderTopWidth'));
-               
-               pos = [box.x - borderLeft, box.y - borderTop];
-            }
-            else { // safari & opera
-               pos = [el.offsetLeft, el.offsetTop];
-               parent = el.offsetParent;
-               if (parent != el) {
-                  while (parent) {
-                     pos[0] += parent.offsetLeft;
-                     pos[1] += parent.offsetTop;
-                     parent = parent.offsetParent;
-                  }
-               }
-               if (
-                  ua.indexOf('opera') != -1 
-                  || ( ua.indexOf('safari') != -1 && this.getStyle(el, 'position') == 'absolute' ) 
-               ) {
-                  pos[0] -= document.body.offsetLeft;
-                  pos[1] -= document.body.offsetTop;
-               } 
-            }
-            
-            if (el.parentNode) { parent = el.parentNode; }
-            else { parent = null; }
-      
-            while (parent && parent.tagName != 'BODY' && parent.tagName != 'HTML') 
-            { // account for any scrolled ancestors
-               pos[0] -= parent.scrollLeft;
-               pos[1] -= parent.scrollTop;
-      
-               if (parent.parentNode) { parent = parent.parentNode; } 
-               else { parent = null; }
-            }
-      
-            return pos;
-         };
-         
-         return this.batch(el, f, this, true);
-      },
-      
-      /**
-       * Gets the current X position of an element based on page coordinates.  The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
-       * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
-       * @return {String/Array} The X position of the element(s)
-       */
-      getX: function(el) {
-         return this.getXY(el)[0];
-      },
-      
-      /**
-       * Gets the current Y position of an element based on page coordinates.  Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
-       * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
-       * @return {String/Array} The Y position of the element(s)
-       */
-      getY: function(el) {
-         return this.getXY(el)[1];
-      },
-      
-      /**
-       * Set the position of an html element in page coordinates, regardless of how the element is positioned.
-       * The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
-       * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
-       * @param {Array} pos Contains X & Y values for new position (coordinates are page-based)
-       * @param {Boolean} noRetry By default we try and set the position a second time if the first fails
-       */
-      setXY: function(el, pos, noRetry) {
-         var f = function(el) {
-   
-            var style_pos = this.getStyle(el, 'position');
-            if (style_pos == 'static') { // default to relative
-               this.setStyle(el, 'position', 'relative');
-               style_pos = 'relative';
-            }
-            
-            var pageXY = YAHOO.util.Dom.getXY(el);
-            if (pageXY === false) { return false; } // has to be part of doc to have pageXY
-            
-            var delta = [
-               parseInt( YAHOO.util.Dom.getStyle(el, 'left'), 10 ),
-               parseInt( YAHOO.util.Dom.getStyle(el, 'top'), 10 )
-            ];
-         
-            if ( isNaN(delta[0]) ) // defaults to 'auto'
-            { 
-               delta[0] = (style_pos == 'relative') ? 0 : el.offsetLeft;
-            } 
-            if ( isNaN(delta[1]) ) // defaults to 'auto'
-            { 
-               delta[1] = (style_pos == 'relative') ? 0 : el.offsetTop;
-            } 
-      
-            if (pos[0] !== null) { el.style.left = pos[0] - pageXY[0] + delta[0] + 'px'; }
-            if (pos[1] !== null) { el.style.top = pos[1] - pageXY[1] + delta[1] + 'px'; }
-      
-            var newXY = this.getXY(el);
-      
-            // if retry is true, try one more time if we miss
-            if (!noRetry && (newXY[0] != pos[0] || newXY[1] != pos[1]) ) {
-               var retry = function() { YAHOO.util.Dom.setXY(el, pos, true); };
-               setTimeout(retry, 0); // "delay" for IE resize timing issue
-            }
-         };
-         
-         this.batch(el, f, this, true);
-      },
-      
-      /**
-       * Set the X position of an html element in page coordinates, regardless of how the element is positioned.
-       * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
-       * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
-       * @param {Int} x to use as the X coordinate for the element(s).
-       */
-      setX: function(el, x) {
-         this.setXY(el, [x, null]);
-      },
-      
-      /**
-       * Set the Y position of an html element in page coordinates, regardless of how the element is positioned.
-       * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
-       * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
-       * @param {Int} x to use as the Y coordinate for the element(s).
-       */
-      setY: function(el, y) {
-         this.setXY(el, [null, y]);
-      },
-      
-      /**
-       * Returns the region position of the given element.
-       * The element must be part of the DOM tree to have a region (display:none or elements not appended return false).
-       * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
-       * @return {Region/Array} A Region or array of Region instances containing "top, left, bottom, right" member data.
-       */
-      getRegion: function(el) {
-         var f = function(el) {
-            return new YAHOO.util.Region.getRegion(el);
-         };
-         
-         return this.batch(el, f, this, true);
-      },
-      
-      /**
-       * Returns the width of the client (viewport).
-       * Now using getViewportWidth.  This interface left intact for back compat.
-       * @return {Int} The width of the viewable area of the page.
-       */
-      getClientWidth: function() {
-         return this.getViewportWidth();
-      },
-      
-      /**
-       * Returns the height of the client (viewport).
-       * Now using getViewportHeight.  This interface left intact for back compat.
-       * @return {Int} The height of the viewable area of the page.
-       */
-      getClientHeight: function() {
-         return this.getViewportHeight();
-      },
-
-      /**
-       * Returns a array of HTMLElements with the given class
-       * For optimized performance, include a tag and/or root node if possible
-       * @param {String} className The class name to match against
-       * @param {String} tag (optional) The tag name of the elements being collected
-       * @param {String/HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point 
-       * @return {Array} An array of elements that have the given class name
-       */
-      getElementsByClassName: function(className, tag, root) {
-         var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');
-         
-         var method = function(el) { return re.test(el['className']); };
-         
-         return this.getElementsBy(method, tag, root);
-      },
-
-      /**
-       * Determines whether an HTMLElement has the given className
-       * @param {String/HTMLElement/Array} el The element or collection to test
-       * @param {String} className the class name to search for
-       * @return {Boolean/Array} A boolean value or array of boolean values
-       */
-      hasClass: function(el, className) {
-         var f = function(el) {
+
+            var computed = document.defaultView.getComputedStyle(el, '');
+            if (computed) { // test computed before touching for safari
+                value = computed[toCamel(property)];
+            }
+
+            return el.style[property] || value;
+        };
+    } else if (document.documentElement.currentStyle && isIE) { // IE method
+        getStyle = function(el, property) {
+            switch( toCamel(property) ) {
+                case 'opacity' :// IE opacity uses filter
+                    var val = 100;
+                    try { // will error if no DXImageTransform
+                        val = el.filters['DXImageTransform.Microsoft.Alpha'].opacity;
+
+                    } catch(e) {
+                        try { // make sure its in the document
+                            val = el.filters('alpha').opacity;
+                        } catch(e) {
+                        }
+                    }
+                    return val / 100;
+                    break;
+                default:
+                    // test currentStyle before touching
+                    var value = el.currentStyle ? el.currentStyle[property] : null;
+                    return ( el.style[property] || value );
+            }
+        };
+    } else { // default to inline only
+        getStyle = function(el, property) { return el.style[property]; };
+    }
+
+    if (isIE) {
+        setStyle = function(el, property, val) {
+            switch (property) {
+                case 'opacity':
+                    if ( typeof el.style.filter == 'string' ) { // in case not appended
+                        el.style.filter = 'alpha(opacity=' + val * 100 + ')';
+
+                        if (!el.currentStyle || !el.currentStyle.hasLayout) {
+                            el.style.zoom = 1; // when no layout or cant tell
+                        }
+                    }
+                    break;
+                default:
+                el.style[property] = val;
+            }
+        };
+    } else {
+        setStyle = function(el, property, val) {
+            el.style[property] = val;
+        };
+    }
+
+    /**
+     * Provides helper methods for DOM elements.
+     * @namespace YAHOO.util
+     * @class Dom
+     */
+    YAHOO.util.Dom = {
+        /**
+         * Returns an HTMLElement reference.
+         * @method get
+         * @param {String | HTMLElement |Array} el Accepts a string to use as an ID for getting a DOM reference, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+         * @return {HTMLElement | Array} A DOM reference to an HTML element or an array of HTMLElements.
+         */
+        get: function(el) {
+            if (!el) { return null; } // nothing to work with
+
+            if (typeof el != 'string' && !(el instanceof Array) ) { // assuming HTMLElement or HTMLCollection, so pass back as is
+                return el;
+            }
+
+            if (typeof el == 'string') { // ID
+                return document.getElementById(el);
+            }
+            else { // array of ID's and/or elements
+                var collection = [];
+                for (var i = 0, len = el.length; i < len; ++i) {
+                    collection[collection.length] = Y.Dom.get(el[i]);
+                }
+
+                return collection;
+            }
+
+            return null; // safety, should never happen
+        },
+
+        /**
+         * Normalizes currentStyle and ComputedStyle.
+         * @method getStyle
+         * @param {String | HTMLElement |Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+         * @param {String} property The style property whose value is returned.
+         * @return {String | Array} The current value of the style property for the element(s).
+         */
+        getStyle: function(el, property) {
+            property = toCamel(property);
+
+            var f = function(element) {
+                return getStyle(element, property);
+            };
+
+            return Y.Dom.batch(el, f, Y.Dom, true);
+        },
+
+        /**
+         * Wrapper for setting style properties of HTMLElements.  Normalizes "opacity" across modern browsers.
+         * @method setStyle
+         * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+         * @param {String} property The style property to be set.
+         * @param {String} val The value to apply to the given property.
+         */
+        setStyle: function(el, property, val) {
+            property = toCamel(property);
+
+            var f = function(element) {
+                setStyle(element, property, val);
+
+            };
+
+            Y.Dom.batch(el, f, Y.Dom, true);
+        },
+
+        /**
+         * Gets the current position of an element based on page coordinates.  Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+         * @method getXY
+         * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
+         * @return {Array} The XY position of the element(s)
+         */
+        getXY: function(el) {
+            var f = function(el) {
+
+            // has to be part of document to have pageXY
+                if (el.parentNode === null || el.offsetParent === null ||
+                        this.getStyle(el, 'display') == 'none') {
+                    return false;
+                }
+
+                var parentNode = null;
+                var pos = [];
+                var box;
+
+                if (el.getBoundingClientRect) { // IE
+                    box = el.getBoundingClientRect();
+                    var doc = document;
+                    if ( !this.inDocument(el) && parent.document != document) {// might be in a frame, need to get its scroll
+                        doc = parent.document;
+
+                        if ( !this.isAncestor(doc.documentElement, el) ) {
+                            return false;
+                        }
+
+                    }
+
+                    var scrollTop = Math.max(doc.documentElement.scrollTop, doc.body.scrollTop);
+                    var scrollLeft = Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft);
+
+                    return [box.left + scrollLeft, box.top + scrollTop];
+                }
+                else { // safari, opera, & gecko
+                    pos = [el.offsetLeft, el.offsetTop];
+                    parentNode = el.offsetParent;
+                    if (parentNode != el) {
+                        while (parentNode) {
+                            pos[0] += parentNode.offsetLeft;
+                            pos[1] += parentNode.offsetTop;
+                            parentNode = parentNode.offsetParent;
+                        }
+                    }
+                    if (isSafari && this.getStyle(el, 'position') == 'absolute' ) { // safari doubles in some cases
+                        pos[0] -= document.body.offsetLeft;
+                        pos[1] -= document.body.offsetTop;
+                    }
+                }
+
+                if (el.parentNode) { parentNode = el.parentNode; }
+                else { parentNode = null; }
+
+                while (parentNode && parentNode.tagName.toUpperCase() != 'BODY' && parentNode.tagName.toUpperCase() != 'HTML')
+                { // account for any scrolled ancestors
+                    if (Y.Dom.getStyle(parentNode, 'display') != 'inline') { // work around opera inline scrollLeft/Top bug
+                        pos[0] -= parentNode.scrollLeft;
+                        pos[1] -= parentNode.scrollTop;
+                    }
+
+                    if (parentNode.parentNode) {
+                        parentNode = parentNode.parentNode;
+                    } else { parentNode = null; }
+                }
+
+
+                return pos;
+            };
+
+            return Y.Dom.batch(el, f, Y.Dom, true);
+        },
+
+        /**
+         * Gets the current X position of an element based on page coordinates.  The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+         * @method getX
+         * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
+         * @return {String | Array} The X position of the element(s)
+         */
+        getX: function(el) {
+            var f = function(el) {
+                return Y.Dom.getXY(el)[0];
+            };
+
+            return Y.Dom.batch(el, f, Y.Dom, true);
+        },
+
+        /**
+         * Gets the current Y position of an element based on page coordinates.  Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+         * @method getY
+         * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
+         * @return {String | Array} The Y position of the element(s)
+         */
+        getY: function(el) {
+            var f = function(el) {
+                return Y.Dom.getXY(el)[1];
+            };
+
+            return Y.Dom.batch(el, f, Y.Dom, true);
+        },
+
+        /**
+         * Set the position of an html element in page coordinates, regardless of how the element is positioned.
+         * The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+         * @method setXY
+         * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
+         * @param {Array} pos Contains X & Y values for new position (coordinates are page-based)
+         * @param {Boolean} noRetry By default we try and set the position a second time if the first fails
+         */
+        setXY: function(el, pos, noRetry) {
+            var f = function(el) {
+                var style_pos = this.getStyle(el, 'position');
+                if (style_pos == 'static') { // default to relative
+                    this.setStyle(el, 'position', 'relative');
+                    style_pos = 'relative';
+                }
+
+                var pageXY = this.getXY(el);
+                if (pageXY === false) { // has to be part of doc to have pageXY
+                    return false;
+                }
+
+                var delta = [ // assuming pixels; if not we will have to retry
+                    parseInt( this.getStyle(el, 'left'), 10 ),
+                    parseInt( this.getStyle(el, 'top'), 10 )
+                ];
+
+                if ( isNaN(delta[0]) ) {// in case of 'auto'
+                    delta[0] = (style_pos == 'relative') ? 0 : el.offsetLeft;
+                }
+                if ( isNaN(delta[1]) ) { // in case of 'auto'
+                    delta[1] = (style_pos == 'relative') ? 0 : el.offsetTop;
+                }
+
+                if (pos[0] !== null) { el.style.left = pos[0] - pageXY[0] + delta[0] + 'px'; }
+                if (pos[1] !== null) { el.style.top = pos[1] - pageXY[1] + delta[1] + 'px'; }
+
+                var newXY = this.getXY(el);
+
+                // if retry is true, try one more time if we miss
+                if (!noRetry && (newXY[0] != pos[0] || newXY[1] != pos[1]) ) {
+                    this.setXY(el, pos, true);
+                }
+
+            };
+
+            Y.Dom.batch(el, f, Y.Dom, true);
+        },
+
+        /**
+         * Set the X position of an html element in page coordinates, regardless of how the element is positioned.
+         * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+         * @method setX
+         * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+         * @param {Int} x The value to use as the X coordinate for the element(s).
+         */
+        setX: function(el, x) {
+            Y.Dom.setXY(el, [x, null]);
+        },
+
+        /**
+         * Set the Y position of an html element in page coordinates, regardless of how the element is positioned.
+         * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+         * @method setY
+         * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+         * @param {Int} x To use as the Y coordinate for the element(s).
+         */
+        setY: function(el, y) {
+            Y.Dom.setXY(el, [null, y]);
+        },
+
+        /**
+         * Returns the region position of the given element.
+         * The element must be part of the DOM tree to have a region (display:none or elements not appended return false).
+         * @method getRegion
+         * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+         * @return {Region | Array} A Region or array of Region instances containing "top, left, bottom, right" member data.
+         */
+        getRegion: function(el) {
+            var f = function(el) {
+                var region = new Y.Region.getRegion(el);
+                return region;
+            };
+
+            return Y.Dom.batch(el, f, Y.Dom, true);
+        },
+
+        /**
+         * Returns the width of the client (viewport).
+         * @method getClientWidth
+         * @deprecated Now using getViewportWidth.  This interface left intact for back compat.
+         * @return {Int} The width of the viewable area of the page.
+         */
+        getClientWidth: function() {
+            return Y.Dom.getViewportWidth();
+        },
+
+        /**
+         * Returns the height of the client (viewport).
+         * @method getClientHeight
+         * @deprecated Now using getViewportHeight.  This interface left intact for back compat.
+         * @return {Int} The height of the viewable area of the page.
+         */
+        getClientHeight: function() {
+            return Y.Dom.getViewportHeight();
+        },
+
+        /**
+         * Returns a array of HTMLElements with the given class.
+         * For optimized performance, include a tag and/or root node when possible.
+         * @method getElementsByClassName
+         * @param {String} className The class name to match against
+         * @param {String} tag (optional) The tag name of the elements being collected
+         * @param {String | HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point
+         * @return {Array} An array of elements that have the given class name
+         */
+        getElementsByClassName: function(className, tag, root) {
+            var method = function(el) { return Y.Dom.hasClass(el, className); };
+            return Y.Dom.getElementsBy(method, tag, root);
+        },
+
+        /**
+         * Determines whether an HTMLElement has the given className.
+         * @method hasClass
+         * @param {String | HTMLElement | Array} el The element or collection to test
+         * @param {String} className the class name to search for
+         * @return {Boolean | Array} A boolean value or array of boolean values
+         */
+        hasClass: function(el, className) {
             var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');
-            return re.test(el['className']);
-         };
-         
-         return this.batch(el, f, this, true);
-      },
-   
-      /**
-       * Adds a class name to a given element or collection of elements
-       * @param {String/HTMLElement/Array} el The element or collection to add the class to
-       * @param {String} className the class name to add to the class attribute
-       */
-      addClass: function(el, className) {
-         var f = function(el) {
-            if (this.hasClass(el, className)) { return; } // already present
-            
-            el['className'] = [el['className'], className].join(' ');
-         };
-         
-         this.batch(el, f, this, true);
-      },
-   
-      /**
-       * Removes a class name from a given element or collection of elements
-       * @param {String/HTMLElement/Array} el The element or collection to remove the class from
-       * @param {String} className the class name to remove from the class attribute
-       */
-      removeClass: function(el, className) {
-         var f = function(el) {
-            if (!this.hasClass(el, className)) { return; } // not present
-            
+
+            var f = function(el) {
+                return re.test(el['className']);
+            };
+
+            return Y.Dom.batch(el, f, Y.Dom, true);
+        },
+
+        /**
+         * Adds a class name to a given element or collection of elements.
+         * @method addClass
+         * @param {String | HTMLElement | Array} el The element or collection to add the class to
+         * @param {String} className the class name to add to the class attribute
+         */
+        addClass: function(el, className) {
+            var f = function(el) {
+                if (this.hasClass(el, className)) { return; } // already present
+
+
+                el['className'] = [el['className'], className].join(' ');
+            };
+
+            Y.Dom.batch(el, f, Y.Dom, true);
+        },
+
+        /**
+         * Removes a class name from a given element or collection of elements.
+         * @method removeClass
+         * @param {String | HTMLElement | Array} el The element or collection to remove the class from
+         * @param {String} className the class name to remove from the class attribute
+         */
+        removeClass: function(el, className) {
             var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', 'g');
-            var c = el['className'];
-            
-            el['className'] = c.replace( re, ' ');
-         };
-         
-         this.batch(el, f, this, true);
-      },
-      
-      /**
-       * Replace a class with another class for a given element or collection of elements.
-       * If no oldClassName is present, the newClassName is simply added.
-       * @param {String/HTMLElement/Array} el The element or collection to remove the class from
-       * @param {String} oldClassName the class name to be replaced
-       * @param {String} newClassName the class name that will be replacing the old class name
-       */
-      replaceClass: function(el, oldClassName, newClassName) {
-         var f = function(el) {
-            this.removeClass(el, oldClassName);
-            this.addClass(el, newClassName);
-         };
-         
-         this.batch(el, f, this, true);
-      },
-      
-      /**
-       * Generates a unique ID
-       * @param {String/HTMLElement/Array} el (optional) An optional element array of elements to add an ID to (no ID is added if one is already present)
-       * @param {String} prefix (optional) an optional prefix to use (defaults to "yui-gen")
-       * @return {String/Array} The generated ID, or array of generated IDs (or original ID if already present on an element)
-       */
-      generateId: function(el, prefix) {
-         prefix = prefix || 'yui-gen';
-         
-         var f = function(el) {
-            el = el || {}; // just generating ID in this case
-            
-            if (!el.id) { el.id = prefix + id_counter++; } // dont override existing
-            
-            return el.id;
-         };
-         
-         return this.batch(el, f, this, true);
-      },
-      
-      /**
-       * Determines whether an HTMLElement is an ancestor of another HTML element in the DOM hierarchy
-       * @param {String/HTMLElement} haystack The possible ancestor
-       * @param {String/HTMLElement} needle The possible descendent
-       * @return {Boolean} Whether or not the haystack is an ancestor of needle
-       */
-      isAncestor: function(haystack, needle) {
-         haystack = this.get(haystack);
-         if (!haystack || !needle) { return false; }
-         
-         var f = function(needle) {
-            if (haystack.contains && ua.indexOf('safari') < 0) 
-            { // safari "contains" is broken
-               return haystack.contains(needle);
-            }
-            else if ( haystack.compareDocumentPosition ) 
-            {
-               return !!(haystack.compareDocumentPosition(needle) & 16);
-            }
-            else 
-            { // loop up and test each parent
-               var parent = needle.parentNode;
-               
-               while (parent) {
-                  if (parent == haystack) {
-                     return true;
-                  }
-                  else if (parent.tagName == 'HTML') {
-                     return false;
-                  }
-                  
-                  parent = parent.parentNode;
-               }
-               
-               return false;
-            }    
-         };
-         
-         return this.batch(needle, f, this, true);     
-      },
-      
-      /**
-       * Determines whether an HTMLElement is present in the current document
-       * @param {String/HTMLElement} el The element to search for
-       * @return {Boolean} Whether or not the element is present in the current document
-       */
-      inDocument: function(el) {
-         var f = function(el) {
-            return this.isAncestor(document.documentElement, el);
-         };
-         
-         return this.batch(el, f, this, true);
-      },
-      
-      /**
-       * Returns a array of HTMLElements that pass the test applied by supplied boolean method
-       * For optimized performance, include a tag and/or root node if possible
-       * @param {Function} method A boolean method to test elements with
-       * @param {String} tag (optional) The tag name of the elements being collected
-       * @param {String/HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point 
-       */
-      getElementsBy: function(method, tag, root) {
-         tag = tag || '*';
-         root = this.get(root) || document;
-         
-         var nodes = [];
-         var elements = root.getElementsByTagName(tag);
-         
-         if ( !elements.length && (tag == '*' && root.all) ) {
-            elements = root.all; // IE < 6
-         }
-         
-         for (var i = 0, len = elements.length; i < len; ++i) 
-         {
-            if ( method(elements[i]) ) { nodes[nodes.length] = elements[i]; }
-         }
-
-         return nodes;
-      },
-      
-      /**
-       * Returns an array of elements that have had the supplied method applied.
-       * The method is called with the element(s) as the first arg, and the optional param as the second ( method(el, o) )
-       * @param {String/HTMLElement/Array} el (optional) An element or array of elements to apply the method to
-       * @param {Function} method The method to apply to the element(s)
-       * @param {Generic} (optional) o An optional arg that is passed to the supplied method
-       * @param {Boolean} (optional) override Whether or not to override the scope of "method" with "o"
-       * @return {HTMLElement/Array} The element(s) with the method applied
-       */
-      batch: function(el, method, o, override) {
-         el = this.get(el);
-         var scope = (override) ? o : window;
-         
-         if (!el || el.tagName || !el.length) 
-         { // is null or not a collection (tagName for SELECT and others that can be both an element and a collection)
-            return method.call(scope, el, o);
-         } 
-         
-         var collection = [];
-         
-         for (var i = 0, len = el.length; i < len; ++i)
-         {
-            collection[collection.length] = method.call(scope, el[i], o);
-         }
-         
-         return collection;
-      },
-      
-      /**
-       * Returns the height of the document.
-       * @return {Int} The height of the actual document (which includes the body and its margin).
-       */
-      getDocumentHeight: function() {
-         var scrollHeight=-1,windowHeight=-1,bodyHeight=-1;
-         var marginTop = parseInt(this.getStyle(document.body, 'marginTop'), 10);
-         var marginBottom = parseInt(this.getStyle(document.body, 'marginBottom'), 10);
-         
-         var mode = document.compatMode;
-         
-         if ( (mode || isIE) && !isOpera ) { // (IE, Gecko)
-            switch (mode) {
-               case 'CSS1Compat': // Standards mode
-                  scrollHeight = ((window.innerHeight && window.scrollMaxY) ?  window.innerHeight+window.scrollMaxY : -1);
-                  windowHeight = [document.documentElement.clientHeight,self.innerHeight||-1].sort(function(a, b){return(a-b);})[1];
-                  bodyHeight = document.body.offsetHeight + marginTop + marginBottom;
-                  break;
-               
-               default: // Quirks
-                  scrollHeight = document.body.scrollHeight;
-                  bodyHeight = document.body.clientHeight;
-            }
-         } else { // Safari & Opera
-            scrollHeight = document.documentElement.scrollHeight;
-            windowHeight = self.innerHeight;
-            bodyHeight = document.documentElement.clientHeight;
-         }
-      
-         var h = [scrollHeight,windowHeight,bodyHeight].sort(function(a, b){return(a-b);});
-         return h[2];
-      },
-      
-      /**
-       * Returns the width of the document.
-       * @return {Int} The width of the actual document (which includes the body and its margin).
-       */
-      getDocumentWidth: function() {
-         var docWidth=-1,bodyWidth=-1,winWidth=-1;
-         var marginRight = parseInt(this.getStyle(document.body, 'marginRight'), 10);
-         var marginLeft = parseInt(this.getStyle(document.body, 'marginLeft'), 10);
-         
-         var mode = document.compatMode;
-         
-         if (mode || isIE) { // (IE, Gecko, Opera)
-            switch (mode) {
-               case 'CSS1Compat': // Standards mode
-                  docWidth = document.documentElement.clientWidth;
-                  bodyWidth = document.body.offsetWidth + marginLeft + marginRight;
-                  winWidth = self.innerWidth || -1;
-                  break;
-                  
-               default: // Quirks
-                  bodyWidth = document.body.clientWidth;
-                  winWidth = document.body.scrollWidth;
-                  break;
-            }
-         } else { // Safari
-            docWidth = document.documentElement.clientWidth;
-            bodyWidth = document.body.offsetWidth + marginLeft + marginRight;
-            winWidth = self.innerWidth;
-         }
-      
-         var w = [docWidth,bodyWidth,winWidth].sort(function(a, b){return(a-b);});
-         return w[2];
-      },
-
-      /**
-       * Returns the current height of the viewport.
-       * @return {Int} The height of the viewable area of the page (excludes scrollbars).
-       */
-      getViewportHeight: function() {
-         var height = -1;
-         var mode = document.compatMode;
-      
-         if ( (mode || isIE) && !isOpera ) {
-            switch (mode) { // (IE, Gecko)
-               case 'CSS1Compat': // Standards mode
-                  height = document.documentElement.clientHeight;
-                  break;
-      
-               default: // Quirks
-                  height = document.body.clientHeight;
-            }
-         } else { // Safari, Opera
-            height = self.innerHeight;
-         }
-      
-         return height;
-      },
-      
-      /**
-       * Returns the current width of the viewport.
-       * @return {Int} The width of the viewable area of the page (excludes scrollbars).
-       */
-      
-      getViewportWidth: function() {
-         var width = -1;
-         var mode = document.compatMode;
-         
-         if (mode || isIE) { // (IE, Gecko, Opera)
-            switch (mode) {
-            case 'CSS1Compat': // Standards mode 
-               width = document.documentElement.clientWidth;
-               break;
-               
-            default: // Quirks
-               width = document.body.clientWidth;
-            }
-         } else { // Safari
-            width = self.innerWidth;
-         }
-         
-         return width;
-      }
-   };
-}();
 
-/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-*/
+            var f = function(el) {
+                if (!this.hasClass(el, className)) { return; } // not present
+
+
+                var c = el['className'];
+                el['className'] = c.replace(re, ' ');
+                if ( this.hasClass(el, className) ) { // in case of multiple adjacent
+                    this.removeClass(el, className);
+                }
+
+            };
+
+            Y.Dom.batch(el, f, Y.Dom, true);
+        },
+
+        /**
+         * Replace a class with another class for a given element or collection of elements.
+         * If no oldClassName is present, the newClassName is simply added.
+         * @method replaceClass
+         * @param {String | HTMLElement | Array} el The element or collection to remove the class from
+         * @param {String} oldClassName the class name to be replaced
+         * @param {String} newClassName the class name that will be replacing the old class name
+         */
+        replaceClass: function(el, oldClassName, newClassName) {
+            if (oldClassName === newClassName) { // avoid infinite loop
+                return false;
+            }
+
+            var re = new RegExp('(?:^|\\s+)' + oldClassName + '(?:\\s+|$)', 'g');
+
+            var f = function(el) {
+
+                if ( !this.hasClass(el, oldClassName) ) {
+                    this.addClass(el, newClassName); // just add it if nothing to replace
+                    return; // note return
+                }
+
+                el['className'] = el['className'].replace(re, ' ' + newClassName + ' ');
+
+                if ( this.hasClass(el, oldClassName) ) { // in case of multiple adjacent
+                    this.replaceClass(el, oldClassName, newClassName);
+                }
+            };
+
+            Y.Dom.batch(el, f, Y.Dom, true);
+        },
+
+        /**
+         * Generates a unique ID
+         * @method generateId
+         * @param {String | HTMLElement | Array} el (optional) An optional element array of elements to add an ID to (no ID is added if one is already present).
+         * @param {String} prefix (optional) an optional prefix to use (defaults to "yui-gen").
+         * @return {String | Array} The generated ID, or array of generated IDs (or original ID if already present on an element)
+         */
+        generateId: function(el, prefix) {
+            prefix = prefix || 'yui-gen';
+            el = el || {};
+
+            var f = function(el) {
+                if (el) {
+                    el = Y.Dom.get(el);
+                } else {
+                    el = {}; // just generating ID in this case
+                }
+
+                if (!el.id) {
+                    el.id = prefix + id_counter++;
+                } // dont override existing
+
+
+                return el.id;
+            };
+
+            return Y.Dom.batch(el, f, Y.Dom, true);
+        },
+
+        /**
+         * Determines whether an HTMLElement is an ancestor of another HTML element in the DOM hierarchy.
+         * @method isAncestor
+         * @param {String | HTMLElement} haystack The possible ancestor
+         * @param {String | HTMLElement} needle The possible descendent
+         * @return {Boolean} Whether or not the haystack is an ancestor of needle
+         */
+        isAncestor: function(haystack, needle) {
+            haystack = Y.Dom.get(haystack);
+            if (!haystack || !needle) { return false; }
+
+            var f = function(needle) {
+                if (haystack.contains && !isSafari) { // safari "contains" is broken
+                    return haystack.contains(needle);
+                }
+                else if ( haystack.compareDocumentPosition ) {
+                    return !!(haystack.compareDocumentPosition(needle) & 16);
+                }
+                else { // loop up and test each parent
+                    var parent = needle.parentNode;
+
+                    while (parent) {
+                        if (parent == haystack) {
+                            return true;
+                        }
+                        else if (!parent.tagName || parent.tagName.toUpperCase() == 'HTML') {
+                            return false;
+                        }
+
+                        parent = parent.parentNode;
+                    }
+                    return false;
+                }
+            };
+
+            return Y.Dom.batch(needle, f, Y.Dom, true);
+        },
+
+        /**
+         * Determines whether an HTMLElement is present in the current document.
+         * @method inDocument
+         * @param {String | HTMLElement} el The element to search for
+         * @return {Boolean} Whether or not the element is present in the current document
+         */
+        inDocument: function(el) {
+            var f = function(el) {
+                return this.isAncestor(document.documentElement, el);
+            };
+
+            return Y.Dom.batch(el, f, Y.Dom, true);
+        },
+
+        /**
+         * Returns a array of HTMLElements that pass the test applied by supplied boolean method.
+         * For optimized performance, include a tag and/or root node when possible.
+         * @method getElementsBy
+         * @param {Function} method - A boolean method for testing elements which receives the element as its only argument.
+
+         * @param {String} tag (optional) The tag name of the elements being collected
+         * @param {String | HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point
+         */
+        getElementsBy: function(method, tag, root) {
+            tag = tag || '*';
+            root = Y.Dom.get(root) || document;
+
+            var nodes = [];
+            var elements = root.getElementsByTagName(tag);
+
+            if ( !elements.length && (tag == '*' && root.all) ) {
+                elements = root.all; // IE < 6
+            }
+
+            for (var i = 0, len = elements.length; i < len; ++i) {
+                if ( method(elements[i]) ) { nodes[nodes.length] = elements[i]; }
+            }
+
+
+            return nodes;
+        },
+
+        /**
+         * Returns an array of elements that have had the supplied method applied.
+         * The method is called with the element(s) as the first arg, and the optional param as the second ( method(el, o) ).
+         * @method batch
+         * @param {String | HTMLElement | Array} el (optional) An element or array of elements to apply the method to
+         * @param {Function} method The method to apply to the element(s)
+         * @param {Any} o (optional) An optional arg that is passed to the supplied method
+         * @param {Boolean} override (optional) Whether or not to override the scope of "method" with "o"
+         * @return {HTMLElement | Array} The element(s) with the method applied
+         */
+        batch: function(el, method, o, override) {
+            var id = el;
+            el = Y.Dom.get(el);
+
+            var scope = (override) ? o : window;
+
+            if (!el || el.tagName || !el.length) { // is null or not a collection (tagName for SELECT and others that can be both an element and a collection)
+                if (!el) {
+                    return false;
+                }
+                return method.call(scope, el, o);
+            }
+
+            var collection = [];
+
+            for (var i = 0, len = el.length; i < len; ++i) {
+                if (!el[i]) {
+                    id = el[i];
+                }
+                collection[collection.length] = method.call(scope, el[i], o);
+            }
+
+            return collection;
+        },
 
+        /**
+         * Returns the height of the document.
+         * @method getDocumentHeight
+         * @return {Int} The height of the actual document (which includes the body and its margin).
+         */
+        getDocumentHeight: function() {
+            var scrollHeight = (document.compatMode != 'CSS1Compat') ? document.body.scrollHeight : document.documentElement.scrollHeight;
+
+            var h = Math.max(scrollHeight, Y.Dom.getViewportHeight());
+            return h;
+        },
+
+        /**
+         * Returns the width of the document.
+         * @method getDocumentWidth
+         * @return {Int} The width of the actual document (which includes the body and its margin).
+         */
+        getDocumentWidth: function() {
+            var scrollWidth = (document.compatMode != 'CSS1Compat') ? document.body.scrollWidth : document.documentElement.scrollWidth;
+            var w = Math.max(scrollWidth, Y.Dom.getViewportWidth());
+            return w;
+        },
+
+        /**
+         * Returns the current height of the viewport.
+         * @method getViewportHeight
+         * @return {Int} The height of the viewable area of the page (excludes scrollbars).
+         */
+        getViewportHeight: function() {
+            var height = self.innerHeight; // Safari, Opera
+            var mode = document.compatMode;
+
+            if ( (mode || isIE) && !isOpera ) { // IE, Gecko
+                height = (mode == 'CSS1Compat') ?
+                        document.documentElement.clientHeight : // Standards
+                        document.body.clientHeight; // Quirks
+            }
+
+            return height;
+        },
+
+        /**
+         * Returns the current width of the viewport.
+         * @method getViewportWidth
+         * @return {Int} The width of the viewable area of the page (excludes scrollbars).
+         */
+
+        getViewportWidth: function() {
+            var width = self.innerWidth;  // Safari
+            var mode = document.compatMode;
+
+            if (mode || isIE) { // IE, Gecko, Opera
+                width = (mode == 'CSS1Compat') ?
+                        document.documentElement.clientWidth : // Standards
+                        document.body.clientWidth; // Quirks
+            }
+            return width;
+        }
+    };
+})();
 /**
- * @class A region is a representation of an object on a grid.  It is defined
- * by the top, right, bottom, left extents, so is rectangular by default.  If 
+ * A region is a representation of an object on a grid.  It is defined
+ * by the top, right, bottom, left extents, so is rectangular by default.  If
  * other shapes are required, this class could be extended to support it.
- *
- * @param {int} t the top extent
- * @param {int} r the right extent
- * @param {int} b the bottom extent
- * @param {int} l the left extent
+ * @namespace YAHOO.util
+ * @class Region
+ * @param {Int} t the top extent
+ * @param {Int} r the right extent
+ * @param {Int} b the bottom extent
+ * @param {Int} l the left extent
  * @constructor
  */
 YAHOO.util.Region = function(t, r, b, l) {
 
     /**
      * The region's top extent
-     * @type int
+     * @property top
+     * @type Int
      */
     this.top = t;
-    
+
     /**
      * The region's top extent as index, for symmetry with set/getXY
-     * @type int
+     * @property 1
+     * @type Int
      */
     this[1] = t;
 
     /**
      * The region's right extent
+     * @property right
      * @type int
      */
     this.right = r;
 
     /**
      * The region's bottom extent
-     * @type int
+     * @property bottom
+     * @type Int
      */
     this.bottom = b;
 
     /**
      * The region's left extent
-     * @type int
+     * @property left
+     * @type Int
      */
     this.left = l;
-    
+
     /**
      * The region's left extent as index, for symmetry with set/getXY
-     * @type int
+     * @property 0
+     * @type Int
      */
     this[0] = l;
 };
 
 /**
  * Returns true if this region contains the region passed in
- *
+ * @method contains
  * @param  {Region}  region The region to evaluate
- * @return {boolean}        True if the region is contained with this region, 
+ * @return {Boolean}        True if the region is contained with this region,
  *                          else false
  */
 YAHOO.util.Region.prototype.contains = function(region) {
-    return ( region.left   >= this.left   && 
-             region.right  <= this.right  && 
-             region.top    >= this.top    && 
+    return ( region.left   >= this.left   &&
+             region.right  <= this.right  &&
+             region.top    >= this.top    &&
              region.bottom <= this.bottom    );
 
-    // this.logger.debug("does " + this + " contain " + region + " ... " + ret);
 };
 
 /**
  * Returns the area of the region
- *
- * @return {int} the region's area
+ * @method getArea
+ * @return {Int} the region's area
  */
 YAHOO.util.Region.prototype.getArea = function() {
     return ( (this.bottom - this.top) * (this.right - this.left) );
@@ -724,7 +778,7 @@
 
 /**
  * Returns the region where the passed in region overlaps with this one
- *
+ * @method intersect
  * @param  {Region} region The region that intersects
  * @return {Region}        The overlap region, or null if there is no overlap
  */
@@ -733,7 +787,7 @@
     var r = Math.min( this.right,  region.right  );
     var b = Math.min( this.bottom, region.bottom );
     var l = Math.max( this.left,   region.left   );
-    
+
     if (b >= t && r >= l) {
         return new YAHOO.util.Region(t, r, b, l);
     } else {
@@ -744,7 +798,7 @@
 /**
  * Returns the region representing the smallest region that can contain both
  * the passed in region and this region.
- *
+ * @method union
  * @param  {Region} region The region that to create the union with
  * @return {Region}        The union region
  */
@@ -759,20 +813,21 @@
 
 /**
  * toString
+ * @method toString
  * @return string the region properties
  */
 YAHOO.util.Region.prototype.toString = function() {
-    return ( "Region {" +
-             "t: "    + this.top    + 
-             ", r: "    + this.right  + 
-             ", b: "    + this.bottom + 
-             ", l: "    + this.left   + 
+    return ( "Region {"    +
+             "top: "       + this.top    +
+             ", right: "   + this.right  +
+             ", bottom: "  + this.bottom +
+             ", left: "    + this.left   +
              "}" );
 };
 
 /**
  * Returns a region that is occupied by the DOM element
- *
+ * @method getRegion
  * @param  {HTMLElement} el The element
  * @return {Region}         The region that the element occupies
  * @static
@@ -790,37 +845,36 @@
 
 /////////////////////////////////////////////////////////////////////////////
 
-
 /**
- * @class
- *
- * A point is a region that is special in that it represents a single point on 
+ * A point is a region that is special in that it represents a single point on
  * the grid.
- *
- * @param {int} x The X position of the point
- * @param {int} y The Y position of the point
+ * @namespace YAHOO.util
+ * @class Point
+ * @param {Int} x The X position of the point
+ * @param {Int} y The Y position of the point
  * @constructor
- * @extends Region
+ * @extends YAHOO.util.Region
  */
 YAHOO.util.Point = function(x, y) {
+   if (x instanceof Array) { // accept output from Dom.getXY
+      y = x[1];
+      x = x[0];
+   }
+
     /**
-     * The X position of the point
-     * @type int
+     * The X position of the point, which is also the right, left and index zero (for Dom.getXY symmetry)
+     * @property x
+     * @type Int
      */
-    this.x      = x;
+
+    this.x = this.right = this.left = this[0] = x;
 
     /**
-     * The Y position of the point
-     * @type int
+     * The Y position of the point, which is also the top, bottom and index one (for Dom.getXY symmetry)
+     * @property y
+     * @type Int
      */
-    this.y      = y;
-    this.top    = y;
-    this[1] = y;
-    
-    this.right  = x;
-    this.bottom = y;
-    this.left   = x;
-    this[0] = x;
+    this.y = this.top = this.bottom = this[1] = y;
 };
 
 YAHOO.util.Point.prototype = new YAHOO.util.Region();

Modified: jifty/trunk/share/web/static/js/yui/event.js
==============================================================================
--- jifty/trunk/share/web/static/js/yui/event.js	(original)
+++ jifty/trunk/share/web/static/js/yui/event.js	Sun Dec  3 21:49:46 2006
@@ -1,24 +1,30 @@
 /*                                                                                                                                                      
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.                                                                                                    
-Code licensed under the BSD License:                                                                                                                    
-http://developer.yahoo.net/yui/license.txt                                                                                                              
-version: 0.10.0                                                                                                                                         
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.12.0
 */ 
 
 /**
  * The CustomEvent class lets you define events for your application
  * that can be subscribed to by one or more independent component.
  *
- * @param {String} type The type of event, which is passed to the callback
- *                 when the event fires
- * @param {Object} oScope The context the event will fire from.  "this" will
- *                 refer to this object in the callback.  Default value: 
- *                 the window object.  The listener can override this.
+ * @param {String}  type The type of event, which is passed to the callback
+ *                  when the event fires
+ * @param {Object}  oScope The context the event will fire from.  "this" will
+ *                  refer to this object in the callback.  Default value: 
+ *                  the window object.  The listener can override this.
+ * @param {boolean} silent pass true to prevent the event from writing to
+ *                  the log system
+ * @namespace YAHOO.util
+ * @class CustomEvent
  * @constructor
  */
-YAHOO.util.CustomEvent = function(type, oScope) {
+YAHOO.util.CustomEvent = function(type, oScope, silent, signature) {
+
     /**
      * The type of event, returned to subscribers when the event fires
+     * @property type
      * @type string
      */
     this.type = type;
@@ -26,39 +32,127 @@
     /**
      * The scope the the event will fire from by default.  Defaults to the window 
      * obj
+     * @property scope
      * @type object
      */
     this.scope = oScope || window;
 
     /**
+     * By default all custom events are logged in the debug build, set silent
+     * to true to disable logging for this event.
+     * @property silent
+     * @type boolean
+     */
+    this.silent = silent;
+
+    /**
+     * Custom events support two styles of arguments provided to the event
+     * subscribers.  
+     * <ul>
+     * <li>YAHOO.util.CustomEvent.LIST: 
+     *   <ul>
+     *   <li>param1: event name</li>
+     *   <li>param2: array of arguments sent to fire</li>
+     *   <li>param3: <optional> a custom object supplied by the subscriber</li>
+     *   </ul>
+     * </li>
+     * <li>YAHOO.util.CustomEvent.FLAT
+     *   <ul>
+     *   <li>param1: the first argument passed to fire.  If you need to
+     *           pass multiple parameters, use and array or object literal</li>
+     *   <li>param2: <optional> a custom object supplied by the subscriber</li>
+     *   </ul>
+     * </li>
+     * </ul>
+     *   @property signature
+     *   @type int
+     */
+    this.signature = signature || YAHOO.util.CustomEvent.LIST;
+
+    /**
      * The subscribers to this event
+     * @property subscribers
      * @type Subscriber[]
      */
     this.subscribers = [];
 
-    // Register with the event utility for automatic cleanup.  Made optional
-    // so that CustomEvent can be used independently of pe.event
-    if (YAHOO.util.Event) { 
-        YAHOO.util.Event.regCE(this);
+    if (!this.silent) {
     }
+
+    var onsubscribeType = "_YUICEOnSubscribe";
+
+    // Only add subscribe events for events that are not generated by 
+    // CustomEvent
+    if (type !== onsubscribeType) {
+
+        /**
+         * Custom events provide a custom event that fires whenever there is
+         * a new subscriber to the event.  This provides an opportunity to
+         * handle the case where there is a non-repeating event that has
+         * already fired has a new subscriber.  
+         *
+         * @event subscribeEvent
+         * @type YAHOO.util.CustomEvent
+         * @param {Function} fn The function to execute
+         * @param {Object}   obj An object to be passed along when the event 
+         *                       fires
+         * @param {boolean|Object}  override If true, the obj passed in becomes 
+         *                                   the execution scope of the listener.
+         *                                   if an object, that object becomes the
+         *                                   the execution scope.
+         */
+        this.subscribeEvent = 
+                new YAHOO.util.CustomEvent(onsubscribeType, this, true);
+
+    } 
 };
 
+/**
+ * Subscriber listener sigature constant.  The LIST type returns three
+ * parameters: the event type, the array of args passed to fire, and
+ * the optional custom object
+ * @property YAHOO.util.CustomEvent.LIST
+ * @static
+ * @type int
+ */
+YAHOO.util.CustomEvent.LIST = 0;
+
+/**
+ * Subscriber listener sigature constant.  The FLAT type returns two
+ * parameters: the first argument passed to fire and the optional 
+ * custom object
+ * @property YAHOO.util.CustomEvent.FLAT
+ * @static
+ * @type int
+ */
+YAHOO.util.CustomEvent.FLAT = 1;
+
 YAHOO.util.CustomEvent.prototype = {
+
     /**
      * Subscribes the caller to this event
-     * @param {Function} fn       The function to execute
-     * @param {Object}   obj      An object to be passed along when the event fires
-     * @param {boolean}  bOverride If true, the obj passed in becomes the execution
-     *                            scope of the listener
+     * @method subscribe
+     * @param {Function} fn        The function to execute
+     * @param {Object}   obj       An object to be passed along when the event 
+     *                             fires
+     * @param {boolean|Object}  override If true, the obj passed in becomes 
+     *                                   the execution scope of the listener.
+     *                                   if an object, that object becomes the
+     *                                   the execution scope.
      */
-    subscribe: function(fn, obj, bOverride) {
-        this.subscribers.push( new YAHOO.util.Subscriber(fn, obj, bOverride) );
+    subscribe: function(fn, obj, override) {
+        if (this.subscribeEvent) {
+            this.subscribeEvent.fire(fn, obj, override);
+        }
+
+        this.subscribers.push( new YAHOO.util.Subscriber(fn, obj, override) );
     },
 
     /**
      * Unsubscribes the caller from this event
+     * @method unsubscribe
      * @param {Function} fn  The function to execute
-     * @param {Object}   obj An object to be passed along when the event fires
+     * @param {Object}   obj  The custom object passed to subscribe (optional)
      * @return {boolean} True if the subscriber was found and detached.
      */
     unsubscribe: function(fn, obj) {
@@ -76,36 +170,77 @@
 
     /**
      * Notifies the subscribers.  The callback functions will be executed
-     * from the scope specified when the event was created, and with the following
-     * parameters:
-     *   <pre>
-     *   - The type of event
-     *   - All of the arguments fire() was executed with as an array
-     *   - The custom object (if any) that was passed into the subscribe() method
-     *   </pre>
-     *   
-     * @param {Array} an arbitrary set of parameters to pass to the handler
+     * from the scope specified when the event was created, and with the 
+     * following parameters:
+     *   <ul>
+     *   <li>The type of event</li>
+     *   <li>All of the arguments fire() was executed with as an array</li>
+     *   <li>The custom object (if any) that was passed into the subscribe() 
+     *       method</li>
+     *   </ul>
+     * @method fire 
+     * @param {Object*} arguments an arbitrary set of parameters to pass to 
+     *                            the handler.
      */
     fire: function() {
-        for (var i=0, len=this.subscribers.length; i<len; ++i) {
+        var len=this.subscribers.length;
+        if (!len && this.silent) {
+            return true;
+        }
+
+        var args=[], ret=true, i;
+
+        for (i=0; i<arguments.length; ++i) {
+            args.push(arguments[i]);
+        }
+
+        var argslength = args.length;
+
+        if (!this.silent) {
+        }
+
+        for (i=0; i<len; ++i) {
             var s = this.subscribers[i];
             if (s) {
-                var scope = (s.override) ? s.obj : this.scope;
-                s.fn.call(scope, this.type, arguments, s.obj);
+                if (!this.silent) {
+                }
+
+                var scope = s.getScope(this.scope);
+
+                if (this.signature == YAHOO.util.CustomEvent.FLAT) {
+                    var param = null;
+                    if (args.length > 0) {
+                        param = args[0];
+                    }
+                    ret = s.fn.call(scope, param, s.obj);
+                } else {
+                    ret = s.fn.call(scope, this.type, args, s.obj);
+                }
+                if (false === ret) {
+                    if (!this.silent) {
+                    }
+
+                    //break;
+                    return false;
+                }
             }
         }
+
+        return true;
     },
 
     /**
      * Removes all listeners
+     * @method unsubscribeAll
      */
     unsubscribeAll: function() {
         for (var i=0, len=this.subscribers.length; i<len; ++i) {
-            this._delete(i);
+            this._delete(len - 1 - i);
         }
     },
 
     /**
+     * @method _delete
      * @private
      */
     _delete: function(index) {
@@ -115,23 +250,36 @@
             delete s.obj;
         }
 
-        delete this.subscribers[index];
+        // delete this.subscribers[index];
+        this.subscribers.splice(index, 1);
+    },
+
+    /**
+     * @method toString
+     */
+    toString: function() {
+         return "CustomEvent: " + "'" + this.type  + "', " + 
+             "scope: " + this.scope;
+
     }
 };
 
 /////////////////////////////////////////////////////////////////////
 
 /**
- * @class Stores the subscriber information to be used when the event fires.
+ * Stores the subscriber information to be used when the event fires.
  * @param {Function} fn       The function to execute
  * @param {Object}   obj      An object to be passed along when the event fires
- * @param {boolean}  bOverride If true, the obj passed in becomes the execution
+ * @param {boolean}  override If true, the obj passed in becomes the execution
  *                            scope of the listener
+ * @class Subscriber
  * @constructor
  */
-YAHOO.util.Subscriber = function(fn, obj, bOverride) {
+YAHOO.util.Subscriber = function(fn, obj, override) {
+
     /**
      * The callback that will be execute when the event fires
+     * @property fn
      * @type function
      */
     this.fn = fn;
@@ -139,6 +287,7 @@
     /**
      * An optional custom object that will passed to the callback when
      * the event fires
+     * @property obj
      * @type object
      */
     this.obj = obj || null;
@@ -147,86 +296,124 @@
      * The default execution scope for the event listener is defined when the
      * event is created (usually the object which contains the event).
      * By setting override to true, the execution scope becomes the custom
-     * object passed in by the subscriber
-     * @type boolean
+     * object passed in by the subscriber.  If override is an object, that 
+     * object becomes the scope.
+     * @property override
+     * @type boolean|object
      */
-    this.override = (bOverride);
+    this.override = override;
+
+};
+
+/**
+ * Returns the execution scope for this listener.  If override was set to true
+ * the custom obj will be the scope.  If override is an object, that is the
+ * scope, otherwise the default scope will be used.
+ * @method getScope
+ * @param {Object} defaultScope the scope to use if this listener does not
+ *                              override it.
+ */
+YAHOO.util.Subscriber.prototype.getScope = function(defaultScope) {
+    if (this.override) {
+        if (this.override === true) {
+            return this.obj;
+        } else {
+            return this.override;
+        }
+    }
+    return defaultScope;
 };
 
 /**
  * Returns true if the fn and obj match this objects properties.
  * Used by the unsubscribe method to match the right subscriber.
  *
+ * @method contains
  * @param {Function} fn the function to execute
  * @param {Object} obj an object to be passed along when the event fires
  * @return {boolean} true if the supplied arguments match this 
  *                   subscriber's signature.
  */
 YAHOO.util.Subscriber.prototype.contains = function(fn, obj) {
-    return (this.fn == fn && this.obj == obj);
+    if (obj) {
+        return (this.fn == fn && this.obj == obj);
+    } else {
+        return (this.fn == fn);
+    }
 };
 
-/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+/**
+ * @method toString
+ */
+YAHOO.util.Subscriber.prototype.toString = function() {
+    return "Subscriber { obj: " + (this.obj || "")  + 
+           ", override: " +  (this.override || "no") + " }";
+};
 
-// Only load this library once.  If it is loaded a second time, existing
-// events cannot be detached.
+/**
+ * The Event Utility provides utilities for managing DOM Events and tools
+ * for building event systems
+ *
+ * @module event
+ * @title Event Utility
+ * @namespace YAHOO.util
+ * @requires yahoo
+ */
+
+// The first instance of Event will win if it is loaded more than once.
 if (!YAHOO.util.Event) {
 
 /**
- * @class
  * The event utility provides functions to add and remove event listeners,
  * event cleansing.  It also tries to automatically remove listeners it
  * registers during the unload event.
- * @constructor
+ *
+ * @class Event
+ * @static
  */
     YAHOO.util.Event = function() {
 
         /**
          * True after the onload event has fired
+         * @property loadComplete
          * @type boolean
+         * @static
          * @private
          */
         var loadComplete =  false;
 
         /**
          * Cache of wrapped listeners
+         * @property listeners
          * @type array
+         * @static
          * @private
          */
         var listeners = [];
 
         /**
-         * Listeners that will be attached during the onload event
-         * @type array
-         * @private
-         */
-        var delayedListeners = [];
-
-        /**
          * User-defined unload function that will be fired before all events
          * are detached
+         * @property unloadListeners
          * @type array
+         * @static
          * @private
          */
         var unloadListeners = [];
 
         /**
-         * Cache of the custom events that have been defined.  Used for
-         * automatic cleanup
-         * @type array
-         * @private
-         */
-        var customEvents = [];
-
-        /**
          * Cache of DOM0 event handlers to work around issues with DOM2 events
          * in Safari
+         * @property legacyEvents
+         * @static
          * @private
          */
         var legacyEvents = [];
 
         /**
          * Listener stack for DOM0 events
+         * @property legacyHandlers
+         * @static
          * @private
          */
         var legacyHandlers = [];
@@ -235,24 +422,32 @@
          * The number of times to poll after window.onload.  This number is
          * increased if additional late-bound handlers are requested after
          * the page load.
+         * @property retryCount
+         * @static
          * @private
          */
         var retryCount = 0;
 
         /**
          * onAvailable listeners
+         * @property onAvailStack
+         * @static
          * @private
          */
         var onAvailStack = [];
 
         /**
          * Lookup table for legacy events
+         * @property legacyMap
+         * @static
          * @private
          */
         var legacyMap = [];
 
         /**
          * Counter for auto id generation
+         * @property counter
+         * @static
          * @private
          */
         var counter = 0;
@@ -262,54 +457,78 @@
             /**
              * The number of times we should look for elements that are not
              * in the DOM at the time the event is requested after the document
-             * has been loaded.  The default is 200 at 50 ms, so it will poll
+             * has been loaded.  The default is 200 at amp;50 ms, so it will poll
              * for 10 seconds or until all outstanding handlers are bound
              * (whichever comes first).
+             * @property POLL_RETRYS
              * @type int
+             * @static
+             * @final
              */
             POLL_RETRYS: 200,
 
             /**
              * The poll interval in milliseconds
+             * @property POLL_INTERVAL
              * @type int
+             * @static
+             * @final
              */
-            POLL_INTERVAL: 50,
+            POLL_INTERVAL: 20,
 
             /**
              * Element to bind, int constant
+             * @property EL
              * @type int
+             * @static
+             * @final
              */
             EL: 0,
 
             /**
              * Type of event, int constant
+             * @property TYPE
              * @type int
+             * @static
+             * @final
              */
             TYPE: 1,
 
             /**
              * Function to execute, int constant
+             * @property FN
              * @type int
+             * @static
+             * @final
              */
             FN: 2,
 
             /**
              * Function wrapped for scope correction and cleanup, int constant
+             * @property WFN
              * @type int
+             * @static
+             * @final
              */
             WFN: 3,
 
             /**
              * Object passed in by the user that will be returned as a 
              * parameter to the callback, int constant
+             * @property OBJ
              * @type int
+             * @static
+             * @final
              */
-            SCOPE: 3,
+            OBJ: 3,
 
             /**
              * Adjusted scope, either the element we are registering the event
              * on or the custom object passed in by the listener, int constant
+             * @property ADJ_SCOPE
              * @type int
+             * @static
+             * @final
              */
             ADJ_SCOPE: 4,
 
@@ -317,7 +536,9 @@
              * Safari detection is necessary to work around the preventDefault
              * bug that makes it so you can't cancel a href click from the 
              * handler.  There is not a capabilities check we can use here.
+             * @property isSafari
              * @private
+             * @static
              */
             isSafari: (/Safari|Konqueror|KHTML/gi).test(navigator.userAgent),
 
@@ -326,36 +547,32 @@
              * capabilities checking didn't seem to work because another 
              * browser that does not provide the properties have the values 
              * calculated in a different manner than IE.
+             * @property isIE
              * @private
+             * @static
              */
             isIE: (!this.isSafari && !navigator.userAgent.match(/opera/gi) && 
                     navigator.userAgent.match(/msie/gi)),
 
             /**
+             * poll handle
+             * @property _interval
              * @private
              */
-            addDelayedListener: function(el, sType, fn, oScope, bOverride) {
-                delayedListeners[delayedListeners.length] =
-                    [el, sType, fn, oScope, bOverride];
-
-                // If this happens after the inital page load, we need to
-                // reset the poll counter so that we continue to search for
-                // the element for a fixed period of time.
-                if (loadComplete) {
-                    retryCount = this.POLL_RETRYS;
-                    this.startTimeout(0);
-                    // this._tryPreloadAttach();
-                }
-            },
+            _interval: null,
 
             /**
+             * @method startInterval
+             * @static
              * @private
              */
-            startTimeout: function(interval) {
-                var i = (interval || interval === 0) ? interval : this.POLL_INTERVAL;
-                var self = this;
-                var callback = function() { self._tryPreloadAttach(); };
-                this.timeout = setTimeout(callback, i);
+            startInterval: function() {
+                if (!this._interval) {
+                    var self = this;
+                    var callback = function() { self._tryPreloadAttach(); };
+                    this._interval = setInterval(callback, this.POLL_INTERVAL);
+                    // this.timeout = setTimeout(callback, i);
+                }
             },
 
             /**
@@ -365,41 +582,75 @@
              * initial page load it will poll for a fixed time for the element.
              * The number of times it will poll and the frequency are
              * configurable.  By default it will poll for 10 seconds.
-             * @param {string} p_id the id of the element to look for.
+             *
+             * @method onAvailable
+             *
+             * @param {string}   p_id the id of the element to look for.
              * @param {function} p_fn what to execute when the element is found.
-             * @param {object} p_obj an optional object to be passed back as
-             * a parameter to p_fn.
-             * @param {boolean} p_override If set to true, p_fn will execute
-             * in the scope of p_obj
+             * @param {object}   p_obj an optional object to be passed back as
+             *                   a parameter to p_fn.
+             * @param {boolean}  p_override If set to true, p_fn will execute
+             *                   in the scope of p_obj
              *
+             * @static
              */
             onAvailable: function(p_id, p_fn, p_obj, p_override) {
-                onAvailStack.push( { id:       p_id, 
-                                     fn:       p_fn, 
-                                     obj:      p_obj, 
-                                     override: p_override } );
+                onAvailStack.push( { id:         p_id, 
+                                     fn:         p_fn, 
+                                     obj:        p_obj, 
+                                     override:   p_override, 
+                                     checkReady: false    } );
+
+                retryCount = this.POLL_RETRYS;
+                this.startInterval();
+            },
+
+            /**
+             * Works the same way as onAvailable, but additionally checks the
+             * state of sibling elements to determine if the content of the
+             * available element is safe to modify.
+             *
+             * @method onContentReady
+             *
+             * @param {string}   p_id the id of the element to look for.
+             * @param {function} p_fn what to execute when the element is ready.
+             * @param {object}   p_obj an optional object to be passed back as
+             *                   a parameter to p_fn.
+             * @param {boolean}  p_override If set to true, p_fn will execute
+             *                   in the scope of p_obj
+             *
+             * @static
+             */
+            onContentReady: function(p_id, p_fn, p_obj, p_override) {
+                onAvailStack.push( { id:         p_id, 
+                                     fn:         p_fn, 
+                                     obj:        p_obj, 
+                                     override:   p_override,
+                                     checkReady: true      } );
 
                 retryCount = this.POLL_RETRYS;
-                this.startTimeout(0);
-                // this._tryPreloadAttach();
+                this.startInterval();
             },
 
             /**
              * Appends an event handler
              *
+             * @method addListener
+             *
              * @param {Object}   el        The html element to assign the 
              *                             event to
              * @param {String}   sType     The type of event to append
              * @param {Function} fn        The method the event invokes
-             * @param {Object}   oScope    An arbitrary object that will be 
+             * @param {Object}   obj    An arbitrary object that will be 
              *                             passed as a parameter to the handler
-             * @param {boolean}  bOverride If true, the obj passed in becomes
+             * @param {boolean}  override  If true, the obj passed in becomes
              *                             the execution scope of the listener
              * @return {boolean} True if the action was successful or defered,
              *                        false if one or more of the elements 
              *                        could not have the event bound to it.
+             * @static
              */
-            addListener: function(el, sType, fn, oScope, bOverride) {
+            addListener: function(el, sType, fn, obj, override) {
 
                 if (!fn || !fn.call) {
                     return false;
@@ -409,11 +660,11 @@
                 if ( this._isValidCollection(el)) {
                     var ok = true;
                     for (var i=0,len=el.length; i<len; ++i) {
-                        ok = ( this.on(el[i], 
+                        ok = this.on(el[i], 
                                        sType, 
                                        fn, 
-                                       oScope, 
-                                       bOverride) && ok );
+                                       obj, 
+                                       override) && ok;
                     }
                     return ok;
 
@@ -426,15 +677,13 @@
 
                     // check to see if we need to delay hooking up the event 
                     // until after the page loads.
-                    if (loadComplete && oEl) {
+                    if (oEl) {
                         el = oEl;
                     } else {
-                        // defer adding the event until onload fires
-                        this.addDelayedListener(el, 
-                                                sType, 
-                                                fn, 
-                                                oScope, 
-                                                bOverride);
+                        // defer adding the event until the element is available
+                        this.onAvailable(el, function() {
+                           YAHOO.util.Event.on(el, sType, fn, obj, override);
+                        });
 
                         return true;
                     }
@@ -450,23 +699,29 @@
                 // prior to automatically unhooking them.  So we hang on to 
                 // these instead of attaching them to the window and fire the
                 // handles explicitly during our one unload event.
-                if ("unload" == sType && oScope !== this) {
+                if ("unload" == sType && obj !== this) {
                     unloadListeners[unloadListeners.length] =
-                            [el, sType, fn, oScope, bOverride];
+                            [el, sType, fn, obj, override];
                     return true;
                 }
 
-
                 // if the user chooses to override the scope, we use the custom
                 // object passed in, otherwise the executing scope will be the
                 // HTML element that the event is registered on
-                var scope = (bOverride) ? oScope : el;
+                var scope = el;
+                if (override) {
+                    if (override === true) {
+                        scope = obj;
+                    } else {
+                        scope = override;
+                    }
+                }
 
-                // wrap the function so we can return the oScope object when
+                // wrap the function so we can return the obj object when
                 // the event fires;
                 var wrappedFn = function(e) {
                         return fn.call(scope, YAHOO.util.Event.getEvent(e), 
-                                oScope);
+                                obj);
                     };
 
                 var li = [el, sType, fn, wrappedFn, scope];
@@ -476,7 +731,11 @@
 
                 if (this.useLegacyEvent(el, sType)) {
                     var legacyIndex = this.getLegacyIndex(el, sType);
-                    if (legacyIndex == -1) {
+
+                    // Add a new dom0 wrapper if one is not detected for this
+                    // element
+                    if ( legacyIndex == -1 || 
+                                el != legacyEvents[legacyIndex][0] ) {
 
                         legacyIndex = legacyEvents.length;
                         legacyMap[el.id + sType] = legacyIndex;
@@ -496,14 +755,11 @@
 
                     // add a reference to the wrapped listener to our custom
                     // stack of events
-                    legacyHandlers[legacyIndex].push(index);
+                    //legacyHandlers[legacyIndex].push(index);
+                    legacyHandlers[legacyIndex].push(li);
 
-                // DOM2 Event model
-                } else if (el.addEventListener) {
-                    el.addEventListener(sType, wrappedFn, false);
-                // Internet Explorer abstraction
-                } else if (el.attachEvent) {
-                    el.attachEvent("on" + sType, wrappedFn);
+                } else {
+                    this._simpleAdd(el, sType, wrappedFn, false);
                 }
 
                 return true;
@@ -511,14 +767,10 @@
             },
 
             /**
-             * Shorthand for YAHOO.util.Event.addListener
-             * @type function
-             */
-            // on: this.addListener,
-
-            /**
              * When using legacy events, the handler is routed to this object
              * so we can fire our custom listener stack.
+             * @method fireLegacyEvent
+             * @static
              * @private
              */
             fireLegacyEvent: function(e, legacyIndex) {
@@ -526,18 +778,11 @@
 
                 var le = legacyHandlers[legacyIndex];
                 for (var i=0,len=le.length; i<len; ++i) {
-                    var index = le[i];
-                    if (index) {
-                        var li = listeners[index];
-                        if ( li && li[this.WFN] ) {
-                            var scope = li[this.ADJ_SCOPE];
-                            var ret = li[this.WFN].call(scope, e);
-                            ok = (ok && ret);
-                        } else {
-                            // This listener was removed, so delete it from
-                            // the array
-                            delete le[i];
-                        }
+                    var li = le[i];
+                    if ( li && li[this.WFN] ) {
+                        var scope = li[this.ADJ_SCOPE];
+                        var ret = li[this.WFN].call(scope, e);
+                        ok = (ok && ret);
                     }
                 }
 
@@ -547,35 +792,27 @@
             /**
              * Returns the legacy event index that matches the supplied 
              * signature
+             * @method getLegacyIndex
+             * @static
              * @private
              */
             getLegacyIndex: function(el, sType) {
-                /*
-                for (var i=0,len=legacyEvents.length; i<len; ++i) {
-                    var le = legacyEvents[i];
-                    if (le && le[0] === el && le[1] === sType) {
-                        return i;
-                    }
-                }
-                return -1;
-                */
-
                 var key = this.generateId(el) + sType;
                 if (typeof legacyMap[key] == "undefined") { 
                     return -1;
                 } else {
                     return legacyMap[key];
                 }
-
             },
 
             /**
              * Logic that determines when we should automatically use legacy
              * events instead of DOM2 events.
+             * @method useLegacyEvent
+             * @static
              * @private
              */
             useLegacyEvent: function(el, sType) {
-
                 if (!el.addEventListener && !el.attachEvent) {
                     return true;
                 } else if (this.isSafari) {
@@ -583,25 +820,26 @@
                         return true;
                     }
                 }
-
                 return false;
             },
                     
             /**
              * Removes an event handler
              *
+             * @method removeListener
+             *
              * @param {Object} el the html element or the id of the element to 
              * assign the event to.
-             * @param {String} sType the type of event to remove
-             * @param {Function} fn the method the event invokes
+             * @param {String} sType the type of event to remove.
+             * @param {Function} fn the method the event invokes.  If fn is
+             * undefined, then all event handlers for the type of event are 
+             * removed.
              * @return {boolean} true if the unbind was successful, false 
-             * otherwise
+             * otherwise.
+             * @static
              */
-            removeListener: function(el, sType, fn, index) {
-
-                if (!fn || !fn.call) {
-                    return false;
-                }
+            removeListener: function(el, sType, fn) {
+                var i, len;
 
                 // The el argument can be a string
                 if (typeof el == "string") {
@@ -609,12 +847,17 @@
                 // The el argument can be an array of elements or element ids.
                 } else if ( this._isValidCollection(el)) {
                     var ok = true;
-                    for (var i=0,len=el.length; i<len; ++i) {
+                    for (i=0,len=el.length; i<len; ++i) {
                         ok = ( this.removeListener(el[i], sType, fn) && ok );
                     }
                     return ok;
                 }
 
+                if (!fn || !fn.call) {
+                    //return false;
+                    return this.purgeElement(el, false, sType);
+                }
+
                 if ("unload" == sType) {
 
                     for (i=0, len=unloadListeners.length; i<len; i++) {
@@ -623,7 +866,7 @@
                             li[0] == el && 
                             li[1] == sType && 
                             li[2] == fn) {
-                                delete unloadListeners[i];
+                                unloadListeners.splice(i, 1);
                                 return true;
                         }
                     }
@@ -632,6 +875,11 @@
                 }
 
                 var cacheItem = null;
+
+                // The index is a hidden parameter; needed to remove it from
+                // the method signature because it was tempting users to
+                // try and take advantage of it, which is not possible.
+                var index = arguments[3];
   
                 if ("undefined" == typeof index) {
                     index = this._getCacheIndex(el, sType, fn);
@@ -645,17 +893,30 @@
                     return false;
                 }
 
+                if (this.useLegacyEvent(el, sType)) {
+                    var legacyIndex = this.getLegacyIndex(el, sType);
+                    var llist = legacyHandlers[legacyIndex];
+                    if (llist) {
+                        for (i=0, len=llist.length; i<len; ++i) {
+                            li = llist[i];
+                            if (li && 
+                                li[this.EL] == el && 
+                                li[this.TYPE] == sType && 
+                                li[this.FN] == fn) {
+                                    llist.splice(i, 1);
+                                    break;
+                            }
+                        }
+                    }
 
-                if (el.removeEventListener) {
-                    el.removeEventListener(sType, cacheItem[this.WFN], false);
-                } else if (el.detachEvent) {
-                    el.detachEvent("on" + sType, cacheItem[this.WFN]);
+                } else {
+                    this._simpleRemove(el, sType, cacheItem[this.WFN], false);
                 }
 
                 // removed the wrapped handler
                 delete listeners[index][this.WFN];
                 delete listeners[index][this.FN];
-                delete listeners[index];
+                listeners.splice(index, 1);
 
                 return true;
 
@@ -663,26 +924,45 @@
 
             /**
              * Returns the event's target element
+             * @method getTarget
              * @param {Event} ev the event
              * @param {boolean} resolveTextNode when set to true the target's
              *                  parent will be returned if the target is a 
-             *                  text node
+             *                  text node.  @deprecated, the text node is
+             *                  now resolved automatically
              * @return {HTMLElement} the event's target
+             * @static
              */
             getTarget: function(ev, resolveTextNode) {
                 var t = ev.target || ev.srcElement;
+                return this.resolveTextNode(t);
+            },
 
-                if (resolveTextNode && t && "#text" == t.nodeName) {
-                    return t.parentNode;
+            /**
+             * In some cases, some browsers will return a text node inside
+             * the actual element that was targeted.  This normalizes the
+             * return value for getTarget and getRelatedTarget.
+             * @method resolveTextNode
+             * @param {HTMLElement} node node to resolve
+             * @return {HTMLElement} the normized node
+             * @static
+             */
+            resolveTextNode: function(node) {
+                // if (node && node.nodeName && 
+                        // "#TEXT" == node.nodeName.toUpperCase()) {
+                if (node && 3 == node.nodeType) {
+                    return node.parentNode;
                 } else {
-                    return t;
+                    return node;
                 }
             },
 
             /**
              * Returns the event's pageX
+             * @method getPageX
              * @param {Event} ev the event
              * @return {int} the event's pageX
+             * @static
              */
             getPageX: function(ev) {
                 var x = ev.pageX;
@@ -699,8 +979,10 @@
 
             /**
              * Returns the event's pageY
+             * @method getPageY
              * @param {Event} ev the event
              * @return {int} the event's pageY
+             * @static
              */
             getPageY: function(ev) {
                 var y = ev.pageY;
@@ -717,7 +999,9 @@
 
             /**
              * Returns the pageX and pageY properties as an indexed array.
+             * @method getXY
              * @type int[]
+             * @static
              */
             getXY: function(ev) {
                 return [this.getPageX(ev), this.getPageY(ev)];
@@ -725,8 +1009,10 @@
 
             /**
              * Returns the event's related target 
+             * @method getRelatedTarget
              * @param {Event} ev the event
              * @return {HTMLElement} the event's relatedTarget
+             * @static
              */
             getRelatedTarget: function(ev) {
                 var t = ev.relatedTarget;
@@ -738,14 +1024,16 @@
                     }
                 }
 
-                return t;
+                return this.resolveTextNode(t);
             },
 
             /**
              * Returns the time of the event.  If the time is not included, the
              * event is modified using the current time.
+             * @method getTime
              * @param {Event} ev the event
              * @return {Date} the time of the event
+             * @static
              */
             getTime: function(ev) {
                 if (!ev.time) {
@@ -753,7 +1041,6 @@
                     try {
                         ev.time = t;
                     } catch(e) { 
-                        // can't set the time property  
                         return t;
                     }
                 }
@@ -763,7 +1050,9 @@
 
             /**
              * Convenience method for stopPropagation + preventDefault
+             * @method stopEvent
              * @param {Event} ev the event
+             * @static
              */
             stopEvent: function(ev) {
                 this.stopPropagation(ev);
@@ -772,7 +1061,9 @@
 
             /**
              * Stops event propagation
+             * @method stopPropagation
              * @param {Event} ev the event
+             * @static
              */
             stopPropagation: function(ev) {
                 if (ev.stopPropagation) {
@@ -784,7 +1075,9 @@
 
             /**
              * Prevents the default behavior of the event
+             * @method preventDefault
              * @param {Event} ev the event
+             * @static
              */
             preventDefault: function(ev) {
                 if (ev.preventDefault) {
@@ -800,8 +1093,10 @@
              * executed automatically for events registered through the event
              * manager, so the implementer should not normally need to execute
              * this function at all.
-             * @param {Event} the event parameter from the handler
+             * @method getEvent
+             * @param {Event} e the event parameter from the handler
              * @return {Event} the event 
+             * @static
              */
             getEvent: function(e) {
                 var ev = e || window.event;
@@ -822,16 +1117,21 @@
 
             /**
              * Returns the charcode for an event
+             * @method getCharCode
              * @param {Event} ev the event
              * @return {int} the event's charCode
+             * @static
              */
             getCharCode: function(ev) {
-                return ev.charCode || ((ev.type == "keypress") ? ev.keyCode : 0);
+                return ev.charCode || ev.keyCode || 0;
             },
 
             /**
-             * @private
              * Locating the saved event handler data by function ref
+             *
+             * @method _getCacheIndex
+             * @static
+             * @private
              */
             _getCacheIndex: function(el, sType, fn) {
                 for (var i=0,len=listeners.length; i<len; ++i) {
@@ -850,14 +1150,17 @@
             /**
              * Generates an unique ID for the element if it does not already 
              * have one.
-             * @param el the element
-             * @return {string} the id of the element
+             * @method generateId
+             * @param el the element to create the id for
+             * @return {string} the resulting id of the element
+             * @static
              */
             generateId: function(el) {
                 var id = el.id;
 
                 if (!id) {
-                    id = "yuievtautoid-" + (counter++);
+                    id = "yuievtautoid-" + counter;
+                    ++counter;
                     el.id = id;
                 }
 
@@ -870,11 +1173,15 @@
              * browsers return different types of collections.  This function
              * tests to determine if the object is array-like.  It will also 
              * fail if the object is an array, but is empty.
+             * @method _isValidCollection
              * @param o the object to test
              * @return {boolean} true if the object is array-like and populated
+             * @static
              * @private
              */
             _isValidCollection: function(o) {
+                // this.logger.debug(o.constructor.toString())
+                // this.logger.debug(typeof o)
 
                 return ( o                    && // o is something
                          o.length             && // o is indexed
@@ -887,13 +1194,17 @@
 
             /**
              * @private
+             * @property elCache
              * DOM element cache
+             * @static
              */
             elCache: {},
 
             /**
              * We cache elements bound by id because when the unload event 
              * fires, we can no longer use document.getElementById
+             * @method getEl
+             * @static
              * @private
              */
             getEl: function(id) {
@@ -902,33 +1213,35 @@
 
             /**
              * Clears the element cache
-             * @deprecated
+             * @deprecated Elements are not cached any longer
+             * @method clearCache
+             * @static
              * @private
              */
             clearCache: function() { },
 
             /**
-             * Called by CustomEvent instances to provide a handle to the 
-             * event * that can be removed later on.  Should be package 
-             * protected.
-             * @private
-             */
-            regCE: function(ce) {
-                customEvents.push(ce);
-            },
-
-            /**
-             * @private
              * hook up any deferred listeners
+             * @method _load
+             * @static
+             * @private
              */
             _load: function(e) {
                 loadComplete = true;
+                var EU = YAHOO.util.Event;
+                // Remove the listener to assist with the IE memory issue, but not
+                // for other browsers because FF 1.0x does not like it.
+                if (this.isIE) {
+                    EU._simpleRemove(window, "load", EU._load);
+                }
             },
 
             /**
              * Polling function that runs before the onload event fires, 
-             * attempting * to attach to DOM Nodes as soon as they are 
+             * attempting to attach to DOM Nodes as soon as they are 
              * available
+             * @method _tryPreloadAttach
+             * @static
              * @private
              */
             _tryPreloadAttach: function() {
@@ -939,7 +1252,6 @@
 
                 this.locked = true;
 
-
                 // keep trying until after the page is loaded.  We need to 
                 // check the page load state prior to trying to bind the 
                 // elements so that we can be certain all elements have been 
@@ -949,88 +1261,162 @@
                     tryAgain = (retryCount > 0);
                 }
 
-                // Delayed listeners
-                var stillDelayed = [];
-
-                for (var i=0,len=delayedListeners.length; i<len; ++i) {
-                    var d = delayedListeners[i];
-                    // There may be a race condition here, so we need to 
-                    // verify the array element is usable.
-                    if (d) {
-
-                        // el will be null if document.getElementById did not
-                        // work
-                        var el = this.getEl(d[this.EL]);
-
-                        if (el) {
-                            this.on(el, d[this.TYPE], d[this.FN], 
-                                    d[this.SCOPE], d[this.ADJ_SCOPE]);
-                            delete delayedListeners[i];
-                        } else {
-                            stillDelayed.push(d);
-                        }
-                    }
-                }
-
-                delayedListeners = stillDelayed;
-
                 // onAvailable
-                notAvail = [];
-                for (i=0,len=onAvailStack.length; i<len ; ++i) {
+                var notAvail = [];
+                for (var i=0,len=onAvailStack.length; i<len ; ++i) {
                     var item = onAvailStack[i];
                     if (item) {
-                        el = this.getEl(item.id);
+                        var el = this.getEl(item.id);
 
                         if (el) {
-                            var scope = (item.override) ? item.obj : el;
-                            item.fn.call(scope, item.obj);
-                            delete onAvailStack[i];
+                            // The element is available, but not necessarily ready
+
+                            if ( !item.checkReady || 
+                                    loadComplete || 
+                                    el.nextSibling ||
+                                    (document && document.body) ) {
+
+                                var scope = el;
+                                if (item.override) {
+                                    if (item.override === true) {
+                                        scope = item.obj;
+                                    } else {
+                                        scope = item.override;
+                                    }
+                                }
+                                item.fn.call(scope, item.obj);
+                                delete onAvailStack[i];
+                            }
                         } else {
                             notAvail.push(item);
                         }
                     }
                 }
 
-                retryCount = (stillDelayed.length === 0 && 
-                                    notAvail.length === 0) ? 0 : retryCount - 1;
+                retryCount = (notAvail.length === 0) ? 0 : retryCount - 1;
 
                 if (tryAgain) {
-                    this.startTimeout();
+                    this.startInterval();
+                } else {
+                    clearInterval(this._interval);
+                    this._interval = null;
                 }
 
                 this.locked = false;
 
+                return true;
+
+            },
+
+            /**
+             * Removes all listeners attached to the given element via addListener.
+             * Optionally, the node's children can also be purged.
+             * Optionally, you can specify a specific type of event to remove.
+             * @method purgeElement
+             * @param {HTMLElement} el the element to purge
+             * @param {boolean} recurse recursively purge this element's children
+             * as well.  Use with caution.
+             * @param {string} sType optional type of listener to purge. If
+             * left out, all listeners will be removed
+             * @static
+             */
+            purgeElement: function(el, recurse, sType) {
+                var elListeners = this.getListeners(el, sType);
+                if (elListeners) {
+                    for (var i=0,len=elListeners.length; i<len ; ++i) {
+                        var l = elListeners[i];
+                        // can't use the index on the changing collection
+                        //this.removeListener(el, l.type, l.fn, l.index);
+                        this.removeListener(el, l.type, l.fn);
+                    }
+                }
+
+                if (recurse && el && el.childNodes) {
+                    for (i=0,len=el.childNodes.length; i<len ; ++i) {
+                        this.purgeElement(el.childNodes[i], recurse, sType);
+                    }
+                }
+            },
+
+            /**
+             * Returns all listeners attached to the given element via addListener.
+             * Optionally, you can specify a specific type of event to return.
+             * @method getListeners
+             * @param el {HTMLElement} the element to inspect 
+             * @param sType {string} optional type of listener to return. If
+             * left out, all listeners will be returned
+             * @return {Object} the listener. Contains the following fields:
+             * &nbsp;&nbsp;type:   (string)   the type of event
+             * &nbsp;&nbsp;fn:     (function) the callback supplied to addListener
+             * &nbsp;&nbsp;obj:    (object)   the custom object supplied to addListener
+             * &nbsp;&nbsp;adjust: (boolean)  whether or not to adjust the default scope
+             * &nbsp;&nbsp;index:  (int)      its position in the Event util listener cache
+             * @static
+             */           
+            getListeners: function(el, sType) {
+                var elListeners = [];
+                if (listeners && listeners.length > 0) {
+                    for (var i=0,len=listeners.length; i<len ; ++i) {
+                        var l = listeners[i];
+                        if ( l  && l[this.EL] === el && 
+                                (!sType || sType === l[this.TYPE]) ) {
+                            elListeners.push({
+                                type:   l[this.TYPE],
+                                fn:     l[this.FN],
+                                obj:    l[this.OBJ],
+                                adjust: l[this.ADJ_SCOPE],
+                                index:  i
+                            });
+                        }
+                    }
+                }
+
+                return (elListeners.length) ? elListeners : null;
             },
 
             /**
              * Removes all listeners registered by pe.event.  Called 
              * automatically during the unload event.
+             * @method _unload
+             * @static
              * @private
              */
-            _unload: function(e, me) {
-                for (var i=0,len=unloadListeners.length; i<len; ++i) {
-                    var l = unloadListeners[i];
+            _unload: function(e) {
+
+                var EU = YAHOO.util.Event, i, j, l, len, index;
+
+                for (i=0,len=unloadListeners.length; i<len; ++i) {
+                    l = unloadListeners[i];
                     if (l) {
-                        var scope = (l[this.ADJ_SCOPE]) ? l[this.SCOPE]: window;
-                        l[this.FN].call(scope, this.getEvent(e), l[this.SCOPE] );
+                        var scope = window;
+                        if (l[EU.ADJ_SCOPE]) {
+                            if (l[EU.ADJ_SCOPE] === true) {
+                                scope = l[EU.OBJ];
+                            } else {
+                                scope = l[EU.ADJ_SCOPE];
+                            }
+                        }
+                        l[EU.FN].call(scope, EU.getEvent(e), l[EU.OBJ] );
+                        delete unloadListeners[i];
+                        l=null;
+                        scope=null;
                     }
                 }
 
                 if (listeners && listeners.length > 0) {
-                    for (i=0,len=listeners.length; i<len ; ++i) {
-                        l = listeners[i];
+                    j = listeners.length;
+                    while (j) {
+                        index = j-1;
+                        l = listeners[index];
                         if (l) {
-                            this.removeListener(l[this.EL], l[this.TYPE], 
-                                    l[this.FN], i);
-                        }
+                            EU.removeListener(l[EU.EL], l[EU.TYPE], 
+                                    l[EU.FN], index);
+                        } 
+                        j = j - 1;
                     }
+                    l=null;
 
-                    this.clearCache();
-                }
-
-                for (i=0,len=customEvents.length; i<len; ++i) {
-                    customEvents[i].unsubscribeAll();
-                    delete customEvents[i];
+                    EU.clearCache();
                 }
 
                 for (i=0,len=legacyEvents.length; i<len; ++i) {
@@ -1039,10 +1425,15 @@
                     // delete the array item
                     delete legacyEvents[i];
                 }
+
+                EU._simpleRemove(window, "unload", EU._unload);
+
             },
 
             /**
              * Returns scrollLeft
+             * @method _getScrollLeft
+             * @static
              * @private
              */
             _getScrollLeft: function() {
@@ -1051,6 +1442,8 @@
 
             /**
              * Returns scrollTop
+             * @method _getScrollTop
+             * @static
              * @private
              */
             _getScrollTop: function() {
@@ -1060,37 +1453,286 @@
             /**
              * Returns the scrollTop and scrollLeft.  Used to calculate the 
              * pageX and pageY in Internet Explorer
+             * @method _getScroll
+             * @static
              * @private
              */
             _getScroll: function() {
-                var dd = document.documentElement; db = document.body;
-                if (dd && dd.scrollTop) {
+                var dd = document.documentElement, db = document.body;
+                if (dd && (dd.scrollTop || dd.scrollLeft)) {
                     return [dd.scrollTop, dd.scrollLeft];
                 } else if (db) {
                     return [db.scrollTop, db.scrollLeft];
                 } else {
                     return [0, 0];
                 }
-            }
+            },
+
+            /**
+             * Adds a DOM event directly without the caching, cleanup, scope adj, etc
+             *
+             * @method _simpleAdd
+             * @param {HTMLElement} el      the element to bind the handler to
+             * @param {string}      sType   the type of event handler
+             * @param {function}    fn      the callback to invoke
+             * @param {boolen}      capture capture or bubble phase
+             * @static
+             * @private
+             */
+            _simpleAdd: function () {
+                if (window.addEventListener) {
+                    return function(el, sType, fn, capture) {
+                        el.addEventListener(sType, fn, (capture));
+                    };
+                } else if (window.attachEvent) {
+                    return function(el, sType, fn, capture) {
+                        el.attachEvent("on" + sType, fn);
+                    };
+                } else {
+                    return function(){};
+                }
+            }(),
+
+            /**
+             * Basic remove listener
+             *
+             * @method _simpleRemove
+             * @param {HTMLElement} el      the element to bind the handler to
+             * @param {string}      sType   the type of event handler
+             * @param {function}    fn      the callback to invoke
+             * @param {boolen}      capture capture or bubble phase
+             * @static
+             * @private
+             */
+            _simpleRemove: function() {
+                if (window.removeEventListener) {
+                    return function (el, sType, fn, capture) {
+                        el.removeEventListener(sType, fn, (capture));
+                    };
+                } else if (window.detachEvent) {
+                    return function (el, sType, fn) {
+                        el.detachEvent("on" + sType, fn);
+                    };
+                } else {
+                    return function(){};
+                }
+            }()
         };
-    } ();
+
+    }();
+
+    (function() {
+        var EU = YAHOO.util.Event;
+
+        /**
+         * YAHOO.util.Event.on is an alias for addListener
+         * @method on
+         * @see addListener
+         * @static
+         */
+        EU.on = EU.addListener;
+
+        // YAHOO.mix(EU, YAHOO.util.EventProvider.prototype);
+        // EU.createEvent("DOMContentReady");
+        // EU.subscribe("DOMContentReady", EU._load);
+
+        if (document && document.body) {
+            EU._load();
+        } else {
+            // EU._simpleAdd(document, "DOMContentLoaded", EU._load);
+            EU._simpleAdd(window, "load", EU._load);
+        }
+        EU._simpleAdd(window, "unload", EU._unload);
+        EU._tryPreloadAttach();
+    })();
+}
+
+/**
+ * EventProvider is designed to be used with YAHOO.augment to wrap 
+ * CustomEvents in an interface that allows events to be subscribed to 
+ * and fired by name.  This makes it possible for implementing code to
+ * subscribe to an event that either has not been created yet, or will
+ * not be created at all.
+ *
+ * @Class EventProvider
+ */
+YAHOO.util.EventProvider = function() { };
+
+YAHOO.util.EventProvider.prototype = {
 
     /**
+     * Private storage of custom events
+     * @property __yui_events
+     * @type Object[]
      * @private
      */
-    YAHOO.util.Event.on = YAHOO.util.Event.addListener;
+    __yui_events: null,
 
-    if (document && document.body) {
-        YAHOO.util.Event._load();
-    } else {
-        YAHOO.util.Event.on(window, "load", YAHOO.util.Event._load, 
-                YAHOO.util.Event, true);
-    }
+    /**
+     * Private storage of custom event subscribers
+     * @property __yui_subscribers
+     * @type Object[]
+     * @private
+     */
+    __yui_subscribers: null,
+    
+    /**
+     * Subscribe to a CustomEvent by event type
+     *
+     * @method subscribe
+     * @param p_type     {string}   the type, or name of the event
+     * @param p_fn       {function} the function to exectute when the event fires
+     * @param p_obj
+     * @param p_obj      {Object}   An object to be passed along when the event 
+     *                              fires
+     * @param p_override {boolean}  If true, the obj passed in becomes the 
+     *                              execution scope of the listener
+     */
+    subscribe: function(p_type, p_fn, p_obj, p_override) {
 
-    YAHOO.util.Event.on(window, "unload", YAHOO.util.Event._unload, 
-                YAHOO.util.Event, true);
+        this.__yui_events = this.__yui_events || {};
+        var ce = this.__yui_events[p_type];
 
-    YAHOO.util.Event._tryPreloadAttach();
+        if (ce) {
+            ce.subscribe(p_fn, p_obj, p_override);
+        } else {
+            this.__yui_subscribers = this.__yui_subscribers || {};
+            var subs = this.__yui_subscribers;
+            if (!subs[p_type]) {
+                subs[p_type] = [];
+            }
+            subs[p_type].push(
+                { fn: p_fn, obj: p_obj, override: p_override } );
+        }
+    },
 
-}
+    /**
+     * Unsubscribes the from the specified event
+     * @method unsubscribe
+     * @param p_type {string}   The type, or name of the event
+     * @param p_fn   {Function} The function to execute
+     * @param p_obj  {Object}   The custom object passed to subscribe (optional)
+     * @return {boolean} true if the subscriber was found and detached.
+     */
+    unsubscribe: function(p_type, p_fn, p_obj) {
+        this.__yui_events = this.__yui_events || {};
+        var ce = this.__yui_events[p_type];
+        if (ce) {
+            return ce.unsubscribe(p_fn, p_obj);
+        } else {
+            return false;
+        }
+    },
+
+    /**
+     * Creates a new custom event of the specified type.  If a custom event
+     * by that name already exists, it will not be re-created.  In either
+     * case the custom event is returned. 
+     *
+     * @method createEvent
+     *
+     * @param p_type {string} the type, or name of the event
+     * @param p_config {object} optional config params.  Valid properties are:
+     *
+     *  <ul>
+     *    <li>
+     *      scope: defines the default execution scope.  If not defined
+     *      the default scope will be this instance.
+     *    </li>
+     *    <li>
+     *      silent: if true, the custom event will not generate log messages.
+     *      This is false by default.
+     *    </li>
+     *    <li>
+     *      onSubscribeCallback: specifies a callback to execute when the
+     *      event has a new subscriber.  This will fire immediately for
+     *      each queued subscriber if any exist prior to the creation of
+     *      the event.
+     *    </li>
+     *  </ul>
+     *
+     *  @return {CustomEvent} the custom event
+     *
+     */
+    createEvent: function(p_type, p_config) {
+
+        this.__yui_events = this.__yui_events || {};
+        var opts = p_config || {};
+        var events = this.__yui_events;
+
+        if (events[p_type]) {
+        } else {
+
+            var scope  = opts.scope  || this;
+            var silent = opts.silent || null;
+
+            var ce = new YAHOO.util.CustomEvent(p_type, scope, silent,
+                    YAHOO.util.CustomEvent.FLAT);
+            events[p_type] = ce;
+
+            if (opts.onSubscribeCallback) {
+                ce.subscribeEvent.subscribe(opts.onSubscribeCallback);
+            }
+
+            this.__yui_subscribers = this.__yui_subscribers || {};
+            var qs = this.__yui_subscribers[p_type];
+
+            if (qs) {
+                for (var i=0; i<qs.length; ++i) {
+                    ce.subscribe(qs[i].fn, qs[i].obj, qs[i].override);
+                }
+            }
+        }
+
+        return events[p_type];
+    },
+
+   /**
+     * Fire a custom event by name.  The callback functions will be executed
+     * from the scope specified when the event was created, and with the 
+     * following parameters:
+     *   <ul>
+     *   <li>The first argument fire() was executed with</li>
+     *   <li>The custom object (if any) that was passed into the subscribe() 
+     *       method</li>
+     *   </ul>
+     * @method fireEvent
+     * @param p_type    {string}  the type, or name of the event
+     * @param arguments {Object*} an arbitrary set of parameters to pass to 
+     *                            the handler.
+     * @return {boolean} the return value from CustomEvent.fire, or null if 
+     *                   the custom event does not exist.
+     */
+    fireEvent: function(p_type, arg1, arg2, etc) {
+
+        this.__yui_events = this.__yui_events || {};
+        var ce = this.__yui_events[p_type];
+
+        if (ce) {
+            var args = [];
+            for (var i=1; i<arguments.length; ++i) {
+                args.push(arguments[i]);
+            }
+            return ce.fire.apply(ce, args);
+        } else {
+            return null;
+        }
+    },
+
+    /**
+     * Returns true if the custom event of the provided type has been created
+     * with createEvent.
+     * @method hasEvent
+     * @param type {string} the type, or name of the event
+     */
+    hasEvent: function(type) {
+        if (this.__yui_events) {
+            if (this.__yui_events[type]) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+};
 

Modified: jifty/trunk/share/web/static/js/yui/yahoo.js
==============================================================================
--- jifty/trunk/share/web/static/js/yui/yahoo.js	(original)
+++ jifty/trunk/share/web/static/js/yui/yahoo.js	Sun Dec  3 21:49:46 2006
@@ -1,61 +1,145 @@
 /*                                                                                                                                                      
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.                                                                                                    
-Code licensed under the BSD License:                                                                                                                    
-http://developer.yahoo.net/yui/license.txt                                                                                                              
-version: 0.10.0                                                                                                                                         
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.12.0
 */ 
 
-/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+/**
+ * The YAHOO object is the single global object used by YUI Library.  It
+ * contains utility function for setting up namespaces, inheritance, and
+ * logging.  YAHOO.util, YAHOO.widget, and YAHOO.example are namespaces
+ * created automatically for and used by the library.
+ * @module yahoo
+ * @title  YAHOO Global
+ */
 
 /**
- * The Yahoo global namespace
- * @constructor
+ * The YAHOO global namespace object
+ * @class YAHOO
+ * @static
  */
-var YAHOO = window.YAHOO || {};
+if (typeof YAHOO == "undefined") {
+    var YAHOO = {};
+}
 
 /**
  * Returns the namespace specified and creates it if it doesn't exist
- *
+ * <pre>
  * YAHOO.namespace("property.package");
  * YAHOO.namespace("YAHOO.property.package");
- *
+ * </pre>
  * Either of the above would create YAHOO.property, then
  * YAHOO.property.package
  *
- * @param  {String} sNameSpace String representation of the desired 
- *                             namespace
- * @return {Object}            A reference to the namespace object
+ * Be careful when naming packages. Reserved words may work in some browsers
+ * and not others. For instance, the following will fail in Safari:
+ * <pre>
+ * YAHOO.namespace("really.long.nested.namespace");
+ * </pre>
+ * This fails because "long" is a future reserved word in ECMAScript
+ *
+ * @method namespace
+ * @static
+ * @param  {String*} arguments 1-n namespaces to create 
+ * @return {Object}  A reference to the last namespace object created
  */
-YAHOO.namespace = function( sNameSpace ) {
-
-    if (!sNameSpace || !sNameSpace.length) {
-        return null;
+YAHOO.namespace = function() {
+    var a=arguments, o=null, i, j, d;
+    for (i=0; i<a.length; ++i) {
+        d=a[i].split(".");
+        o=YAHOO;
+
+        // YAHOO is implied, so it is ignored if it is included
+        for (j=(d[0] == "YAHOO") ? 1 : 0; j<d.length; ++j) {
+            o[d[j]]=o[d[j]] || {};
+            o=o[d[j]];
+        }
     }
 
-    var levels = sNameSpace.split(".");
+    return o;
+};
 
-    var currentNS = YAHOO;
+/**
+ * Uses YAHOO.widget.Logger to output a log message, if the widget is available.
+ *
+ * @method log
+ * @static
+ * @param  {String}  msg  The message to log.
+ * @param  {String}  cat  The log category for the message.  Default
+ *                        categories are "info", "warn", "error", time".
+ *                        Custom categories can be used as well. (opt)
+ * @param  {String}  src  The source of the the message (opt)
+ * @return {Boolean}      True if the log operation was successful.
+ */
+YAHOO.log = function(msg, cat, src) {
+    var l=YAHOO.widget.Logger;
+    if(l && l.log) {
+        return l.log(msg, cat, src);
+    } else {
+        return false;
+    }
+};
 
-    // YAHOO is implied, so it is ignored if it is included
-    for (var i=(levels[0] == "YAHOO") ? 1 : 0; i<levels.length; ++i) {
-        currentNS[levels[i]] = currentNS[levels[i]] || {};
-        currentNS = currentNS[levels[i]];
+/**
+ * Utility to set up the prototype, constructor and superclass properties to
+ * support an inheritance strategy that can chain constructors and methods.
+ *
+ * @method extend
+ * @static
+ * @param {Function} subc   the object to modify
+ * @param {Function} superc the object to inherit
+ * @param {String[]} overrides  additional properties/methods to add to the
+ *                              subclass prototype.  These will override the
+ *                              matching items obtained from the superclass 
+ *                              if present.
+ */
+YAHOO.extend = function(subc, superc, overrides) {
+    var F = function() {};
+    F.prototype=superc.prototype;
+    subc.prototype=new F();
+    subc.prototype.constructor=subc;
+    subc.superclass=superc.prototype;
+    if (superc.prototype.constructor == Object.prototype.constructor) {
+        superc.prototype.constructor=superc;
     }
 
-    return currentNS;
+    if (overrides) {
+        for (var i in overrides) {
+            subc.prototype[i]=overrides[i];
+        }
+    }
 };
 
 /**
- * Global log method.
+ * Applies all prototype properties in the supplier to the receiver if the
+ * receiver does not have these properties yet.  Optionally, one or more
+ * methods/properties can be specified (as additional parameters).  This
+ * option will overwrite the property if receiver has it already.
+ *
+ * @method augment
+ * @static
+ * @param {Function} r  the object to receive the augmentation
+ * @param {Function} s  the object that supplies the properties to augment
+ * @param {String*}  arguments zero or more properties methods to augment the
+ *                             receiver with.  If none specified, everything
+ *                             in the supplier will be used unless it would
+ *                             overwrite an existing property in the receiver
  */
-YAHOO.log = function(sMsg,sCategory) {
-    if(YAHOO.widget.Logger) {
-        YAHOO.widget.Logger.log(null, sMsg, sCategory);
+YAHOO.augment = function(r, s) {
+    var rp=r.prototype, sp=s.prototype, a=arguments, i, p;
+    if (a[2]) {
+        for (i=2; i<a.length; ++i) {
+            rp[a[i]] = sp[a[i]];
+        }
     } else {
-        return false;
+        for (p in sp) { 
+            if (!rp[p]) {
+                rp[p] = sp[p];
+            }
+        }
     }
 };
 
-YAHOO.namespace("util");
-YAHOO.namespace("widget");
-YAHOO.namespace("example");
+YAHOO.namespace("util", "widget", "example");
+


More information about the Jifty-commit mailing list