var numero = 0; //Esta es una variable de control para mantener nombres
            //diferentes de cada campo creado dinamicamente.

//Variables del Menu Leyenda ubicado en caso clinico
var menu1=new Array()
menu1[2]='<td align="center" valign="top">'
menu1[3]='<table width="400px" border="1" cellpadding="1" cellspacing="1">'
menu1[4]='<tr align="center" bgcolor="#ffffff">'
menu1[5]='<td class="style2" align="right"><strong>En proceso:&nbsp;</strong></td>'
menu1[6]='<td class="style2" align="left">Caso que el m&eacute;dico Consultante envi&oacute; solicitud de 2da opini&oacute;n m&eacute;dica y el especialista a&uacute;n no ha respondido</td>'
menu1[7]='</tr>'
menu1[8]='<tr  align="center" bgcolor="#ffffff">'
menu1[9]='<td class="style2" align="right"><strong>Respondidos:&nbsp;</strong></td>'
menu1[10]='<td class="style2" align="left">Caso enviado por M&eacute;dico Consultante al cual ya se le dio segunda opini&oacute;n m&eacute;dica por el especialista</td>'
menu1[11]='</tr>'
menu1[12]='<tr align="center" bgcolor="#ffffff">'
menu1[13]='<td class="style2" align="right"><strong>Cerrados:&nbsp;</strong></td>'
menu1[14]='<td class="style2" align="left">Caso que el M&eacute;dico Consultante envi&oacute;, le fue respondido, ya el M&eacute;dico Consultante ley&oacute; la respuesta de 2da opini&oacute;n m&eacute;dico y la cerr&oacute;</td>'
menu1[15]='</tr>'
menu1[16]='</table>'

var menu2=new Array()
menu2[2]='<td align="center" valign="top">'
menu2[3]='<table width="212px" border="1" cellpadding="1" cellspacing="1">'
menu2[4]='<tr align="center" bgcolor="#ffffff">'
menu2[6]='<td class="style2" align="left">Coloque un nombre o palabra con la cual acceder\u00e1 al sistema</td>'
menu2[7]='</tr>'
menu2[8]='</table>'

