$(function() {
    $(".tab").not(':first').hide();
    var oldCaption='';
    $('li','ul#tabs')
        .hover  (   function() { if (!$(this).hasClass('current')) {$(this).addClass('hover');}},
                    function() {$(this).removeClass('hover');}
                )
        .children('a')
            .data('tabDisabled',false)
            .click(function() {
                    var hash = this.hash.replace("#",'');
                    $(this).trigger('showTab');
                    return false;
            })
            .bind('hideTab',function() {
                    $(this)
                        .css('cursor',null)
                        .parent()
                            .removeClass('current');
                    $(this.hash).hide();
                    return $(this);
            })
            .bind('showTab',function() {
                    if (!$(this).data('tabDisabled')) {
                      if($('#tabs li.current').length > 0) {
                            $('#tabs li.current a').trigger('hideTab');
                      }
                      $(this)
                        .parent()
                            .addClass('current')
                            .removeClass('hover');
                      var newCaption = " - " +$(this).attr('title');
                      $(this.hash).show();
                      document.title = document.title.replace(oldCaption,'') + newCaption;
                      oldCaption = newCaption;
                    }
                    return $(this);
            });
	
	
	if (location.hash != '') {
		hash = location.hash
		if (hash.substring(0,1) != '#') {
		  hash = "#"+hash;
		}
		$("a[href='"+hash+"']").trigger('showTab');
	}
	else {	
	  $('#tabs li:first a').trigger('showTab');
	}
});     
