$(document).ready(function(){

  $('#loading').hide();

	//Check if url hash value exists (for bookmark)
	// $.history.init(pageload);	
	    
	//highlight the selected link
	// $('a[href=' + document.location.hash + ']').addClass('selected');
	
	//Seearch for link with REL set to ajax
	$('a').live("click",function () {
		
		//grab the full url
		// var hash = this.href;
		
		//remove the # value
		// hash = hash.replace(/^.*#/, '');
		
		//for back button
	 	// $.history.load(hash);	
	 	
	 	//clear the selected class and add the class class to the selected link
	 	// $('a[rel=ajax]').removeClass('selected');
	 	// $(this).addClass('selected');
	 	
	 	//hide the content and show the progress bar
	 	// alert('aa');
	 	$('#loading').fadeIn(500, 0);
	 	$('#obsah').slideUp("fast",getPage(this.href));
	 	
	 	
	 	// alert('aa');
	 	//run the ajax
		
		
	
		//cancel the anchor tag behaviour
		return false;
	});

function getPage(i) {
	
	//generate the parameter for the php script
	// var data = 'page=' + document.location.hash.replace(/^.*#/, '');
	var data="";
	var req="";
	i=i.replace("http://www.msuh.cz","");
  
  if (i.substr(0,4)=="http") {
    window.location.href=i;
  } else {

  // if (req) req.abort();
  
	req = $.ajax({
		url: "/loadajax"+i,	
		type: "GET",		
		data: data,		
		cache: false,
		success: function (html) {	
			$('#loading').fadeOut(500, 0);	
			$('#obsah').html(html);
			$('#obsah').slideDown();
			$('a.lbox').click(function(){return false;});
			Shadowbox.setup("a.lbox", {
        
      });
      req = null;		
		}		
	});
  
  }
	
}
  
  	
});
	

	

