function verifyDeletePlayer(name)
{
	return confirm("Are you sure you wish to delete \"" + name + "\"");
}

function getControlName(pNum, suffix)
{
	return ("p" + pNum + suffix);
}

function getControl(controlName)
{
	return eval("document.updateRoster."+controlName);
}

function updateSPP(pNum)
{
	startSPPElem = document.getElementById(getControlName(pNum,"stspp"));
	startSPP = parseInt(startSPPElem.innerHTML);	
	
	finalSPP = startSPP;
	
	cmpCtrl = getControl(getControlName(pNum, "CMP"));
	cmpVal = cmpCtrl.options[cmpCtrl.selectedIndex].value;
	
	finalSPP += (1 * cmpVal);
	
	casCtrl = getControl(getControlName(pNum, "CAS"));
	casVal = casCtrl.options[casCtrl.selectedIndex].value;
	
	finalSPP += (2 * casVal);
	
	intCtrl = getControl(getControlName(pNum, "INT"));
	intVal = intCtrl.options[intCtrl.selectedIndex].value;
	
	finalSPP += (2 * intVal);
	
	tdCtrl = getControl(getControlName(pNum, "TD"));
	tdVal = tdCtrl.options[tdCtrl.selectedIndex].value;
	
	finalSPP += (3 * tdVal);
	
	mvpCtrl = getControl(getControlName(pNum, "MVP"));
	mvpVal = mvpCtrl.options[mvpCtrl.selectedIndex].value;
	
	finalSPP += (5 * mvpVal);
	
	endSPPElem = document.getElementById(getControlName(pNum,"enspp"));
	endSPPElem.innerHTML = finalSPP;
}

function checkPasswords()
{
	p1 = document.coachEdit.p1.value;
	p2 = document.coachEdit.p2.value;
	
	if(p1 != p2)
	{
		alert("Passwords do not match.\nPlease correct or clear the fields.");
		return false;
	}
	
	if(p1.length < 6)
	{
		alert("Password must be at least 6 characters in length.\nPlease correct or clear the fields.");
		return false;
	}
	
	return true;
}

var globalXmlHttp;
function getXmlHttp()
{
	var xmlHttp;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	return xmlHttp;
}

function ajax_loadTeamsAgainst()
{
	globalXmlHttp = getXmlHttp();
	globalXmlHttp.onreadystatechange=function()
	{
		if(globalXmlHttp.readyState==4)
		{
			text = globalXmlHttp.responseText;
		
			//alert(text);	
			// Get the data from the server's response
			elem = document.getElementById("teamAgainst");
			elem.innerHTML = text;
		}
	}

	elem = document.getElementById("teamFor");
	elemAll = document.getElementById("allTeams");
	url="opponentTeams.php?id="+elem.value+"&all="+elemAll.checked;
	//alert(url);
	globalXmlHttp.open("GET",url,true);
	globalXmlHttp.send(null);
} 