// Run this code once the page is ready to run JavaScript.
$(document).ready(function(){

	// Setup the help dialog.
	$('#helpDialog').dialog
	(
		{
			autoOpen: false,
			draggable: true,
			width: 860,
			height: 570,
			overlay:
			{
				opacity: 0.5,
				background: "black"
			},
			bgiframe: true,
			modal: true
		}
	);


	$(".helpLink").bind("click", function(e) {
		// Remove "selected" class from all help links.
		$('.helpLink').removeClass('selected');
		
		// Add "selected" class to the help link just clicked.
		$(this).addClass('selected');
		
		// Load the help page specified in the link.
		var contentUrl = $(this).attr('href');
		$('#helpContent').load(contentUrl);
		$('#helpContent').scrollTop(0);
		
		// Return false so that the browser doesn't treat
		// the click like a regular link click.
		return false;
	});
});

function loadHelpFile(name) {
	var helpLink = $('#' + name);

	// Remove "selected" class from all help links.
	$('.helpLink').removeClass('selected');

	// Open up help dialog.
	$('#helpDialog').dialog('open');

	// Add "selected" class to the help link.
	$(helpLink).addClass('selected');

	// Load the help page specified in the link.
	var contentUrl = $(helpLink).attr('href');
	$('#helpContent').load(contentUrl);
	$('#helpContent').scrollTop(0);
}

var helpLink = $('#' + name);
