// this variable keeps track of which element is being shown
// 0 - none
var on = 0;

var x = 0;
var y = 0;

function hide_element(id)
{
	if(on > 0)
	{
		//alert("hide: "+on);
		$("#"+on).hide();
		on = 0;
	}
}

$(function(){
	
	$(".calendar").mousemove(function(e){
		x = e.pageX;
		y = e.pageY;
		
		// debugging positioning
		//$("#status").html("e.pageX = "+e.pageX+", e.pageY = "+e.pageY);
	});

	$("td.clickable").live("click", function(e){
		
		var id = $(this).attr("other_id");
		
		if(id != on)
		{
			if(on > 0)
				$("#"+on).hide();
			
			var win_width 	= $(window).width();
			var win_height 	= $(window).height();
			var doc_width 	= $(document).width();
			var doc_height	= $(document).height();
			var div_width 	= $("#"+id).width();
			var div_height 	= $("#"+id).height();
			
			var top 		= $(document).scrollTop();
			var left 		= $(document).scrollLeft();
			
			// show and change the display variable
			$("#"+id).fadeIn("fast");
			on = id;
		}
		else
			hide_element(id);
		
	});
});
