/* 
 * author: Pavel Studeník
 * email: studenik@varhoo.cz
 * web: http://www.varhoo.cz/
 */

function reload_ajax(){
	$("a[rel='ajax']").click(function(){
		url = $(this).attr("href");
		location.href = "#"+url;
		loadDataByUrl(url);
		return false;
	});
}

function loadDataByUrl(url){
	$.get(url,{},function(data){
		$("#indexMainBody").attr("class","indexMainBody");
		t = $(data).find("#content").html();
		$("#content").fadeOut(500,function(){
			$("#content").html(t);
			setTimeout(function(){$("#content").fadeIn(500)},500);
			//reload_ajax();
		});
	});
}

$(document).ready(function(){

	$("#blogoneArticlesBody .text img").each(function(){
	   $(this).wrap("<a href='"+$(this).attr("src")+"'/></a>");
	   
	   $(this).parent().fancybox({
			'titleShow'     : false,
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'elastic',
			'easingIn'      : 'easeOutBack',
			'easingOut'     : 'easeInBack',
	//		'autoScale'	: true
		});
	 });
	 
	pos = location.href.indexOf("#");
	if(pos>0){
		 loadDataByUrl(location.href.substr(pos+1));
	}
	reload_ajax();
});


