var xmlHttp

function showUser(str)
{ 
	
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url="http://www.baiadevis.ro/ajax_select_subcategories.php"
url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.open("GET",url,true)
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.send(null)

}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 //document.getElementById("scateg").innerHTML=xmlHttp.responseText 
 	xmlDoc = xmlHttp.responseXML;
	container = document.getElementById('scateg');
	container.innerHTML = "";
	
	x = xmlDoc.getElementsByTagName("item");
	
	option = document.createElement("option");
	option.innerHTML =   'Alege ...';
	option.value  =  -1 ;
	container.appendChild(option);
	
	for(i=0;i<x.length;i++){
		
		
		option = document.createElement("option");
		option.innerHTML =   x[i].childNodes[1].firstChild.nodeValue ;
		option.value  =  x[i].childNodes[0].firstChild.nodeValue ;
		container.appendChild(option);
		 
	}
 } 
}

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;
}
