function get_xmlhttp(){
	try{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}catch(e){
		try{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}catch(E){
			xmlhttp = false;
		}
	}
	
	if(!xmlhttp && typeof XMLHttpRequest!='undefined'){
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp
}

function enviar(xmlhttp,metodo,url,async,callback,vars){
	xmlhttp.open(metodo, url,async);
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4){
			callback(xmlhttp)
		}
	}
	if(metodo == 'POST')
	{
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xmlhttp.send(vars);
	}else{
		xmlhttp.send(null);
	}
}

function submenu(mod,id,code) {
	var uid = new Date();
	
	xmlhttp=get_xmlhttp()	
	enviar(xmlhttp,"GET","includes/submenu.php?id="+encodeURIComponent(id)+"&mod="+encodeURIComponent(mod)+"&code="+encodeURIComponent(code)+"&uid="+uid,true,getSubMenu,'');
}
function getSubMenu(xmlhttp) {
	val=""
	for(i in xmlhttp) {
		try {
			val+="xmlhttp."+i+"="+xmlhttp[i]+"\n"
		} catch(e) {}
	}
	if(xmlhttp.status==404) {
		alert("Page not found.")
	}	
	document.getElementById('menutopsubitems').innerHTML = xmlhttp.responseText;
}

function cerrarPopup(pid)
   {
      document.getElementById(pid).style.visibility = 'hidden';      
   }

function abrirPopup(pid)
   {
  	  var subpid = pid.substring(0,pid.length-1);
	  for (i=1;i<10;i++){
		  //document.getElementById(subpid + i).style.visibility = 'hidden';
		if (document.getElementById(subpid + i) != null)
		{
			document.getElementById(subpid + i).style.visibility = 'hidden';
		}		  
	  }
      document.getElementById(pid).style.visibility = 'visible';      
   }


