
$().ready(function(){
	$(".tb tr").mouseover(function(e){
		idx = $(".tb tr").index(this);
		new_class = 'tb_highlight_row';
		if( $(e.target).is('a') && (e.target.href.match(/.*(del|delete|erase|remove|kill|drop).*/)))
			new_class = 'tb_highlight_red_row';
		if (idx>0 || (idx==0 && $(this).attr('class')!='tb_head_row'))
			$(".tb tr:eq("+idx+")").attr('class', new_class);
	});
	$(".tb tr").mouseout(function(){
		idx = $(".tb tr").index(this);
		if (idx>0 || (idx==0 && $(this).attr('class')!='tb_head_row'))
			$(".tb tr:eq("+idx+")").attr('class', idx%2==0 ? 'tb_dark_row' : 'tb_light_row');
	});
	$(".tb tr").click(function(){
		idx = $(".tb tr").index(this);
		len = $(".tb tr:eq("+idx+") td").length-1;
		len2 = $(".tb tr:eq("+idx+") td:eq("+len+") a").length;

		href = '';
		for( i=0; i<len2; i++ )
		{
			href = $(".tb tr:eq("+idx+") td:eq("+len+") a:eq("+i+")").attr("href");
			if (href.indexOf('edit')>=0) break;
		}
		if (href!='')
			location = href;
	});
//	$(".tb").each('a').is(/.*(del|delete|erase|remove|kill|drop).*/i).click(function(){
//		alert( $(".tb a").index(this) );
//	});



	over = false;
	$("#l_0 li").mouseover(function(e){
		id = '#l_0';
		idx = $(id+" li").index(this);
		new_class = 'tb_highlight_row';
		if( !over && $(e.target).is('a') && (e.target.href.match(/.*(del|delete|erase|remove|kill|drop).*/)))
		{
			id = '#'+$(e.currentTarget).parent().attr('id');
			new_class = 'tb_highlight_red_row';
			if (id.substr(-1,1)==0 && $(e.currentTarget).html().indexOf('id="l_1"')>=0)
				$("#l_1 li").attr('class',new_class);
		}
		if (idx>=0)
			$(id+" li:eq("+idx+")").attr('class',new_class);
	});
	$("#l_1 li").mouseover(function(e){
		id = '#l_1';
		idx = $(id+" li").index(this);
		new_class = 'tb_highlight_row';
		over = false;
		if( $(e.target).is('a') && (e.target.href.match(/.*(del|delete|erase|remove|kill|drop).*/)))
		{
			over = true;
			id = '#'+$(e.currentTarget).parent().attr('id');
			new_class = 'tb_highlight_red_row';
		}
		if (idx>=0)
			$(id+" li:eq("+idx+")").attr('class',new_class);
	});
	$(".sortable li").mouseout(function(){
		$(".sortable li").attr('class','ui-state-default');
	});
});
