// start tmnt_display js
function savescore(id, tid)
{ 
 var score=document.getElementById("score_"+id).value; 
 score=parseInt(score);
 if (score=="")
 {
 score="0";
 }
 document.getElementById("cmpt_"+id).innerHTML=score; 
 document.getElementById("cmpt_"+id).style.color = 'red';
 updatescore(id, score, tid);
}
var xmlHttp;
function updatescore(id, score, tid)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp===null)
 {
 alert ("Browser does not support HTTP Request");
 return;
 }
var url="ajax_competitions.php";
url=url+"?do=updatescore";
url=url+"&id="+id;
url=url+"&score="+score;
url=url+"&tid="+tid;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged; 
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
var xmlHttp;

function showUser(str)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp===null)
 {
 alert ("Browser does not support HTTP Request");
 return;
 }
var url="ajax_competitions.php";
url=url+"?do=getuserid";
url=url+"&username="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.vbform.userid.value=xmlHttp.responseText; 
 } 
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}
// end tmnt_display js

// start load more js
var xmlHttp

function loadmore_ladder(tab, lid, offset, team, round, group)
{
	var more = document.getElementById(tab+'_more_'+offset);
	more.style.display = 'none';
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="ajax_competitions.php"
	url=url+"?do=getmore"
	url=url+"&type="+tab
	url=url+"&lid="+lid
	url=url+"&offset="+offset
	url=url+"&team="+team
	url=url+"&round="+round
	url=url+"&group="+group
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		var table = document.getElementById('table_matches');
		table.innerHTML += xmlHttp.responseText;
	}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}
// end load more js

