			var months = [];
			months['January'] = 1;
			months['February'] = 2;
			months['March'] = 3;
			months['April'] = 4;
			months['May'] = 5;
			months['June'] = 6;
			months['July'] = 7;
			months['August'] = 8;
			months['September'] = 9;
			months['October'] = 10;
			months['November'] = 11;
			months['December'] = 12;

			var months2 = [];
			months2[1] = 'January';
			months2[2] = 'February';
			months2[3] = 'March';
			months2[4] = 'April';
			months2[5] = 'May';
			months2[6] = 'June';
			months2[7] = 'July';
			months2[8] = 'August';
			months2[9] = 'September';
			months2[10] = 'October';
			months2[11] = 'November';
			months2[12] = 'December';
			$.noConflict();
			jQuery(document).ready(function() { getCalendar(); }); // ajax

			var calendarLoaded = false;
			function getCalendar(setTo){
				jQuery.ajax({
					url: "/ajax/getEvents",
					data: "action=showdates",
					dataType: "json",
					success: function(calendarEvents){
						if(setTo != undefined){
							jQuery('#callendar').datepicker("destroy");
						}else{
							var setTo = new Date();
						}
						jQuery('#callendar').datepicker({
							inline: true,
							showOtherMonths: true,
							readonly: true,
							disabled: true,
							defaultDate: setTo,
							onChangeMonthYear:function(year, month, inst){
								getCalendar(new Date(year, month, 1, 0, 0, 0, 0));
								jQuery('#callendar').css({
									'background-image' : 'url(/images/calendar/months/'+months2[month]+'.png)',
									'background-repeat' : 'no-repeat',
									'background-position': '43% 5px'
								});
							}
						});

						if(!calendarLoaded)
						{
							setTimeout(function() {
								date = new Date();
								year = date.getFullYear();
								month = date.getMonth() + 1;
								jQuery('#callendar').css({
									'background-image' : 'url(/images/calendar/months/'+months2[month]+'.png)',
									'background-repeat' : 'no-repeat',
									'background-position': '43% 5px'
								});
							}, 1);
							calendarLoaded = true;
						}

						for(i = 0; i < calendarEvents.length; i++){
							if(calendarEvents[i][0] == months[jQuery("#callendar span.ui-datepicker-month").text()] && calendarEvents[i][2] == jQuery("#callendar span.ui-datepicker-year").text()){
								jQuery(".ui-datepicker a").each(function(){
									if(jQuery(this).text() == calendarEvents[i][1]){
										jQuery(this).addClass('ui-state-event');
									}
								});
							}
						}
						jQuery(".ui-datepicker a.ui-state-event").each(function(){
							jQuery(this).qtip(
								{
									position: {
						               my: "left center", // Use the corner...
						               at: "right center" // ...and opposite corner
						            },
									content: {
							            // Set the text to an image HTML string with the correct src URL to the loading image you want to use
							            text: 'Some text',
							            ajax: {
							               url: "/ajax/getEvent",
										   data: "day="+jQuery(this).text() + '-' + jQuery("#callendar span.ui-datepicker-month").text() + '-' + jQuery("#callendar span.ui-datepicker-year").text()
							            },
							            title: {
							               text: 'Events on - ' + jQuery(this).text() + ' ' + jQuery("#callendar span.ui-datepicker-month").text() + ' ' + jQuery("#callendar span.ui-datepicker-year").text() // Give the tooltip a title using each elements text
							            }
							         },
									 show: {
							            solo: true // Only show one tooltip at a time
							         },
									 hide:{

									 	event: 'unfocus'
									 },
							         style: {
							            classes: 'ui-tooltip-wiki ui-tooltip-light ui-tooltip-shadow'
							         }
								}
							);
						});
						jQuery(".ui-datepicker a").click(function(){return false;});
				     } // success
				});
}

