function toggle_display(obj_id, display_type)
{
	obj = document.getElementById(obj_id);
	if(obj != null)
		{
		if(obj.style.display == display_type)
			obj.style.display = 'none';
		else
			obj.style.display = display_type;
		}
}


function show_solution()
{
	solution_div = document.getElementById("solution");
	show_link_span = document.getElementById("solution_show_link");
	hide_link_span = document.getElementById("solution_hide_link");

	solution_div.style.display = 'block';
	show_link_span.style.display = 'none';
	hide_link_span.style.display = 'inline';
}


function hide_solution()
{
	solution_div = document.getElementById("solution");
	show_link_span = document.getElementById("solution_show_link");
	hide_link_span = document.getElementById("solution_hide_link");

	solution_div.style.display = 'none';
	show_link_span.style.display = 'inline';
	hide_link_span.style.display = 'none';
}


function show_hints(hint_count)
{
	hint = true;
	for(i = 1; hint != null; i++)
		{
		hint = document.getElementById("hint_" + i);
		if(hint != null)
			{
			if(i <= hint_count)
				hint.style.display = 'block';
			else
				hint.style.display = 'none';
			}
		}
}


function show_handbook(query)
{
	target = get_website_root_path() + 'handbook/content.php';

	if(query != null)
		{
		query = query.replace(/ /g, '+');
		target = target + '?query=' + query;
		}

	window.open(target);
}


function shuffle_array(array_to_shuffle)
{
	array_len = array_to_shuffle.length;

	// Shuffle four times
	for(j = 0; j < 4; j++)
		{
		// Swap each card with another randomly-chosen card
		for(i = 0; i < array_len; i++)
			{
			swap_with = Math.round(Math.random() * (array_len - 1));
	
			temp = array_to_shuffle[i];
			array_to_shuffle[i] = array_to_shuffle[swap_with];
			array_to_shuffle[swap_with] = temp;
			}
		}
}
