function nuevoAjax(){ 
	var xmlhttp=false; 
	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 abrirMenu(id,idioma){
	var ap=nuevoAjax();
	ap.open("GET", "ajax/especialidades.php?idioma=" + idioma+"&idEspecialidad="+id, true);
	ap.onreadystatechange=function(){ 
		if (ap.readyState==4){ 
			document.getElementById('derecha').innerHTML = ap.responseText;
		} 
	}
	ap.send(null);
}

function cargarMenu(cual,idioma){
	var menu=nuevoAjax();
	menu.open("GET", "include/menu.php?pagina="+cual+"&idioma="+idioma, true);
	menu.onreadystatechange=function(){ 
		if (menu.readyState==4){ 
			document.getElementById('menu').innerHTML = menu.responseText;
		} 
	}
	menu.send(null);
}


function cargarApartado(cual,idioma){
	cargarMenu(cual,idioma)

	var ap=nuevoAjax();
	ap.open("GET", "ajax/" + cual.toLowerCase() + ".php?idioma=" + idioma, true);
	ap.onreadystatechange=function(){ 
		if (ap.readyState==4){ 
			document.getElementById('derecha').innerHTML = ap.responseText;
			sendToActionScript(cual);
		} 
	}
	ap.send(null);
}

var listadoEspecialistas = new Array();

function addEspecialista(id){
	listadoEspecialistas.push(id);
}

function desplegarProfesional(id){
	if (document.getElementById('especialista_' + id).style.display == "none" || document.getElementById('especialista_' + id).style.display == "") {
		cerrarTodosLosEspecialistas();
		document.getElementById('especialista_' + id).style.display = "block";
		document.getElementById('persona_'+id).innerHTML = str_replace("+","-",document.getElementById('persona_'+id).innerHTML);
		document.getElementById('persona_'+id).className = "personaSeleccionada";
	}else{
		document.getElementById('especialista_' + id).style.display = "none";
		document.getElementById('persona_'+id).innerHTML = str_replace("-","+",document.getElementById('persona_'+id).innerHTML);
		document.getElementById('persona_'+id).className = "persona";
	}
}

function cerrarTodosLosEspecialistas(){
	for(x=0;x<listadoEspecialistas.length;x++){
		document.getElementById('especialista_' + listadoEspecialistas[x]).style.display = "none";
		document.getElementById('persona_'+listadoEspecialistas[x]).innerHTML = str_replace("-","+",document.getElementById('persona_'+listadoEspecialistas[x]).innerHTML);
		document.getElementById('persona_'+listadoEspecialistas[x]).className = "persona";
	}
}

function str_replace(busca, repla, orig){
	str 	= new String(orig);

	//rExp	= "/"+busca+"/g";
	//rExp	= eval(rExp);
	newS	= String(repla);

	str = new String(str.replace(busca, newS));

	return str;
}

