var xmlHttp
function checkUserName()
{ 
xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
    alert ("Browser does not support HTTP Request")
    return
    }
    
var n=document.getElementById("user").value;
var url="https://theboaterswave.com/check_user_name.php"

url=url+"?n="+n
url=url+"&sid="+Math.random() 
xmlHttp.open("GET",url,true)
xmlHttp.onreadystatechange=stateChanged
xmlHttp.send(null)
}

function stateChanged() 
{ 
    if (xmlHttp.readyState==4 && xmlHttp.status== 200){   

    /*Works with IE and Firefox */
    var parentElement = document.getElementById("userStatus");  
    var wrappingDiv = document.createElement('div');
    wrappingDiv.innerHTML = xmlHttp.responseText;
    parentElement.appendChild(wrappingDiv);
    var oldDiv = document.getElementsByTagName("div")[5];
    oldDiv.parentNode.replaceChild(wrappingDiv, oldDiv);
     
     /*Works with Firefox and IE 8 only
     document.getElementById("userStatus").innerHTML=xmlHttp.responseText; */
    }
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

