var goals_last_value = new Array();
var mt_content = '';
var tour_content = '';
var fav_tour_content = '';
var close_tour_content = '';
var	ticker_content = '';
var global_tour_match = new Array();
var chk_tour = '';
var result_after = "1";
var html_live_body = '';
var temp_inc_id;
var temp_goal_id;
var hidden_incidents = new Array();
var hidden_goals = new Array();
var no_game_selected;
var chk_border_flag = false;
var minute_flag_content = new Array();
var mfr = 0;
function display_screen(){
	var my_matches_chk_bg = '';
	var chk_tour_bg = '';
	var temp_main_matches = new Array();
	var chk_last_goal = check_last_goal();
	var ticker_counter = 0;
	html_live_body = '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	var content = new Array();
	var main_counter = 0;
	var main_matches = new Array();
	var finished_matches = new Array();
	var finished_counter = 0;
	var last_goal_row = new Array();
	var last_incident_row = new Array();
	var lir = 0;
	var gtm_cnt = 0;
	g_sort = check_gsort();
	if(g_date == to_day){
		result_after = check_result();
	} else {
		result_after = "1";
	}
	half_flag = 0;
	is_whistle = false;
	position_display = document.settings.position.checked;//check_status('position');
	commentary_display = document.settings.commentary.checked;//check_status('commentary');
	league_info_display = document.settings.league_info.checked;//check_status('league_info');
	odds_display = document.settings.odds.checked;//check_status('odds');
	whistle_display = check_status('whistle');
	goal_popup = check_status('small_popup');
	content = xml_content.split("\n");
	mt_content = '';
	tour_content = '';
	fav_tour_content = '';
	close_tour_content = '';
	parse_mymatches_from_cookie();
	parse_tourhide_from_cookie();
	parse_favtour_from_cookie();
	parse_closetour_from_cookie();
	global_tour_match = new Array();
	for(cnt =0; cnt < content.length-1; cnt++){
		if(content[cnt].substring(0,3) == "@@@"){
			temp_date = date = content[cnt].substring(3);
			head_content = new Array();
			head_content = temp_date.split("##");
			live_time_stamp = head_content[1];
			if(g_sort == "gt" || g_sort == "gt_desc" || g_sort == "goals" || g_sort == "over" || g_sort == "under"){
				html_live_body += '<tr><td class="headbg b" colspan="7">&nbsp;&nbsp;' + head_content[0] + '</td><td class="headbg b c">HT</td><td class="headbg" colspan="6">&nbsp;</td></tr>';
			}
		} else {
			match_info = content[cnt].split("##");
			global_tour_match[gtm_cnt] = Array(match_info[0], match_info[6]);
			gtm_cnt++;
			if(only_live_matches == "0" && chk_last_goal == "1" && match_info[28] > 0){
				if(isMyMatch(match_info[6])){
					my_match = 'checked';
				} else {
					my_match = '';
				}
				if(last_goal_row.length == 0 || match_info[28] > last_goal_row[28]){
					last_goal_row = new Array(match_info[2] + " " + match_info[5], match_info[20], match_info[0], match_info[1], match_info[2], match_info[3], match_info[4], match_info[5], match_info[6], match_info[7], match_info[8], match_info[9], match_info[10], match_info[11], match_info[12], match_info[13], match_info[14], match_info[15], match_info[16], match_info[17], match_info[18], match_info[19], match_info[20], match_info[21], match_info[22], match_info[23], match_info[24], my_match, match_info[25], match_info[26], match_info[27], match_info[29], match_info[30]);
				}
			}
			if(only_live_matches == "0" || (match_info[9] != "NS" && match_info[9] != "FT" && match_info[9] != "POS" && match_info[9] != "PEN" && match_info[9] != "FAET")){
				if((only_country == '' || only_country == match_info[3]) && (only_league == '' || only_league == match_info[0])){
					if(isMyMatch(match_info[6])){
						my_match = 'checked';
					} else {
						my_match = '';
					}
					if(match_mode == "all_matches" || show_matches == "all" || my_match == 'checked'){
						if(g_sort == "league" || g_sort == "league_desc"){
							temp_main_matches = new Array(match_info[2] + " " + match_info[5] + " " + match_info[4], match_info[20], match_info[0], match_info[1], match_info[2], match_info[3], match_info[4], match_info[5], match_info[6], match_info[7], match_info[8], match_info[9], match_info[10], match_info[11], match_info[12], match_info[13], match_info[14], match_info[15], match_info[16], match_info[17], match_info[18], match_info[19], match_info[20], match_info[21], match_info[22], match_info[23], match_info[24], my_match, match_info[25], match_info[26], match_info[27], match_info[29], match_info[30]);
						} else if(g_sort == "goals" || g_sort == "under" || g_sort == "over"){
							var mv = match_info[13].split("-");
							total_temp = parseInt(mv[0]) + parseInt(mv[1]);
							mv = null;
							if(total_temp == "NaN"){
								total_temp = -1;
							}
							temp_main_matches = new Array(20-total_temp, match_info[20], match_info[0], match_info[1], match_info[2], match_info[3], match_info[4], match_info[5], match_info[6], match_info[7], match_info[8], match_info[9], match_info[10], match_info[11], match_info[12], match_info[13], match_info[14], match_info[15], match_info[16], match_info[17], match_info[18], match_info[19], match_info[20], match_info[21], match_info[22], match_info[23], match_info[24], my_match, match_info[25], match_info[26], match_info[27], match_info[29], match_info[30]);
						} else {
							temp_main_matches = new Array(match_info[20], match_info[2] + " " + match_info[5] + " " + match_info[4], match_info[0], match_info[1], match_info[2], match_info[3], match_info[4], match_info[5], match_info[6], match_info[7], match_info[8], match_info[9], match_info[10], match_info[11], match_info[12], match_info[13], match_info[14], match_info[15], match_info[16], match_info[17], match_info[18], match_info[19], match_info[20], match_info[21], match_info[22], match_info[23], match_info[24], my_match, match_info[25], match_info[26], match_info[27], match_info[29], match_info[30]);
						}
						if(result_after == "2" && match_info[9] == "FT"){
						}else if(result_after == "3" && match_info[9] == "FT"){
							finished_matches[finished_counter] = temp_main_matches;
							finished_counter++;
						} else {
							main_matches[main_counter] = temp_main_matches;
							main_counter++;
						}
					}
				}
			}
		}
	}
	main_matches.sort();
	finished_matches.sort();
	if(g_sort == "league_desc" || g_sort == "under"){
		main_matches.reverse();
	}
	if(chk_last_goal == "1" && last_goal_row.length > 0 && g_date == to_day){
		var last_goal_info = new Array();
		last_goal_info[0] = last_goal_row;
		for( var mc=0; mc < main_matches.length; mc++){
			if(last_goal_row[8] != main_matches[mc][8]){
				last_goal_info[last_goal_info.length] = main_matches[mc];
			}
		}
		main_matches = last_goal_info;
		last_goal_info = null;
	}
	var tour_id = 0;
	ticker_content = '';
	var tour_display='';
	for( var mc=0; mc < main_matches.length; mc++){
		if(mc % 2 == 0){
			row_class = 'odd';
		} else {
			row_class = 'even';
		}
		if(main_matches[mc][30] == "female"){
			row_class = "fe_" + row_class;
		}
		js_link = main_matches[mc][8] + ',' + main_matches[mc][2] + ',' + main_matches[mc][12] + ',' + main_matches[mc][13];
		if(main_matches[mc][17] == "1"){
			current_link = '<a href="javascript:popupWin(' + js_link + ')" title="' + word_mo_score + '">';
			current_score = '<a href="javascript:popupWin(' +  js_link + ')" title="' + word_mo_score + '">' + main_matches[mc][15] + '</a>';
		} else {
			current_link = '';
			current_score = main_matches[mc][15];
		}
		if(main_matches[mc][18] == "1" && commentary_display){
			livestats = '<a href="javascript:comment(' + js_link + ')"><img src="' + livescoresPath + 'img/ico_c.gif" border="0" title="' + word_mo_commentary+ '"></a>';
		} else {
			livestats = '&nbsp;';
		}
		compare_part = '<a href="javascript:compare(' +  js_link + ')"><img src="' + livescoresPath + 'img/ico_vs.gif" border="0" title="' + word_mo_compare + '"></a>';
		if(odds_display && main_matches[mc][23] == "1" && main_matches[mc][29] != "1"){
			odds_part = '<a href="javascript:odds(' + js_link + ')"><img src="' + livescoresPath + 'img/v2/btn_odds_animated.gif" border="0" title="' + word_mo_odds + '"></a>';
		} else if(odds_display && main_matches[mc][23] == "1" && main_matches[mc][29] == "1"){
			odds_part = '<a href="javascript:odds(' + js_link + ')"><img src="' + livescoresPath + 'img/v2/btn_odds+live_animated.gif" border="0" title="' + word_mo_odds + '"></a>';
		} else {
			odds_part = '&nbsp;';
		}
		if(ticker_counter < 20){
			if(main_matches[mc][11] != "NS" && main_matches[mc][11] != "POS" && main_matches[mc][15] != "0-0"){
				ticker_content += ' <b>' + main_matches[mc][11] + '</b> ' + main_matches[mc][9] + ' ' + current_score + ' ' + main_matches[mc][10] + ' | ';
				ticker_counter++;
			}
		}
		temp_home_name = main_matches[mc][9];
		temp_away_name = main_matches[mc][10];
		if(main_matches[mc][24] && position_display){
			main_matches[mc][9] = '(' + main_matches[mc][24] + ') ' + main_matches[mc][9];
		}
		if(main_matches[mc][25] && position_display){
			main_matches[mc][10] = main_matches[mc][10] + ' (' + main_matches[mc][25] + ')';
		}
		my_matches_chk_bg = '';
		if(match_mode == "my_matches"){
			my_matches_chk = '<input type="checkbox" name="matchid[]" id="match_' + main_matches[mc][8] + '"value="' + main_matches[mc][8] + '" onclick="setMyMatch('+ main_matches[mc][8] + ',this.checked,' + main_matches[mc][2] +')" class="nb" ' + main_matches[mc][27] + '>';
			if(chk_border_flag){
				my_matches_chk_bg = ' chkboxbg'
			}
		} else {
			my_matches_chk = '&nbsp;';
		}
		if(main_matches[mc][4] == "International" && (main_matches[mc][6].substring(0,17) != "Toulon Tournament" && main_matches[mc][2] != 816476 && main_matches[mc][2] != 816460)){
			tour_head_title = main_matches[mc][6];		
		} else {
			tour_head_title = main_matches[mc][4] + " - " + main_matches[mc][6];
		}
		if(main_matches[mc][14]){
			tour_head_title += ' - ' + main_matches[mc][14] + '. ' + word_round;
		}
		if(main_matches[mc][3]){
			flag = '<a href="stats.php?tourFK=' + main_matches[mc][2] + '" target="_blank"><img src="' + livescoresPath + 'img/flags/' + main_matches[mc][3] + '" border="0" title="' + tour_head_title + '" /></a>';
		} else {
			flag = '&nbsp;';
		}
		if(league_info_display){
			tour_info = '<a href="stats.php?tourFK=' + main_matches[mc][2] + '" target="_blank"><img src="' + livescoresPath + 'img/v2/btn_league_info.gif" title="' + word_mo_league_info + '" width="16" height="16">';
		} else {
			tour_info = '&nbsp;';
		}
		var head_tour_display = 'block';
		if(g_sort == "league" || g_sort == "league_desc"){
			if(main_matches[mc][24] && main_matches[mc][25]){
				is_standings = '<a href="stats.php?tourFK=' + main_matches[mc][2] + '#standing" target="_blank" title="' + word_mo_standings + '">'+ word_standings + '</a>';
			} else {
				is_standings = '&nbsp;';
			}
			if(only_country == ''){
				if(isTourHide(main_matches[mc][2])){
					tour_display = 'none';
					tour_image = livescoresPath + 'img/sh_show.jpg';
					tour_tip = word_bar_show;
				} else if(isTourClose(main_matches[mc][2])){
					tour_display = 'none';
					head_tour_display = 'none';
					tour_image = livescoresPath + 'img/sh_hide.jpg';
					tour_tip = word_bar_hide;
				} else {
					tour_display = 'block';
					tour_image = livescoresPath + 'img/sh_hide.jpg';
					tour_tip = word_bar_hide;
				}
			} else {
				tour_display = 'block';
				tour_image = livescoresPath + 'img/sh_hide.jpg';
				tour_tip = word_bar_hide;
			}
			if(tour_id != main_matches[mc][2]){
				chk_tour_bg = '';
				if(match_mode == 'my_matches'){
					if(isTourFav(main_matches[mc][2])){
						chk_tour = '<input class="nb" type="checkbox" name="tourid[]" value="' + main_matches[mc][2] + '" id="chk_tr_' + main_matches[mc][2] + '" onclick="selectTour(this.checked, \'' + main_matches[mc][2] + '\')" checked >';
					} else {
						chk_tour = '<input class="nb" type="checkbox" name="tourid[]" value="' + main_matches[mc][2] + '" id="chk_tr_' + main_matches[mc][2] + '" onclick="selectTour(this.checked, \'' + main_matches[mc][2] + '\')">';					
					}
					if(chk_border_flag){
						chk_tour_bg = ' chkboxbg';
					}
				} else {
					chk_tour = '&nbsp;';
				}
				html_live_body += '</table><table id="head_' + main_matches[mc][2] + '" border="0" cellspacing="0" cellpadding="0" style="display:' + head_tour_display + ';background:url(' + livescoresPath + 'img/gradiant_bar.jpg) repeat-x;height:20px;"><tr><td width="26" class="l" valign="top"><div class="showHideDiv" id="img-' + main_matches[mc][2] + '"><img src="' + tour_image + '" onclick="javascript:showHide(\'' + main_matches[mc][2] + '\');" title="'+tour_tip+'" /></div></td><td width="28" class="c">' + flag + '</td><td width="21" class="c">' + tour_info + '</td><td class="stageTitle" width="446">' + tour_head_title + '</td><td width="36" class="b c">HT</td><td width="84">&nbsp;</td><td width="20" class="c' + chk_tour_bg + '">' + chk_tour + '</td></tr></table><table id="' + main_matches[mc][2] + '" style="display:' + tour_display + ';" border="0" cellspacing="0" cellpadding="0">';
				if(main_matches[mc][30] == "female"){
					html_live_body += '<tfoot><tr><td colspan=13 class="fe_even"><table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td width=33%>&nbsp;<a href="stats.php?cmd=nextonly&tourFK=' + main_matches[mc][2] + '#nextonly" target="_blank" title="'+ word_mo_next_matches + '">'+ word_next_matches + '</a></td><td width=33% align="center">' + is_standings + '</td><td width=33% align="right"><a href="stats.php?cmd=lastonly&tourFK=' + main_matches[mc][2] + '#lastonly" target="_blank" title="'+ word_mo_results + '">'+ word_results + '</a>&nbsp;</td></tr></table></td></tr></tfoot>';				
				} else {
					html_live_body += '<tfoot><tr><td colspan=13><table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td width=33%>&nbsp;<a href="stats.php?cmd=nextonly&tourFK=' + main_matches[mc][2] + '#nextonly" target="_blank" title="' + word_mo_next_matches + '">'+ word_next_matches + '</a></td><td width=33% align="center">' + is_standings + '</td><td width=33% align="right"><a href="stats.php?cmd=lastonly&tourFK=' + main_matches[mc][2] + '#lastonly" target="_blank" title="'+ word_mo_results + '">'+ word_results + '</a>&nbsp;</td></tr></table></td></tr></tfoot>';
				}
			}
		}
		if(main_matches[mc][16] != "-" && main_matches[mc][16] != " - "){
			main_matches[mc][16] = "(" + current_link +  main_matches[mc][16] + "</a>)";
		}
		goal_img = '';
		home_last_inc_html = '';
		away_last_inc_html = '';
		if(g_date == to_day && main_matches[mc][11] != "FT"){
			temp_goal_id =0;
			temp_inc_id = 0;
//			if(main_matches[mc][21] != "" && !in_array(main_matches[mc][32], hidden_goals, false)){
			if(main_matches[mc][21] != ""){
				is_new_goal = true;
				goal_img = '<img src="' + livescoresPath + 'img/goal2-new2.gif" border="0" id="i_' + main_matches[mc][32] + '" style="position:absolute;" />';
				if(main_matches[mc][21] == "H"){
					 main_matches[mc][9] = '<font color="#FF0000">' + main_matches[mc][9] + '</font>';
				}
				if(main_matches[mc][21] == "A"){
					 main_matches[mc][10] = '<font color="#FF0000">' + main_matches[mc][10] + '</font>';
				 }
				 temp_goal_id = main_matches[mc][32];
			}
			if(goal_popup && main_matches[mc][28]){
				last_inc = main_matches[mc][28].split("#");
				if(!in_array(last_inc[4], hidden_incidents, false)){
					if(last_inc[3] == "H"){
						home_last_inc_html = ' <div id="z_' + last_inc[4] + '" class="incident"><img src="' + livescoresPath + 'img/v1/cards/'+last_inc[1]+'.gif" border="0"> ' + last_inc[2] + '\' ' + last_inc[0] + '</div> ';
						away_last_inc_html='';
					} else {
						away_last_inc_html = ' <div id="z_' + last_inc[4] + '" class="incidentr"><img src="' + livescoresPath + 'img/v1/cards/'+last_inc[1]+'.gif" border="0"> ' + last_inc[2] + '\' ' + last_inc[0] + '</div> ';
						home_last_inc_html='';
					}
					temp_inc_id = last_inc[4];
				}
			}
			if(main_matches[mc][26] == "1"){
				is_whistle = true;
			}
			if(temp_goal_id || temp_inc_id){
				setTimeout("hide_goal_icon(" + temp_goal_id + "," + temp_inc_id + ")", 30000);
			}
		}
		if(main_matches[mc][19] != ""){ // red and 2nd yellow cards
			main_matches[mc][9] = current_link + parse_cards(main_matches[mc][19]) + '</a> ' + main_matches[mc][9];
		}
		if(main_matches[mc][20] != ""){
			main_matches[mc][10] = main_matches[mc][10] + '&nbsp;' + current_link + parse_cards(main_matches[mc][20]) + '</a>';
		}
		if(main_matches[mc][11] == "NS"){
			main_matches[mc][11] = print_date(main_matches[mc][22]);
		}
		if(main_matches[mc][11] == "1H" || main_matches[mc][11] == "2H"){
			minute_flag_content[mfr] = new Array(main_matches[mc][8], main_matches[mc][11], main_matches[mc][22]);
			main_matches[mc][11] = '<span id="min_' + main_matches[mc][8] + '">' + main_matches[mc][11] + "-" + calc_time(main_matches[mc][22], main_matches[mc][11]) + '</span>';
			mfr++;
			half_flag = 1;
		}		
		if(g_sort == "league" || g_sort == "league_desc"){
			html_live_body += '<tr height="20" class="' + row_class + '"><td class="dateCol '+row_class+'">' + goal_img + main_matches[mc][11] + '</td><td valign="top">'+home_last_inc_html +'</td><td class="teamA '+row_class+' pr">' + main_matches[mc][9] + '</td><td class="score">' + current_score + '</td><td class="teamB '+row_class+' pl">' + away_last_inc_html + main_matches[mc][10] + '</td><td>' + '' +'</td><td class="htscore '+row_class+'">' + main_matches[mc][16] + '</a></td><td width=22 class="'+row_class+' c">&nbsp;</td><td width=22 class="' + row_class+' c">' + livestats + '</td><td width=22 class="'+row_class+'">' + compare_part + '</td><td width=24 class="' + row_class+'">' + odds_part + '</td><td width=20 class="'+row_class+' c' + my_matches_chk_bg + '">' + my_matches_chk + '</td></tr>';
		} else {
			html_live_body += '<tr height="20" class="' + row_class + '"><td width="20" class="' + row_class + ' c">' + goal_img + flag + '</td><td class="'+row_class+' c br" title="' + main_matches[mc][21] + '">' + main_matches[mc][11] + '</td><td valign="top">'+home_last_inc_html +'</td><td class="'+row_class+' r pr">'+ main_matches[mc][9] + '</td><td class="score">' + current_score + '</td><td class="'+row_class+' pl">'+ away_last_inc_html + main_matches[mc][10] + '</td><td>' + '' + '</td><td class="htscore '+row_class+'">'+ main_matches[mc][16] + '</a></td><td width=22 class="'+row_class+' c">' + tour_info + '</td><td width=22 class="'+row_class+' c">' + livestats + '</td><td width=22 class="'+row_class+' c">' + compare_part + '</td><td width=24 class="'+row_class+' c">' + odds_part + '</td><td width=20 class="'+row_class+' c' + my_matches_chk_bg + '">' + my_matches_chk + '</td></tr>';
		}
		if(main_matches[mc][31] && tour_display != "none"){
			context = main_matches[mc][31].split("#");
			last_incident_row[lir] = new Array(context[1], context[0], context[2], temp_home_name, temp_away_name, current_score, main_matches[mc][8]);
			lir++;
		}
		tour_id = main_matches[mc][2];
	}
	if(result_after == "3" && finished_matches.length > 0){
		html_live_body += '<tr><td class="headbg b" colspan="7">&nbsp;&nbsp;' + head_content[0] + ' Finished Matches</td><td class="headbg b c">HT</td><td class="headbg" colspan="6">&nbsp;</td></tr>';
		for( var mc=0; mc < finished_matches.length; mc++){
			if(mc % 2 == 0){
				row_class = 'odd';
			} else {
				row_class = 'even';
			}
			if(finished_matches[mc][30] == "female"){
				row_class = "fe_" + row_class;
			}
			js_link = finished_matches[mc][8] + ',' + finished_matches[mc][2] + ',' + finished_matches[mc][12] + ',' + finished_matches[mc][13];
			if(finished_matches[mc][17] == "1"){
				current_link = '<a href="javascript:popupWin(' + js_link + ')" title="' + word_mo_score + '">';
				current_score = '<a href="javascript:popupWin(' +  js_link + ')" title="' + word_mo_score + '">' + finished_matches[mc][15] + '</a>';
			} else {
				current_link = '';
				current_score = finished_matches[mc][15];
			}
			if(finished_matches[mc][18] == "1" && commentary_display){
				livestats = '<a href="javascript:comment(' + js_link + ')"><img src="' + livescoresPath + 'img/ico_c.gif" border="0" title="' + word_mo_commentary+ '"></a>';
			} else {
				livestats = '&nbsp;';
			}
			compare_part = '<a href="javascript:compare(' +  js_link + ')"><img src="' + livescoresPath + 'img/ico_vs.gif" border="0" title="' + word_mo_compare + '"></a>';
			if(odds_display && finished_matches[mc][23] == "1" && finished_matches[mc][29] != "1"){
				odds_part = '<a href="javascript:odds(' + js_link + ')"><img src="' + livescoresPath + 'img/v2/btn_odds_animated.gif" border="0" title="' + word_mo_odds + '"></a>';
			} else if(odds_display && finished_matches[mc][23] == "1" && finished_matches[mc][29] == "1"){
				odds_part = '<a href="javascript:odds(' + js_link + ')"><img src="' + livescoresPath + 'img/v2/btn_odds+live_animated.gif" border="0" title="' + word_mo_odds + '"></a>';
			} else {
				odds_part = '&nbsp;';
			}
			if(ticker_counter < 20){
				if(finished_matches[mc][11] != "NS" && finished_matches[mc][11] != "POS" && finished_matches[mc][15] != "0-0"){
					ticker_content += ' <b>' + finished_matches[mc][11] + '</b> ' + finished_matches[mc][9] + ' ' + current_score + ' ' + finished_matches[mc][10] + ' &nbsp;| &nbsp; ';
					ticker_counter++;
				}
			}
			temp_home_name = finished_matches[mc][9];
			temp_away_name = finished_matches[mc][10];
			if(finished_matches[mc][24] && position_display){
				finished_matches[mc][9] = '(' + finished_matches[mc][24] + ') ' + finished_matches[mc][9];
			}
			if(finished_matches[mc][25] && position_display){
				finished_matches[mc][10] = finished_matches[mc][10] + ' (' + finished_matches[mc][25] + ')';
			}
			my_matches_chk_bg = '';
			if(match_mode == "my_matches"){
				my_matches_chk = '<input type="checkbox" id="match_' + finished_matches[mc][8] + '" name="matchid[]" value="' + finished_matches[mc][8] + '" onclick="setMyMatch('+ finished_matches[mc][8] + ',this.checked,' + finished_matches[mc][2] + ')" class="nb" ' + finished_matches[mc][27] + '>';
				if(chk_border_flag){
					my_matches_chk_bg = ' chkboxbg';
				}
			} else {
				my_matches_chk = '&nbsp;';
			}
			tour_head_title = finished_matches[mc][4] + " - " + finished_matches[mc][6];
			if(finished_matches[mc][14]){
				tour_head_title += ' - ' + finished_matches[mc][14] + '. ' + word_round;
			}
			if(finished_matches[mc][3]){
				flag = '<a href="stats.php?tourFK=' + finished_matches[mc][2] + '" target="_blank"><img src="' + livescoresPath + 'img/flags/' + finished_matches[mc][3] + '" border="0" title="' + tour_head_title + '" /></a>';
			} else {
				flag = '&nbsp;';
			}
			if(league_info_display){
				tour_info = '<a href="stats.php?tourFK=' + finished_matches[mc][2] + '" target="_blank"><img src="' + livescoresPath + 'img/v2/btn_league_info.gif" title="' + word_mo_league_info + '" width="16" height="16">';
			} else {
				tour_info = '&nbsp;';
			}
			if(g_sort == "league" || g_sort == "league_desc"){
				if(finished_matches[mc][24] && finished_matches[mc][25]){
					is_standings = '<a href="stats.php?tourFK=' + finished_matches[mc][2] + '#standing" target="_blank" title="' + word_mo_standings + '">'+ word_standings + '</a>';
				} else {
					is_standings = '&nbsp;';
				}
				if(only_country == '' && isTourHide(finished_matches[mc][2])){
					tour_display = 'none';
					tour_image = 'img/sh_show.jpg';
					tour_tip = word_bar_show;
				} else {
					tour_display = 'block';
					tour_image = 'img/sh_hide.jpg';
					tour_tip = word_bar_hide;
				}
				var head_tour_display = 'block';
				if(tour_id != finished_matches[mc][2]){
					chk_tour_bg = '';
					if(match_mode == 'my_matches'){
						if(isTourFav(finished_matches[mc][2])){
							chk_tour = '<input class="nb" type="checkbox" name="tourid[]" value="' + finished_matches[mc][2] + '" id="chk_tr_' + finished_matches[mc][2] + '" onclick="selectTour(this.checked, \'' + finished_matches[mc][2] + '\')" checked>';
						} else {
							chk_tour = '<input class="nb" type="checkbox" name="tourid[]" value="' + finished_matches[mc][2] + '" id="chk_tr_' + finished_matches[mc][2] + '" onclick="selectTour(this.checked, \'' + finished_matches[mc][2] + '\')">';					
						}
						if(chk_border_flag){
							chk_tour_bg = ' chkboxbg';
						}
					} else {
						chk_tour = '&nbsp;';
					}
					html_live_body += '</table><table id="head_' + finished_matches[mc][2] + '" border="0" cellspacing="0" cellpadding="0" style="display:' + head_tour_display + ';background:url(' + livescoresPath + 'img/gradiant_bar.jpg) repeat-x;height:20px;"><tr><td width="26" class="l"><div class="showHideDiv" id="img-' + finished_matches[mc][2] + '"><img src="' + tour_image + '" onclick="javascript:showHide(\'' + finished_matches[mc][2] + '\');" title="'+tour_tip+'" /></div></td><td width="28" class="c">' + flag + '</td><td width="21" class="c">' + tour_info + '</td><td class="stageTitle" width="446">' + tour_head_title + '</td><td width="36" class="b c">HT</td><td width="84">&nbsp;</td><td width="20" class="c' + chk_tour_bg + '">' + chk_tour + '</td></tr></table><table id="' + finished_matches[mc][2] + '" style="display:' + tour_display + ';" border="0" cellspacing="0" cellpadding="0">';
					if(finished_matches[mc][30] == "female"){
						html_live_body += '<tfoot><tr><td colspan=13 class="fe_even"><table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td width=33%>&nbsp;<a href="stats.php?cmd=nextonly&tourFK=' + finished_matches[mc][2] + '#nextonly" target="_blank" title="'+ word_mo_next_matches + '">'+ word_next_matches + '</a></td><td width=33% align="center">' + is_standings + '</td><td width=33% align="right"><a href="stats.php?cmd=lastonly&tourFK=' + finished_matches[mc][2] + '#lastonly" target="_blank" title="'+ word_mo_results + '">'+ word_results + '</a>&nbsp;</td></tr></table></td></tr></tfoot>';				
					} else {
						html_live_body += '<tfoot><tr><td colspan=13><table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td width=33%>&nbsp;<a href="stats.php?cmd=nextonly&tourFK=' + finished_matches[mc][2] + '#nextonly" target="_blank" title="' + word_mo_next_matches + '">'+ word_next_matches + '</a></td><td width=33% align="center">' + is_standings + '</td><td width=33% align="right"><a href="stats.php?cmd=lastonly&tourFK=' + finished_matches[mc][2] + '#lastonly" target="_blank" title="'+ word_mo_results + '">'+ word_results + '</a>&nbsp;</td></tr></table></td></tr></tfoot>';
					}
				}
				head_tour_display = null;
			}
			if(finished_matches[mc][16] != "-" && finished_matches[mc][16] != " - "){
				finished_matches[mc][16] = "(" + current_link +  finished_matches[mc][16] + "</a>)";
			}
			if(finished_matches[mc][19] != ""){ // red and 2nd yellow cards
				finished_matches[mc][9] = current_link + parse_cards(finished_matches[mc][19]) + '</a> ' + finished_matches[mc][9];
			}
			if(finished_matches[mc][20] != ""){
				finished_matches[mc][10] = finished_matches[mc][10] + '&nbsp;' + current_link + parse_cards(finished_matches[mc][20]) + '</a>';
			}
			if(goal_popup && finished_matches[mc][28]){
				last_inc = finished_matches[mc][28].split("#");
				if(last_inc[3] == "H"){
					home_last_inc_html = ' <div class="incident"><img src="' + livescoresPath + 'img/v1/cards/'+last_inc[1]+'.gif" border="0"> ' + last_inc[2] + '\' ' + last_inc[0] + '</div> ';
					away_last_inc_html='';
				} else {
					away_last_inc_html = ' <div class="incidentr"><img src="' + livescoresPath + 'img/v1/cards/'+last_inc[1]+'.gif" border="0"> ' + last_inc[2] + '\' ' + last_inc[0] + '</div> ';
					home_last_inc_html='';
				}
			} else {
				home_last_inc_html = '';
				away_last_inc_html = '';
			}
			if(g_sort == "league" || g_sort == "league_desc"){
				html_live_body += '<tr height="20" class="' + row_class + '"><td class="dateCol '+row_class+'">' + goal_img + finished_matches[mc][11] + '</td><td valign="top">'+home_last_inc_html +'</td><td class="teamA '+row_class+' pr">' + finished_matches[mc][9] + '</td><td class="score">' + current_score + '</td><td class="teamB '+row_class+' pl">' + away_last_inc_html + finished_matches[mc][10] + '</td><td>' + '' +'</td><td class="htscore '+row_class+'">' + finished_matches[mc][16] + '</a></td><td width=22 class="'+row_class+' c">&nbsp;</td><td width=22 class="' + row_class+' c">' + livestats + '</td><td width=22 class="'+row_class+'">' + compare_part + '</td><td width=24 class="' + row_class+'">' + odds_part + '</td><td width=20 class="'+row_class+' c' + my_matches_chk_bg + '">' + my_matches_chk + '</td></tr>';
			} else {
				html_live_body += '<tr height="20" class="' + row_class + '"><td width="20" class="' + row_class + ' c">' + goal_img + flag + '</td><td class="'+row_class+' c br" title="' + finished_matches[mc][21] + '">' + finished_matches[mc][11] + '</td><td valign="top">'+home_last_inc_html +'</td><td class="'+row_class+' r pr">'+ finished_matches[mc][9] + '</td><td class="score">' + current_score + '</td><td class="'+row_class+' pl">'+ away_last_inc_html + finished_matches[mc][10] + '</td><td>' + '' + '</td><td class="htscore '+row_class+'">'+ finished_matches[mc][16] + '</a></td><td width=22 class="'+row_class+' c">' + tour_info + '</td><td width=22 class="'+row_class+' c">' + livestats + '</td><td width=22 class="'+row_class+' c">' + compare_part + '</td><td width=24 class="'+row_class+' c">' + odds_part + '</td><td width=20 class="'+row_class+' c' + my_matches_chk_bg + '">' + my_matches_chk + '</td></tr>';
			}
			tour_id = finished_matches[mc][2];
			if(finished_matches[mc][31]){
				context = finished_matches[mc][31].split("#");
				last_incident_row[lir] = new Array(context[1], context[0], context[2], temp_home_name, temp_away_name, current_score, finished_matches[mc][8]);
				lir++;
			}
		}
	}
	html_live_body += '</table>';
	no_game_selected = true;
	if(only_live_matches == "1" && html_live_body == '<table width="100%" border="0" cellspacing="0" cellpadding="0"></table>'){
		document.getElementById("live_container").innerHTML = "<CENTER><h1>" + word_no_live_match_string + "</h1></CENTER>";	
	} else if(match_mode == 'my_matches' && html_live_body == '<table width="100%" border="0" cellspacing="0" cellpadding="0"></table>'){
		no_game_selected = false;
	} else {
		document.getElementById("live_container").innerHTML = html_live_body;	
	}
	if(g_date == to_day){
		var livescore_content = '<table width="100%" cellspacing="0" cellpadding="1" border="0" id="livescore">';
		if(last_incident_row.length > 0){
			last_incident_row.sort();
			last_incident_row.reverse();
			var temp_last_incident_row = new Array();
			for (var lcv=0;lcv <  last_incident_row.length; lcv++){
				if(last_incident_row[lcv][1] != "y" && last_incident_row[lcv][1] != "y2" && last_incident_row[lcv][1] != "r" && temp_last_incident_row.length == 0){
					temp_last_incident_row = last_incident_row[lcv];
				}
				if(last_incident_row[lcv][2] == "H"){
					livescore_content += "<tr><td><img src='img/v1/cards/" + last_incident_row[lcv][1]+".gif' border='0'></td><td class='l b'><font color='#ff0000'>" + last_incident_row[lcv][3] + "</font></td><td nowrap class='b'>" + last_incident_row[lcv][5] + "</td><td class='b pr r'>" + last_incident_row[lcv][4] + "</td></tr>";
				} else {
					livescore_content += "<tr><td><img src='img/v1/cards/" + last_incident_row[lcv][1]+".gif' border='0'></td><td class='l b'>" + last_incident_row[lcv][3] + "</td><td nowrap class='b'>" + last_incident_row[lcv][5] + "</td><td class='b pr r'><font color='#ff0000'>" + last_incident_row[lcv][4] + "</font></td></tr>";			
				}
				if(lcv > 6){
					break;
				}
			}
			if(temp_last_incident_row.length > 0){
				if(temp_last_incident_row[2] == "H"){
					document.getElementById("titleBar3").innerHTML = "<table width='100%' border='0'><tr><td width='4%'><img src='img/v1/cards/" + temp_last_incident_row[1] + ".gif' border='0'></td><td width='40%'><font color=#ff0000>" + temp_last_incident_row[3] + "</font></td><td width='12%' align='center'>" + temp_last_incident_row[5] + "</td><td align='right' width='40%'>" + temp_last_incident_row[4] + "</td><td align='right' width='4%'>&nbsp;</td></table>";
				} else {
					document.getElementById("titleBar3").innerHTML = "<table width='100%' border='0'><tr><td width='4%'>&nbsp;</td><td width='40%'>" + temp_last_incident_row[3] + "</td><td width='12%' align='center'>" + temp_last_incident_row[5] + "</td><td align='right' width='40%'><font color=#ff0000>" + temp_last_incident_row[4] + "</font></td><td align='right' width='4%'><img src='img/v1/cards/" + temp_last_incident_row[1]+".gif' border='0'></td></table>";		
				}
			} else {
				document.getElementById("titleBar3").innerHTML = "";
			}
			temp_last_incident_row = null;
		} else {
			document.getElementById("titleBar3").innerHTML = "";
		}
		livescore_content += '<tr><td colspan=5 id="titleBar" style="cursor:move;text-align:center;" onmouseover="isHot=true" onmouseout="isHot=false">' + word_click_here_to_drag_box + '</td></tr></table>';
		document.getElementById("titleBardata").innerHTML = livescore_content;
		livescore_content = null;
	}
	if(check_timestamp == "1"){
		document.getElementById("scoreFlash").innerHTML = '<marquee scrolldelay="150" style="padding:3px;" id="live_ticker" onmouseover="this.stop()" onmouseout="this.start()">' + ticker_content + '</marquee>';
		document.getElementById("live_ticker").start();
	}
	tour_id = null;
	tour_display = null;
	temp_main_matches = null;
	chk_last_goal = null;
	ticker_counter = null;
	content = null;
	main_counter = null;
	main_matches = null;
	finished_matches = null;
	finished_counter = null;
	last_goal_row = null;
	last_incident_row = null;
	lir = null;
	gtm_cnt = null;
	html_live_body = null;
	if(!no_game_selected){
		alert(word_no_game_selected);
	}
	my_matches_chk_bg = null;
	chk_tour_bg = null;
}
function hide_goal_icon(matchid, incid){
	if(document.getElementById("i_" + matchid)){
		document.getElementById("i_" + matchid).style.display = "none";
		if(!in_array(matchid, hidden_goals, true)){
			hidden_goals[hidden_goals.length] = matchid;
		}
	}
	if(document.getElementById("z_" + incid)){
		document.getElementById("z_" + incid).style.display = "none";
		if(!in_array(incid, hidden_incidents, true)){
			hidden_incidents[hidden_incidents.length] = incid;
		}
	}
}