
function popupevent(){
	$('td.date_has_event').mouseover(function (){
		$('div.events', this).css({display: "block"});						
	})
	.mouseout(function (){
		$('div.events', this).css({display: "none"});						
	});
	if(($.browser.msie) && ($.browser.version <= "6.0"))
	{
		$('.events').each(function(){
			$(this).css("display","block");
			if($("ul",this).height()%2 == 1 )
				$("ul",this).height($("ul",this).height()+1)
			$(this).css("display","none");
		});
	}
}

function linkitem(){	
	var remoteUrl = '/includes/homeagenda.php?name=';	
	var remoteCache = new Array();		
	$('div.thdata a').each(function(i,item){
		var linkId = item.id;
		var ref = item.rel;
		var linkUrl = remoteUrl+linkId+'&langcode='+ref;		
//		var linkUrl = remoteUrl+linkId;		
		$(this).click(function(){			
			var calendarEvents = $('#result');						
			if( remoteCache[linkId] != undefined ) { 
				calendarEvents.html(remoteCache[linkId]);
				popupevent();
				linkitem()
			} else {
				calendarEvents.load(linkUrl,function(){
					remoteCache[linkId] = calendarEvents.html();
					popupevent();
					linkitem()
				});
			}
		});
	});
}

jQuery(document).ready(function($){
								
	popupevent();
	linkitem();
});

