jQuery(document).ready(function($) {

	//CHANGE ME!!! Define the relative or absolute path to your backend script
	var remoteUrl = '/incs/calendar_backend.php';
	
	//Initialize the HTTP cache
	var remoteCache = new Array();
	
	//For each link in the calendar...
	jQuery('table.calendar a').each(function(i,item){
		
		//Unique ID for the link
		var linkId = item.id;
		
		//Unique URL for the link
		var linkUrl = remoteUrl+'?timestamp='+linkId;
		
		//Attach onclick event handler
		/*jQuery(this).click(function(){			
			var calendarEvents = jQuery('#calendar-events');			
			calendarEvents.slideUp('fast',function(){			
				if( remoteCache[linkId] != undefined ) { 
					calendarEvents.html(remoteCache[linkId]);
					calendarEvents.slideDown('fast');
				} else {
					calendarEvents.load(linkUrl,function(){
						remoteCache[linkId] = calendarEvents.html();
						calendarEvents.slideDown('fast');
					});
				}
			});
			return false;
		});*/
		
	});
	
	// Calendar NAV
	jQuery('#cal_previous').click(function() {
		sendValue(jQuery(this).val());       
		//jQuery('#calSubHdr').html();
	});
	jQuery('#cal_next').click(function() {
		sendValue(jQuery(this).val());       
	});
	
	// Homepage Toggles
	$('#PresidentsMessage').hide();

	/*$('a#Cal').click(function(){
		$('#PresidentsMessage').hide();
		$('#Home_Calendar').show();
	});
	
	$('a#Pres').click(function(){
		$('#Home_Calendar').hide();
		$('#PresidentsMessage').show();
	})*/
	
	// QTip
   jQuery('table.calendar a[tooltip]').each(function() {
      jQuery(this).qtip({
        content: jQuery(this).attr('tooltip'), // Use the tooltip attribute of the element for the content
		position: {
			corner: {
				target: 'rightMiddle',
				tooltip: 'leftMiddle'
			}
		},
		style: {
			border: {
				width: 3,
				radius: 3,
				color: '#444'
		  	},
			width: {
				max: 388
			},
			//background: 'transparent url(images/qtip_bg.png) repeat top left',
			background: '#444',
			padding: 3,
			color: 'white',
			'font-size': 11,
			textAlign: 'left',
			tip: true // Give it a speech bubble tip with automatic corner detection
		}
      });
   });
	
	
});

function sendValue(str){
   
    jQuery.post("incs/ajax.php", { sendValue: str },	function(data){ jQuery('#CalAjax').html(data);});

}