//Variables del Menu Municipios
var municipios_1=new Array("Seleccione...","Libertador")
var municipios_2=new Array("Seleccione...","Municipio Aut\u00f3nomo Alto Orinoco","Municipio Aut\u00f3nomo Atabapo","Municipio Aut\u00f3nomo Atures","Municipio Aut\u00f3nomo Autana","Municipio Aut\u00f3nomo Maroa","Municipio Aut\u00f3nomo Manapiare","Municipio Aut\u00f3nomo R\u00edo Negro")
var municipios_3=new Array("Seleccione...","Anaco","Aragua","Fernando de Pe\u00f1alver","Francisco del Carmen Carvajal","Francisco de Miranda","Guanta","Independencia","Juan Antonio Sotillo","Juan Manuel Cajigal","Jos\u00e9 Gregorio Monagas","Libertad","Manuel Ezequiel Bruzual","Pedro Mar\u00eda Freites","P\u00edritu","San Jos\u00e9 de Guanipa","San Juan de Capistrano","Santa Ana","Sim\u00f3n Bol\u00edvar","Sim\u00f3n Rodr\u00edguez","Sir Arthur Mc Gregor","Municipio Tur\u00edstico Diego Bautista Urbaneja")
var municipios_4=new Array("Seleccione...","Achaguas","Biruaca","Mu\u00f1oz","P\u00e1ez","Pedro Camejo","R\u00f3mulo Gallegos","San Fernando")
var municipios_5=new Array("Seleccione...","Bol\u00edvar","Camatagua","Girardot","Jos\u00e9 Angel Lamas","Jos\u00e9 F\u00e9lix Ribas","Jos\u00e9 Rafael Revenga","Libertador","Mario Brice\u00f1o Iragorry","San Casimiro","San Sebasti\u00e1n","Santiago Mari\u00f1o","Santos Michelena","Sucre","Tovar","Urdaneta","Zamora","Francisco Linares Alc\u00e1ntara","Ocumare de La Costa de Oro")
var municipios_6=new Array("Seleccione...","Alberto Arvelo Torrealba","Antonio Jos\u00e9 de Sucre","Arismendi","Barinas","Bol\u00edvar","Cruz Paredes","Ezequiel Zamora","Obispos","Pedraza","Rojas","Sosa","Andr\u00e9s Eloy Blanco","Jos\u00e9 Antonio P\u00e1ez")
var municipios_7=new Array("Seleccione...","Caron\u00ed","Cede\u00f1o","El Callao","Gran Sabana","Heres","Ra\u00fal Leoni","Roscio","Sifontes","Sucre","Padre Pedro Chien")
var municipios_8=new Array("Seleccione...","Bejuma","Carlos Arvelo","Diego Ibarra","Guacara","Libertador","Los Guayos","Miranda","Naguanagua","Puerto Cabello","San Diego","San Joaqu\u00edn","Valencia","Miguel Pe\u00f1a")
var municipios_9=new Array("Seleccione...","Anzo\u00e1tegui","Falc\u00f3n","Girardot","Lima Blanco","Pao de San Juan Bautista","Ricaurte","R\u00f3mulo Gallegos","San Carlos","Tinaco")
var municipios_10=new Array("Seleccione...","Antonio D\u00edaz","Casacoima","Pedernales","Tucupita")
var municipios_11=new Array("Seleccione...","Acosta","Bol\u00edvar","Cacique Manaure","Carirubana","Dabajuro","Democracia","Federaci\u00f3n","Los Taques","Mauroa","Miranda","Monse\u00f1or Iturriza","Palmasola","Petit","P\u00edritu","San Francisco","Silva","Sucre","Toc\u00f3pero","Uni\u00f3n","Urumaco","Zamora")
var municipios_12=new Array("Seleccione...","Camagu\u00e1n","Chaguaramas","El Socorro","San Ger\u00f3nimo de Guayabal","Leonardo Infante","Las Mercedes","Juli\u00e1n Mellado","Francisco de Miranda","Jos\u00e9 Tadeo Monagas","Ortiz","Jos\u00e9 F\u00e9lix Ribas","Juan Germ\u00e1n Roscio","San Jos\u00e9 de Guaribe","Santa Mar\u00eda de Ipire","Pedro Zaraza")
var municipios_13=new Array("Seleccione...","Andr\u00e9s Eloy Blanco","Crespo","Jim\u00e9nez","Mor\u00e1n","Palavecino","Sim\u00f3n Planas","Torres","Urdaneta")
var municipios_14=new Array("Seleccione...","Alberto Adriani","Andr\u00e9s Bello","Antonio Pinto Salinas","Aricagua","Campo El\u00edas","Caracciolo Parra Olmedo","Cardenal Quintero","Guaraque","Julio C\u00e9sar Salas","Justo Brice\u00f1o","Libertador","Miranda","Obispo Ramos de Lora","Padre Noguera","Pueblo Llano","Rangel","Rivas D\u00e1vila","Santos Marquina","Sucre","Tovar","Tulio Febres Cordero","Zea")
var municipios_15=new Array("Seleccione...","Acevedo","Andr\u00e9s Bello","Baruta","Bri\u00f3n","Buroz ","Carrizal","Chacao","Crist\u00f3bal Rojas","El Hatillo","Guaicaipuro","Independencia","Lander","Los Salias","P\u00e1ez","Paz Castillo","Pedro Gual","Plaza","Sim\u00f3n Bol\u00edvar","Sucre","Urdaneta","Zamora")
var municipios_16=new Array("Seleccione...","Acosta","Aguasay","Bol\u00edvar","Caripe","Cede\u00f1o","Ezequiel Zamora","Libertador","Matur\u00edn","Piar","Punceres","Santa B\u00e1rbara","Sotillo","Uracoa")
var municipios_17=new Array("Seleccione...","Antol\u00edn del Campo","Arismendi","D\u00edaz","Garc\u00eda","G\u00f3mez","Maneiro","Marcano","Mari\u00f1o","Pen\u00ednsula de Macanao","Tubores","Villalba")
var municipios_18=new Array("Seleccione...","Agua Blanca","Araure","Esteller","Guanare","Guanarito","Monse\u00f1or Jos\u00e9 Vicente de Unda","Ospino","P\u00e1ez","Papel\u00f3n","San Genaro de Boconoito","San Rafael de Onoto","Santa Rosal\u00eda","Tur\u00e9n")
var municipios_19=new Array("Seleccione...","Andr\u00e9s Eloy Blanco","Andr\u00e9s Mata","Arismendi","Ben\u00edtez","Berm\u00fadez","Bol\u00edvar","Cruz Salmer\u00f3n Acosta","Libertador","Mari\u00f1o","Mej\u00eda","Montes","Ribero","Sucre","Valdez")
var municipios_20=new Array("Seleccione...","Andr\u00e9s Bello","Antonio R\u00f3mulo Costa","Ayacucho","C\u00e1rdenas","C\u00f3rdoba","Fern\u00e1ndez Feo","Francisco de Miranda","Garc\u00eda de Hevia","Gu\u00e1simos","Independencia","J\u00e1uregui","Jos\u00e9 Mar\u00eda Vargas","Jun\u00edn","Libertad","Libertador","Lobatera","Michelena","Panamericano","Pedro Mar\u00eda Ure\u00f1a","Rafael Urdaneta","Samuel Dar\u00edo Maldonado","San Crist\u00f3bal","Seboruco","Sim\u00f3n Rodr\u00edguez","Sucre","Torbes ","Uribante","San Judas Tadeo")
var municipios_21=new Array("Seleccione...","Andr\u00e9s Bello","Bocon\u00f3","Bol\u00edvar","Candelaria","Carache","Escuque","Jos\u00e9 Felipe M\u00e1rquez Ca\u00f1izales","Juan Vicente Campo El\u00edas","La Ceiba","Miranda","Monte Carmelo","Motat\u00e1n","Pamp\u00e1n","Pampanito","Rafael Rangel","San Rafael de Carvajal","Sucre","Trujillo","Urdaneta","Valera")
var municipios_22=new Array("Seleccione...","Ar\u00edstides Bastidas","Bol\u00edvar","Bruzual","Cocorote","Independencia","Jos\u00e9 Antonio P\u00e1ez","La Trinidad","Manuel Monge","Nirgua","Pe\u00f1a","San Felipe","Sucre","Urachiche","Veroes")
var municipios_23=new Array("Seleccione...","Almirante Padilla","Baralt","Cabimas","Catatumbo","Col\u00f3n","Francisco Javier Pulgar","Jes\u00fas Enrique Lossada","Jes\u00fas Mar\u00eda Sempr\u00fan","La Ca\u00f1ada de Urdaneta","Lagunillas","Machiques de Perij\u00e1","Mara","Maracaibo","Miranda","P\u00e1ez","Rosario de Perij\u00e1","San Francisco","Santa Rita","Sim\u00f3n Bol\u00edvar","Sucre","Valmore Rodr\u00edguez")
var municipios_24=new Array("Seleccione...","Vargas")

//Variables del menu hover en caso clinico
var menuwidth='80px' //Width del menu
var menubgcolor='#FFFFFF'  //Menu Backgroundcolor
var disappeardelay=25  //Tiempo para desaparecer
var hidemenu_onclick="yes" //Esconder menu fuera del click
var ie4=document.all
var ns6=document.getElementById&&!document.all

