function mostrar_2(obj, esp){
	if(obj.value=="ME" || obj.value=="VE") {
		verEspecialidades(obj, 'usu_codespecialidad', esp);
	} else {
		limpiarCombo('usu_codespecialidad');
		mostrarCapa('selespecialidad', 'none');
	}
}

function mostrar(){
	var opc=document.getElementById("esUsted").selectedIndex;

	//No mostramos el texto de error.
	validar_consulta();

	switch(opc) {
		  //Sin opcioón
		case 0:
				for(var i=1;i<=2;i++) {
					var element=document.getElementById("prof_sanit"+i);
					element.style.display="none";
				}
				mostrarCapa('empresa', 'block');
				mostrarCapa('selespecialidad', 'none');
				document.getElementById("usu_codperfil").selectedIndex=0;
				for(var i=1;i<=6;i++) {  
					var element=document.getElementById("obligatorio"+i);
					element.style.display="none";
				}
				break;
		 //Professional Sanitario
		case 1:
		        for(var i=1;i<=2;i++) {
					var element=document.getElementById("prof_sanit"+i);
					element.style.display="block";
				}				
				mostrarCapa('empresa', 'none');
				mostrarCapa('selespecialidad', 'none');
				for(var i=1;i<=6;i++) {  //Marco con asterisco los campos que son obligatorios
					var element=document.getElementById("obligatorio"+i);
					element.style.display="inline";
				}
				break;
		  //Empresa
		case 2:
				for(var i=1;i<=2;i++) {
					var element=document.getElementById("prof_sanit"+i);
					element.style.display="none";
				}				
				mostrarCapa('empresa', 'block');
				mostrarCapa('selespecialidad', 'none');
				document.getElementById("usu_codperfil").selectedIndex=0;
				for(var i=1;i<=6;i++) {
					var element=document.getElementById("obligatorio"+i);
					element.style.display="inline";
				}
				break;
		 //Particular
		case 3:
			   for(var i=1;i<=2;i++) {
					var element=document.getElementById("prof_sanit"+i);
					element.style.display="none";
				}				
				mostrarCapa('empresa', 'none');
				mostrarCapa('selespecialidad', 'none');
				document.getElementById("usu_codperfil").selectedIndex=0;
				for(var i=1;i<=6;i++) {
					var element=document.getElementById("obligatorio"+i);
					element.style.display="none";
				}
				break;
		}
}

function validar_consulta(){
	var opc=document.getElementById("esUsted").selectedIndex;
	var id=document.getElementById("tipoConsulta").selectedIndex;
	
	if(id==2 || id==3 || id==4) {
		if(opc==3 || opc==2) document.getElementById("error").style.display="block";
		else document.getElementById("error").style.display="none";
	} else document.getElementById("error").style.display="none";
}

function cargarProvincias(boxPais, boxProv, prov){
	var pais=getSeleccionado(boxPais)

	limpiarCombo(boxProv);
	if (pais != "0")  {
		cargarBox(boxProv, 'op=prv&pais='+pais);
		if (document.getElementById(boxProv).options.length>1){
			seleccionarCombo(boxProv, prov);
		}
	}

	actualizarSeleccionadoCSS(boxProv);	
}

function obtenerTextosContacto(){
	obtenerTextosCombos();

	Elements.txt_eres.value=Elements.esUsted.options[Elements.esUsted.selectedIndex].text;
	if (Elements.usu_codperfil.selectedIndex!="0") {
		Elements.txt_perfil.value=Elements.usu_codperfil.options[Elements.usu_codperfil.selectedIndex].text;
	}
 	Elements.txt_consulta.value=Elements.tipoConsulta.options[Elements.tipoConsulta.selectedIndex].text;
}

function cargarDatos(eres, provincia, especialidad){
	document.getElementById("esUsted").selectedIndex=eres;
	mostrar();
	actualizarSeleccionadoCSS('esUsted');

	if (provincia) cargarProvincias('usu_codpais', 'usu_codprovestado', provincia);
	if (especialidad) mostrar_2(document.getElementById('usu_codperfil'), especialidad);
}


