/**
 * @fileoverview HD Test Ride YUI Overwrite Javascript File. 
 * Contains YUI overwritten functions
 * @author Aaron Walker (Aaron.Walker@Harley-Davidson.com)
 * @version 1.0
 */


/** OVERWRITTEN FUNCTION **
 *  we have overwritten the YAHOO Calendar init method to include the optional "date" variable
 *  the date variable must be a Date object and will be used to set the "today" variable of the YUI
 *  calendar. we did this to prevent the clients system clock from messing up the "today" variable since
 *  yui uses that to set the init calendar.
 * 
 * Initializes the Calendar widget.
 * @method init
 *
 * @param {String} id optional The id of the table element that will represent the Calendar widget. As of 2.4.0, this argument is optional.
 * @param {String | HTMLElement} container The id of the container div element that will wrap the Calendar table, or a reference to a DIV element which exists in the document.
 * @param {Object} config optional The configuration object containing the initial configuration values for the Calendar.
 * @param {Date} date you want to set as today's date
 */
YAHOO.widget.Calendar.prototype.init = function(id, container, config, date){
   
   var Dom = YAHOO.util.Dom,
   Event = YAHOO.util.Event,
   Lang = YAHOO.lang,
   DateMath = YAHOO.widget.DateMath;
   
   // Normalize 2.4.0, pre 2.4.0 args
   var nArgs = this._parseArgs(arguments);

   id = nArgs.id;
   container = nArgs.container;
   config = nArgs.config;

   this.oDomContainer = Dom.get(container);
   if (!this.oDomContainer) { 
     //error
   }

   if (!this.oDomContainer.id) {
       this.oDomContainer.id = Dom.generateId();
   }
   if (!id) {
       id = this.oDomContainer.id + "_t";
   }

   this.id = id;
   this.containerId = this.oDomContainer.id;

   this.initEvents();

   /**
   * The Config object used to hold the configuration variables for the Calendar
   * @property cfg
   * @type YAHOO.util.Config
   */
   this.cfg = new YAHOO.util.Config(this);

   /**
   * The local object which contains the Calendar's options
   * @property Options
   * @type Object
   */
   this.Options = {};

   /**
   * The local object which contains the Calendar's locale settings
   * @property Locale
   * @type Object
   */
   this.Locale = {};

   this.initStyles();

   Dom.addClass(this.oDomContainer, this.Style.CSS_CONTAINER);
   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();
   
   this.today = date || this.cfg.getProperty("today"); // only part we overwrite
};