//Obtener Fecha Actual
var today = new Date();
var day   = today.getDate();
var month = today.getMonth();
var year  = today.getYear();

evento = function (evt) { //esta funcion nos devuelve el tipo de evento disparado
   return (!evt) ? event : evt;
}
addCampo = function (motivoSOM) {
	//alert(motivoSOM);
	if(motivoSOM!=null){
		document.getElementById('motivoSOM').value =  motivoSOM ;
	}
   //document.formaArchivoNueva.motivoSOM.value=motivoSOM;
   //alert(document.formaArchivoNueva.motivoSOM.value);
//Creamos un nuevo div para que contenga el nuevo campo
   nDiv = document.createElement('div');
//con esto se establece la clase de la div
   nDiv.className = 'archivo';
//este es el id de la div, aqui la utilidad de la variable numero
//nos permite darle un id unico
   nDiv.id = 'file' + (++numero);
//creamos el input para el formulario:
   nCampo = document.createElement('input');
//le damos un nombre, es importante que lo nombren como vector, pues todos los campos
//compartiran el nombre en un arreglo, asi es mas facil procesar posteriormente con php
   nCampo.name = 'file'+numero;
//Establecemos el tipo de campo
   nCampo.type = 'file';

   nCampo.setAttribute("value","");
//Establecemos la funcion para cargar el archivo onChange()
	nCampo.setAttribute("onChange","CargarImagen('formaArchivoNueva')");
//Ahora creamos un link para poder eliminar un campo que ya no deseemos
   a = document.createElement('a');
//El link debe tener el mismo nombre de la div padre, para efectos de localizarla y eliminarla
   a.name = nDiv.id;
//Este link no debe ir a ningun lado
   a.href = '#';
//Establecemos que dispare esta funcion en click
   a.onclick = elimCamp;
//Con esto ponemos el texto del link
   a.innerHTML = 'Eliminar';
//Bien es el momento de integrar lo que hemos creado al documento,
//primero usamos la funci�n appendChild para adicionar el campo file nuevo
   nDiv.appendChild(nCampo);
//Adicionamos el Link
   nDiv.appendChild(a);
//Ahora si recuerdan, en el html hay una div cuyo id es 'adjuntos', bien
//con esta funci�n obtenemos una referencia a ella para usar de nuevo appendChild
//y adicionar la div que hemos creado, la cual contiene el campo file con su link de eliminaci�n:
   container = document.getElementById('adjuntos');
   container.appendChild(nDiv);
}

/*addEnlaceOtraCirugia= function()
{
	 nDiv = document.createElement('div');
	 nDiv.className = 'otraCirugia';
	 nDiv.id = 'otraCirugia';
	 tr1=document.createElement("TR");
	 td1=document.createElement("TD");

	 a = document.createElement('a');
	 a.name = nDiv.id;
   	 a.href = '#';
     a.onclick = addCirugia;
   	 a.innerHTML = 'Agregar otra cirug�a';

     td1.appendChild(a);
     tr1.appendChild(td1);
	 nDiv.appendChild(tr1);

	 container = document.getElementById('otraCirugia');
     container.appendChild(nDiv);


}
*/

