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;
}
function check_n()
{
    //alert(xmlHttp.responseText)
    if ( xmlHttp.responseText == 0 )
    {
        
        if(document.getElementById) 
        {
            document.getElementById('error').style.display = 'none';
            document.getElementById('username').style.border = '';
        }
    }
    else
    {
        if(document.getElementById) 
        {
            document.getElementById('error').style.display = '';
            document.getElementById('error').style.background = 'red';
            document.getElementById('error').style.color = '#FFFFFF';
            var string = '';
            if( document.getElementById('sid').value == 'lt') string = 'Toks vartotojo vardas jau yra mūsų sistemoje. Įveskite kitą.';
            if( document.getElementById('sid').value == 'en') string = 'This Username in use. Please enter another Username.';
            if( document.getElementById('sid').value == 'ru') string = 'Это Имя пользователя в использовании. Пожалуйста введите другое Имя пользователя';
            document.getElementById('error').innerHTML = string;
            document.getElementById('username').style.border = '1px solid red';
            document.getElementById('username').focus();
            document.getElementById('username').value = '';
        }
    }
}
function check_name(id,oldname)
{
    xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	//alert(oldname);
	var url="ajax.php?act=check_name&name=" + document.getElementById(id).value + "&oldname=" + oldname + "&sid=" + Math.random();
	xmlHttp.onreadystatechange=check_n;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

