/**
 * warroster.js - WAR roster support
 *
 * @author      Thomas M. Edwards <tmedwards@motoslave.net>
 * @copyright   Copyright (c) 2008-2009 Thomas Michael Edwards
 * @version     1.01, 2009-07-17
 */

/******************************************************************************/

/**
 * setup a ready event to initialize roster interactivity
 */
$(document).ready
(
	function()
	{
		// setup variables
		var wrHead = $('#warroster thead th');
		var wrFoot = $('#warroster tfoot th');
		var wrRows = $('#warroster tbody tr');

		// hook onclick and hover actions
		wrHead
			.each
			(
				function()
				{
					var thisAction	= $(this).find('a').attr('href');
					var thisBgColor	= $(this).css('background-color');
					$(this)
						.click
						(
							function() { window.location.href = thisAction; }
						)
						.hover
						(
							function() { $(this).css({ backgroundColor: '#555' }); },
							function() { $(this).css({ backgroundColor: thisBgColor }); }
						)
						.css({ cursor: 'pointer' });
				}
			);
		wrFoot
			.each
			(
				function()
				{
					var thisAction	= $(this).find('a').attr('href');
					var thisBgColor	= $(this).css('background-color');
					$(this)
						.click
						(
							function() { window.location.href = thisAction; }
						)
						.css({ cursor: 'pointer' });
				}
			);
		wrRows
			.each
			(
				function()
				{
					var thisAction	= $(this).find('td.name').find('a').attr('href');
					var thisBgColor	= $(this).find('td.name').css('background-color');
					$(this)
						.click
						(
							function() { if (thisAction) window.location.href = thisAction; }
						)
						.hover
						(
							function() { $(this).find('td').css({ backgroundColor: '#555' }); },
							function() { $(this).find('td').css({ backgroundColor: thisBgColor }); }
						)
						.css({ cursor: 'pointer' });
				}
			);

	}
);

