var url_addProductToBasket = 'addMatchupWait.php';
var ajaxObjects = new Array();





function AddMatchup()
{
	var ajaxIndex = ajaxObjects.length;
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = url_addProductToBasket;
	ajaxObjects[ajaxIndex].onCompletion = function(){ AddDone() };	// Specify function that will be executed after file has been found
	ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function		
}

function AddDone()
{
	document.getElementById("Matched").innerHTML="<center style='font-size:12px'><b>You are currently waiting in the queue</b><br>You can wait here or navigate to other pages and the top menu will notify you when your matchup has been created.<br><br><a href='QueueRemove.php' id='mlinkb'>Remove me from the queue</a></center>";
	GetWait();
}

function GetWait()
{
	var ajaxIndex = ajaxObjects.length;
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = 'getMatchupWait.php';
	ajaxObjects[ajaxIndex].onCompletion = function(){ Done(ajaxIndex) };	// Specify function that will be executed after file has been found
	ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function
}

function Done(ajaxIndex)
{
	pre=document.getElementById("numReg").value;
	var users = ajaxObjects[ajaxIndex].response.split('|');
	document.getElementById("Signed").style.display="block";
	document.getElementById("Signed").innerHTML="";
	for(i=0; i<users.length; i++)
	{
		document.getElementById("Signed").innerHTML+=users[i] + "<br>";
	}
	if(pre > 1 && (users.length == 1 || users.length == 0))
		manual();
	document.getElementById("numReg").value=users.length;
}

function StartShow()
{
	document.getElementById("Matched").style.display="none";
	document.getElementById("Signed").style.display="none";
	var msave=document.getElementById("Matched").innerHTML;
	var ssave=document.getElementById("Signed").innerHTML;
	
}