addCirugia = function () {

	tabla = document.createElement('table');
	tbody = document.createElement('tbody');
    nDiv = document.createElement('div');

   nDiv.className = 'cirugia';
//este es el id de la div, aqui la utilidad de la variable numero
//nos permite darle un id unico
   nDiv.id = 'cirugia' + (++numero);

	//alert(numero+"numerooooo");
	if ( numero==1)
	{
		var tr1=document.createElement("TR");
		var tr2=document.createElement("TR");
		var tr3=document.createElement("TR");
		var tr4=document.createElement("TR");
		var tr5=document.createElement("TR");
		var tr6=document.createElement("TR");
		var td1=document.createElement("TD");
		var td2=document.createElement("TD");
		var td3=document.createElement("TD");
		var td4=document.createElement("TD");
		var td1t=document.createElement("TD");
		var td2t=document.createElement("TD");
		var td3t=document.createElement("TD");
		var td4t=document.createElement("TD");
		var td5=document.createElement("TD");
		var td5t=document.createElement("TD");
		var td6=document.createElement("TD");
		var td7=document.createElement("TD");


		textC=document.createTextNode("Cirug\u00eda");
		textD=document.createTextNode("Descripc\u00f3n:");
		textF=document.createTextNode("Fecha de Cirug\u00eda:");
		textM=document.createTextNode("M\u00e9dico Tratante:");
		textP=document.createTextNode("Patolog\u00eda:");
		textE=document.createTextNode("");

		nCampo1 = document.createElement('textarea');
		nCampo2 = document.createElement('input');
		nCampo3 = document.createElement('input');
		nCampo4 = document.createElement('input');
		nCampo5 = document.createElement('input');

	   nCampo1.name = 'descripcion'+numero;
	   nCampo2.name = 'fecha_c'+numero;
	   nCampo3.name = 'medico_t'+numero;
	   nCampo4.name = 'patologia'+numero;
	   nCampo5.name = 'n_cirugia';

	//Establecemos el tipo de campo
	   nCampo1.setAttribute("cols","20");
	   nCampo1.setAttribute("rows","2");
	   nCampo2.setAttribute("size","25");
	   nCampo3.setAttribute("size","25");
	   nCampo4.setAttribute("size","25");

	   nCampo2.type = 'text';
	   nCampo3.type = 'text';
	   nCampo4.type = 'text';
	   nCampo5.type = 'hidden';
	   nCampo5.setAttribute("value",numero);

	   // se agregan los atributos y elementos a los td de la izquierda
	   td1.appendChild(textD);
	   td1.setAttribute("valign","top");
	   td1.setAttribute("class","Style2");
	   td1.setAttribute("align","right");
	   td2.appendChild(textF);
	   td2.setAttribute("class","Style2");
	   td2.setAttribute("align","right");
	   td3.appendChild(textM);
	   td3.setAttribute("class","Style2");
	   td3.setAttribute("align","right");
	   td4.appendChild(textP);
	   td4.setAttribute("class","Style2");
	   td4.setAttribute("align","right");
	   td5.appendChild(textC);
	   td5.setAttribute("class","stylenegrita");
	   td5.setAttribute("align","left");

	   td6.appendChild(textE);
	   td6.setAttribute("class","Style2");
	   td6.setAttribute("align","center");
	   td6.setAttribute("colspan","2");

	   // Se agregan los atrbutos y elementos a los td de la derecha
	   td1t.appendChild(nCampo1);
	   td1t.setAttribute("align","left");
	   td2t.appendChild(nCampo2);
	   td2t.setAttribute("align","left");
	   td3t.appendChild(nCampo3);
	   td3t.setAttribute("align","left");
	   td4t.appendChild(nCampo4);
	   td4t.setAttribute("align","left");
	   td5t.appendChild(nCampo5);
	   td5t.setAttribute("align","left");

	   // se agregan los tds a los respectivos tr
		tr1.appendChild(td1);
		tr1.appendChild(td1t);
		tr2.appendChild(td2);
		tr2.appendChild(td2t);
		tr3.appendChild(td3);
		tr3.appendChild(td3t);
		tr4.appendChild(td4);
		tr4.appendChild(td4t);
		tr5.appendChild(td5);
		tr5.appendChild(td5t);

	//Ahora creamos un link para poder eliminar un campo que ya no deseemos
	   a = document.createElement('a');
	//El link debe tener el mismo nombre de la div padre, para efectos de localizarla y eliminarla
	   a.name = nDiv.id;
	//Este link no debe ir a ningun lado
	   a.href = '#';
	//Establecemos que dispare esta funcion en click
	   a.onclick = elimCamp;
	//Con esto ponemos el texto del link
	   a.innerHTML = 'Eliminar';




	   // Se agrega la etiqueta de eliminar
	   td6.appendChild(a);
	   tr6.appendChild(td6);

	//Bien es el momento de integrar lo que hemos creado al documento,
	//primero usamos la funci�n appendChild para adicionar el campo file nuevo
	   nDiv.appendChild(tr5);
	   nDiv.appendChild(tr4);
	   nDiv.appendChild(tr2);
	   nDiv.appendChild(tr3);
	   nDiv.appendChild(tr1);


	//Adicionamos el Link
	   //nDiv.appendChild(a);
	   nDiv.appendChild(tr6);
	   eval("document.getElementById('nro_cirugia').value='"+numero+"'");
	//Ahora si recuerdan, en el html hay una div cuyo id es 'adjuntos', bien
	//con esta funci�n obtenemos una referencia a ella para usar de nuevo appendChild
	//y adicionar la div que hemos creado, la cual contiene el campo file con su link de eliminaci�n:
		tbody.appendChild(nDiv);
		tabla.appendChild(tbody);
		document.getElementById('tdagregar').innerHTML = 'Agregar otra Cirug&iacute;a';

	   container = document.getElementById('cirugia');
	   container.appendChild(tabla);

	  // addEnlaceOtraCirugia();
	}
	if (numero > 1)
	{
		tr1=document.createElement("TR");
		tr2=document.createElement("TR");
		tr3=document.createElement("TR");
		tr4=document.createElement("TR");
		tr5=document.createElement("TR");
		tr6=document.createElement("TR");
		td1=document.createElement("TD");
		td2=document.createElement("TD");
		td3=document.createElement("TD");
		td4=document.createElement("TD");
		td1t=document.createElement("TD");
		td2t=document.createElement("TD");
		td3t=document.createElement("TD");
		td4t=document.createElement("TD");
		td5=document.createElement("TD");
		td5t=document.createElement("TD");
		td6=document.createElement("TD");
		td7=document.createElement("TD");


		textC=document.createTextNode("Cirug\u00eda");
		textD=document.createTextNode("Descripci\u00f3n:");
		textF=document.createTextNode("Fecha de Cirug\u00eda:");
		textM=document.createTextNode("M\u00e9dico Tratante:");
		textP=document.createTextNode("Patolog\u00eda:");
		textE=document.createTextNode("");

		nCampo1 = document.createElement('textarea');
		nCampo2 = document.createElement('input');
		nCampo3 = document.createElement('input');
		nCampo4 = document.createElement('input');
		nCampo5 = document.createElement('input');

	   nCampo1.name = 'descripcion'+numero;
	   nCampo2.name = 'fecha_c'+numero;
	   nCampo3.name = 'medico_t'+numero;
	   nCampo4.name = 'patologia'+numero;
	   nCampo5.name = 'n_cirugia';

	//Establecemos el tipo de campo
	   nCampo1.setAttribute("cols","20");
	   nCampo1.setAttribute("rows","2");

	   nCampo2.type = 'text';
	   nCampo3.type = 'text';
	   nCampo4.type = 'text';
	   nCampo5.type = 'hidden';
	   nCampo5.setAttribute("value",numero);

	   // se agregan los atributos y elementos a los td de la izquierda
	   td1.appendChild(textD);
	   td1.setAttribute("valign","top");
	   td1.setAttribute("class","Style2");
	   td1.setAttribute("align","right");
	   td2.appendChild(textF);
	   td2.setAttribute("class","Style2");
	   td2.setAttribute("align","right");
	   td3.appendChild(textM);
	   td3.setAttribute("class","Style2");
	   td3.setAttribute("align","right");
	   td4.appendChild(textP);
	   td4.setAttribute("class","Style2");
	   td4.setAttribute("align","right");
	   td5.appendChild(textC);
	   td5.setAttribute("class","stylenegrita");
	   td5.setAttribute("align","left");

	   td6.appendChild(textE);
	   td6.setAttribute("class","Style2");
	   td6.setAttribute("align","center");
	   td6.setAttribute("colspan","2");

	   // Se agregan los atrbutos y elementos a los td de la derecha
	   td1t.appendChild(nCampo1);
	   td1t.setAttribute("align","left");
	   td2t.appendChild(nCampo2);
	   td2t.setAttribute("align","left");
	   td3t.appendChild(nCampo3);
	   td3t.setAttribute("align","left");
	   td4t.appendChild(nCampo4);
	   td4t.setAttribute("align","left");
	   td5t.appendChild(nCampo5);
	   td5t.setAttribute("align","left");

	   // se agregan los tds a los respectivos tr
		tr1.appendChild(td1);
		tr1.appendChild(td1t);
		tr2.appendChild(td2);
		tr2.appendChild(td2t);
		tr3.appendChild(td3);
		tr3.appendChild(td3t);
		tr4.appendChild(td4);
		tr4.appendChild(td4t);
		tr5.appendChild(td5);
		tr5.appendChild(td5t);

	//Ahora creamos un link para poder eliminar un campo que ya no deseemos
	   a = document.createElement('a');
	//El link debe tener el mismo nombre de la div padre, para efectos de localizarla y eliminarla
	   a.name = nDiv.id;
	//Este link no debe ir a ningun lado
	   a.href = '#';
	//Establecemos que dispare esta funcion en click
	   a.onclick = elimCamp;
	//Con esto ponemos el texto del link
	   a.innerHTML = 'Eliminar';

	   // Se agrega la etiqueta de eliminar
	   td6.appendChild(a);
	   tr6.appendChild(td6);

	//Bien es el momento de integrar lo que hemos creado al documento,
	//primero usamos la funci�n appendChild para adicionar el campo file nuevo
	   nDiv.appendChild(tr5);
	   nDiv.appendChild(tr4);
	   nDiv.appendChild(tr2);
	   nDiv.appendChild(tr3);
	   nDiv.appendChild(tr1);

	//Adicionamos el Link
	   //nDiv.appendChild(a);
	   nDiv.appendChild(tr6);
	   eval("document.getElementById('nro_cirugia').value='"+numero+"'");

	//Ahora si recuerdan, en el html hay una div cuyo id es 'adjuntos', bien
	//con esta funci�n obtenemos una referencia a ella para usar de nuevo appendChild
	//y adicionar la div que hemos creado, la cual contiene el campo file con su link de eliminaci�n:
		tbody.appendChild(nDiv);
		tabla.appendChild(tbody);
		document.getElementById('tdagregar').innerHTML = 'Agregar otra Cirug&iacute;a';
	   container = document.getElementById('cirugia');
	   container.appendChild(tabla);
	}

}
//con esta funci�n eliminamos el campo cuyo link de eliminaci�n sea presionado
elimCamp = function (evt){
   evt = evento(evt);
   nCampo = rObj(evt);
   numero= numero-1;
   div = document.getElementById(nCampo.name);
   div.parentNode.removeChild(div);
    eval("document.getElementById('nro_cirugia').value='"+numero+"'");
	if(numero==0)
	{
	document.getElementById('tdagregar').innerHTML = 'Agregar';
	}

}
//con esta funci�n recuperamos una instancia del objeto que disparo el evento
rObj = function (evt) {
   return evt.srcElement ?  evt.srcElement : evt.target;
}

