﻿$(document).ready(function() {
	// Highlight complete row (category highlighting)
	$("TABLE.ListDataGrid TR TD.ListTitle DIV").each(function(i) {
		$(this).parents("TR").css("background-color", $(this).css("background-color"));
	});

	// Insert row with date (Month Year)
	var dates = $("TABLE.ListDataGrid TR TD.ListDate");
	var months = new Array('Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember');

	$.each(dates, function(i) {
		//alert('#' + $(dates[i]) + '#');
		//alert('#' + jQuery.trim($(dates[i]).text()) + '#');			

		if (i == 0 || jQuery.trim($(dates[i]).text()).substr(3, 2) != jQuery.trim($(dates[i - 1]).text()).substr(3, 2)) {
			$(this).parent().before($('<tr class="ThemePUR MonthRow"><td class="ThemePUR MonthCell" colspan="' + ($(this).parent().children().length) + '">' + months[parseInt(jQuery.trim($(dates[i]).text()).substr(3, 2), 10) - 1] + ' ' + jQuery.trim($(dates[i]).text()).substr(6, 4) + '</td></tr>'));
			$(this).parent().before($("TABLE.ListDataGrid TR:first").clone());
		}
	});
	$("TABLE.ListDataGrid TR:first").remove();

	// Highlight rows with location Boulodrom
	$("TABLE.ListDataGrid TR TD.ListLocation A").each(function(i) {
		//alert('#' + jQuery.trim($(this).text()) + '#');
		if (jQuery.trim($(this).text()) == 'Boulodrome') {
			$(this).parent().parent().parent().css("background-color", "yellow");
		}
	});
});