function toggle_cmpt(id, imgid, force)
{
	var e = document.getElementById(id);
	var f = document.getElementById(imgid);
	if(e.style.display == 'block' && force != 'block')
	{
		e.style.display = 'none';
		f.style.maxWidth='25px';
		f.style.maxHeight='25px';
	}
	else
	{
		e.style.display = 'block';
		f.style.maxWidth='100px';
		f.style.maxHeight='100px';
	}
}
function cmpt_img(id, f)
{
	var d = document.getElementById('more_'+id);
	var e = document.getElementById('img_'+id);
	if (f == 'bigger')
	{
		e.style.maxWidth='100px';
		e.style.maxHeight='100px';
	}
	else if (d.style.display != 'block')
	{
		e.style.maxWidth='25px';
		e.style.maxHeight='25px';
	}
}
function img_size(g, f)
{
	if (f == 'bigger')
	{
		g.style.maxWidth='100px';
		g.style.maxHeight='100px';
	}
	else
	{
		g.style.maxWidth='25px';
		g.style.maxHeight='25px';
	}
}
function switch_t_l(id)
{
	if (id == 'l')
	{
		oid = 't';
		oidt = 'lg';
		var l = 'block';
		var lg = 'none';
		var t = 'none';
	}
	else if (id == 't')
	{
		var oid = 'l';
		var oidt = 'lg';
		var l = 'none';
		var lg = 'none';
		var t = 'block';
	}
	else if (id == 'lg')
	{
		var oid = 'l';
		var oidt = 't';
		var l = 'none';
		var lg = 'block';
		var t = 'none';
	}
	var a = document.getElementById('table_l');
	if (a != null)
	{
		a.style.display = l;
	}
	var aa = document.getElementById('h2_'+oid);
	if (aa != null)
	{
		aa.style.textDecoration = 'none';
		aa.style.fontWeight = 'normal';
	}
	var b = document.getElementById('table_t');
	if (b != null)
	{
		b.style.display = t;
	}
	var bb = document.getElementById('h2_'+id);
	if (bb != null)
	{
		bb.style.textDecoration = 'underline';
		bb.style.fontWeight = 'bold';
	}
	var c = document.getElementById('table_lg');
	if (c != null)
	{
		c.style.display = lg;
	}
	var cc = document.getElementById('h2_'+oidt);
	if (cc != null)
	{
		cc.style.textDecoration = 'none';
		cc.style.fontWeight = 'normal';
	}
}
function switch_tc_mc(id)
{
	if (id == 'mc')
	{
		oid = 'tc';
		var mc = 'block';
		var tc = 'none';
	}
	else if (id == 'tc')
	{
		var oid = 'mc';
		var mc = 'none';
		var tc = 'block';
	}
	var a = document.getElementById('table_mc');
	if (a != null)
	{
		a.style.display = mc;
	}
	var aa = document.getElementById('h2_'+oid);
	if (aa != null)
	{
		aa.style.textDecoration = 'none';
		aa.style.fontWeight = 'normal';
	}
	var b = document.getElementById('table_tc');
	if (b != null)
	{
		b.style.display = tc;
	}
	var bb = document.getElementById('h2_'+id);
	if (bb != null)
	{
		bb.style.textDecoration = 'underline';
		bb.style.fontWeight = 'bold';
	}
}
function switch_rg_ug(id)
{
	if (id == 'rg')
	{
		oid = 'ug';
		var rg = 'table';
		var ug = 'none';
	}
	else if (id == 'ug')
	{
		var oid = 'rg';
		var rg = 'none';
		var ug = 'table';
	}
	var a = document.getElementById('table_rg');
	if (a != null)
	{
		a.style.display = rg;
	}
	var aa = document.getElementById('h2_'+oid);
	if (aa != null)
	{
		aa.style.textDecoration = 'none';
		aa.style.fontWeight = 'normal';
	}
	var b = document.getElementById('table_ug');
	if (b != null)
	{
		b.style.display = ug;
	}
	var bb = document.getElementById('h2_'+id);
	if (bb != null)
	{
		bb.style.textDecoration = 'underline';
		bb.style.fontWeight = 'bold';
	}
	return false;
}
function switch_sh(id)
{
	var i=0;
	while (i<=7)
	{
		i++;
		var a = document.getElementById('sh_'+i);
		if (a != null)
		{
			a.style.display = 'none';
		}
		var aa = document.getElementById('l_sh_'+i);
		if (aa != null)
		{
			aa.style.textDecoration = 'none';
			aa.style.fontWeight = 'normal';
		}
	}
	var e = document.getElementById(id);
	if (e != null)
	{
		e.style.display = 'block';
	}
	var ee = document.getElementById('l_'+id);
	if (ee != null)
	{
		ee.style.textDecoration = 'underline';
		ee.style.fontWeight = 'bold';
	}
	return false;
}
function show_hide(id, shdo)
{
	var e = document.getElementById(id);
	if(shdo == 'hide' && e)
	{
		e.style.display = 'none';
	}
	else if (e)
	{
		e.style.display = 'block';
	}
}
function toggle_visibility(id)
{
	var e = document.getElementById(id);
	if (e.style.display == 'block')
	{
		e.style.display = 'none';
	}
	else
	{
		e.style.display = 'block';
	}
}
function toggle_tabletr(id)
{
	var e = document.getElementById(id);
	if (e.style.display == 'table-row')
	{
		e.style.display = 'none';
	}
	else
	{
		e.style.display = 'table-row';
	}
}
function joins(A)
{
	return openWindow("competitions.php?"+SESSIONURL+"do=viewteamjoins&id="+A,260,300);
}
function wins(A)
{
	return openWindow("competitions.php?"+SESSIONURL+"do=viewteamwins&id="+A,260,300);
}
function progress(id, userid, username, round, slot, userid2, slot2, round2) 
{
	var idd = 'bracket_' + round + '_slot' + slot;
	if (round2 == '')
	{
		round2 = round;
	}
	if (document.getElementById(idd))
	{
	document.getElementById(idd).innerHTML = '<font color="red">' + username + "</font>";
	}
	if (confirm("Are you sure you want to progress '" + username + "' to next round?")) {
		window.location.href = 'tournaments.php?do=progress&id=' + id + '&userid=' + userid + '&round=' + round + '&slot=' + slot + '&userid2=' + userid2 + '&slot2=' + slot2 + '&round2=' + round2;
	}
	else
	{
		document.getElementById('bracket_' + round + '_slot' + slot).innerHTML = " &nbsp; &nbsp; &nbsp; ";
	}
}
function regress(id, userid, username, round) 
{
	var answer = confirm("Are you sure you want to regress '" + username + "' to previous round?");
	
	if (answer)
	{
		window.location.href = 'tournaments.php?do=progress&id=' + id + '&userid=' + userid + '&round=' + round + '&slot=0';
	}
	else
	{
	}
}
function progressfinish(id, userid, username, round, slot) 
{
	if (confirm("Are you sure you want to progress '" + username + "' to next round?")) {
		window.location.href = 'tournaments.php?do=progressfinish&id=' + id + '&userid=' + userid + '&round=' + round + '&slot=' + slot;
	}
}
function showhide(value, divid)
{
	if (value=="1") {
		document.getElementById(divid).style.display="";
	}
	if (value=="0")
	{
		document.getElementById(divid).style.display="none";
	}
}

function editscore(id, tid)
{ 
 var score=document.getElementById("cmpt_"+id).innerHTML;
 score=parseInt(score);
if (score=="")
 {
 score="0";
 }
 document.getElementById("cmpt_"+id).innerHTML='<input type="text" class="textbox numeric" size="3" value="'+score+'" id="score_'+id+'" onblur="savescore('+id+', '+tid+')" />';
}
