// jQuery.preloadImages = function()
// {
// 	for(var i = 0; i<arguments.length; i++)
// 	{
// 		jQuery("<img>").attr("src", arguments[i]);
// 	}
// }
// $.preloadImages("/img/assets/nav/history_over.gif", "/img/assets/nav/testing_over.gif", "/img/assets/nav/operations_over.gif", "/img/assets/nav/health_over.gif", "/img/assets/nav/links_over.gif");

$(document).ready(function() {
	$("img#history_nav").hover(
		function() { $(this).attr("src", "/img/assets/nav/history_over.gif"); },
		function() { $(this).attr("src", "/img/assets/nav/history.gif"); }
	);
	$("img#history_nav_on").hover(
		function() { $(this).attr("src", "/img/assets/nav/history_over.gif"); },
		function() { $(this).attr("src", "/img/assets/nav/history_on.gif"); }
	);
	$("img#testing_nav").hover(
		function() { $(this).attr("src", "/img/assets/nav/testing_over.gif"); },
		function() { $(this).attr("src", "/img/assets/nav/testing.gif"); }
	);
	$("img#testing_nav_on").hover(
		function() { $(this).attr("src", "/img/assets/nav/testing_over.gif"); },
		function() { $(this).attr("src", "/img/assets/nav/testing_on.gif"); }
	);
	$("img#operations_nav").hover(
		function() { $(this).attr("src", "/img/assets/nav/operations_over.gif"); },
		function() { $(this).attr("src", "/img/assets/nav/operations.gif"); }
	);
	$("img#operations_nav_on").hover(
		function() { $(this).attr("src", "/img/assets/nav/operations_over.gif"); },
		function() { $(this).attr("src", "/img/assets/nav/operations_on.gif"); }
	);
	$("img#health_nav").hover(
		function() { $(this).attr("src", "/img/assets/nav/health_over.gif"); },
		function() { $(this).attr("src", "/img/assets/nav/health.gif"); }
	);
	$("img#health_nav_on").hover(
		function() { $(this).attr("src", "/img/assets/nav/health_over.gif"); },
		function() { $(this).attr("src", "/img/assets/nav/health_on.gif"); }
	);
	$("img#links_nav").hover(
		function() { $(this).attr("src", "/img/assets/nav/links_over.gif"); },
		function() { $(this).attr("src", "/img/assets/nav/links.gif"); }
	);
	$("img#links_nav_on").hover(
		function() { $(this).attr("src", "/img/assets/nav/links_over.gif"); },
		function() { $(this).attr("src", "/img/assets/nav/links_on.gif"); }
	);
});

function check_group_form()
{
	var num_errors = 0;
	var error_messages = "You did not complete the form's required fields:\n";
	if ($('#ContentGroupTitle').val() == '')
	{
		num_errors++;
		error_messages += " * You did not specify a Group Title.\n";
	}
	if ($('#ContentGroupOrder').val() == '')
	{
		num_errors++;
		error_messages += " * You did not specify the Group's Order.\n";
	}

	if (num_errors == 0)
	{
		return true;
	}
	else
	{
		alert(error_messages);
		return false;
	}
	
}

function check_section_form()
{
	var num_errors = 0;
	var error_messages = "You did not complete the form's required fields:\n";
	if ($('#SectionName').val() == '')
	{
		num_errors++;
		error_messages += " * You did not specify a Section Name.\n";
	}
	if ($('#SectionShortName').val() == '')
	{
		num_errors++;
		error_messages += " * You did not specify the Section Short Name.\n";
	}
	if ($('#SectionHeaderImage').val() == '')
	{
		num_errors++;
		error_messages += " * You did not specify the Section Header Image.\n";
	}

	if (num_errors == 0)
	{
		return true;
	}
	else
	{
		alert(error_messages);
		return false;
	}
	
}

function check_link_form()
{
	var num_errors = 0;
	var error_messages = "You did not complete the form's required fields:\n";
	if ($('#LinkLinkType').val() == '')
	{
		num_errors++;
		error_messages += " * You did not specify a Link Type.\n";
	}
	if (($('#LinkLinkType').val() == 'f') && ($('#LinkUploadFilename').val() == ''))
	{
		num_errors++;
		error_messages += " * You did not specify a File to upload.\n";
	}
	if (($('#LinkLinkType').val() == 'u') && ($('#LinkUrl').val() == ''))
	{
		num_errors++;
		error_messages += " * You did not specify a Link URL (web address).\n";
	}
	if ($('#LinkIconstyle').val() == '')
	{
		num_errors++;
		error_messages += " * You did not specify an icon (or no icon) to use.\n";
	}

	if ($('#LinkOrder').val() == '')
	{
		num_errors++;
		error_messages += " * You did not specify a Link Order.\n";
	}

	if (num_errors == 0)
	{
		return true;
	}
	else
	{
		alert(error_messages);
		return false;
	}
}