function requestData(xLocation,Handler,PassiveVars)
{
	checkMail = 1;
	var nResult = 0;
	if (PassiveVars == "email") {
		nResult += Email( nResult, 'email','Email' );
	}
/*	
	if (PassiveVars == "userid") {
		
		nResult += FromToChars( nResult, 'userid','Tên truy cập',6,10 );
	}
*/	
	//document.getElementById('reg_button').disabled =true
	xLocation = xLocation + document.getElementById(PassiveVars).value
	document.getElementById(PassiveVars + "_check").innerHTML = "Đang kiểm tra... vui lòng refresh nếu phải đợi quá lâu"
	
	Request=false; //Clear our fetching variable
        try {
                Request = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) 
        {
            try {
                        Request = new ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) 
            	{
                Request = false;
                }
        }
        if (!Request && typeof XMLHttpRequest!='undefined') {
                Request = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
	
/*		if(Request)
		{ */
		Request.onreadystatechange = function(){collectData(Handler,PassiveVars)}
		Request.open("GET", xLocation + '&nocache=' + Math.random(0,9999), true)
		Request.send(null)
		//}
return;		
}

function collectData(Handler,PassiveVars)
{
	if(Request.readyState == 4)
		{
		if(Request.status == 200)
			{
			eval(Handler + '(Request,PassiveVars)')
			}
		}
}

function CheckDuplicated(Request,PassiveVars)
{
	Data = Request.responseXML.documentElement
	result  = Data.getElementsByTagName('result')[0].firstChild.data
	
	if (result == "0") 
	{ // Not Duplicated

		document.getElementById(PassiveVars + "_check").innerHTML = "";
		document.getElementById(PassiveVars + "_status").value = "OK";
		if (checkMail == 1)	{
			document.getElementById('reg_button').disabled = false
		}
	} 
	else 
	{
		if (result == "2")
		{
			document.getElementById("email_check").innerHTML = ""	
			document.getElementById(PassiveVars + "_status").value = ""	
			document.getElementById('reg_button').disabled = true		
			document.getElementById("email").focus()
		}
		else
		{
			if (PassiveVars == "email") 
			{
			document.getElementById("email_check").innerHTML = "<font color=#FF0000>Email này đã được sử dụng</font>"	
			document.getElementById(PassiveVars + "_status").value = ""	
			document.getElementById('reg_button').disabled = true		
			document.getElementById("email").focus()
			} 
		}
		
	}
}

function Email( old_res, id, field_title )
{ // test
   if ( old_res==0 )
   {
      var el = document.getElementById( id );
      if ( typeof(el)=='object' && el!=null )
      {
         var re = /^[a-zA-Z0-9_\.\-]+@([a-zA-Z0-9][a-zA-Z0-9-]+\.)+[a-zA-Z]{2,4}$/;

         if (el.value.search(re) != -1 )  return 0;
         else
         {
            alert( '"'+field_title+'" không hợp lệ' );
            checkMail = 0;
            return 1;
         }
      }
   }
   return 0;
}

function refreshCapcha()
{
	document.getElementById("capchaid").innerHTML="<img src='../modules/capcha.php'>";
	return;
}
