// JavaScript Document
var Widget_livescore_main = Widget_livescore.extend({
	
	onready:{
		'remove_buttons': function(){$('#audio_chooser').css('opacity','0');}
	}
	,
	update_data_each: function(eventFK, val, old, event_row, init, sound){
		var me = this;
	
		/*Update Result*/
		if(val.st === 'finished' || val.st === 'inprogress' || val.st === 'interrupted'){
			/*Update Result*/			
			var sets = ['i1','i2','i3','i4','i5','i6','i7','i8','i9','ei','rs','hit','er'];
			
			for(var t=1;t<=2;t=t+1){
				
				$.each(sets, function(index,value){
					if(val['p'+t][value]){
						$(event_row.find('.rs_cell .team_'+t+'_rs td').get(index)).html(val['p'+t][value]);
						/*Highlight*/
						if( val['p'+t][value] > old['p'+t][value]){
							me.highlight($(event_row.find('.rs_cell .team_'+t+'_rs td').get(index)), 10000, 'hl_'+eventFK);
						}
					}
				});
				
			}
			/*Update Score*/
			var rs1 = rs2 = old_rs1 = old_rs2 = 0;
			rs1 = (val.p1.rs) ? val.p1.rs : 0; old_rs1 = (old.p1.rs) ? old.p1.rs : 0;
			rs2 = (val.p2.rs) ? val.p2.rs : 0; old_rs2 = (old.p2.rs) ? old.p2.rs : 0;
			event_row.find('.score .team_1_rs td').html(rs1);
			event_row.find('.score .team_2_rs td').html(rs2);
			if(rs1>old_rs1){
				me.highlight(event_row.find('.score .team_1_rs td'), 10000, 'rs_1_' + eventFK);
			}
			if(rs2>old_rs2){
				me.highlight(event_row.find('.score .team_2_rs td'), 10000, 'rs_2_' + eventFK);
			}
		}
	}
	
});
