$(document).ready(function() {
	// DATA TABLE
	$('table.data tbody tr').hover(
		function()
		{
			$(this).css({ backgroundColor:'#CCCCFF' });
		},
		function()
		{
			$(this).css({ backgroundColor:'#ffffff' });
		}
	);
	
	// AJAX STATUS
	$('div.ajax-status').ajaxStart(function() {
		$(this).html('<img src="/images/ajax/loading.gif" alt="ajax loading" />');
	});
	$('div.ajax-status').ajaxStop(function() {
		$(this).html('');
	});
	
	// Progress bar
	$('.progress').each(
					function() 
					{
						var progress = $(this).html();
						$(this).empty();
						$(this).progressbar({
							value: progress
						});
						
						// change bar color according to percentage
						var red = progress < 50 ? 255 : (200 - (progress * 2)) * 2.5;
						var green = progress > 50 ? 255 : progress * 5;
						$(this).children('div.ui-progressbar-value').css({ 'background':'rgb(' + red + ', ' + green + ',0)', 'height':'1.2em' });
					}
	);


	// run w3c validation
	$('a.w3c-run').click( 
						function(e)
						{
							e.preventDefault();
							var url = $(this).attr('href');
							$.get(url);
							$(this).parent().html('Sent');
						}
	);
});

