
var xmlhttp=false;

function getAjexObject(){
  try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
  try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
  try { return new XMLHttpRequest(); } catch(e) {}
  alert("XMLHttpRequest not supported");
  return null;
}

if (!xmlhttp ){//&& typeof XMLHttpRequest!='undefined') {
  xmlhttp = getAjexObject();//new XMLHttpRequest();
}

function showBrand(str)
{
	//hideMenu("brand");
	/*if (document.getElementById("spnBrand_"+str).innerHTML!="")
	{
		document.getElementById("spnBrand_"+str).innerHTML=""
		return
	}*/
	hideMenu("brand");
	var url="lib/ajxMenuPhpFunc.php"
	
try{

	param="&section_id="+str
	xmlhttp.open("POST",url,false)
	xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlhttp.send("call=getBrand"+param + '&date=' + Date())
	document.getElementById("spnBrand_"+str).innerHTML=xmlhttp.responseText
}catch(e){}
}

function showCategory(str,section_id)
{
	//hideMenu("category");
	if (document.getElementById("spnCat_"+str).innerHTML!="")
	{
		document.getElementById("spnCat_"+str).innerHTML=""
		return
	}
	hideMenu("category");
	var url="lib/ajxMenuPhpFunc.php"

	param="&brand_id="+str+"&section_id="+section_id
	xmlhttp.open("POST",url,false)
	xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlhttp.send("call=getCategory"+param)
	document.getElementById("spnCat_"+str).innerHTML=xmlhttp.responseText
}


function showSubcategory(str)
{
	//hideMenu("subcategory");
	if (document.getElementById("spnSubcat_"+str).innerHTML!="")
	{
		document.getElementById("spnSubcat_"+str).innerHTML=""
		return
	}
	hideMenu("subcategory");
	var url="lib/ajxMenuPhpFunc.php"

	param="&category_id="+str
	xmlhttp.open("POST",url,false)
	xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlhttp.send("call=getSubcategory"+param)
	document.getElementById("spnSubcat_"+str).innerHTML=xmlhttp.responseText
}

function hideMenu(str)
{
	var e=document.getElementsByTagName("span");

	switch(str)
	{
		case "brand":
		{
			for(var i=0;i<e.length;i++)
			{
				if(e[i].id.indexOf("spnBrand_")!=-1)
					e[i].innerHTML = ""
			}
			break
		}
		case "category":
		{
			for(var i=0;i<e.length;i++)
			{
				if(e[i].id.indexOf("spnCat_")!=-1)
					e[i].innerHTML = ""
			}
			break
		}
		case "subcategory":
		{
			for(var i=0;i<e.length;i++)
			{
				if(e[i].id.indexOf("spnSubcat_")!=-1)
				e[i].innerHTML = ""
			}
			break
		}
	}
}

