function checkAll()
{
	$('.selector').each(function(){$(this).attr('checked', '1'); trHighlight(this, 1)});
}

function uncheckAll()
{
	$('.selector').each(function(){$(this).attr('checked', ''); trHighlight(this, 2)});
}

function switchAll()
{
	$('.selector').each(function(){ 
		if ($(this).attr('checked') == '') {
			$(this).attr('checked', '1'); trHighlight(this);
		} else {
			$(this).attr('checked', ''); trHighlight(this);
		}
	});
}

function trHighlight(e, on)
{
		if (on == 1) {
			if ($(e).closest('tr').attr('class') == 'odd') {
				$(e).closest('tr').attr('class', 'odd tr_checked');
			} else if ($(e).closest('tr').attr('class') == 'even') {
				$(e).closest('tr').attr('class', 'even tr_checked');
			}
			
		} else if (on == 2) {
			if ($(e).closest('tr').attr('class') == 'odd tr_checked') {
				$(e).closest('tr').attr('class', 'odd');
			} else if ($(e).closest('tr').attr('class') == 'even tr_checked') {
				$(e).closest('tr').attr('class', 'even');
			}
		} else {
			if ($(e).closest('tr').attr('class') == 'odd') {
				$(e).closest('tr').attr('class', 'odd tr_checked');
			} else if ($(e).closest('tr').attr('class') == 'even') {
				$(e).closest('tr').attr('class', 'even tr_checked');
			} else if ($(e).closest('tr').attr('class') == 'odd tr_checked') {
				$(e).closest('tr').attr('class', 'odd');
			} else if ($(e).closest('tr').attr('class') == 'even tr_checked') {
				$(e).closest('tr').attr('class', 'even');
			}
		}
}
