jQuery(document).ready(function ($) {

	function setDifferences() {
		if ($('#show-differences')[0].checked) {
			$('#content del').show();
			$('#content ins').removeClass('nocolor');
		} else {
			$('#content del').hide();
			$('#content ins').addClass('nocolor');
		}
	}

	function showIt(area) {
		if (area == null || area.toString().toLowerCase() == 'summary') {
			$('#content').html('');
			$('#index-summary').show();
		} else {

			$('#content').html('Loading');
			$('#index-summary').hide();

			$.ajax({
				url: area + '.htm',
				dataType: 'html',
				success: function (d) {
					var doc = $(d);
					$('#content').html(d);
					setDifferences();
				}
			});
		}
	}

	// show differences
	$('#show-differences').click(function () {
		setDifferences();
	});

	// drop down
	$('#chapter-list').change(function () {

		// set hash
		window.location.hash = '#' + this.value;
		showIt(this.value);

	});

	if (window.location.hash != '') {
		var val = window.location.hash.substring(1)
		showIt(val);
		$('#chapter-list').val(val);
	}

});