/*
 * table_cls.js
 *
 *  Put css classes in table
 *
 * Copyright (c) 2009 Rrota
 * Faton Sopa
 * www.rrota.com
 *
 * -----
 * 
 */
 
loop_tr	=	0;
loop_td	=	0;
$('table').addClass('rounded');
$('table').children('tbody').each(function(index, domEle) {

	$('table tbody').children('tr').each(function(index, domEle) {
		loop_tr++;
		CountTr	=	$('table:nth-child('+loop_tr+') tbody').children('tr').length;

		if (CountTr % 2 == 0){
			$('table:nth-child('+loop_tr+') tbody tr:last').addClass("last");
		}
		else{
			$('table:nth-child('+loop_tr+') tbody tr:last').addClass("last-grayc");
		}
		$('table:nth-child('+loop_tr+') tbody tr:first').addClass("first");
		$('table:nth-child('+loop_tr+') tbody tr:even').addClass('grayc');
		$('table:nth-child('+loop_tr+') tbody tr:first').removeClass("grayc");
		
		$('table:nth-child('+loop_tr+') tbody tr').children('td').each(function(index, domEle) {
			loop_td++;
			test	=	$('table:nth-child('+loop_tr+') tbody tr').children('td').length;
			CountTr =	Math.ceil(test / CountTr);
			$('table:nth-child('+loop_tr+') tbody tr td:nth-child(1)').addClass("left");
			$('table:nth-child('+loop_tr+') tbody tr td:nth-child('+CountTr+')').addClass("last");
			$("table:nth-child("+loop_tr+") tbody tr td").addClass("center");
			$("table:nth-child("+loop_tr+") tbody tr td:nth-child(1)").removeClass("center");	
		});
	
	});
});