function activarDescripcionP(id)
	{
		if(id==1)
		{
			if(document.getElementById('pat_cardiovascular_p').checked)
			{
				document.getElementById('pat_cardiov_p').type='absolute';
			}else
			{
				document.getElementById('pat_cardiov_p').type='hidden';
			}

		}
		if(id==2)
		{
			if(document.getElementById("pat_diabetes_p").checked)
			{
				document.getElementById("pat_diabete_p").type='absolute';
			}else
			{
				document.getElementById("pat_diabete_p").type='hidden';
			}
		}
		if(id==3)
		{
			if(document.getElementById("pat_epoc_p").checked)
			{
				document.getElementById("pat_epoct_p").type='absolute';
			}else
			{
				document.getElementById("pat_epoct_p").type='hidden';
			}

		}
		if(id==4)
		{
			if(document.getElementById("pat_ginecoobstetras_p").checked)
			{
				document.getElementById("pat_ginecoobstetra_p").type='absolute';
			}else
			{
				document.getElementById("pat_ginecoobstetra_p").type='hidden';
			}
		}
		if(id==5)
		{
			if(document.getElementById("pat_infectocontagiosos_p").checked)
			{
				document.getElementById("pat_infectocontagioso_p").type='absolute';
			}else
			{
				document.getElementById("pat_infectocontagioso_p").type='hidden';
			}

		}
		if(id==6)
		{
			if(document.getElementById("pat_oncologicos_p").checked)
			{
				document.getElementById("pat_oncologico_p").type='absolute';
			}else
			{
				document.getElementById("pat_oncologico_p").type='hidden';
			}


		}
		if(id==7)
		{
			if(document.getElementById("pat_psiquiatricos_p").checked)
			{
				document.getElementById("pat_psiquiatrico_p").type='absolute';
			}else
			{
				document.getElementById("pat_psiquiatrico_p").type='hidden';
			}

		}
		if(id==8)
		{
			if(document.getElementById("pat_respiratorios_p").checked)
			{
				document.getElementById("pat_respiratorio_p").type='absolute';
			}else
			{
				document.getElementById("pat_respiratorio_p").type='hidden';
			}

		}
		if(id==9)
		{
			if(document.getElementById("pat_otros_p").checked)
			{
				document.getElementById("pat_otro_p").type='absolute';
			}else
			{
				document.getElementById("pat_otro_p").type='hidden';
			}

		}

	}

	function activarDescripcion(id)
	{
		if(id==1)
		{
			if(document.getElementById("pat_respiratorios").checked)
			{
				document.getElementById("pat_respiratorio").type='absolute';
				document.getElementById("select_respiratorio").style.display = "block";
			}else
			{
				document.getElementById("pat_respiratorio").type='hidden';
				document.getElementById("select_respiratorio").style.display = "none";
			}

		}
		if(id==2)
		{
			if(document.getElementById("pat_psiquiatricos").checked)
			{
				document.getElementById("pat_psiquiatrico").type='absolute';
				document.getElementById("select_psiquiatricos").style.display = "block";
			}else
			{
				document.getElementById("pat_psiquiatrico").type='hidden';
				document.getElementById("select_psiquiatricos").style.display = "none";
			}
		}
		if(id==3)
		{
			if(document.getElementById("pat_infectocontagiosos").checked)
			{
				document.getElementById("pat_infectocontagioso").type='absolute';
				document.getElementById("select_infectocontagiosos").style.display = "block";
			}else
			{
				document.getElementById("pat_infectocontagioso").type='hidden';
				document.getElementById("select_infectocontagiosos").style.display = "none";
			}

		}
		if(id==4)
		{
			if(document.getElementById("pat_oncologicos").checked)
			{
				document.getElementById("pat_oncologico").type='absolute';
				document.getElementById("select_oncologicos").style.display = "block";
			}else
			{
				document.getElementById("pat_oncologico").type='hidden';
				document.getElementById("select_oncologicos").style.display = "none";
			}
		}
		if(id==5)
		{
			if(document.getElementById("pat_cardiovascular").checked)
			{
				document.getElementById("pat_cardiov").type='absolute';
				document.getElementById("select_cardiovascular").style.display = "block";
			}else
			{
				document.getElementById("pat_cardiov").type='hidden';
				document.getElementById("select_cardiovascular").style.display = "none";
			}

		}
		if(id==6)
		{
			if(document.getElementById("pat_diabetes").checked)
			{
				document.getElementById("pat_diabete").type='absolute';
				document.getElementById("select_diabetes").style.display = "block";
			}else
			{
				document.getElementById("pat_diabete").type='hidden';
				document.getElementById("select_diabetes").style.display = "none";
			}


		}
		if(id==7)
		{
			if(document.getElementById("pat_otros").checked)
			{
				document.getElementById("pat_otro").type='absolute';
				document.getElementById("select_otros").style.display = "block";
			}else
			{
				document.getElementById("pat_otro").type='hidden';
				document.getElementById("select_otros").style.display = "none";
			}

		}
		if(id==8)
		{
			if(document.getElementById("pat_epoc").checked)
			{
				document.getElementById("pat_epoct").type='absolute';
				document.getElementById("select_epoc").style.display = "block";
			}else
			{
				document.getElementById("pat_epoct").type='hidden';
				document.getElementById("select_epoc").style.display = "none";
			}

		}
		if(id==9)
		{
			if(document.getElementById("pat_ginecoobstetras").checked)
			{
				document.getElementById("pat_ginecoobstetra").type='absolute';
				document.getElementById("select_ginecoobstetra").style.display = "block";
			}else
			{
				document.getElementById("pat_ginecoobstetra").type='hidden';
				document.getElementById("select_ginecoobstetra").style.display = "none";
			}

		}


	}

	function activarTiempoEvolucion(id)
	{
		if(id==1)
		{

			if(document.getElementById('adenopatias').checked)
			{
				document.getElementById('adenopatias_texto').style.display = "block";
			}else
			{
				document.getElementById('adenopatias_texto').style.display = "none";
			}

		}
		if(id==2)
		{
			if(document.getElementById("dolor_t").checked)
			{
				document.getElementById('dolor_t_texto').style.display = "block";
			}else
			{
				document.getElementById('dolor_t_texto').style.display = "none";

			}
		}
		if(id==3)
		{
			if(document.getElementById("palpitaciones").checked)
			{
				document.getElementById('palpitaciones_texto').style.display = "block";

			}else
			{
				document.getElementById('palpitaciones_texto').style.display = "none";
			}

		}
		if(id==4)
		{
			if(document.getElementById("artralgias").checked)
			{
				document.getElementById("artralgias_texto").style.display = "block";
			}else
			{
				document.getElementById("artralgias_texto").style.display = "none";
			}
		}
		if(id==5)
		{
			if(document.getElementById("escalofrios").checked)
			{
				document.getElementById("escalofrios_texto").style.display = "block";

			}else
			{
				document.getElementById("escalofrios_texto").style.display = "none";

			}

		}
		if(id==6)
		{
			if(document.getElementById("perdida_c").checked)
			{
				document.getElementById("perdida_c_texto").style.display = "block";
			}else
			{
				document.getElementById("perdida_c_texto").style.display = "none";
			}


		}
		if(id==7)
		{
			if(document.getElementById("aumento_v").checked)
			{
				document.getElementById("aumento_v_texto").style.display = "block";

			}else
			{
				document.getElementById("aumento_v_texto").style.display = "none";
			}

		}
		if(id==8)
		{
			if(document.getElementById("erupcion").checked)
			{
				document.getElementById("erupcion_texto").style.display = "block";
			}else
			{
				document.getElementById("erupcion_texto").style.display = "none";
			}

		}
		if(id==9)
		{
			if(document.getElementById("perdida_m").checked)
			{
				document.getElementById("perdida_m_texto").style.display = "block";
			}else
			{
				document.getElementById("perdida_m_texto").style.display = "none";
			}

		}
		if(id==10)
		{
			if(document.getElementById("cefalea").checked)
			{
				document.getElementById("cefalea_texto").style.display = "block";
			}else
			{
				document.getElementById("cefalea_texto").style.display = "none";
			}

		}
		if(id==11)
		{
			if(document.getElementById("fiebre").checked)
			{
				document.getElementById("fiebre_texto").style.display = "block";
			}else
			{
				document.getElementById("fiebre_texto").style.display = "none";
			}

		}
		if(id==12)
		{
			if(document.getElementById("rinorrea").checked)
			{
				document.getElementById("rinorrea_texto").style.display = "block";
			}else
			{
				document.getElementById("rinorrea_texto").style.display = "none";
			}

		}
		if(id==13)
		{
			if(document.getElementById("congestion_n").checked)
			{
				document.getElementById("congestion_texto").style.display = "block";
			}else
			{
				document.getElementById("congestion_texto").style.display = "none";
			}

		}
		if(id==14)
		{
			if(document.getElementById("lesiones_b").checked)
			{
				document.getElementById("lesiones_b_texto").style.display = "block";
			}else
			{
				document.getElementById("lesiones_b_texto").style.display = "none";
			}

		}
		if(id==15)
		{
			if(document.getElementById("sudoracion").checked)
			{
				document.getElementById("sudoracion_texto").style.display = "block";
			}else
			{
				document.getElementById("sudoracion_texto").style.display = "none";
			}

		}
		if(id==16)
		{
			if(document.getElementById("convulcion").checked)
			{
				document.getElementById("convulcion_texto").style.display = "block";
			}else
			{
				document.getElementById("convulcion_texto").style.display = "none";
			}

		}
		if(id==17)
		{
			if(document.getElementById("mareos").checked)
			{
				document.getElementById("mareos_texto").style.display = "block";
			}else
			{
				document.getElementById("mareos_texto").style.display = "none";
			}

		}
		if(id==18)
		{
			if(document.getElementById("tos").checked)
			{
				document.getElementById("tos_texto").style.display = "block";
			}else
			{
				document.getElementById("tos_texto").style.display = "none";
			}

		}
		if(id==19)
		{
			if(document.getElementById("diarrea").checked)
			{
				document.getElementById("diarrea_texto").style.display = "block";
			}else
			{
				document.getElementById("diarrea_texto").style.display = "none";
			}

		}
		if(id==20)
		{
			if(document.getElementById("mialgias").checked)
			{
				document.getElementById("mialgias_texto").style.display = "block";
			}else
			{
				document.getElementById("mialgias_texto").style.display = "none";
			}

		}
		if(id==21)
		{
			if(document.getElementById("vomitos").checked)
			{
				document.getElementById("vomitos_texto").style.display = "block";
			}else
			{
				document.getElementById("vomitos_texto").style.display = "none";
			}

		}
		if(id==22)
		{
			if(document.getElementById("disnea").checked)
			{
				document.getElementById("disnea_texto").style.display = "block";
			}else
			{
				document.getElementById("disnea_texto").style.display = "none";
			}

		}if(id==23)
		{
			if(document.getElementById("nauseas").checked)
			{
				document.getElementById("nauseas_texto").style.display = "block";
			}else
			{
				document.getElementById("nauseas_texto").style.display = "none";
			}

		}if(id==24)
		{
			if(document.getElementById("dolor_ab").checked)
			{
				document.getElementById("dolor_ab_texto").style.display = "block";
			}else
			{
				document.getElementById("dolor_ab_texto").style.display = "none";
			}

		}if(id==25)
		{
			if(document.getElementById("odinofagia").checked)
			{
				document.getElementById("odinofagia_texto").style.display = "block";
			}else
			{
				document.getElementById("odinofagia_texto").style.display = "none";
			}

		}

	}
