var inintCalendar = function(id){
	var req = new GAjax();
	req.inintLoading('wait', true);
	var patt = /^calendar\-(([0-9]+){0,2}\-([0-9]+){0,2}\-([0-9]+){0,4})\-([0-9a-z_]+)$/;
	forEach($E(id).getElementsByTagName('a'), function(item){
		if(hs = patt.exec(item.id)){
			if (hs[5] == 'back' || hs[5] == 'next' || hs[5] == 'today'){
				item.onclick = function(){
					hs = patt.exec(item.id);
					if (hs[5] == 'back'){
						var query = 'd=' + hs[1] + '&n=-1';
					}else if (hs[5] == 'next'){
						var query = 'd=' + hs[1] + '&n=+1';
					}else{
						var query = null;
					}
					req.send('widgets/calendar/get.php' , query , function(xhr) {
						$E('widget-calendar').innerHTML = xhr.responseText;
						inintCalendar('widget-calendar');
					});
					return false;
				};
			}else{
				item.onclick = function(){
					loaddoc(this.href);
					return false;
				};
				item.onmousemove = function(){
					mTooltipShow(this.id, 'widgets/calendar/tooltip.php', this)
				};
			};
		};
	});
};