
mandarina = {
	
	addLoadEvent : function(func){
		// thanks simon.
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				if (oldonload) {
					oldonload();
				}
				func();
			}
		}
	}
	
	
}

var init	= function(){

			
			var myCal	= new YAHOO.widget.Calendar('newCal', 'minical');
			myCal.customConfig = function(){
				this.Options.LOCALE_WEEKDAYS = this.Config.Locale.WEEKDAYS_1CHAR;
				this.Options.START_WEEKDAY = 1;
				this.Options.NAV_ARROW_LEFT='/img/cal-left.gif';
				this.Options.NAV_ARROW_RIGHT='/img/cal-right.gif';
			}
			myCal.setupConfig();
			
			
			
			myCal.cellDisabled = function(workingDate, cell) {
				YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_OOB);
				cell.innerHTML = workingDate.getDate();
				return true;
			}
			
			myCal.cellBusy = function(workingDate, cell) {
				YAHOO.util.Dom.addClass(cell, 'busy');
				cell.innerHTML = workingDate.getDate();
				return true;
			}
			
			myCal.cellTentative = function(workingDate, cell) {
				YAHOO.util.Dom.addClass(cell, 'tnt');
				cell.innerHTML = workingDate.getDate();
				return true;
			}
			
			myCal.cellAvailable	= 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();

				link.appendChild(document.createTextNode(this.buildDayLabel(workingDate)));
				cell.appendChild(link);
				return YAHOO.widget.Calendar_Core.STOP_RENDER;
			}
			
			
			myCal.renderCellDefault	= myCal.cellDisabled;
			
			for(i=0; i<busyDates.length; i++) {
				myCal.addRenderer(busyDates[i], myCal.cellBusy);
			}
			for(i=0; i<tentativeDates.length; i++) {
				myCal.addRenderer(tentativeDates[i], myCal.cellTentative);
			}
			
			
			myCal.render();
			
			
		}

	
function tooltips() {
	var tips = YAHOO.util.Dom.getElementsByClassName('ts','*',document);
	
	YAHOO.util.Dom.generateId(tips,'tt');
	for(i=0; i<tips.length; i++) {
		var newtt = new YAHOO.widget.Tooltip("newtt", { context:'tt'+i } ); 
	}
	
	YAHOO.util.Event.addListener('casestudyID', 'change', function(){document.getElementById('casestudyselect').submit()});	
}




	
YAHOO.util.Event.onAvailable('minical', init);

YAHOO.util.Event.addListener(window, 'load', tooltips);