//Funciones hover de Signo de Interrogacion de Caso Clinico (empieza aqui)

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')
document.write('<div id="dropmenudiv2" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
		while (parentEl!=null){
			totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
			parentEl=parentEl.offsetParent;
		}
return totaloffset;
}

function showhide(obj, e, visible, hidden, menuwidth){
	if (ie4||ns6)
		dropmenuobj.style.left=dropmenuobj.style.top=-500
	if (menuwidth!=""){
		dropmenuobj.widthobj=dropmenuobj.style
		dropmenuobj.widthobj.width=menuwidth
	}
	if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
		obj.visibility=visible
	else if (e.type=="click")
		obj.visibility=hidden
}

function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
	if (whichedge=="rightedge"){
		var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
		dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
	if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
		edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
	}
	else{
		var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
		dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
			if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
			edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
	}
return edgeoffset
}

function populatemenu(what){
	if (ie4||ns6)
		dropmenuobj.innerHTML=what.join("")
}

function dropdownmenu(obj, e, menucontents, menuwidth){
	if (window.event) event.cancelBubble=true
		else if (e.stopPropagation) e.stopPropagation()
		clearhidemenu()
		dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
		populatemenu(menucontents)

	if (ie4||ns6){
		showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
		dropmenuobj.x=getposOffset(obj, "left")
		dropmenuobj.y=getposOffset(obj, "top")
		dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
		dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
	}
return clickreturnvalue()
}

