$(document).ready(function() {
	// Stuff to do as soon as the DOM is ready;
	
	

    // Document title
    var title = document.title;

	var menu = '#menu ul li';
	
	$(menu).first().css('color', '#333366');


    // Address handler
    $.address.init(function(event) {
  
    
    }).change(function(event) {

        // Sets the page title
		$("#content").load($('[rel=address:' + event.value + ']').attr('href'));

		var names = $.map(event.pathNames, function(n) {
            return n.substr(0, 1).toUpperCase() + n.substr(1);
        }).concat(event.parameters.id ? event.parameters.id.split('.') : []);
        var links = names.slice();
        var match = links.length ? links.shift() + ' ' + links.join('.') : 'Home';
        $('a').each(function() {
            $(this).toggleClass('selected', $(this).text() == match);
        });
        $.address.title([title].concat(names).join(' | '));

	   


    }).internalChange(function(event) {

        // Select the proper tab
       // tabs.tabs('select', $('a').filter('[rel=address:' + event.value + ']').attr('href'));
		$("#content").load($('[rel=address:' + event.value + ']').attr('href'));
        
    });
});
