var xmlHttp
var divall;
var lastmessage="";
function showSubCategory(str,divid)
{
divall=divid;
if(divall==1)
{
var f=rem();
}
if(divall==1)
{
	            var len=document.getElementById("subcat2").options.length;
				for(var i=1;i<len;)
                  {
				  document.getElementById("subcat2").options[i] = null;
				  i=1;
				 len--;
                  }
}
document.getElementById("div1").style.display="block";
if (str==0)
{ 
               var len=document.getElementById("subcat2").options.length;
				for(var i=1;i<len;)
                  {
				  document.getElementById("subcat2").options[i] = null;
				  i=1;
				 len--;
                  }
				 /*var len=document.getElementById("subcat1").options.length;
				for(var i=1;i<len;)
                  {
				  document.getElementById("subcat1").options[i] = null;
				  i=1;
				 len--;
                  }*/
return false
}
xmlHttp_dup=GetXmlHttpObject()
if (xmlHttp_dup==null)
{
alert ("Browser does not support HTTP Request")
return
} 
var url="../fetch_category.php"
url=url+"?q="+str
url=url+"&subid="+divall
url=url+"&sid="+Math.random()

xmlHttp_dup.onreadystatechange=stateChanged_dup 
xmlHttp_dup.open("GET",url,true)
xmlHttp_dup.send(null)
} 
function stateChanged_dup() 
{ 

if (xmlHttp_dup.readyState==4 || xmlHttp_dup.readyState=="complete")
{
//alert(xmlHttp_dup.responseText)
document.getElementById("div"+divall).innerHTML=xmlHttp_dup.responseText
} 
}
function showSubCategory1(str,divid,level)
{
	alert('abc');
divall=divid;

if (str.length==0)
{ 
document.getElementById("div"+divall).innerHTML=""
return
}
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
} 
var url="fetch_category1.php"
url=url+"?q="+str
url=url+"&subid="+divall
url=url+"&level="+level
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 

function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
} 


function stateChanged() 
{ 

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
	//alert(xmlHttp.responseText)
document.getElementById("div"+divall).innerHTML=xmlHttp.responseText
} 
}
function rem() {
var t = document.getElementById('add');
t.parentNode.removeChild(t);
var m=makeInput();
}

function makeInput() {
	
document.getElementById('myDiv').innerHTML = '<input name="add" type="button" id="add" value="Add" onClick="addCategory1(1)" class="button1">';

}


