
// *************************************************************************************
// 	Name:						ajaxValidation.js
// 	Description:		Ajax code to check real time Validation of a field.
// 	Author:					Edward Bates
// 	Created Date:		21/11/2007
// 	Dependancies:		/AJAX.asp
// 	Revision History:
// 
// 	Date	    Revised By		    Description
// 	----------------------------------------------------------------------------------
// 
// 
// **************************************************************************************


//If our user enters data in the username input, then we need to enable our button
function OnChangedUsername(formName,strUsername){
	if(document.forms[formName].elements[strValue].value == ""){
		document.forms[formName].btnCheckAvailability.disabled = true;
	}
	else{
		document.forms[formName].btnCheckAvailability.disabled = false;
	}
}

function OnCheckValidation(formName,strValue,strCmd, strValue2){

	if(window.XMLHttpRequest){
		oRequest = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){
		oRequest = new ActiveXObject("Microsoft.XMLHTTP");
	}

	oRequest.open("POST", "/AJAX.asp", true);
	oRequest.onreadystatechange = function UpdateCheckAvailability(){
																	if(oRequest.readyState == 4){ 
																		if(oRequest.status == 200){
																			document.getElementById(strCmd).innerHTML = oRequest.responseText;
																		}
																		else{
																			document.getElementById(strCmd).innerHTML = "Asychronous Error";
																		}
																	}
																}

	oRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	if(strValue2 == ""){
		oRequest.send("strCmd="+strCmd+"&strValue=" + document.forms[formName].elements[strValue].value);
	}
	else{	
		oRequest.send("strCmd="+strCmd+"&strValue=" + document.forms[formName].elements[strValue].value+"&strValue2=" + document.forms[formName].elements[strValue2].value);
	}
}



