	var timerRessource = null;
	var WAIT_TIME = 400;
	
	
		var strRecentSearch = '';
		var http = null;
		
function check_nick( objEvent, blnUpdate )
	{
	
	var val = document.getElementById( "nick" ).value.replace(/[^a-z\d_-]+/ig, '');
     document.getElementById( "nick" ).value = val; 
     
	
		if( !blnUpdate )
		{
			// monitor key strokes 
			if( timerRessource )
				window.clearTimeout( timerRessource );
			timerRessource = window.setTimeout( "check_nick( null, true )", WAIT_TIME );
		}
		// input has finished, send request 
		else
		{
			// check, if keyword has changed
			var strKeyword = document.getElementById( "nick" ).value;
			if( strKeyword == strRecentSearch )
				return;
			
			strRecentSearch = strKeyword;
			
			okay = false;
			
if (strKeyword.length >= 3) {
  okay = true;
 }else {
 document.getElementById( "nick" ).style.border = "solid red 1px";
 document.getElementById( "chat_error" ).innerHTML = "<br />Mind. 3 Zeichen";
 }
			
			
			if(okay){
				
				http = null;
				if (window.XMLHttpRequest) {
				   http = new XMLHttpRequest();
				} else if (window.ActiveXObject) {
				   http = new ActiveXObject("Microsoft.XMLHTTP");
				}
				if (http != null) {
				   var jetzt = new Date();
	  			   var tmp_id = jetzt.getSeconds();
				   http.open("GET", "/xml/nick_status.html?"+tmp_id+"&nick=" + strKeyword, true);
				   http.onreadystatechange = ausgeben;
				   http.send(null);
				}
			}
		}
	}
	
	function ausgeben() {
			   if (http.readyState == 4) {
			      re = http.responseText;
			      if(re == 1){
			      	document.getElementById( "nick" ).style.border = "solid red 1px";
			      	 document.getElementById( "chat_error" ).innerHTML = "<br />Nickname schon vorhanden";
			      }else if(re == 2){
			      	document.getElementById( "nick" ).style.border = "solid red 1px";
			      	 document.getElementById( "chat_error" ).innerHTML = "<br />unseriöser Nickname";
			      }else{
			      	document.getElementById( "nick" ).style.border = "solid black 1px";
			      	 document.getElementById( "chat_error" ).innerHTML = "";
			      }
			   }
			}