﻿var XMLHttp;

function CreateXMLHttp() {
    try {
        XMLHttp = new XMLHttpRequest();
    }
    catch (e) {
        try {
            XMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e) {
            try {
                XMLHttp = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e) {
                return false;
            }
        }
    }
}

function HandleResponse() {
    if (XMLHttp.readyState == 4) {
        if (XMLHttp.status == 200) {
        	document.getElementById("ctl00_cphCollegeMaster_status").innerHTML = XMLHttp.responseText;
            if (XMLHttp.responseText != "") {
                document.getElementById('Loading').style.visibility = 'hidden';
            }
        }
        else {
            alert("Unable to get the data from the server. Readystate: " +
          XMLHttp.readyState + " Status: " + XMLHttp.status);

        }
    }
}

function ajaxGetValue() {


	var clientValue = document.getElementById('ctl00_cphCollegeMaster_txtUserName');

	document.getElementById("ctl00_cphCollegeMaster_status").innerHTML = ' ';
	document.getElementById('Loading').style.visibility = 'visible';

	if (clientValue.value.length < 1) {
		document.getElementById('Loading').style.visibility = 'hidden';
	}
	
    if (clientValue.value.length >= 6) {
        var requestUrl = "UserName.aspx?UserName=" + clientValue.value;

        CreateXMLHttp();

        if (XMLHttp) {
            XMLHttp.onreadystatechange = HandleResponse;
            XMLHttp.open("POST", requestUrl, true);
            XMLHttp.send(null);

    }
    else { document.getElementById('Loading').style.visibility = 'hidden'; }

    
    }
}

