var ckeck_url = "http://"+ window.location.hostname +"/includes/check_username.php?user_name=";
var http = getHTTPObject();

function updateName() { 
  	var name = document.getElementById("username").value; 
	if(name.length > 2) {
  		document.getElementById('uncn').style.display = 'block';
		document.getElementById('uncn').innerHTML = "<img src='http://"+ window.location.hostname +"/images/loading.gif' alt='wird geladen' />"; 
	  http = null;
      http = getHTTPObject();
	  http.open("GET", ckeck_url + escape(name), true); 
	  http.onreadystatechange = handleHttpResponse; 
	  http.send(null); 
	}
} 

function handleHttpResponse() { 
  if (http.readyState == 4) { 
    results = http.responseText; 
    var name = document.getElementById("username").value; 
    if(results == "") results = "Username <i>"+name+"</i> nicht vorhanden..."; 
    // the div in which the message appears 
    document.getElementById('uncn').innerHTML = results; 
  } 
} 

function getHTTPObject() { 
  var xmlhttp; 
  /*@cc_on 
  @if (@_jscript_version >= 5) 
    try { 
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
    } catch (e) { 
      try { 
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
      } catch (E) { 
        xmlhttp = false; 
      } 
    } 
  @else 
  xmlhttp = false; 
  @end @*/ 
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { 
    try { 
      xmlhttp = new XMLHttpRequest(); 
    } catch (e) { 
      xmlhttp = false; 
    } 
  } 
  return xmlhttp; 
} 