// JavaScript Document
//If our user enters data in the username input, then we need to enable our button
function OnChangedUsername(whichfield,whichbutton)
{
	if (document.getElementById(whichfield).value == "")
		{
		document.getElementById(whichbutton).disabled = true;
		}
	else
		{
		document.getElementById(whichbutton).disabled = false;
		}
}

function OnCheckAvailability(GetField,GetValue,URL)
{
	if(window.XMLHttpRequest)
	{
	oRequest = new XMLHttpRequest();
	}
	else if(window.ActiveXObject)
	{
	oRequest = new ActiveXObject("Microsoft.XMLHTTP");
	}
	oRequest.open("POST", URL + "/a/users/_ssi/AjaxCheckUsername.asp", true);
	
	oRequest.onreadystatechange = UpdateCheckAvailability;
	
	var getField = GetField
	var getValue = document.getElementById(GetValue).value
	
	getValue = getValue.replace(' ','|')
	getValue = getValue.replace(' ','|')
	getValue = getValue.replace(' ','|')
	getValue = getValue.replace(' ','|')
	getValue = getValue.replace(' ','|')
	getValue = getValue.replace(' ','|')
	getValue = getValue.replace(' ','|')
	getValue = getValue.replace(' ','|')
	
	oRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	oRequest.send("strCmd=availability&strField=" + getField + "&strValue=" + getValue);
}

function UpdateCheckAvailability()
{
	if(oRequest.readyState == 4)
	{ 
	if(oRequest.status == 200)
	{
	var InnHTML = oRequest.responseText
	InnHTML = InnHTML.replace('*',' ')
	
	document.getElementById("Available").innerHTML = InnHTML;
	document.getElementById("CheckText").style.display = 'block';
	}
	else
	{
	document.getElementById("Available").innerHTML = "Asychronous Error";
	}
	}
}