function dropdownmenu2(obj, e, menucontents, menuwidth){
	if (window.event) event.cancelBubble=true
		else if (e.stopPropagation) e.stopPropagation()
		clearhidemenu()
		dropmenuobj=document.getElementById? document.getElementById("dropmenudiv2") : dropmenudiv2
		populatemenu(menucontents)

	if (ie4||ns6){
		showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
		dropmenuobj.x=getposOffset(obj, "left")
		dropmenuobj.y=getposOffset(obj, "top")
		dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
		dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
	}
return clickreturnvalue()
}

function clickreturnvalue(){
	if (ie4||ns6) return false
	else return true
}

function contains_ns6(a, b){
	while (b.parentNode)
		if ((b = b.parentNode) == a)
		return true;
		return false;
}

function dynamichide(e){
	if (ie4&&!dropmenuobj.contains(e.toElement))
		delayhidemenu()
	else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
		delayhidemenu()
}

function hidemenu(e){
	if (typeof dropmenuobj!="undefined"){
		if (ie4||ns6)
		dropmenuobj.style.visibility="hidden"
	}
}

function delayhidemenu(){
	if (ie4||ns6)
		delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
	if (typeof delayhide!="undefined")
		clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
	document.onclick=hidemenu

//Funcion Hover de Signo de Interrogacion en Inicio de Clinico (termina aqui)/---------------------

//Funccion para mostrar los campos ocultos
function activar(elemento) //registroUsuarioSucces.php
{
// Validacion (Si el campo escogido fue otros, se muestra el campo "Indique su tipo de usuario")
if(elemento.tipo_usuario.options[elemento.tipo_usuario.selectedIndex].value=="7")
  {
    document.getElementById("aux").style.visibility = "visible";
    document.getElementById("aux").style.display = "";
  }
else
  {
     document.getElementById("aux").style.visibility = "hidden";
     document.getElementById("aux").style.display = "none";
  }
 // Validacion (Si el campo escogido fue especialista, muestra la lista de las especialidades disponibles)
if(elemento.tipo_usuario.options[elemento.tipo_usuario.selectedIndex].value=="4")
  {
    document.getElementById("aux2").style.visibility = "visible";
    document.getElementById("aux2").style.display = "";
  }
else
  {
     document.getElementById("aux2").style.visibility = "hidden";
     document.getElementById("aux2").style.display = "none";
  }
  if(elemento.tipo_usuario.options[elemento.tipo_usuario.selectedIndex].value=="4")
  {
    document.getElementById("aux3").style.visibility = "visible";
    document.getElementById("aux3").style.display = "";
    document.getElementById("aux4").style.visibility = "visible";
    document.getElementById("aux4").style.display = "";
    document.getElementById("aux5").style.visibility = "visible";
    document.getElementById("aux5").style.display = "";
    document.getElementById("aux6").style.visibility = "visible";
    document.getElementById("aux6").style.display = "";
  }
else
  {
     document.getElementById("aux3").style.visibility = "hidden";
     document.getElementById("aux3").style.display = "none";
     document.getElementById("aux4").style.visibility = "hidden";
     document.getElementById("aux4").style.display = "none";
     document.getElementById("aux5").style.visibility = "hidden";
     document.getElementById("aux5").style.display = "none";
     document.getElementById("aux6").style.visibility = "hidden";
     document.getElementById("aux6").style.display = "none";
  }

}

function activar2(elemento) //registroUsuarioSucces.php
{
  if(elemento.id_ambulatorio.options[elemento.id_ambulatorio.selectedIndex].value=="40")
  {
    document.getElementById("aux7").style.visibility = "visible";
    document.getElementById("aux7").style.display = "";
  }
  else
  {
     document.getElementById("aux7").style.visibility = "hidden";
     document.getElementById("aux7").style.display = "none";
  }
}

//Funcion para activar checkbox en Registro de Usuarios
function tterminos()
{
 document.getElementById("terminos").disabled= false;
}

//Funcion para activar boton de registro de usuario
function boton(obj)
{
 if(obj.checked==true){
		document.getElementById("button").disabled=false;
	}else{
		document.getElementById("button").disabled=true;
	}

}

//Funcion para mostrar los municipios
function cambia_municipio(){
    var estado
    estado = document.forma.estado[document.forma.estado.selectedIndex].value
    if (estado != 0) {
       mis_municipios=eval("municipios_" + estado)
       num_municipios = mis_municipios.length
       document.forma.municipio.length = num_municipios
       for(i=0;i<num_municipios;i++){
          document.forma.municipio.options[i].value=mis_municipios[i]
          document.forma.municipio.options[i].text=mis_municipios[i]
       }
    }else{
       document.forma.municipio.length = 1
       document.forma.municipio.options[0].value = "-"
       document.forma.municipio.options[0].text = "-"
    }
    document.forma.municipio.options[0].selected = true
}

 //Funcion que calcula la edad en base a la fecha del calendario
function Edad(){
    if (document.form.fecha_nac.value!=""){
        if (year < 1000){year += 1900;}
        //Obtener Fecha de Nacimiento
        var actual = document.form.fecha_nac.value;
        var dia = actual.substring(0,2);
        var mes = actual.substring(3,5);
        var ayo = actual.substring(6,10);
        var cont=1
        //Calculos
        if (mes<(month+1)){cont=0} //getMonth devuelve enero como mes 0 es por eso que se suma 1.

        if (mes==(month+1)){ //getMonth devuelve enero como mes 0 es por eso que se suma 1.
            if (dia<=day){cont=0;}
        }
        var edad=year-ayo-cont;
        document.form.edad.value=edad;
        }
}

//Fecha que calcula el año aproximado en el que naciste segun la edad
function Edad_2(){
    var edad = document.form.edad.value;
    if (year < 1000){year += 1900;}
    var imp = 0;
    var cont=1;
    var str="";
    if (document.form.fecha_nac.value==""){
        imp = year-edad;
        str = "01-01-"+imp;
    }else{
        var actual = document.form.fecha_nac.value;
        var dia = actual.substring(0,2);
        var mes = actual.substring(3,5);
        if (mes<(month+1)){cont=0} //getMonth devuelve enero como mes 0 es por eso que se suma 1.
        if (mes==(month+1)){ //getMonth devuelve enero como mes 0 es por eso que se suma 1.
            if (dia<=day){cont=0;}
        }
        imp = year-edad-cont;
        str = dia+"-"+mes+"-"+imp;
    }
    document.form.fecha_nac.value=str;
}
