function prepareVideo()
{
	$('.videoPreview').click(function(){
		var id=this.id;
		$.post('/engine/ajax/youtube.php',{id:this.id},function(data){
			$('#'+id).css('background-color','#000');
			$('#'+id+' div').css('background-image','none');
			$('#'+id).animate({width:'500px',height:'400px'},'fast','',function(){
				//alert(data);
				$('#'+id+' div').replaceWith(data);
			});
		});
		return false;
	});
}

$(document).ready(function(){

	prepareVideo();

	$('.showMore').click(function(){
		var id=this.id;
		var onpage=$('#onpage_'+id).val();
		var visible=$('#visible_'+id).val();
		var from=$('#from_'+id).val();
		var target=$('#target_'+id).val();
		var max=$('#max_'+id).val();
		$.post(from,{onpage:onpage,visible:visible},function(data){
			$('#'+target).append(data);
			prepareVideo();
		});
		$('#visible_'+id).val(parseInt(parseInt(visible)+parseInt(onpage)));
		if ($('#visible_'+id).val()>=max) {$(this).fadeOut();}
		return false;
	});

function activeCalendar()
{
	$('#colCalendarContent #calendarSpace .calendar-month a').click(function(){
		var date=this.href;
		date=date.split('#');
		date=date[1];
		$.post('/engine/ajax/kalendar.php',{date:date},function(data){
			$('#colCalendarContent #calendarSpace').html(data);
			activeCalendar();
		});
		return false;
	});
	$('#colCalendarContent #calendarSpace td a').click(function(){
		var date=this.href;
		date=date.split('#');
		date=date[1];
		$.post('/engine/ajax/kalendar.php',{detail:true,date:date},function(data){
			$('#colCalendarContent #eventsDay').html(data);
			//activeCalendar();
		});
		return false;
	});
}

	activeCalendar();

/* facebook */
/*
	(function()
	{
		var e = document.createElement('script');
		e.type = 'text/javascript';
		e.src = document.location.protocol+'//connect.facebook.net/cs_CZ/all.js#appId=185203184837945&amp;xfbml=1';
		e.async = true;
		document.getElementById('fb-root').appendChild(e);
	}());
	//window.fbAsyncInit = function() {FB.init({ status: true, cookie: true, xfbml: true});}
/**/

});

function loaded()
{

}
