var xmlHttp
var xmlHttp2
var tagID
var tagID2
window.onload = openCategory;

function openCategory(){

	if (window.location.hash!='' && window.location.hash!='#'){
		var id= window.location.hash.split("=")[1];
		show('getExpandedCat.php?showcat='+id+'',id);
	}
}

function show(url,id)
{ 
xmlHttp=GetXmlHttpObject()
xmlHttp2=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
//this is showPage
tagID = id;
if (url.indexOf('getRetractedCat')==-1){
var body = document.getElementById("body");
var divs = body.getElementsByTagName("div");
for (var d=0;d<divs.length;d++){		
	if (divs[d].getAttribute("class")==("prd-btn-b")){
		divs[d].innerHTML='<div align=center><br><img src="ajax-loader.gif"/></div>';
		xmlHttp2.onreadystatechange=stcclose;
		tagID2 = divs[d-1].getAttribute("id");
	//	window.location.hash='';
		xmlHttp2.open("GET",'getRetractedCat.php?maincat='+tagID2,true);
		xmlHttp2.send(null);
	}
}
}

/*if (window.location.hash==''){
	window.location.hash = 'openButton='+id;
}else if (url.indexOf('getRetractedCat')!=-1){
	window.location.hash='';
}*/
document.getElementById(id).innerHTML='<div align=center><br><img src="ajax-loader.gif"/></div>';
xmlHttp.onreadystatechange=stc;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stc() 
{ 
//alert("xml "+xmlHttp.readyState)
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 

 document.getElementById(tagID).innerHTML=xmlHttp.responseText 
 
 }
}

function stcclose() 
{ 
//alert(xmlHttp2.readyState)
if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
 { 

 document.getElementById(tagID2).innerHTML=xmlHttp2.responseText 
 
 }
}

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