function calendar(weekid,placeid,availibility)
{
	if(availibility)
	{
		$('tabela').fade(0.3);
		$('tabela').store('weekid',weekid);
		$('tabela').store('placeid',placeid);
		makebasic();
		new Request(
		{
			url:'ajax/big_center.php', 
			onSuccess: function(text)
			{
				$$('#calendartable td').removeClass('highlight');
				$$('#week_'+weekid+' td').addClass('highlight');
				var idji=new Array('hours','mon','tue','wed','thu','fri','sat','sun');
				var instructions=text.split(';');
				var j=0
				for(var i=0;i<instructions.length;i++)
				{
					var ins=instructions[i];
					if(ins=='newday')
					{
						j++;
						new Element('li',{'class':'tc bck_s fc2','html':instructions[++i]}).inject('center_'+idji[j]);
					}
					else if(ins=='empty' || ins=='disabled' || ins=='fullday' || ins=='occupied' || ins=='sibling')
					{
						makeslot(ins,instructions[++i],instructions[++i],instructions[++i],idji[j]);
					}
				}
				$('tabela').show();
				$('tabela').fade(1);
				aktivnitermini();
			},
			onFailure: function(){alert('Check internet connection.');}
		}).send('weekid='+weekid+'&placeid='+placeid);
	}
}
function makeslot(type,two,three,four,whereid)
{
	//if(!four)alert(type+' '+two+' '+three+' '+four+' '+whereid);
	//    disabled 22-4   undefined fri
	var sirinadelcka=15;
	var hei_wid=two.split('-');
	var titl=four.split('-');
	var titli=' ';
	if(titl[3])titli=titl[2]+'.'+titl[1]+'.'+titl[0]+' ob '+(titl[3].match('.5')?titl[3].replace('.5','.30'):titl[3]+'.00');
	new Element('li',
	{
		'title':titli,
		'class':'pa tc b '+type,
		'styles':{
			'height':(hei_wid[0])*40,
			'width':(hei_wid[1])*sirinadelcka,
			'top':(hei_wid[2]-5.5)*40,
			'left':(hei_wid[3])*sirinadelcka,
			'opacity':(type=='empty'?0.5:0.5)
		},
		'html':three,
		'events':{
			'click':function(){dosomething(this.retrieve('acttype'),this.retrieve('four'));},
			'mouseenter':function(){this.fade(0.9);},
			'mouseleave':function(){this.fade(0.5);}
		}
	}).inject('center_'+whereid).store('four',four).store('acttype',type);
}
function makebasic()
{
	var tabela=$('tabela');
	tabela.empty().addClass('pr');
	var idji=new Array('hours','mon','tue','wed','thu','fri','sat','sun');
	for(var i=0;i<8;i++)
	{
		new Element('ul',
		{
			'id':'center_'+idji[i],
			'class':'day fl bck_s fc2 pr',
			'styles':{
				'height':(23.5-5.5)*40+1
			}
		}).inject(tabela);
		if(i==0)$('center_'+idji[i]).setStyle('width',80);
	}
	new Element('li',
	{
		'class':'tc b bck_s',
		'html':'&nbsp;'
	}).inject('center_hours');
	for(var i=6;i<23.5;i+=0.5)
	{
		new Element('li',
		{
			'class':'tc b bck_s',
			'html':i-i%1+':'+(i%1?'30':'00')
		}).inject('center_hours').setStyle('width',80);
	}
	//$('center_hours').clone().inject(tabela).removeClass('pr').removeClass('fl').setStyle('position','absolute');
}
