var loadedpage = false;

$(document).ready(function(){

$('#mainmenu a, #icons .calendar, #icons .news').click(function(e){
e.preventDefault();
$(this).blur();
var isloaded = false;
	if (loadedpage != false) {
	isloaded = true;
	}
loadedpage = $(this).attr('href').substr(1);
$('#bgphoto').animate({'left':'-135px'},500);
$('.jspVerticalBar').fadeOut(500);
$('#pagecontent').slideDown(500,function(){
if (!isloaded) {
$('#loadcontent').children('div').hide();
$('#pagecontent').jScrollPane();
$('#'+loadedpage).show();
$('#loadcontent').fadeIn(500,function(){
$('#pagecontent').jScrollPane();
$('.jspVerticalBar').hide().fadeIn(500);
});
}
});
if (isloaded) {
$('.jspVerticalBar').fadeOut(500);
$('#loadcontent').fadeOut(500,function(){
$(this).children('div').hide();
$('#pagecontent').jScrollPane();
$('#'+loadedpage).show();
}).fadeIn(500,function(){
$('#pagecontent').jScrollPane();
$('.jspVerticalBar').hide().fadeIn(500);
});

}
document.location.hash = loadedpage;
void(0);
return false;
});

$('.mainlink').click(function(e){
e.preventDefault();
$(this).blur();
loadedpage = false;
$('#bgphoto').animate({'left':'0'},500);
$('#pagecontent').slideUp(500,function(){
$('#loadcontent').hide();
$('#pagecontent').jScrollPane();
});
document.location.hash = '';
void(0);
return false;
});

$('#foto a').lightBox({	txtImage: 'Zdjęcie',txtOf: 'z'});

$('#icons a').tooltip({showURL: false, track: true, top:55,left:-10,fade: 200, delay:0 });

if (document.location.hash != '' && $('a[href="'+ document.location.hash +'"]').length > 0) {
$('a[href="'+ document.location.hash +'"]').trigger('click');
}



});
