function json(url) {
	$.ajax({
		dataType: 'json',
	    error: 
	    	function(XHR, status, errorThrown) {
	    		$('body').html(status + ' - ' + errorThrown);  
	    	},
	    success:
            function(data, status, xhr) {
    			update(data);            
            },
        url: url + (url.indexOf('params') < 0 ? '/params/json/1' : '/json/1')
	});
}

function update(data) {
	var h1 = $('h1');
	var content = $('#content');
	if(typeof(data.title) != 'undefined' && data.title !== null) {
		h1.html(decodeURIComponent(data.title));
	} else {
		h1.html('');
	}
	if(typeof(data.content) != 'undefined' && data.content !== null) {
		content.html(data.content);
	} else {
		content.html('');
	}
	$.getScript('/fw/app/fibu/stuff/js/script.js');
}

$(function() {
	$('.menu').find('a:not(.json)').each(function(idx, el) {
		if($(el).attr('href').indexOf('javascript') < 0 &&  
			$(el).attr('href').indexOf('http') < 0 &&  
			$(el).attr('href') !== '#') {
			$(el).attr('href', 'javascript:json("' + $(el).attr('href') + '");').addClass('json');
		}
	});
});
