var CC = {
  Version: '1.0',
  prototypeVersion: parseFloat(Prototype.Version.split(".")[0] + "." + Prototype.Version.split(".")[1])
}

if ( ( typeof Prototype == 'undefined' ) || CC.prototypeVersion < 1.4 ) {
	throw( "Class Connection requires the Prototype JavaScript Framework >= 1.4" );
}

CC.ToolTips = Class.create();
CC.ToolTips.prototype = {
	initialize: function( pContainer ) {
		this.pContainer									= $( pContainer );
		this.persistent									= false;
		this.tooltip									= null;

		if ( !pContainer ) {
			return;
		}

		this._attachBehaviors();
	},
	
	onClick: function( e , tContainer ) {
		if (this.persistent == false) {
			this.persistent									= true;
			this.tooltip									= tContainer;
		} else {
			this.persistent									= false;
			
			this.onMouseOut( e , this.tooltip );
			
			this.onMouseOver( e , tContainer );
		}
	},
	
	onMouseOver: function( e , tContainer ) {
		if (this.persistent == false) {
			$( tContainer.id  + "_ToolTip" ).style.display	= "";	
			$( tContainer.id  + "_ToolTip" ).style.top		= "-180px";
			$( tContainer.id  + "_ToolTip" ).style.left		= "-99px";
			$( tContainer.id  + "_ToolTip" ).innerHTML		= "<div id='calendarEventDetails'><h4>Event Listing</h4><ul>" + $( tContainer.id + "_List" ).innerHTML + "</ul></div>";
		}
	},

	onMouseOut: function( e , tContainer ) {
		if (this.persistent == false) {
			$( tContainer.id  + "_ToolTip" ).style.display	= "none";
			$( tContainer.id  + "_ToolTip" ).innerHTML		= "";
		}
	},
	
	_attachBehaviors: function() {
		$( this.pContainer ).getElementsByClassName('DayEventsListDiv').each( function(c) {
			c.onclick									= this.onClick.bindAsEventListener( this , c );
			c.onmouseover								= this.onMouseOver.bindAsEventListener( this , c );
			c.onmouseout								= this.onMouseOut.bindAsEventListener( this , c );
		}.bind(this));
	}
};
