var xmlHttp

function chk_avail_new()
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	//frm_signup
	var str = document.getElementById('login_username').value;
	var url="../ajax_user/chk_avail_new_php.php";	
	url=url+"?name="+str;
	url=url+"&sid="+Math.random();
	//alert(url);
	xmlHttp.onreadystatechange=stateChanged2;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}


function stateChanged2() 
{ 
	if (xmlHttp.readyState==4)
	{
		//alert(xmlHttp.responseText);
		if(xmlHttp.responseText == 'yes')
		{
			document.getElementById('not_available').style.display = 'none';
			document.getElementById('available').style.display = 'block';
		}
		else
		{
			document.getElementById('available').style.display = 'none';
			document.getElementById('not_available').style.display = 'block';
		}
		document.getElementById('user_loading').style.display = "none";
	}
	else
	{
		document.getElementById('user_loading').style.display = "block";
	}
}

function chk_avail_new_company()
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	//frm_signup
	var str = document.getElementById('txtcompany').value;
	var url="../ajax_user/chk_avail_new_php.php";	
	url=url+"?name_company="+str;
	url=url+"&sid="+Math.random();
	//alert(url);
	xmlHttp.onreadystatechange=stateChangedCopmany;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChangedCopmany() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		//alert(xmlHttp.responseText);
		if(xmlHttp.responseText == 'yes')
		{
			document.getElementById('not_available_company').style.display = 'none';
			document.getElementById('available_company').style.display = 'block';
		}
		else
		{
			document.getElementById('available_company').style.display = 'none';
			document.getElementById('not_available_company').style.display = 'block';
		}
		document.getElementById('company_loading').style.display = "none";
	}
	else
	{
		document.getElementById('company_loading').style.display = "block";
	}
}

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;
}
