var isMSIE = window.navigator.userAgent.indexOf("MSIE") >= 1;
var nDialog = null;
function n(t,e)
{
	var posX = 693;
	var posY = 17 * t.parentNode.parentNode.rowIndex + 17;
	parent.popFrame.location.replace(
		'/LiveScore.do?state=promptTennisInfo&mid=' +
		t.parentNode.parentNode.id + '&x=' + posX + '&y=' + posY);
}

// Checks if the passed in row is a game row or not.
// a game row should have an a id with the match id.
function isGameRow(row)
{
	return row.id != '' && row.id != 'finished' && row.id != 'live' &&
		row.id != 'gameRow';
}

function showTournament(sport, tid)
{
	parent.parent.contentMenuFrame.changeTables(2);
	parent.window.location.replace(
		"/LiveScore.do?state=eventFS&newState=promptTennisTournament&sport=" + sport + "&tid=" + tid);
}

function init(day, city, time, isViewByTournament, sport, h, timeZone, server)
{
	// update the tabFrame with the day, city name and time
	parent.tabFrame.updateTab(day, city, time);
	
	var table = document.getElementById("scoreTable");
	var row;
	var i;
	for(i = 1; i < table.rows.length; i++)
	{
		row = table.rows[i];
		if(isGameRow(row))
		{
			if(row.cells[1].innerHTML == 'Post')
				row.cells[0].innerHTML='(' + table.rows[i].cells[0].innerHTML + ')';
			else
				row.cells[0].innerHTML='<b>' + table.rows[i].cells[0].innerHTML + '</b>';
			row.cells[12].innerHTML = "<b>" + row.cells[12].innerHTML + "</b>";
		}
	 }
	 // set if it is view by tournament
	 parent.tabFrame.globalViewByTournament = isViewByTournament;
	
	// only use the update for livescore
	if(parent.tabFrame.globalUpdateTool.length == 0)
	{
		// initialize the client update
		clientUpdateSport = sport;
		clientUpdateHistory = h;
		clientUpdateTimeZone = timeZone;
		
		setInterval("clientUpdate('" + server + "')", 60000);
	}
}

function showLayer(html)
{
	var s = document.getElementById('p');
	s.innerHTML = html;
	s.style.visibility = '';
}

var clientUpdateSport;
var clientUpdateHistory;
var clientUpdateTimeZone;

function clientUpdate(server)
{
//	parent.updateFrame.location.replace('/LiveScoreData.do?state=clientUpdate' +
//		'&s=' + clientUpdateSport + '&h=' + clientUpdateHistory +
//		'&tz=' + clientUpdateTimeZone);
	parent.updateFrame.location.replace('http://' + server +
		'/updateHistory/UpdateHistory?state=clientUpdate' +
		'&s=' + clientUpdateSport + '&h=' + clientUpdateHistory +
		'&tz=' + clientUpdateTimeZone);
}
