var mapaModif = false;
var estadoPersistencia = -1;

function actualizarTitulo(pId, pIdSub)
{
	top.document.getElementById("cAyudaCampo").style.visibility = "hidden";
	top.document.getElementById("tituloEditor").innerHTML = "";
	top.document.getElementById("tituloEditor").innerHTML = "&nbsp;" + arrayMenuGeneral[0].id ;
	var codigo = "";
	var i;
	for (i=0;i<arrayMenuEditor.length;i++)
	{
		if (codigo != "" ) codigo += " | ";
		if (pId != i)
			codigo += '<A class="link" HREF="javascript:' + arrayMenuEditor[i].accion + '">' + arrayMenuEditor[i].id + '</A>';
		else
			codigo += '<span class="linkActivo">' + arrayMenuEditor[i].id + '</span>';		
	}
	top.document.getElementById("menuEditor").innerHTML = "";
	top.document.getElementById("menuEditor").innerHTML = codigo + "&nbsp;";
	if(pIdSub!=null)
	{
		codigo = '<table cellpadding="0" cellspacing="0" border="0" width="760" height="26">\n'
			+ '<tr>\n'
			+ '	<td colspan="2" background="img/pTrans.gif" height="10" width="1"></td>\n'
			+ '</tr>\n'
			+ '<tr class="TDSubTitulo">\n'
			+ '	<td class="TDSubTitulo" align="center">';
		for(i=0;i<arrayMenuSub.length;i++)
		{
			if (i>0) codigo += ' | ';
			if (i == pIdSub)
				codigo += '<SPAN class="linkActivo">'
					+ arrayMenuSub[i].id
					+ '</SPAN>';
			else
				codigo += '<A class="link" HREF="javascript:' + arrayMenuSub[i].accion + '">'
					+ arrayMenuSub[i].id
					+ '</A>';
		}
		codigo += '</td>\n'
			+ '</tr>\n'
			+ '<tr>\n'
			+ '	<td colspan="2" background="img/pTrans.gif" height="5" width="1"></td>\n'
			+ '</tr>\n'
			+ '</table>\n'
	}
	else
		codigo = "";
	top.document.getElementById("subCabecera").innerHTML = "";
	top.document.getElementById("subCabecera").innerHTML = codigo;
}

function cabeceraPanel(pTitulo)
{
	var codigo = '<table cellpadding="0" cellspacing="0" border="0" width="760" class="TDAreaEdicion">\n'
		+ '<tr class="TDSubTitulo">\n'
		+ '	<td colspan="3" class="TDSubTitulo" width="760" height="10"></td>\n'
		+ '</tr>\n'
		+ '<tr class="TDSubTitulo">\n'
		+ '	<td colspan="3" class="TDSubTitulo" width="760">' + pTitulo + '</td>\n'
		+ '</tr>\n'
		+ '<tr>\n'
		+ '<td bgcolor="#000000" width="760" height="1" colspan="3"></td>\n'
		+ '</tr>\n'
		+ '<tr>\n'
		+ '<td width="760" height="10" class="TDAreaEdicion" colspan="3"></td>\n'
		+ '</tr>\n';
	return codigo;
}

function botonesPanel()
{
	var i=0;
	var codigo="";
	while(i<arguments.length)
	{
		if(codigo!="") codigo += "&nbsp;";
		codigo += '<input name="button2" type="button" class="btnGen" onClick="' + arguments[i+1]+ '" value="' + arguments[i] + '"> \n'
		i = i+2;
	}
	codigo = '<tr><td width="760" class="TDAreaEdicion" colspan="3" align="center">'
		+  codigo
		+ '</td></tr>\n'
	return codigo;
}

function subTituloPanel(pTitulo)
{
	var codigo = '<tr>\n'
		+ '<td width="760" height="10" class="TDAreaEdicion" colspan="3"></td>\n'
		+ '</tr>\n'
		+ '<tr>\n'
		+ '<td width="10" height="1" class="TDAreaEdicion"></td>\n'
		+ '<td width="740" class="TDAreaEdicion">' + pTitulo + '</td>\n'
		+ '<td width="10" height="1" class="TDAreaEdicion"></td>\n'
		+ '</tr>\n'
		+ '<tr>\n'
		+ '<td width="10" height="1" class="TDAreaEdicion"></td>\n'
		+ '<td width="740" height="1" bgcolor="#000000"></td>\n'
		+ '<td width="10" height="1" class="TDAreaEdicion"></td>\n'
		+ '</tr>\n'
		+ '<tr>\n'
		+ '<td width="760" height="5" class="TDAreaEdicion" colspan="3"></td>\n'
		+ '</tr>\n'
	return codigo;
}

function piePanel()
{
	var codigo = '<tr>\n'
		+ '<td width="760" height="10" class="TDAreaEdicion" colspan="3"></td>\n'
		+ '</tr>\n'
		+ '<tr>\n'
		+ '<td bgcolor="#000000" width="760" height="1" colspan="3"></td>\n'
		+ '</tr>\n'
		+ '<tr class="TDSubTitulo">\n'
		+ '	<td colspan="3" class="TDSubTitulo" width="760" height="20"></td>\n'
		+ '</tr>\n'
		+ '</table>\n'
	return codigo;
}

function cambiarEstadoModif()
{
	top.ifMapa.mapa.modificado = true;
}

/*****************************************************************************************************/

function verEditorMapas()
{
	top.document.getElementById("ifMapa").style.height = 270;
	top.ifMapa.location = "emapa.htm";
	top.ifContenido.location = "editarAyuda.htm";
}

function cargarEditar()
{
	if (top.estadoPersistencia==1)
	{
		alert(txtMensImportando);
		return;
	}
	if (top.estadoPersistencia==2)
	{
		alert(txtMensExportando);
		return;
	}
	var continuar = true;
	if ((top.ifMapa.mapa.estado != 2) && (top.ifMapa.mapa.modificado))
		continuar = (confirm(confCancelGen))
	if (continuar)
	{
		top.ifContenido.location = "editarAyuda.htm?tipo=0";
	}
}

function verEditar()
{
	top.ocultarAyuda();
	top.ifContenido.verResultado(pETituloEd, pEAyuda);
	top.ifMapa.mapa.estado = 2;
	top.ifMapa.mapa.modificado = false;
	top.ifMapa.cargarMapa(1,-1);
	actualizarTitulo(0, -1);
}

function cargarEditarNodo(accion, pPreguntar)
{
	if ((pPreguntar==null) && (top.ifMapa.mapa.estado != 2) && (top.ifMapa.mapa.modificado))
	{
		if (!confirm(confCancelGen))
			return;
	}
	if ((accion==1) && (top.ifMapa.mapa.itemModif.tipo!="C"))
	{
		alert(pEKoModSel);
		return;
	}
	if(accion==1)
		top.ifContenido.location = "modificarNodo.htm";
	else
		top.ifContenido.location = "editarConcepto.htm";
}

function verEditarConcepto(accion, pPreguntar) //0:insertar; 1:modificar
{
	var codigo;
	var i,j;
	var encontrado;
	var posFrase, posConcepto;

	top.ifMapa.mapa.resetEdicion(accion);

	codigo = '<form name="insertar">\n'
		+ cabeceraPanel( ((accion == 0) ? pETituloIns : pETituloMod))
		+ botonesPanel(botonAceptar, ('aceptar' + ((accion == 0) ? "Ins" : "Mod") + '()'), botonCancelar, 'cancelarIns()')
		+ subTituloPanel(pESubTitulo1)
		+ '<tr>\n'
		+ '<td width="10" height="1" class="TDAreaEdicion"></td>\n'
		+ '<td width="740" class="TDAreaEdicion">\n'
		+ '	<table cellpadding="0" cellspacing="0" border="0">\n'
		+ '	<tr>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '		<td class="TDAreaEdicion">' + pENombre.texto + ':&nbsp;</td>\n'
		+ '		        <td class="TDAreaEdicion"><input type="text" class="campoTxt" name="txtNombre" size="40" value="' + ((accion == 0) ? "" : top.ifMapa.mapa.itemModif.nombre) + '" onChange="cambiarEstadoModif()">&nbsp;'
		+ '							<select class="texto" name="selNombre" onChange="cambiarNombre();cambiarEstadoModif();">\n'
		+ '							<option value="-1">' + pENombre.valorDef + '</option>\n';
	var nombreActual ="";
	for (i=0;i<top.ifMapa.mapa.nodos.contenido.length;i++)
	{
		if ((top.ifMapa.mapa.nodos.contenido[i].tipo=="C") 
				&& (nombreActual!=top.ifMapa.mapa.nodos.contenido[i].nombre))
		{
			nombreActual=top.ifMapa.mapa.nodos.contenido[i].nombre;
			codigo += '<option value="'  + top.ifMapa.mapa.nodos.contenido[i].nombre + '"';
			if ((accion == 1) && (top.ifMapa.mapa.itemModif.nombre ==	top.ifMapa.mapa.nodos.contenido[i].nombre))
				codigo += ' selected ';
			codigo += '>' + top.ifMapa.mapa.nodos.contenido[i].nombre + '</option>\n';
		}
	}
	codigo += '							</select>\n'
		+ '             <input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pEPagAyudaConcepto + '#' + pENombre.ayuda + '\')">\n'
		+ '		</td>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '	</tr>\n';
		
	
	if ((accion == 0) || ((accion==1) && (top.ifMapa.mapa.itemModif.padre!=null)))
	{
		codigo += '	<tr><td colspan="4" width="1" height="5"></td></tr>\n'
			+ '	<tr>\n'
			+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
			+ '		<td class="TDAreaEdicion">' + pEPadre.texto + ':&nbsp;</td>\n'
			+ '		<td class="TDAreaEdicion"><select class="texto" name="selPadre" onChange="cambiarFrases();cambiarEstadoModif();">';
		var sel = top.ifMapa.mapa.conceptoActual.id;
		if (accion==1) 
			sel = top.ifMapa.mapa.itemModif.padre.padre.id;
		if ((accion==0) && (top.ifMapa.mapa.itemModif.tipo == "F"))
			sel = top.ifMapa.mapa.itemModif.padre.id;
		var aux;
		for(i=0;i<top.ifMapa.mapa.nodos.contenido.length;i++)
		{
			aux = "_" + top.ifMapa.mapa.itemModif.id + "_";
			if ((top.ifMapa.mapa.nodos.contenido[i].tipo=="C") && 
					((accion==0) || ((accion==1) && (top.ifMapa.mapa.nodos.contenido[i].id!=top.ifMapa.mapa.itemModif.id)
						&& (top.ifMapa.mapa.nodos.contenido[i].antepasados.indexOf(aux)==-1) )))
			{
				codigo += '<option value="' + top.ifMapa.mapa.nodos.contenido[i].id +'"';
				if (sel == top.ifMapa.mapa.nodos.contenido[i].id)
					codigo += ' selected ';
				codigo += '>' + top.ifMapa.mapa.nodos.contenido[i].nombre;
				if (top.ifMapa.mapa.nodos.contenido[i].padre==null)
					codigo += ' [concepto raíz]' + '</option>';
				else
				{
					codigo += ' ['
						+ top.ifMapa.mapa.nodos.contenido[i].padre.padre.nombre
						+ ' -> '
						+ top.ifMapa.mapa.nodos.contenido[i].padre.nombre
						+ ']'
						+ '</option>';
				}
			}
		}
		codigo += '		</select>'
			+ '		<input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pEPagAyudaConcepto + '#' + pEPadre.ayuda + '\')">'
			+ '		</td>'
			+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
			+ '	</tr>\n'
			+ '	<tr><td colspan="4" width="1" height="5"></td></tr>\n'
			+ '	<tr>\n'
			+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
			+ '		<td class="TDAreaEdicion">' + pEFrase.texto + ':&nbsp;</td>\n'
			+ '		<td class="TDAreaEdicion">\n'
			+ '			<input type="text" class="campoTxt" name="txtFrase" size="40" onChange="cambiarEstadoModif()">\n'
			+ '			<select class="texto" name="selFrase" onChange="cambiarPosiciones();cambiarEstadoModif();"><option></option></select>\n'
			+ '<input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pEPagAyudaConcepto + '#' + pEFrase.ayuda + '\')">\n'
			+ '		</td>\n'
			+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
			+ '	</tr>\n'
			+ '	<tr><td colspan="4" width="1" height="5"></td></tr>\n'
			+ '	<tr>\n'
			+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
			+ '		<td class="TDAreaEdicion">' + pEPosFrase.texto + ':&nbsp;</td>\n'
			+ '		        <td class="TDAreaEdicion"> <select class="texto" name="selPosFrase" onChange="cambiarEstadoModif()"><option></option></select>\n'
			+ '<input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pEPagAyudaConcepto + '#' + pEPosFrase.ayuda + '\')">\n'
			+ '		</td>\n'
			+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
			+ '	</tr>\n'
			+ '	<tr><td colspan="4" width="1" height="5"></td></tr>\n'
			+ '	<tr>\n'
			+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
			+ '		<td class="TDAreaEdicion">' + pEPosConcepto.texto + ':&nbsp;</td>\n'
			+ '		        <td class="TDAreaEdicion"> <select class="texto" name="selPosConcepto" onChange="cambiarEstadoModif()"><option></option></select>\n'
			+ ' <input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pEPagAyudaConcepto + '#' + pEPosConcepto.ayuda + '\')">\n'
			+ '		</td>\n'
			+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
			+ '	</tr>\n'
			+ '	<tr><td colspan="4" width="1" height="5"></td></tr>\n'
	}
	codigo = codigo
		+ '	</table>\n'
		+ '</td>\n'
		+ '<td width="10" height="1" class="TDAreaEdicion"></td>\n'
		+ '</tr>\n'
		+ '<tr>\n'
		+ '<td width="760" height="5" class="TDAreaEdicion" colspan="3"></td>\n'
		+ '</tr>\n'
		+ subTituloPanel(pESubTitulo2)
		+ '<tr>\n'
		+ '<td width="10" height="1" class="TDAreaEdicion"></td>\n'
		+ '<td width="740" class="TDAreaEdicion">\n'
		+ '	<table width="740" cellpadding="0" cellspacing="0" border="0">\n'
		+ '	<tr>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '		<td width="363">\n'
		+ '			<table cellpadding="0" cellspacing="0" border="0">\n'
		+ '			<tr>\n'
		+ '				<td width="110" class="TDAreaEdicion">' + pENombreRec.texto + ':&nbsp;</td>\n'
		+ '				<td width="217" class="TDAreaEdicion"><input type="text" class="campoTxt" name="txtNombreRec" size="40">&nbsp;<input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pEPagAyudaConcepto + '#' + pENombreRec.ayuda + '\')"></td>\n'
		+ '			</tr>\n'
		+ '			<tr><td colspan="2" width="1" height="5"></td></tr>\n'
		+ '			<tr>\n'
		+ '				<td class="TDAreaEdicion">' + pETipRec.texto + ':&nbsp;</td>\n'
		+ '				<td class="TDAreaEdicion"><select class="campoTxt" name="selTipRec" onChange="cambiarTipoRec()">\n'
		+ '				<option value="0" selected>' + pETipRec.valores[0] + '</option>\n'
	for(i=1;i<pETipRec.valores.length;i++)
		codigo += '<option value="' + i + '">' + pETipRec.valores[i] + '</option>\n'

	codigo += '</select>\n'
		+ '				<input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pEPagAyudaConcepto + '#' + pETipRec.ayuda + '\')"></td>\n'
		+ '			</tr>\n'
		+ '			<tr><td colspan="2" width="1" height="5"></td></tr>\n'
		+ '			<tr>\n'
		+ '				<td class="TDAreaEdicion">' + pETipDirRec.texto + ':&nbsp;</td>\n'
		+ '				<td class="TDAreaEdicion"><select class="campoTxt" name="selTipDirRec" onChange="cambiarTipDirRec()"><option value="0">' + pETipDirRec.valores[0] + '</option><option value="1">' + pETipDirRec.valores[1] + '</option></select>&nbsp;<input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pEPagAyudaConcepto + '#' + pETipDirRec.ayuda + '\')"></td>\n'
		+ '			</tr>\n'
		+ '			<tr><td colspan="2" width="1" height="5"></td></tr>\n'
		+ '			<tr>\n'
		+ '				<td class="TDAreaEdicion">' + pEDirRec.texto + ':</td>\n'
		+ '				<td class="TDAreaEdicion"><input type="text" class="campoTxt" name="txtDirRec" size="40" value="http://">&nbsp;<input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pEPagAyudaConcepto + '#' + pEDirRec.ayuda + '\')"></td>\n'
		+ '			</tr>\n'
		+ '			<tr><td colspan="2" width="1" height="5"></td></tr>\n'
		+ '			<tr>\n'
		+ '				<td class="TDAreaEdicion" valign="top">' + pEDescRec.texto + ':</td>\n'
		+ '				<td class="TDAreaEdicion"><textarea name="txtDescRec" cols="40" rows="5" class="texto" style="width:190px"></textarea>&nbsp;<input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pEPagAyudaConcepto + '#' + pEDescRec.ayuda + '\')"></td>\n'
		+ '			</tr>\n'
		+ '			</table>\n'
		+ '		</td>\n'
		+ '		<td width="117" class="TDAreaEdicion">\n'
		+ '			<table cellpadding="0" cellspacing="0" border="0">\n'
		+ '				<tr><td><input type="button" class="btn" value="' + botonAnadir+ '" onClick="anadirRec();cambiarEstadoModif();" name="btnAnadirRec"></td></tr>\n'
		+ '				<tr><td width="3" height="3"></td></tr>\n'
		+ '				<tr><td><input type="button" class="btn" value="' + botonModificar + '" onClick="modificarRec();cambiarEstadoModif();" name="btnModificarRec"></td></tr>\n'
		+ '				<tr><td width="3" height="3"></td></tr>\n'
		+ '				<tr><td><input type="button" class="btn" value="' + botonEliminar + '" onClick="eliminarRec();cambiarEstadoModif();" name="btnEliminarRec"></td></tr>\n'
		+ '			</table>\n'
		+ '		</td>\n'
		+ '		<td width="250" class="TDAreaEdicion">\n'
		+ '			<table cellpadding="0" cellspacing="0" border="0">\n'
		+ '			<tr><td align="center">\n'
		+ '			<input type="button" class="btnGen" value="' + botonArriba + '" onClick="moverRec(-1);cambiarEstadoModif();" name="btnArriba"> <input type="button" class="btnGen" value="' + botonAbajo + '" onClick="moverRec(1);cambiarEstadoModif();" name="btnAbajo"> <input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pEPagAyudaConcepto + '#' + pEListaRecursos.ayuda + '\')">\n'
		+ '			</td></tr>\n'
		+ '			<tr><td width="3" height="3"></td></tr>\n'
		+ '			<tr><td>\n'
		+ '			<select class="listBoxP" size="13" name="listaRec"><option></option>\n'
		+ '			</select>\n'
		+ '			</td></tr>\n'
		+ '			</table>\n'
		+ '		</td>\n'
		+ '	</tr>\n'
		+ '	</table>\n'
		+ '</td>\n'
		+ '<td width="10" height="1" class="TDAreaEdicion"></td>\n'
		+ '</tr>\n'
		+ '<tr>\n'
		+ '<td width="760" height="15" class="TDAreaEdicion" colspan="3"></td>\n'
		+ '</tr>\n'
		+ botonesPanel(botonAceptar, ('aceptar' + ((accion == 0) ? "Ins" : "Mod") + '()'), botonCancelar, 'cancelarIns()')
		+ piePanel()
		+ '</form>\n';
	document.getElementById("contenido").innerHTML = "";
	document.getElementById("contenido").innerHTML = "<div id='cont'>"+codigo+"</div>";
	top.calcHeight();
	if (accion == 1) 
	{
		if (top.ifMapa.mapa.itemModif.padre!=null)
		{
			top.ifMapa.mapa.conceptoActual = top.ifMapa.mapa.itemModif.padre.padre;
			if(top.ifContenido.document.insertar.selFrase.selectedIndex>=0)
				top.ifContenido.document.insertar.txtFrase.value = top.ifContenido.document.insertar.selFrase.options[top.ifContenido.document.insertar.selFrase.selectedIndex].text;
		}
		restaurarListaRec();	
	}
	if ((accion==0) || (top.ifMapa.mapa.itemModif.padre!=null))
		cambiarFrases(1);
	actualizarTitulo(0, accion);
}

function cambiarNombre()
{
	var idNombre = top.ifContenido.document.insertar.selNombre.options[top.ifContenido.document.insertar.selNombre.selectedIndex].value;
	if (idNombre=="-1")
		top.ifContenido.document.insertar.txtNombre.value = "";
	else
		top.ifContenido.document.insertar.txtNombre.value = top.ifContenido.document.insertar.selNombre.options[top.ifContenido.document.insertar.selNombre.selectedIndex].value;
}

function cambiarFrases(pModo)
{
	var sel = 0;
	if (pModo==null)
	{
		var idPadre = parseInt(top.ifContenido.document.insertar.selPadre.options[top.ifContenido.document.insertar.selPadre.selectedIndex].value);
		top.ifMapa.mapa.setActualId(idPadre);
		padre = top.ifMapa.mapa.conceptoActual;
	}
	else
	{
		if ((top.ifMapa.mapa.itemModif.tipo=="F") && (top.ifMapa.mapa.estado==0))
			padre = top.ifMapa.mapa.itemModif.padre;
		if ((top.ifMapa.mapa.itemModif.tipo=="C") && (top.ifMapa.mapa.estado==0))
			padre = top.ifMapa.mapa.itemModif;
		if (top.ifMapa.mapa.estado==1)
			padre = top.ifMapa.mapa.itemModif.padre.padre;
	}
	
	if (padre!=null)
	{
		var i;
		borrarListBox(top.ifContenido.document.insertar.selFrase);
		if ((top.ifMapa.mapa.estado==0) && (top.ifMapa.mapa.itemModif.tipo=="C"))
			anadirOpt(top.ifContenido.document.insertar.selFrase, pEFrase.valorDef,"-1", true);
		else
			anadirOpt(top.ifContenido.document.insertar.selFrase, pEFrase.valorDef,"-1", false);
		for (i=0; i<padre.hijos.contenido.length;i++)
		{
			if (top.ifMapa.mapa.estado==1)
			{
				if (padre.hijos.contenido[i].id == top.ifMapa.mapa.itemModif.padre.id)
				{
					anadirOpt(top.ifContenido.document.insertar.selFrase, padre.hijos.contenido[i].nombre, padre.hijos.contenido[i].id, true);
					sel = i+1;
				}
				else
					anadirOpt(top.ifContenido.document.insertar.selFrase, padre.hijos.contenido[i].nombre, padre.hijos.contenido[i].id, false);
			}
			else
			{
				if ((top.ifMapa.mapa.itemModif.tipo=="F") && (top.ifMapa.mapa.itemModif.id==padre.hijos.contenido[i].id))
				{
					anadirOpt(top.ifContenido.document.insertar.selFrase, padre.hijos.contenido[i].nombre, padre.hijos.contenido[i].id, true);
					sel = i+1;
				}
				else
					anadirOpt(top.ifContenido.document.insertar.selFrase, padre.hijos.contenido[i].nombre, padre.hijos.contenido[i].id, false);
			}
			top.ifContenido.document.insertar.selFrase.selectedIndex = sel;
		}
		cambiarPosiciones();
	}
}


function cambiarPosiciones()
{
	var sel = 0;
	var idFrase= top.ifContenido.document.insertar.selFrase.options[top.ifContenido.document.insertar.selFrase.selectedIndex].value;
	if (top.ifMapa.mapa.conceptoActual.tipo=="F")
		var padre = top.ifMapa.mapa.conceptoActual.padre;
	else
		var padre = top.ifMapa.mapa.conceptoActual;
	if (padre!=null)
	{
		if (idFrase=="-1")
		{
			top.ifContenido.document.insertar.txtFrase.value = "";
			var i;
			// actualizamos la posicion de la frase
			borrarListBox(top.ifContenido.document.insertar.selPosFrase);
			anadirOpt(top.ifContenido.document.insertar.selPosFrase, pEPosFrase.valorDef,-1, false);
			for (i=0; i<padre.hijos.contenido.length;i++)
			{
				if ((top.ifMapa.mapa.estado==0) || (top.ifMapa.mapa.itemModif.padre.hijos.contenido.length>1)
				 || (top.ifMapa.mapa.itemModif.padre.id != padre.hijos.contenido[i].id)) 
					anadirOpt(top.ifContenido.document.insertar.selPosFrase, pEPosFrase.valor + ' "' + padre.hijos.contenido[i].nombre + '"', (i+1), false);
			}
			top.ifContenido.document.insertar.selPosFrase.selectedIndex = (top.ifContenido.document.insertar.selPosFrase.options.length -1)
			// actualizamos la posicion del concepto 
			borrarListBox(top.ifContenido.document.insertar.selPosConcepto);
			anadirOpt(top.ifContenido.document.insertar.selPosConcepto, pEPosConcepto.valorDef,-1, true);
		}
		else
		{
			top.ifContenido.document.insertar.txtFrase.value = top.ifContenido.document.insertar.selFrase.options[top.ifContenido.document.insertar.selFrase.selectedIndex].text;
			var frase = padre.hijos.buscar(idFrase);
			if (frase!=null)
			{	
				// actualizamos la posicion de la frase
				borrarListBox(top.ifContenido.document.insertar.selPosFrase);
				anadirOpt(top.ifContenido.document.insertar.selPosFrase, pEPosFrase.valorNo,-1);
				// actualizamos la posicion de los conceptos
				borrarListBox(top.ifContenido.document.insertar.selPosConcepto);
				sel = 0;
				if ((top.ifMapa.mapa.estado==0) || (frase.hijos.contenido[0].id == top.ifMapa.mapa.itemModif.id))
					anadirOpt(top.ifContenido.document.insertar.selPosConcepto, pEPosConcepto.valorDef,-1, true);
				else
					anadirOpt(top.ifContenido.document.insertar.selPosConcepto, pEPosConcepto.valorDef,-1, false);
				if (top.ifMapa.mapa.estado==0)
				{
					for (i=0; i<frase.hijos.contenido.length;i++)
						anadirOpt(top.ifContenido.document.insertar.selPosConcepto, pEPosConcepto.valor + ' "' + frase.hijos.contenido[i].nombre + '"', (i+1), false);
					sel = (top.ifContenido.document.insertar.selPosConcepto.options.length - 1)
				}
				else
				{
					for (i=0;i<frase.hijos.contenido.length;i++)
					{
						if (top.ifMapa.mapa.itemModif.id != frase.hijos.contenido[i].id)
						{
							if ((i+1<frase.hijos.contenido.length) && (top.ifMapa.mapa.itemModif.id == frase.hijos.contenido[i+1].id))
							{
								sel = i + 1;								
								anadirOpt(top.ifContenido.document.insertar.selPosConcepto, pEPosConcepto.valor + ' "' + frase.hijos.contenido[i].nombre + '"', frase.hijos.contenido[i].id, true);
							}
							else
								anadirOpt(top.ifContenido.document.insertar.selPosConcepto, pEPosConcepto.valor + ' "' + frase.hijos.contenido[i].nombre + '"', frase.hijos.contenido[i].id, false);
						}
					}
					if (frase.id != top.ifMapa.mapa.itemModif.padre.id)
						sel = (top.ifContenido.document.insertar.selPosConcepto.options.length - 1)
				}
				top.ifContenido.document.insertar.selPosConcepto.selectedIndex = sel;
			}
		}
	}
}

function cambiarTipDirRec()
{
	var idTipo= top.ifContenido.document.insertar.selTipDirRec.options[top.ifContenido.document.insertar.selTipDirRec.selectedIndex].value;
	var dirRec = top.ifContenido.document.insertar.txtDirRec.value;
	var dirRecAux = dirRec.toLowerCase();
	var pos = dirRecAux.indexOf('http://');
	if ((pos == 0) && (idTipo == 1))
		dirRec = dirRec.substring(7);
	if ((pos != 0) && (idTipo == 0))
		dirRec = 'http://' + dirRec;
	top.ifContenido.document.insertar.txtDirRec.value = dirRec;
}

function borrarListBox(lista)
{
	for (i = lista.options.length;i > 0;i--)
		 lista.options[0] = null;
}

function anadirOpt(lista, nombre, valor, estado)
{
	var optionName = new Option(nombre,valor,estado,estado)
  var length = lista.options.length;
  lista.options[length] = optionName;
}

function quitarOpt(lista, id)
{
	lista.options[id] = null;
}

function cambiarTipoRec()
{
	var tipRec = top.ifContenido.document.insertar.selTipRec.options[top.ifContenido.document.insertar.selTipRec.selectedIndex].value;
	if (parseInt(tipRec)==6)
	{
		top.ifContenido.document.insertar.selTipDirRec.disabled = true;
		top.ifContenido.document.insertar.selTipDirRec.style.color=COLORINACTIVO;
		top.ifContenido.document.insertar.txtDirRec.disabled = true;
		top.ifContenido.document.insertar.txtDirRec.style.color=COLORINACTIVO;
		top.ifContenido.document.insertar.selTipDirRec.selectedIndex = 0;
		top.ifContenido.document.insertar.txtDirRec.value="";
	}
	else
	{
		top.ifContenido.document.insertar.selTipDirRec.disabled = false;
		top.ifContenido.document.insertar.selTipDirRec.style.color=COLORACTIVO;
		top.ifContenido.document.insertar.txtDirRec.disabled = false;
		top.ifContenido.document.insertar.txtDirRec.style.color=COLORACTIVO;
		top.ifContenido.document.insertar.selTipDirRec.selectedIndex = 0;
		top.ifContenido.document.insertar.txtDirRec.value="http://";
	}
}

var posRecursoModif = -1;
function anadirRec()
{
	// recopilamos los datos
	var nombre = top.ifContenido.document.insertar.txtNombreRec.value;
	var tipoRec = top.ifContenido.document.insertar.selTipRec.options[top.ifContenido.document.insertar.selTipRec.selectedIndex].value;
	var tipoDirRec = top.ifContenido.document.insertar.selTipDirRec.options[top.ifContenido.document.insertar.selTipDirRec.selectedIndex].value;
	var direccion = hacerTrim(top.ifContenido.document.insertar.txtDirRec.value);
	var desc = top.ifContenido.document.insertar.txtDescRec.value;
	
	// comprobamos que los datos sean correctos
	var error="";
	if(nombre=="")
		error += pTxtError_0 + pENombreRec.texto + pTxtError_1;
	if(tipoRec=="-1")
		error += pTxtError_0 + pETipRec.texto + pTxtError_1;
	if(parseInt(top.ifContenido.document.insertar.selTipRec.options[top.ifContenido.document.insertar.selTipRec.selectedIndex].value)!=6)
	{
		if(direccion=="")
			error += pTxtError_0 + pEDirRec.texto + pTxtError_1;
		else
		{
			if(hacerTrim(direccion).toLowerCase() == "http://")
				error += pTxtError_0 + pEDirRec.texto + pTxtError_1b;
		}
	}
	if (error=="")
	{
		if (top.ifContenido.document.insertar.btnAnadirRec.value!=botonAceptar)
		{
			top.ifMapa.mapa.anadirRecurso(nombre, tipoRec, desc, direccion, tipoDirRec);
			anadirOpt(top.ifContenido.document.insertar.listaRec, pETipRec.valores[tipoRec] + ': ' + nombre , pETipRec.valores[tipoRec] + ': ' + nombre);
			restaurarAreaRec();
		}
		else
		{
			var rec = top.ifMapa.mapa.listaAux.contenido[posRecursoModif];
			rec.nombre = top.ifContenido.document.insertar.txtNombreRec.value;
			rec.tipo = top.ifContenido.document.insertar.selTipRec.options[top.ifContenido.document.insertar.selTipRec.selectedIndex].value;
			rec.tipoDireccion = top.ifContenido.document.insertar.selTipDirRec.options[top.ifContenido.document.insertar.selTipDirRec.selectedIndex].value;
			rec.direccion = hacerTrim(top.ifContenido.document.insertar.txtDirRec.value);
			rec.descripcion = top.ifContenido.document.insertar.txtDescRec.value;
			restaurarAreaRec();
		}
	}
	else
	{
		error =pTxtError_2
			+ error
			+ pTxtError_3
		alert(error);
	}
}

function modificarRec(pEstado)
{
	if (top.ifContenido.document.insertar.btnModificarRec.value!=botonCancelar)
	{
		if ((top.ifContenido.document.insertar.listaRec.options.length>0) && (top.ifContenido.document.insertar.listaRec.selectedIndex>=0))
		{
			var posRec = top.ifContenido.document.insertar.listaRec.selectedIndex;
			if (posRec>=0)
			{
				posRecursoModif = posRec;
				var rec = top.ifMapa.mapa.listaAux.contenido[posRec];
				if(rec!=null)
				{
					top.ifContenido.document.insertar.txtNombreRec.value = rec.nombre;
					top.ifContenido.document.insertar.selTipRec.selectedIndex = (parseInt(rec.tipo));
					top.ifContenido.document.insertar.selTipDirRec.selectedIndex = parseInt(rec.tipoDireccion);
					top.ifContenido.document.insertar.txtDirRec.value = rec.direccion;
					top.ifContenido.document.insertar.txtDescRec.value = rec.descripcion;
					top.ifContenido.document.insertar.btnAnadirRec.value=botonAceptar;		
					top.ifContenido.document.insertar.btnModificarRec.value=botonCancelar;		
					top.ifContenido.document.insertar.btnEliminarRec.disabled=true;		
					top.ifContenido.document.insertar.btnEliminarRec.style.color=COLORINACTIVO;		
					top.ifContenido.document.insertar.btnArriba.disabled=true;		
					top.ifContenido.document.insertar.btnArriba.style.color=COLORINACTIVO;		
					top.ifContenido.document.insertar.btnAbajo.disabled=true;		
					top.ifContenido.document.insertar.btnAbajo.style.color=COLORINACTIVO;		
					top.ifContenido.document.insertar.listaRec.disabled=true;
					top.ifContenido.document.insertar.listaRec.style.color=COLORINACTIVO;		
					if (parseInt(rec.tipoDireccion)==6)
					{
						top.ifContenido.document.insertar.selTipDirRec.disabled = true;
						top.ifContenido.document.insertar.selTipDirRec.style.color=COLORINACTIVO;
						top.ifContenido.document.insertar.txtDirRec.disabled = true;
						top.ifContenido.document.insertar.txtDirRec.style.color=COLORINACTIVO;
					}
				}
			}
		}
	}
	else
	{
		if (pEstado==null)
		{
			if(confirm(confCancelGen))
				restaurarAreaRec();
		}
		else
			restaurarAreaRec();
	}
}

function restaurarAreaRec()
{
	top.ifContenido.document.insertar.txtNombreRec.value = "";
	top.ifContenido.document.insertar.selTipRec.selectedIndex = 0;
	top.ifContenido.document.insertar.selTipDirRec.selectedIndex = 0;
	top.ifContenido.document.insertar.txtDirRec.value = "http://";
	top.ifContenido.document.insertar.txtDescRec.value = "";
	top.ifContenido.document.insertar.btnAnadirRec.value=botonAnadir;		
	top.ifContenido.document.insertar.btnModificarRec.value=botonModificar;		
	top.ifContenido.document.insertar.btnEliminarRec.disabled=false;		
	top.ifContenido.document.insertar.btnEliminarRec.style.color=COLORACTIVO;
	top.ifContenido.document.insertar.btnArriba.disabled=false;		
	top.ifContenido.document.insertar.btnArriba.style.color=COLORACTIVO;
	top.ifContenido.document.insertar.btnAbajo.disabled=false;		
	top.ifContenido.document.insertar.btnAbajo.style.color=COLORACTIVO;
	top.ifContenido.document.insertar.listaRec.disabled=false;
	top.ifContenido.document.insertar.listaRec.style.color=COLORACTIVO;		
	top.ifContenido.document.insertar.selTipDirRec.disabled = false;
	top.ifContenido.document.insertar.selTipDirRec.style.color=COLORACTIVO;
	top.ifContenido.document.insertar.txtDirRec.disabled = false;
	top.ifContenido.document.insertar.txtDirRec.style.color=COLORACTIVO;
	top.ifContenido.document.insertar.selTipDirRec.selectedIndex = 0;
	top.ifContenido.document.insertar.txtDirRec.value="http://";
	restaurarListaRec()
}

function restaurarListaRec()
{
	borrarListBox(top.ifContenido.document.insertar.listaRec);
	var i;
	var rec;
	for(i=0;i<top.ifMapa.mapa.listaAux.contenido.length;i++)
	{
		rec = top.ifMapa.mapa.listaAux.contenido[i]
		anadirOpt(top.ifContenido.document.insertar.listaRec, pETipRec.valores[rec.tipo] + ': ' + rec.nombre , pETipRec.valores[rec.tipo] + ': ' + rec.nombre)
	}
}

function eliminarRec()
{
	if ((top.ifContenido.document.insertar.listaRec.options.length>0) && (top.ifContenido.document.insertar.listaRec.selectedIndex>=0))
	{
		var rec = top.ifContenido.document.insertar.listaRec.selectedIndex;
		if (confirm(pTxtConfBorrarRec_0 + top.ifContenido.document.insertar.listaRec.options[rec].value + pTxtConfBorrarRec_1))
		{
			top.ifMapa.mapa.listaAux.borrarPos(rec);
			top.ifContenido.document.insertar.listaRec.options[rec] = null;
			restaurarListaRec();
		}
	}
}

function moverRec(pDireccion)
{
	var posActual = top.ifContenido.document.insertar.listaRec.selectedIndex;
	if (posActual>=0)
	{
		top.ifMapa.mapa.listaAux.mover(posActual,pDireccion);
		restaurarListaRec();
		top.ifContenido.document.insertar.listaRec.selectedIndex = posActual+pDireccion	;
	}
}

function aceptarIns()
{
	if (top.ifContenido.document.insertar.btnAnadirRec.value==botonAceptar)
	{
		if(!confirm(pTxtConfCancelarRecIns))
		{
			modificarRec(true);
			return;
		}
	}
	
	// recopilamos los datos
	var nombre;
	var concepto;
	nombre = hacerTrim(top.ifContenido.document.insertar.txtNombre.value);
	var idPadre = parseInt(top.ifContenido.document.insertar.selPadre.options[top.ifContenido.document.insertar.selPadre.selectedIndex].value);
	var idFrase = top.ifContenido.document.insertar.selFrase.options[top.ifContenido.document.insertar.selFrase.selectedIndex].value;
	var txtFrase = hacerTrim(top.ifContenido.document.insertar.txtFrase.value);
	var posFrase = top.ifContenido.document.insertar.selPosFrase.options[top.ifContenido.document.insertar.selPosFrase.selectedIndex].value;
	var posConcepto = top.ifContenido.document.insertar.selPosConcepto.options[top.ifContenido.document.insertar.selPosConcepto.selectedIndex].value;
	
	// comprobamos los datos
	var error = "";
	if (nombre=="")
		error += pTxtError_0 + pENombre.texto + pTxtError_1;
	if ((idFrase=="-1") && (hacerTrim(txtFrase)==""))
		error += pTxtError_0 + pEFrase.texto + pTxtError_1;
	
	if (error == "")
	{
		// insertamos el concepto
		top.ifMapa.mapa.setActualId(idPadre);	
		if(idFrase=="-1") // la frase es nueva
		{
			top.ifMapa.mapa.anadirConcepto(nombre, txtFrase, posFrase, posConcepto);
		}
		else
		{
			top.ifMapa.mapa.anadirConceptoFrase(nombre, idFrase, posConcepto);
		}
		top.ifMapa.mapa.conceptoActual.recursos = top.ifMapa.mapa.listaAux.clonar();
		top.ifMapa.mapa.listaAux = null;
		top.ifMapa.mapa.estado = 2;
		top.ifMapa.mapa.modificado = false;
		top.ifMapa.cargarMapa(1, -1);
		verResultado(pETituloIns, pEOkIns);
		actualizarTitulo(0,-1)
		top.mapaModif = true;
	}
	else
	{
		error =pTxtError_2
			+ error
			+ pTxtError_3
		alert(error);
	}
}

function cancelarIns()
{
	if (confirm(confCancelGen))
	{
		if (top.ifMapa.mapa.listaAux != null)
			top.ifMapa.mapa.listaAux.vaciar();
		top.ifMapa.mapa.listaAux = null;
		if (top.ifMapa.mapa.estado == 0)
			verResultado(pETituloIns, pEKoIns);
		else
			verResultado(pETituloMod, pEKoMod);
		actualizarTitulo(0,-1)
		top.ifMapa.mapa.estado = 2;
		top.ifMapa.mapa.modificado = false;
	}
}


function aceptarMod()
{
	if (top.ifContenido.document.insertar.btnAnadirRec.value==botonAceptar)
	{
		if(!confirm(pTxtConfCancelarRecMod))
		{
			modificarRec(true);
			return;
		}
	}
	
	// recopilamos los datos
	var nombre;
	var concepto;
	var idNombre = top.ifContenido.document.insertar.selNombre.options[top.ifContenido.document.insertar.selNombre.selectedIndex].value;
	nombre = hacerTrim(top.ifContenido.document.insertar.txtNombre.value);
	if (top.ifMapa.mapa.itemModif.padre!=null)
	{
		var idPadre = parseInt(top.ifContenido.document.insertar.selPadre.options[top.ifContenido.document.insertar.selPadre.selectedIndex].value);
		var idFrase = top.ifContenido.document.insertar.selFrase.options[top.ifContenido.document.insertar.selFrase.selectedIndex].value;
		var txtFrase = hacerTrim(top.ifContenido.document.insertar.txtFrase.value);
		var posFrase = top.ifContenido.document.insertar.selPosFrase.options[top.ifContenido.document.insertar.selPosFrase.selectedIndex].value;
		var posConcepto = top.ifContenido.document.insertar.selPosConcepto.options[top.ifContenido.document.insertar.selPosConcepto.selectedIndex].value;
	}
	// comprobamos los datos
	var error = "";
	if (nombre=="")
		error += pTxtError_0 + pENombre.texto + pTxtError_1;
	if (top.ifMapa.mapa.itemModif.padre!=null)
	{
		if ((idFrase=="-1") && (hacerTrim(txtFrase)==""))
			error += pTxtError_0 + pEFrase.texto + pTxtError_1;
	}
	if (error == "")
	{
		if (top.ifMapa.mapa.itemModif.padre!=null)
			top.ifMapa.mapa.aceptarItemModif(nombre, idPadre, idFrase, txtFrase, posFrase, posConcepto);
		else
			top.ifMapa.mapa.aceptarItemModif(nombre, -1, -1, -1, -1, -1);
		top.ifMapa.mapa.estado = 2;
		top.ifMapa.mapa.modificado = false;
		top.ifMapa.cargarMapa(1, -1);
		verResultado(pETituloMod, pEOkMod);//, "verEditar()");
		actualizarTitulo(0,-1);
		top.mapaModif = true;
	}
	else
	{
		error =pTxtError_2
			+ error
			+ pTxtError_3
		alert(error);
	}
}

function borrarConcepto()
{
	var continuar = true;
	if ((top.ifMapa.mapa.estado != 2) && (top.ifMapa.mapa.modificado))
		continuar = (confirm(confCancelGen))
	if (continuar)
	{
		if (top.ifMapa.mapa.conceptoActual.padre == null)
			alert(pEKoBor);
		else
		{
			if (confirm(pETxtConfBor_0 + top.ifMapa.mapa.conceptoActual.nombre + pETxtConfBor_1))
			{
				top.ifMapa.mapa.borrarActual();
				top.ifMapa.cargarMapa(1);
				top.ifContenido.verResultado(pETituloBor, pEOkBor);
				actualizarTitulo(0,-1);
				top.mapaModif = true;
			}
		}
	}
}

function borrarFrase()
{
	var continuar = true;
	if ((top.ifMapa.mapa.estado != 2) && (top.ifMapa.mapa.modificado))
		continuar = (confirm(confCancelGen))
	if (continuar)
	{
		if (confirm( pETxtConfBor_0 + top.ifMapa.mapa.itemModif.nombre + pETxtConfBor_1))
		{
			top.ifMapa.mapa.borrarFrase();
			top.ifMapa.cargarMapa(1,-1);
			top.ifContenido.verResultado(pETituloBorFrase, pEOkBorFrase);
			actualizarTitulo(0,-1);
			top.mapaModif = true;
		}
	}
}

function borrarNodo()
{
	if (top.ifMapa.mapa.itemModif.tipo == "C")
		borrarConcepto();
	if (top.ifMapa.mapa.itemModif.tipo == "F")
		borrarFrase();
}

function verEditarFrase(pPregunta)
{

	var i;
	var codigo = '<form name="insertar">\n'
		+ cabeceraPanel(pETituloModFrase)
		+ botonesPanel(botonAceptar, "aceptarModFrase()", botonCancelar, "cancelarModFrase()")
		+ subTituloPanel(pESubTitulo1)		
		+ '<tr>\n'
		+ '<td width="10" height="1" class="TDAreaEdicion"></td>\n'
		+ '<td width="740" class="TDAreaEdicion">\n'
		+ '	<table cellpadding="0" cellspacing="0" border="0">\n'
		+ '	<tr>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '		<td class="TDAreaEdicion">' + pEFNombre.texto + ':&nbsp;</td>\n'
		+ '		        <td class="TDAreaEdicion"> <input type="text" class="campoTxt" name="txtNombre" size="40" value="'
		+ top.ifMapa.mapa.itemModif.nombre
		+ '" onChange="cambiarEstadoModif()">&nbsp;<input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pEPagAyudaFrase + '#' + pEFNombre.ayuda + '\')">\n'
		+ '		</td>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '	</tr>\n'
		+ '	<tr><td colspan="4" width="1" height="5"></td></tr>\n'
		+ '	<tr>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '		<td class="TDAreaEdicion">' + pEFPadre.texto + ':&nbsp;</td>\n'
		+ '		        <td class="TDAreaEdicion"><select class="texto" name="selPadre" onChange="cambiarPosFrase();cambiarEstadoModif();">\n';
	var arrayAux = new Array();
	for(i=0;i<top.ifMapa.mapa.itemModif.hijos.contenido.length;i++)
		arrayAux[i]  = top.ifMapa.mapa.itemModif.hijos.contenido[i].id;
	var mostrar = true;
	var j;

	for(i=0;i<top.ifMapa.mapa.nodos.contenido.length;i++)
	{
		mostrar = (top.ifMapa.mapa.nodos.contenido[i].tipo == "C");
		if (mostrar)
		{	
			j=0;
			while ((mostrar) && (j<arrayAux.length))
			{
				mostrar = (arrayAux[j]!=top.ifMapa.mapa.nodos.contenido[i].id) && (top.ifMapa.mapa.nodos.contenido[i].antepasados.indexOf(arrayAux[j])==-1)
				j++;
			}
		}
		if (mostrar)
		{
			codigo += '<option ' 
				+ ((top.ifMapa.mapa.nodos.contenido[i].id == top.ifMapa.mapa.itemModif.padre.id) ? "selected" : "")
				+ ' value="'
				+ top.ifMapa.mapa.nodos.contenido[i].id
				+ '">' + top.ifMapa.mapa.nodos.contenido[i].nombre + ' ['
			if (top.ifMapa.mapa.nodos.contenido[i].padre== null)
				codigo += pEFPadre.raiz
			else
				codigo += top.ifMapa.mapa.nodos.contenido[i].padre.padre.nombre
					+ ' -> '
					+ top.ifMapa.mapa.nodos.contenido[i].padre.nombre
			codigo += ']</option>\n'
		}
	}
	codigo = codigo
		+ '              </select>\n'
		+ '              <input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pEPagAyudaFrase + '#' + pEFPadre.ayuda + '\')">\n'
		+ '		</td>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '	</tr>\n'
		+ '	<tr><td colspan="4" width="1" height="5"></td></tr>\n'
		+ '	<tr>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '		<td class="TDAreaEdicion">' + pEFPosFrase.texto + ':&nbsp;</td>\n'
		+ '		        <td class="TDAreaEdicion"><select class="texto" name="selPosicion" onChange="cambiarEstadoModif()"><option></option>\n'
		+ '              </select>\n'
		+ '              <input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pEPagAyudaFrase + '#' + pEFPosFrase.ayuda + '\')">\n'
		+ '		</td>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '	</tr>\n'		
		+ '	<tr><td colspan="4" width="1" height="5"></td></tr>\n'
		+ '	</table>\n'
		+ '</td>\n'
		+ '<td width="10" height="1" class="TDAreaEdicion"></td>\n'
		+ '</tr>\n'
		+ '<tr>\n'
		+ '<td width="760" height="15" class="TDAreaEdicion" colspan="3"></td>\n'
		+ '</tr>\n'
		+ subTituloPanel(pESubTitulo3)
		+ '<tr>\n'
		+ '<td width="10" height="1" class="TDAreaEdicion"></td>\n'
		+ '<td width="740" class="TDAreaEdicion" align="center">\n'
		+ '			<table cellpadding="0" cellspacing="0" border="0">\n'
		+ '			<tr><td align="center" class="TDAreaEdicion">\n'
		+ '			<input type="button" class="btnGen" value="' + botonArriba +'" onClick="moverCon(-1);cambiarEstadoModif();"> <input type="button" class="btnGen" value="' + botonAbajo + '" onClick="moverCon(1);cambiarEstadoModif();">\n'
		+ '              <input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pEPagAyudaFrase + '#' + pEFLista.ayuda + '\')">\n'
		+ '			</td></tr>\n'
		+ '			<tr><td width="3" height="3"></td></tr>\n'
		+ '			<tr><td>\n'
		+ '			<select class="listBoxP2" size="13" name="listaHijos">\n';
	for(i=0;i<top.ifMapa.mapa.itemModif.hijos.contenido.length;i++)
	{
		codigo = codigo
			+ '<option value="' + top.ifMapa.mapa.itemModif.hijos.contenido[i].id +'">'
			+ top.ifMapa.mapa.itemModif.hijos.contenido[i].nombre
			+ '</option>';
	}
	codigo = codigo
		+ '			</select>\n'
		+ '			</td></tr>\n'
		+ '			</table>\n'
		+ '</td>\n'
		+ '<td width="10" height="1" class="TDAreaEdicion"></td>\n'
		+ '</tr>\n'
		+ '<tr>\n'
		+ '<td width="760" height="15" class="TDAreaEdicion" colspan="3"></td>\n'
		+ '</tr>\n'
		+ botonesPanel(botonAceptar, "aceptarModFrase()", botonCancelar, "cancelarModFrase()")
		+ piePanel()
		+ '</form>\n';
	document.getElementById("contenido").innerHTML = "";
	document.getElementById("contenido").innerHTML = "<div id='cont'>"+codigo+"</div>";
	top.calcHeight();
	top.ifMapa.mapa.estado = 1;
	top.ifMapa.mapa.resetModifFrase();
	actualizarTitulo(0, 1);
	cambiarPosFrase();
}

function cambiarPosFrase()
{
	var sel = 0;
	var idPadre = parseInt(top.ifContenido.document.insertar.selPadre.options[top.ifContenido.document.insertar.selPadre.selectedIndex].value);
	top.ifMapa.mapa.setActualId(idPadre);
	padre = top.ifMapa.mapa.conceptoActual;
	var i;
	borrarListBox(top.ifContenido.document.insertar.selPosicion);
	anadirOpt(top.ifContenido.document.insertar.selPosicion, pEFPosFrase.valorDef,-1, true);
	for (i=0; i<padre.hijos.contenido.length;i++)
	{
		if (padre.hijos.contenido[i].id != top.ifMapa.mapa.itemModif.id)
		{
			if ((padre.id == top.ifMapa.mapa.itemModif.padre.id)
				&& (i+1<padre.hijos.contenido.length) 
				&& (padre.hijos.contenido[i+1].id == top.ifMapa.mapa.itemModif.id))
			{
				anadirOpt(top.ifContenido.document.insertar.selPosicion, pEFPosFrase.valor + ' "' + padre.hijos.contenido[i].nombre + '"', padre.hijos.contenido[i].id, true);
				sel = i+1;
			}
			else
				anadirOpt(top.ifContenido.document.insertar.selPosicion, pEFPosFrase.valor + ' "' + padre.hijos.contenido[i].nombre + '"', padre.hijos.contenido[i].id, false);
		}
	}
	if (padre.id != top.ifMapa.mapa.itemModif.padre.id)
		sel = (top.ifContenido.document.insertar.selPosicion.options.length -1)
	top.ifContenido.document.insertar.selPosicion.selectedIndex = sel;
}

function cargarModificar(pPregunta)
{
	if (top.ifMapa.mapa.itemModif.tipo == "C")
		cargarEditarNodo(1,pPregunta)
	if (top.ifMapa.mapa.itemModif.tipo == "F")
		cargarEditarFrase(pPregunta);
}

function cargarEditarFrase(pPregunta)
{
	if ((pPregunta==null) && (top.ifMapa.mapa.estado != 2) && (top.ifMapa.mapa.modificado))
	{
		if (!confirm(confCancelGen))
			return;
	}
	if (top.ifMapa.mapa.itemModif.tipo!="F")
	{
		alert(pEKoModFraseSel);
		return;
	}	
	top.ifContenido.location="modificarNodo.htm"
}

function modificarNodo(pPregunta)
{
	if (top.ifMapa.mapa.itemModif.tipo == "C")
		verEditarConcepto(1,pPregunta);
	if (top.ifMapa.mapa.itemModif.tipo == "F")
		verEditarFrase(pPregunta);
}


function moverCon(pDireccion)
{
	var posActual = top.ifContenido.document.insertar.listaHijos.selectedIndex;
	if (posActual>=0)
	{
		top.ifMapa.mapa.listaAux.mover(posActual,pDireccion);
		restaurarListaHijos();
		top.ifContenido.document.insertar.listaHijos.selectedIndex = posActual+pDireccion	;
	}
}

function restaurarListaHijos()
{
	borrarListBox(top.ifContenido.document.insertar.listaHijos);
	var i;
	var con;
	for(i=0;i<top.ifMapa.mapa.listaAux.contenido.length;i++)
	{
		con = top.ifMapa.mapa.listaAux.contenido[i];
		anadirOpt(top.ifContenido.document.insertar.listaHijos, con.nombre, con.nombre)
	}
}

function aceptarModFrase()
{
	var error = "";
	var nombre = hacerTrim(top.ifContenido.document.insertar.txtNombre.value);
/*
	var re = /'/gi;
	nombre = nombre.replace(re, "&#39;");
*/
	var idPadre = parseInt(top.ifContenido.document.insertar.selPadre.options[top.ifContenido.document.insertar.selPadre.selectedIndex].value);
	var posFrase = parseInt(top.ifContenido.document.insertar.selPosicion.options[top.ifContenido.document.insertar.selPosicion.selectedIndex].value);
	if (nombre=="")
		error += pTxtError_0 + pEFNombre.texto + pTxtError_1;
	if (error=="")
	{
		top.ifMapa.mapa.aceptarModifFrase(nombre, idPadre, posFrase); 
		top.ifMapa.mapa.estado = 2;
		top.ifMapa.mapa.modificado = false;
		top.ifMapa.cargarMapa(1, -1);
		verResultado(pETituloModFrase, pEOkModFrase);//, "verEditar()");
		actualizarTitulo(0,-1);
		top.mapaModif = true;
	}
	else
	{
		error =pTxtError_2
			+ error
			+ pTxtError_3
		alert(error);
	}
}

function cancelarModFrase()
{
	if (confirm(confCancelGen))
	{
		top.ifMapa.mapa.estado = 2;
		top.ifMapa.mapa.modificado = false;
		verResultado(pETituloModFrase, pEKoModFrase);//, "verEditar()");
		actualizarTitulo(0,-1)
	}
}

function cargarVistas()
{
	if (top.estadoPersistencia==1)
	{
		alert(txtMensImportando);
		return;
	}
	if (top.estadoPersistencia==2)
	{
		alert(txtMensExportando);
		return;
	}
	var continuar = true;
	if ((top.ifMapa.mapa.estado != 2) && (top.ifMapa.mapa.modificado))
		continuar = (confirm(confCancelGen))
	if (continuar)
	{
		top.ifContenido.location = "vistas.htm";
	}
}

function verVistas()
{
	ocultarAyuda();
	var i;
	var codigo = '<form name="insertar">\n'
		+ cabeceraPanel(pVTitulo)
		+ botonesPanel(botonAceptar, "aceptarVistas()", botonCancelar, "cancelarVistas()")
		+ subTituloPanel(pVSubTitulo1)
		+ '<tr>\n'
		+ '<td width="10" class="TDAreaEdicion"></td>\n'
		+ '<td width="740" class="TDAreaEdicion">\n'
		+ '	<table cellpadding="0" cellspacing="0" border="0">\n'
		+ '	<tr>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '		        <td class="TDAreaEdicion">' + pVAutor.texto + ':&nbsp;</td>\n'
		+ '		        <td class="TDAreaEdicion"><input type="text" class="campoTxt" name="txtAutor" size="40" '  
		+ ' value="' + top.ifMapa.mapa.autor + '"'
		+ ' onChange="cambiarEstadoModif()">&nbsp;<input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pVPagAyuda + '#' + pVAutor.ayuda + '\')">\n'
		+ '		</td>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '	</tr>\n'
		+ '	<tr><td colspan="4" width="1" height="5"></td></tr>\n'
		+ '	<tr>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '		        <td class="TDAreaEdicion">' + pVEmail.texto + ':&nbsp;</td>\n'
		+ '		<td class="TDAreaEdicion"><input type="text" class="campoTxt" name="txtEmail" size="40" '
		+ ' value="' + top.ifMapa.mapa.email + '"'
		+ ' onChange="cambiarEstadoModif()">	<input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pVPagAyuda + '#' + pVEmail.ayuda + '\')">\n'
		+ '		</td>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '	</tr>\n'
		+ '	<tr><td colspan="4" width="1" height="5"></td></tr>\n'
		+ '	<tr>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '		        <td class="TDAreaEdicion">' + pVFecha.texto + ':&nbsp;</td>\n'
		+ '		<td class="TDAreaEdicion">\n'
		+ '			<input type="text" class="campoTxt" name="txtFecha" size="40" '
		+ 'value="' + top.ifMapa.mapa.fecha + '"'
		+ ' onChange="cambiarEstadoModif()">&nbsp;<input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pVPagAyuda + '#' + pVFecha.ayuda + '\')">\n'
		+ '		</td>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '	</tr>\n'
		+ '	<tr><td colspan="4" width="1" height="5"></td></tr>\n'
		+ '	<tr>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '		        <td class="TDAreaEdicion">' + pVDatos.texto + ':&nbsp;</td>\n'
		+ '		        <td class="TDAreaEdicion"> <select class="texto" name="selDatosGen" onChange="cambiarEstadoModif()">\n'
		+ '							 <option value="1" ' + ((top.ifMapa.mapa.datosGenerales == 1) ? " selected " : "")+ '>' + txtSi + '</option>\n'
		+ '              <option value="0"' + ((top.ifMapa.mapa.datosGenerales == 0) ? " selected " : "")+ '>' + txtNo + '</option>\n'
		+ '              </select>\n'
		+ '              &nbsp; \n'
		+ '              <input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pVPagAyuda + '#' + pVDatos.ayuda + '\')">\n'
		+ '		</td>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '	</tr>\n'
		+ '	<tr><td colspan="4" width="1" height="5"></td></tr>\n'
		+ '	<tr>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '		        <td class="TDAreaEdicion">' + pVCentrado.texto + ':&nbsp;</td>\n'
		+ '		        <td class="TDAreaEdicion"> <select class="texto" name="selCentrado" onChange="cambiarEstadoModif()">\n'
		+ '							 <option value="1" ' + ((top.ifMapa.mapa.centrado == 1) ? " selected " : "")+ '>' + txtSi + '</option>\n'
		+ '              <option value="0"' + ((top.ifMapa.mapa.centrado == 0) ? " selected " : "")+ '>' + txtNo + '</option>\n'
		+ '              </select>\n'
		+ '              &nbsp; \n'
		+ '              <input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pVPagAyuda + '#' + pVCentrado.ayuda + '\')">\n'
		+ '		</td>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '	</tr>\n'
		+ '	<tr><td colspan="4" width="1" height="5"></td></tr>\n'
		+ '	<tr>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '		        <td class="TDAreaEdicion">' + pVX.texto + ':&nbsp;</td>\n'
		+ '		<td class="TDAreaEdicion">\n'
		+ '			<input type="text" class="texto" name="txtX" size="5" '
		+ 'value="' + top.ifMapa.mapa.posX + '"'
		+ ' onChange="cambiarEstadoModif()">&nbsp;<input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pVPagAyuda + '#' + pVX.ayuda + '\')">\n'
		+ '		</td>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '	</tr>\n'
		+ '	<tr><td colspan="4" width="1" height="5"></td></tr>\n'
		+ '	<tr>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '		        <td class="TDAreaEdicion">' + pVY.texto + ':&nbsp;</td>\n'
		+ '		<td class="TDAreaEdicion">\n'
		+ '			<input type="text" class="texto" name="txtY" size="5" '
		+ 'value="' + top.ifMapa.mapa.posY + '"'
		+ ' onChange="cambiarEstadoModif()">&nbsp;<input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pVPagAyuda + '#' + pVX.ayuda + '\')">\n'
		+ '		</td>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '	</tr>\n'
		+ '	<tr><td colspan="4" width="1" height="5"></td></tr>\n'
		+ '	</table>\n'
		+ '</td>\n'
		+ '<td width="10" height="1" class="TDAreaEdicion"></td>\n'
		+ '</tr>\n'
		+ '<tr>\n'
		+ '<td width="760" height="15" class="TDAreaEdicion" colspan="3"></td>\n'
		+ '</tr>\n'
		+ subTituloPanel(pVSubTitulo2)
		+ '<tr>\n'
		+ '<td width="10" height="1" class="TDAreaEdicion"></td>\n'
		+ '<td width="740" class="TDAreaEdicion">\n'
		+ '	<table width="740" cellpadding="0" cellspacing="0" border="0">\n'
		+ '	<tr>\n'
		+ '		<td class="TDAreaEdicion" width="10" height="1"></td>\n'
		+ '		<td width="363">\n'
		+ '			<table cellpadding="0" cellspacing="0" border="0">\n'
		+ '			<tr><td width="1" height="5"></td></tr>\n'
		+ '			<tr>\n'
		+ '				<td width="120" class="TDAreaEdicion">' + pVNombre.texto + ':</td>\n'
		+ '				<td width="222" class="TDAreaEdicion"><input type="text" class="campoTxt" name="txtNombreVista" size="40">&nbsp;<input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pVPagAyuda + '#' + pVNombre.ayuda + '\')"></td>\n'
		+ '			</tr>\n'
		+ '			<tr><td colspan="2" width="1" height="5"></td></tr>\n'
		+ '			<tr>\n'
		+ '				<td class="TDAreaEdicion">' + pVTipoLetra.texto + ':</td>\n'
		+ '				<td class="TDAreaEdicion"><select class="campoTxt" name="selTipLetra" onChange="actualizarVista()">\n';
	for(i=0;i<pVTipoLetra.valores.length;i++)
	{
		codigo = codigo
			+ '				<option value="' + i + '">' + pVTipoLetra.valores[i] + '</option>\n'
	}
	codigo = codigo
		+ '				</select>\n'
		+ '				<input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pVPagAyuda + '#' + pVTipoLetra.ayuda + '\')"></td>\n'
		+ '			</tr>\n'
		+ '			<tr><td colspan="2" width="1" height="5"></td></tr>\n'
		+ '			<tr>\n'
		+ '				<td class="TDAreaEdicion">' + pVTamLetra.texto + ':</td>\n'
		+ '				<td class="TDAreaEdicion"><select class="campoTxt" name="selTamLetra" onChange="actualizarVista(\'' + pVPagAyuda + '#' + pVTamLetra.ayuda + '\')">\n';
	for(i=pVTamLetra.minimo;i<=pVTamLetra.maximo;i++)
	{
		codigo = codigo
			+ '				<option value="' + i + '" ';
		if (i == pVTamLetra.def)
			codigo = codigo + ' selected ';
		codigo = codigo
			+ ' >' + i + '</option>\n';
	}
	codigo = codigo
		+ '				</select>\n'
		+ '				<input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'ayudaVistas.htm#tamLetra\')"></td>\n'
		+ '			</tr>\n'
		+ '			<tr><td colspan="2" width="1" height="5"></td></tr>\n'
		+ '			<tr>\n'
		+ '				<td class="TDAreaEdicion">' + pVDesplegar.texto + ':</td>\n'
		+ '				<td class="TDAreaEdicion"><select class="campoTxt" name="selDesplegar" onChange="actualizarVista()">\n'
		+ '				<option value="1">' + pVDesplegar.valores[1] + '</option>\n'
		+ '				<option value="2">' + pVDesplegar.valores[2] + '</option>\n'
		+ '				<option value="-1" selected>' + pVDesplegar.valores[0] + '</option>\n'
		+ '				</select>\n'
		+ '				<input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pVPagAyuda + '#' + pVDesplegar.ayuda + '\')"></td>\n'
		+ '			</tr>\n'
		+ '			<tr><td colspan="2" width="1" height="5"></td></tr>\n'
		+ '			<tr>\n'
		+ '				<td class="TDAreaEdicion">' + pVMostrar.texto + ':&nbsp;</td>\n'
		+ '				<td class="TDAreaEdicion"><select class="campoTxt" name="selMostrar" onChange="actualizarVista()"><option value="0" selected>' + pVMostrar.valores[0] + '</option><option value="1">' + pVMostrar.valores[1] + '</option></select>&nbsp;<input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pVPagAyuda + '#' + pVMostrar.ayuda + '\')"></td>\n'
		+ '			</tr>\n'
		+ '			<tr><td colspan="2" width="1" height="5"></td></tr>\n'
		+ '			<tr>\n'
		+ '				<td class="TDAreaEdicion">' + pVOrientacion.texto + ':</td>\n'
		+ '				<td class="TDAreaEdicion"><select class="campoTxt" name="selOrientacion" onChange="actualizarVista()"><option value="0" selected>' + pVOrientacion.valores[0] + '</option><option value="1">' + pVOrientacion.valores[1] + '</option></select>&nbsp;<input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pVPagAyuda + '#' + pVOrientacion.ayuda + '\')"></td>\n'
		+ '			</tr>\n'
		+ '			<tr><td colspan="2" width="1" height="5"></td></tr>\n'
		+ '			<tr>\n'
		+ '				<td class="TDAreaEdicion">' + pVEnlaces.texto + ':</td>\n'
		+ '				<td class="TDAreaEdicion"><select class="texto" name="selEnlaces">'
		+ '<option value="1" selected>' + txtSi + '</option>'
		+ '<option value="0">' + txtNo + '</option></select>&nbsp;<input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pVPagAyuda + '#' + pVEnlaces.ayuda + '\')"></td>\n'
		+ '			</tr>\n'
		+ '			<tr><td colspan="2" width="1" height="5"></td></tr>\n'
		+ '			<tr>\n'
		+ '				<td class="TDAreaEdicion">' +pVMenu.texto  + ':</td>\n'
		+ '				<td class="TDAreaEdicion"><select class="texto" name="selMenu">'
		+ '<option value="1" selected>' + txtSi + '</option>'
		+ '<option value="0">' + txtNo + '</option></select>&nbsp;<input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pVPagAyuda + '#' + pVMenu.ayuda + '\')"></td>\n'
		+ '			</tr>\n'
		+ '			</table>\n'
		+ '		</td>\n'
		+ '		<td width="117" class="TDAreaEdicion">\n'
		+ '			<table cellpadding="0" cellspacing="0" border="0">\n'
		+ '				<tr><td><input type="button" class="btn" value="' + botonAnadir +'" onClick="anadirVista();cambiarEstadoModif();" name="btnAnadirVista"></td></tr>\n'
		+ '				<tr><td width="3" height="3"></td></tr>\n'
		+ '				<tr><td><input type="button" class="btn" value="' + botonModificar + '" onClick="modificarVista();cambiarEstadoModif();" name="btnModificarVista"></td></tr>\n'
		+ '				<tr><td width="3" height="3"></td></tr>\n'
		+ '				<tr><td><input type="button" class="btn" value="' + botonEliminar +'" onClick="eliminarVista();cambiarEstadoModif();" name="btnEliminarVista"></td></tr>\n'
		+ '			</table>\n'
		+ '		</td>\n'
		+ '		<td width="250" class="TDAreaEdicion">\n'
		+ '			<table cellpadding="0" cellspacing="0" border="0">\n'
		+ '			<tr><td align="center">\n'
		+ '			<input type="button" class="btnGen" value="' + botonArriba + '" onClick="moverVista(-1);cambiarEstadoModif();" name="btnArriba"> <input type="button" class="btnGen" value="' + botonAbajo + '" onClick="moverVista(1);cambiarEstadoModif();" name="btnAbajo"> <input type="button" class="btnGen" value="Ver" onClick="actualizarMapaVista()" name="btnVer"> <input type="button" value="&nbsp;?&nbsp;" class="btnAyuda" onClick="ayudaCampo(\'' + pVPagAyuda + '#' + pVListaVistas.ayuda + '\')">\n'
		+ '			</td></tr>\n'
		+ '			<tr><td width="3" height="3"></td></tr>\n'
		+ '			<tr><td>\n'
		+ '			<select class="listBoxP" size="12" name="listaVistas"><option></option>\n'
		+ '			</select>\n'
		+ '			</td></tr>\n'
		+ '			</table>\n'
		+ '		</td>\n'
		+ '	</tr>\n'
		+ '	</table>\n'
		+ '</td>\n'
		+ '<td width="10" height="1" class="TDAreaEdicion"></td>\n'
		+ '</tr>\n'
		+ '<tr>\n'
		+ '<td width="760" height="15" class="TDAreaEdicion" colspan="3"></td>\n'
		+ '</tr>\n'
		+ botonesPanel(botonAceptar, "aceptarVistas()", botonCancelar, "cancelarVistas()")
		+ piePanel()
		+ '</form>\n';
	document.getElementById("contenido").innerHTML = "";
	document.getElementById("contenido").innerHTML = "<div id='cont'>"+codigo+"</div>";
	top.calcHeight();
	top.ifMapa.mapa.resetDefinirVistas();
	top.ifMapa.cargarMapa(0, -1);
	actualizarListaVistas();
	actualizarTitulo(1);	
}

function  actualizarVista()
{
	top.ifMapa.mapa.nombreVista = top.ifContenido.document.insertar.txtNombreVista.value;
	top.ifMapa.mapa.tipoLetra = parseInt(top.ifContenido.document.insertar.selTipLetra[top.ifContenido.document.insertar.selTipLetra.selectedIndex].value);
	top.ifMapa.mapa.tamanoLetra = parseInt(top.ifContenido.document.insertar.selTamLetra[top.ifContenido.document.insertar.selTamLetra.selectedIndex].value);
	top.ifMapa.mapa.desplegar = parseInt(top.ifContenido.document.insertar.selDesplegar[top.ifContenido.document.insertar.selDesplegar.selectedIndex].value);
	top.ifMapa.mapa.orientacion = parseInt(top.ifContenido.document.insertar.selOrientacion[top.ifContenido.document.insertar.selOrientacion.selectedIndex].value);
	top.ifMapa.mapa.mostrar = parseInt(top.ifContenido.document.insertar.selMostrar[top.ifContenido.document.insertar.selMostrar.selectedIndex].value);
	top.ifMapa.mapa.verEnlaces = parseInt(top.ifContenido.document.insertar.selEnlaces[top.ifContenido.document.insertar.selEnlaces.selectedIndex].value);
	top.ifMapa.mapa.verMenu = parseInt(top.ifContenido.document.insertar.selMenu[top.ifContenido.document.insertar.selMenu.selectedIndex].value);
	top.ifMapa.cargarMapa(0, -2);
}

function actualizarMapaVista()
{
	top.ifMapa.cargarMapa(0, parseInt(top.ifContenido.document.insertar.listaVistas[top.ifContenido.document.insertar.listaVistas.selectedIndex].value));
}

function actualizarListaVistas()
{
	var i;
	borrarListBox(top.ifContenido.document.insertar.listaVistas);
	for(i=0;i<top.ifMapa.mapa.vistasAux.contenido.length;i++)
	{
		anadirOpt(top.ifContenido.document.insertar.listaVistas, top.ifMapa.mapa.vistasAux.contenido[i].nombre,top.ifMapa.mapa.vistasAux.contenido[i].id);		
	}
}

function anadirVista()
{
	if (top.ifContenido.document.insertar.txtNombreVista.value == "")
	{
		var error = pTxtError_2
			+ pTxtError_0
			+ pVNombre.texto
			+ pTxtError_1
			+ pTxtError_3
		alert(error);
	}
	else
	{
		if (top.ifContenido.document.insertar.btnAnadirVista.value!=botonAceptar)
		{
			if (top.ifMapa.mapa.vistasAux.contenido.length == 12)
				alert(pVKoNo);
			else
			{
				top.ifMapa.mapa.nombreVista = top.ifContenido.document.insertar.txtNombreVista.value;
				top.ifMapa.mapa.tipoLetra = parseInt(top.ifContenido.document.insertar.selTipLetra[top.ifContenido.document.insertar.selTipLetra.selectedIndex].value);
				top.ifMapa.mapa.tamanoLetra = parseInt(top.ifContenido.document.insertar.selTamLetra[top.ifContenido.document.insertar.selTamLetra.selectedIndex].value);
				top.ifMapa.mapa.desplegar = parseInt(top.ifContenido.document.insertar.selDesplegar[top.ifContenido.document.insertar.selDesplegar.selectedIndex].value);
				top.ifMapa.mapa.orientacion = parseInt(top.ifContenido.document.insertar.selOrientacion[top.ifContenido.document.insertar.selOrientacion.selectedIndex].value);
				top.ifMapa.mapa.mostrar = parseInt(top.ifContenido.document.insertar.selMostrar[top.ifContenido.document.insertar.selMostrar.selectedIndex].value);

				top.ifMapa.mapa.verMenu = top.ifContenido.document.insertar.selMenu.options[top.ifContenido.document.insertar.selMenu.selectedIndex].value;
				top.ifMapa.mapa.verEnlaces = top.ifContenido.document.insertar.selEnlaces.options[top.ifContenido.document.insertar.selEnlaces.selectedIndex].value;

				top.ifMapa.mapa.anadirVista();
				actualizarListaVistas()
				resetBotonesModifVista()
			}
		}
		else
		{
			top.ifMapa.mapa.nombreVista = top.ifContenido.document.insertar.txtNombreVista.value;
			top.ifMapa.mapa.tipoLetra = parseInt(top.ifContenido.document.insertar.selTipLetra[top.ifContenido.document.insertar.selTipLetra.selectedIndex].value);
			top.ifMapa.mapa.tamanoLetra = parseInt(top.ifContenido.document.insertar.selTamLetra[top.ifContenido.document.insertar.selTamLetra.selectedIndex].value);
			top.ifMapa.mapa.desplegar = parseInt(top.ifContenido.document.insertar.selDesplegar[top.ifContenido.document.insertar.selDesplegar.selectedIndex].value);
			top.ifMapa.mapa.orientacion = parseInt(top.ifContenido.document.insertar.selOrientacion[top.ifContenido.document.insertar.selOrientacion.selectedIndex].value);
			top.ifMapa.mapa.mostrar = parseInt(top.ifContenido.document.insertar.selMostrar[top.ifContenido.document.insertar.selMostrar.selectedIndex].value);
			top.ifMapa.mapa.verMenu = top.ifContenido.document.insertar.selMenu.options[top.ifContenido.document.insertar.selMenu.selectedIndex].value;
			top.ifMapa.mapa.verEnlaces = top.ifContenido.document.insertar.selEnlaces.options[top.ifContenido.document.insertar.selEnlaces.selectedIndex].value;
			top.ifMapa.mapa.modifVista();
			actualizarListaVistas();
			resetBotonesModifVista();
		}
	}
}

function resetBotonesModifVista()
{
	top.ifContenido.document.insertar.btnAnadirVista.value=botonAnadir;		
	top.ifContenido.document.insertar.btnModificarVista.value=botonModificar;		
	top.ifContenido.document.insertar.btnEliminarVista.disabled=false;		
	top.ifContenido.document.insertar.btnEliminarVista.style.color=COLORACTIVO;		
	top.ifContenido.document.insertar.btnArriba.disabled=false;		
	top.ifContenido.document.insertar.btnArriba.style.color=COLORACTIVO;		
	top.ifContenido.document.insertar.btnAbajo.disabled=false;		
	top.ifContenido.document.insertar.btnAbajo.style.color=COLORACTIVO;		
	top.ifContenido.document.insertar.btnVer.disabled=false;		
	top.ifContenido.document.insertar.btnVer.style.color=COLORACTIVO;		
	top.ifContenido.document.insertar.listaVistas.disabled=false;
	top.ifContenido.document.insertar.listaVistas.style.color=COLORACTIVO;
	
	top.ifContenido.document.insertar.txtNombreVista.value = "";
	top.ifContenido.document.insertar.selTipLetra.selectedIndex = 0;
	top.ifContenido.document.insertar.selTamLetra.selectedIndex = (pVTamLetra.def-pVTamLetra.minimo);
	top.ifContenido.document.insertar.selDesplegar.selectedIndex = 2;
	top.ifContenido.document.insertar.selOrientacion.selectedIndex = 0;
	top.ifContenido.document.insertar.selMostrar.selectedIndex = 0;
	top.ifContenido.document.insertar.selEnlaces.selectedIndex = 0;
	top.ifContenido.document.insertar.selMenu.selectedIndex = 0;
	
	actualizarVista()	
}

function modificarVista()
{
	if (top.ifContenido.document.insertar.btnAnadirVista.value!=botonAceptar)
	{
			var pos = top.ifContenido.document.insertar.listaVistas.selectedIndex;
			if (pos==-1)
			{
				pos = 0;
				top.ifContenido.document.insertar.listaVistas.selectedIndex = pos;
			}
			top.ifMapa.cargarMapa(0, parseInt(top.ifContenido.document.insertar.listaVistas.options[pos].value));
			var aux = top.ifMapa.mapa.vistasAux.buscar(parseInt(top.ifContenido.document.insertar.listaVistas.options[pos].value))
			top.ifContenido.document.insertar.txtNombreVista.value = aux.nombre;
			top.ifContenido.document.insertar.selTipLetra.selectedIndex = aux.tipoLetra;
			top.ifContenido.document.insertar.selTamLetra.selectedIndex = (aux.tamanoLetra-pVTamLetra.minimo);
			if (aux.desplegar!=-1)
				top.ifContenido.document.insertar.selDesplegar.selectedIndex = aux.desplegar;
			else
				top.ifContenido.document.insertar.selDesplegar.selectedIndex = 2;
			top.ifContenido.document.insertar.selOrientacion.selectedIndex = aux.orientacion;
			top.ifContenido.document.insertar.selMostrar.selectedIndex = aux.mostrar;
			if (aux.enlaces==0)
				top.ifContenido.document.insertar.selEnlaces.selectedIndex = 1;
			else
				top.ifContenido.document.insertar.selEnlaces.selectedIndex = 0;
			if(aux.menu==0)
				top.ifContenido.document.insertar.selMenu.selectedIndex = 1;
			else
				top.ifContenido.document.insertar.selMenu.selectedIndex = 0;
			
			top.ifContenido.document.insertar.btnAnadirVista.value=botonAceptar;		
			top.ifContenido.document.insertar.btnModificarVista.value=botonCancelar;		
			top.ifContenido.document.insertar.btnEliminarVista.disabled=true;		
			top.ifContenido.document.insertar.btnEliminarVista.style.color=COLORINACTIVO;		
			top.ifContenido.document.insertar.btnArriba.disabled=true;		
			top.ifContenido.document.insertar.btnArriba.style.color=COLORINACTIVO;		
			top.ifContenido.document.insertar.btnAbajo.disabled=true;		
			top.ifContenido.document.insertar.btnAbajo.style.color=COLORINACTIVO;		
			top.ifContenido.document.insertar.btnVer.disabled=true;		
			top.ifContenido.document.insertar.btnVer.style.color=COLORINACTIVO;		
			top.ifContenido.document.insertar.listaVistas.disabled=true;
			top.ifContenido.document.insertar.listaVistas.style.color=COLORINACTIVO;
			top.ifMapa.mapa.idVistaModif = parseInt(top.ifContenido.document.insertar.listaVistas.options[top.ifContenido.document.insertar.listaVistas.selectedIndex].value);
	}
	else
		resetBotonesModifVista()
}

function eliminarVista()
{
	if(confirm(pTxtConfBorrarVista))
	{
		top.ifMapa.mapa.borrarVista(parseInt(top.ifContenido.document.insertar.listaVistas.options[top.ifContenido.document.insertar.listaVistas.selectedIndex].value));	
		actualizarListaVistas();
		top.ifMapa.cargarMapa(0, -1);
	}
}

function moverVista(pDireccion)
{
	var posActual = top.ifContenido.document.insertar.listaVistas.selectedIndex;
	if (posActual>=0)
	{
		top.ifMapa.mapa.vistasAux.mover(posActual,pDireccion);
		actualizarListaVistas();
		top.ifContenido.document.insertar.listaVistas.selectedIndex = posActual+pDireccion;
	}
}

function aceptarVistas()
{
	var continuar=true;
	var error="";
	var fecha;
	var posX = top.ifContenido.document.insertar.txtX.value;
	var posY = top.ifContenido.document.insertar.txtY.value;
	
	if (top.ifContenido.document.insertar.btnAnadirVista.value==botonAceptar)
		continuar = confirm(pTxtConfCancelarVista);
		
	if(top.ifMapa.mapa.vistasAux.contenido.length==0)
		error = pTxtError_7;
	
	// comprobamos que la fecha introducida sea correcta
	if (continuar)
	{	
		fecha = top.ifContenido.document.insertar.txtFecha.value;
		if(fecha!="")
		{
			var arrayAux = fecha.split("/");
			if (arrayAux.length!=3) error = pTxtError_4;
			else
			{
				if ((arrayAux[0].length!=2) || (arrayAux[1].length!=2)|| (arrayAux[2].length!=4))
					error = pTxtError_4;
				else
				{
					var dia = parseInt(arrayAux[0],10);
					var mes = parseInt(arrayAux[1],10);
					var anyo = parseInt(arrayAux[2],10);
					if (isNaN(dia) || isNaN(mes) || isNaN(anyo)) error = pTxtError_4;
					else
					{
						if ((mes<1) || (mes>12))  error = pTxtError_5;
						else
						{
							if ((dia<1) || (dia>31))  error = pTxtError_5;
							else
							{
								if ((mes==4 || mes==6 || mes==9 || mes==11) && dia==31)  error = pTxtError_5;
								else
								{
									if(mes==2)
									{
										var bisiesto = (anyo % 4 == 0 && (anyo % 100 != 0 || anyo % 400 == 0));
										if (dia>29 || (dia==29 && !bisiesto)) error = pTxtError_5;
									}
								}
							}
						}
					}
				}
			}
		}
		var aux = comprobarNumero(posX);
		if (aux == -2) 
			error += pTxtError_0
				+ pVX.texto
				+ pTxtError_6;
		aux = comprobarNumero(posY);
		if (aux == -2) 
			error += pTxtError_0
				+ pVY.texto
				+ pTxtError_6;
		if (error!="")
		{
			error =pTxtError_2
			+ error
			+ pTxtError_3
			alert(error);
			continuar = false;
		}
	}
	if(continuar)
	{
		top.ifMapa.mapa.autor = top.ifContenido.document.insertar.txtAutor.value;
		top.ifMapa.mapa.email = top.ifContenido.document.insertar.txtEmail.value;
		top.ifMapa.mapa.fecha = top.ifContenido.document.insertar.txtFecha.value;
		top.ifMapa.mapa.datosGenerales = parseInt(top.ifContenido.document.insertar.selDatosGen.options[top.ifContenido.document.insertar.selDatosGen.selectedIndex].value);
		top.ifMapa.mapa.centrado = parseInt(top.ifContenido.document.insertar.selCentrado.options[top.ifContenido.document.insertar.selCentrado.selectedIndex].value);
		top.ifMapa.mapa.posX = parseInt(top.ifContenido.document.insertar.txtX.value);
		top.ifMapa.mapa.posY = parseInt(top.ifContenido.document.insertar.txtY.value);
		top.ifMapa.mapa.aceptarVistas();
		verResultado(pVTitulo, pVOk);
		actualizarTitulo(-1);
		top.mapaModif = true;
	}
}

function cancelarVistas()
{
	if (confirm(confCancelGen))
	{
		top.ifMapa.mapa.cancelarVistas();
		verResultado(pVTitulo, pVKo);
		actualizarTitulo(-1)
	}
}

function verVistaPre()
{
	if (top.estadoPersistencia==1)
	{
		alert(txtMensImportando);
		return;
	}
	if (top.estadoPersistencia==2)
	{
		alert(txtMensExportando);
		return;
	}
	var win = open("vpMapa.htm","","statusbar=NO,location=NO,menubar=NO,resizable=YES,scrollbars,status,WIDTH=790,HEIGHT=500");
}

function cargarImportar()
{
	if (top.estadoPersistencia==1)
	{
		alert(txtMensImportando);
		return;
	}
	if (top.estadoPersistencia==2)
	{
		alert(txtMensExportando);
		return;
	}
	var continuar = true;
	if ((top.ifMapa.mapa.estado != 2) && (top.ifMapa.mapa.modificado))
		continuar = (confirm(confCancelGen))
	if (continuar)
	{
		top.ifContenido.location = "importar.htm";
	}
}
/*
function verImportar()
{
	ocultarAyuda();
	top.ifMapa.mapa.estado = 2;
	top.ifMapa.mapa.modificado = false;
	top.ifMapa.cargarMapa(0, -1);
	actualizarTitulo(3);		
	document.getElementById("contenido").innerHTML = "";
	document.getElementById("contenido").innerHTML = "<div id='cont'>"
		+ "<iframe name='ifGuardar' height='0' widht='0' src='acceso.asp?ok=top.verPanelImportar()&ko=top.verNoAutorizado(1)' frameborder='0'></iframe>"
		+"</div>";
	top.calcHeight();
}
*/
function verPanelImportar(pModo)
{
	ocultarAyuda();
	top.ifMapa.mapa.estado = 2;
	top.ifMapa.mapa.modificado = false;
	var codigo = '<form name="importar" action="upload.asp" target="ifImportar" method="POST" ENCTYPE="multipart/form-data">'
		+ cabeceraPanel(pITitulo)
		+ '<tr>\n'
		+ '	<td colspan="3" width="760" height="10" ></td>\n'
		+ '</tr>\n'
		+ '<tr>\n'
		+ '	<td width="10" height="10"></td>\n'
		+ '  <td width="740" class="texto" align="center">\n'
	if (pModo!=null)
		codigo += '		<table class="TDAreaEdicion">\n'
			+ '			<tr><td>' +pICodigo.texto + ':</td></tr>\n'
			+ '			<tr><td><textarea cols="70" rows="10" class="texto" name="codigoXML"></textarea></td></tr>\n'
			+ '			<tr><td align="center"><input type="button" value="' + botonAceptar + '" class="btn" onClick="aceptarImp()"> <input type="button" value="' + botonCancelar +'" class="btn" onClick=\'verResultado("' + pITitulo + '","' + pIKo + '");actualizarTitulo(-1);\'> <input type="button" value="?" class="btnAyuda" onClick="ayudaCampo(\'' + pIPagAyuda + '#' + pICodigo.ayuda + '\')"></td></tr>\n'
			+ '		</table>\n'
	else
	{
		codigo += '		<div id="divImportar"><table class="TDAreaEdicion" width="500" border="0">\n'
			+ '			<tr><td>' + pIArchivo.texto + ': </td><td><input name="File1" type="file" class="texto"> <input type="button" value="' + botonAceptar + '" class="btn" onClick="aceptarImpMapa()"> <input type="button" value="?" class="btnAyuda" onClick="ayudaCampo(\'' + pIPagAyuda + '#' + pIArchivo.ayuda + '\')"></td></tr>\n'
		if (document.all)
		{
			re = /#/;
			codigo += '			<tr><td align="left" colspan="2">'
			 + pITxtImportar.replace(re, '<A HREF="javascript:verPanelImportar(1)">').replace(re, '</a>')
		}
		else
			codigo += '			<tr><td align="left" colspan="2">' + pINoExplorer + '</td></tr>\n'
		codigo += '		</table></div>\n'
	}
	codigo = codigo
		+ '	</td>\n'
		+ '	<td width="10" height="10"></td>\n'
		+ '</tr>\n'
		+ '<tr>\n'
		+ '	<td colspan="3" width="760" class="TDAreaEdicion" height="10"></td>\n'
		+ '</tr>\n'
		+ piePanel()
		+ '</form>\n';
	if (pModo==null)
	{
		codigo = codigo + '<iframe name="ifImportar" height="0" width="0" src="blanco.htm" frameborder="0"></iframe>'
	}
	document.getElementById("contenido").innerHTML = "";
	document.getElementById("contenido").innerHTML = "<div id='cont'>"+codigo+"</div>";
	top.calcHeight();
	actualizarTitulo(3);
}

function aceptarImpMapa()
{
	top.importar(document.importar.File1.value);
	document.getElementById("divImportar").innerHTML = "";
	document.getElementById("divImportar").innerHTML = '<table class="TDAreaEdicion" width="500" border="0">\n'
		+ '<tr><td align="center">' + pITxtImportando + '</td></tr>\n'
		+ '</table>'
	top.estadoPersistencia = 1;
}

function aceptarImp()
{
	top.ifMapa.importarMapa(document.importar.codigoXML.value);
	top.mapaModif = true;
}

function cancelarImp()
{
	top.ifContenido.document.insertar.codigoXML.value = "";
}

var textoMostrar="";
var tituloMostrar="";
function verResultado(pTitulo, pTexto, pAccion)
{
	top.textoMostrar = pTexto;
	top.tituloMostrar = pTitulo;
	top.ifContenido.location = "verResultado.htm";
	top.estadoPersistencia = -1;
	actualizarTitulo(-1);
}

function cargarAyuda()
{
	top.ifContenido.location = "ayuda.htm";
}

function verAyuda()
{
	if (top.estadoPersistencia==1)
	{
		alert(txtMensImportando);
		return;
	}
	if (top.estadoPersistencia==2)
	{
		alert(txtMensExportando);
		return;
	}
	var continuar=true;
	if ((top.ifMapa.mapa.estado != 2) && (top.ifMapa.mapa.modificado))
		continuar = (confirm(confCancelGen))
	if (continuar)
	{
		top.ifMapa.mapa.estado = 2;
		top.ifMapa.mapa.modificado = false;
		var codigoAyuda = "ayuda";
		var codigo = '<iframe name="ifAyuda" height="200" width="760" src="ayudaEditor.htm" frameborder="0"></iframe>'
		document.getElementById("ayuda").innerHTML = "";
		document.getElementById("ayuda").innerHTML = "<div id='cont'>"+codigo+"</div>";
		document.getElementById("ayuda").style.top = (parseInt(document.getElementById("cabecera").offsetHeight) +50)
			+ parseInt(document.getElementById("cabeceraGeneral").offsetHeight);
		document.getElementById("ayuda").style.visibility = "visible";
		document.getElementById("frame").style.visibility = "hidden";
		document.getElementById("subCabecera").innerHTML = "";
		top.actualizarTitulo(5);
		top.ifContenido.location = "blanco.htm";
		document.getElementById('ifContenido').style.height=1;
	}
}

function ocultarAyuda()
{
	top.document.getElementById("ayuda").innerHTML = "";
	top.document.getElementById("ayuda").style.visibility = "hidden";
	top.document.getElementById("frame").style.visibility = "visible";
}

function ayudaCampo(pLink)
{
	top.ifContAyuda.ifAyudaCampo.location = pLink;
	var ancho = 760;
	var yAux = top.document.getElementById("cabeceraGeneral").offsetHeight 
		+ top.document.getElementById("cabecera").offsetHeight
		+ top.document.getElementById("subCabecera").offsetHeight
		+ top.document.getElementById("frame").offsetHeight
		+ 20;
	var alto = parseInt(top.document.getElementById('ifContenido').style.height);
	top.document.getElementById("cAyudaCampo").style.left = Math.round((ancho - top.document.getElementById("cAyudaCampo").offsetWidth)/2);
	top.document.getElementById("cAyudaCampo").style.top = yAux + Math.round((alto - top.document.getElementById("cAyudaCampo").offsetHeight)/2);
	top.document.getElementById("cAyudaCampo").style.visibility = "visible";
	top.document.getElementById("cAyudaCampo").style.zIndex = 10000;
}

function cerrarAyuda()
{
	document.getElementById("cAyudaCampo").style.visibility = "hidden";
	document.getElementById("cAyudaCampo").style.left = "0px";
	document.getElementById("cAyudaCampo").style.top = "0px";
}

/*
function verNoAutorizado(pModo)
{
	if(pModo==0)
		verResultado(pGTitulo, pGKoNoAutorizado)
	if(pModo==1)
		verResultado(pITitulo, pIKoNoAutorizado)
	actualizarTitulo(-1);
	top.cabecera.mostrarForm();
}
*/

function cargarGuardar()
{
	if (top.estadoPersistencia==1)
	{
		alert(txtMensImportando);
		return;
	}
	if (top.estadoPersistencia==2)
	{
		alert(txtMensExportando);
		return;
	}
	ocultarAyuda();
	var continuar = true;
	if ((top.ifMapa.mapa.estado != 2) && (top.ifMapa.mapa.modificado))
		continuar = (confirm(confCancelGen))
	if (continuar)
	{
		top.ifMapa.mapa.estado = 2;
		top.ifMapa.mapa.modificado = false;
		top.ifMapa.cargarMapa(0, -1);
		top.actualizarTitulo(4);		
		top.ifContenido.location = "guardar.htm";
	}
}
/*
function verGuardar()
{
	ocultarAyuda();
	var continuar = true;
	if ((top.ifMapa.mapa.estado != 2) && (top.ifMapa.mapa.modificado))
		continuar = (confirm(confCancelGen))
	if (continuar)
	{
		top.ifMapa.mapa.estado = 2;
		top.ifMapa.mapa.modificado = false;
		top.ifMapa.cargarMapa(0, -1);
		actualizarTitulo(4);		
		document.getElementById("contenido").innerHTML = "";
		document.getElementById("contenido").innerHTML = "<div id='cont'>"
			+ "<iframe name='ifGuardar' height='0' width='0' src='acceso.asp?ok=top.verCondiciones()&ko=top.verNoAutorizado(0)' frameborder='0'></iframe>"
			+"</div>";
		top.calcHeight();
	}
}
*/
function verCondiciones(pEstado)
{
	ocultarAyuda();
	var codigo = '<form name="insertar" action="guardarMapa.asp" method="POST" target="ifGuardar">'
		+ cabeceraPanel(pGTitulo)
		+ '<tr>\n'
		+ '	<td colspan="3" width="760" height="10"></td>\n'
		+ '</tr>\n'
		+ '<tr>\n'
		+ '	<td width="10" height="10"></td>\n'
		+ '  <td width="740" class="texto" align="center">\n'
		+ '<table cellpading="0" cellspacing="0" border="0" width="500"><tr>'
	if (pEstado==null)
		codigo = codigo + '<td align="left" class="TDAreaEdicion">' + pGTxtCondiciones
	else
		codigo = codigo + '<td align="center" class="TDAreaEdicion">' + pGTxtGenerando
	codigo += '</td></tr></table>'
		+ '	</td>\n'
		+ '	<td width="10" height="10"></td>\n'
		+ '</tr>\n'
	if (pEstado==null)
		codigo = codigo 
			+ '<tr>\n'
			+ '	<td colspan="3" width="760" align="center"><input type="button" value="' + botonAceptar + '" class="btn" onClick="verCondiciones(true)">'
			+ ' <input type="button" value="' + botonCancelar + '" class="btn" onClick="verResultado(\'' + pGTitulo + '\',\'' + pGKo + '\');actualizarTitulo(-1);">'
			+ '</td>\n'
			+ '</tr>\n'
	codigo = codigo 
		+ piePanel()
	codigo = codigo
		+ '</form>\n'
	document.getElementById("contenido").innerHTML = "";
	document.getElementById("contenido").innerHTML = "<div id='cont'>"+codigo+"</div>";	
	top.calcHeight();
	if (pEstado!=null)
	{
		var parametros = top.ifMapa.mapa.codigoJS();

		if(top.ifMapa.mapa.autor=="") parametros += "¦¦¦" + "×";
		else parametros += "¦¦¦" + top.ifMapa.mapa.autor;
		if(top.ifMapa.mapa.fecha=="")	parametros += "¦¦¦" + "×";
		else parametros += "¦¦¦" + top.ifMapa.mapa.fecha;
		if(top.ifMapa.mapa.email=="")	parametros += "¦¦¦" + "×";
		else parametros += "¦¦¦" + top.ifMapa.mapa.email;
		if(top.ifMapa.mapa.centrado=="") parametros += "¦¦¦" + "0";
		else parametros += "¦¦¦" + top.ifMapa.mapa.centrado;
		if(top.ifMapa.mapa.posX=="") parametros += "¦¦¦" + "0";
		else parametros += "¦¦¦" + top.ifMapa.mapa.posX;
		if(top.ifMapa.mapa.posY=="") parametros += "¦¦¦" + "0";
		else parametros += "¦¦¦" + top.ifMapa.mapa.posY;
		if(top.ifMapa.mapa.textDescription()=="") parametros += "¦¦¦" + "×";
		else parametros += "¦¦¦" + top.ifMapa.mapa.textDescription();
		if(top.ifMapa.mapa.textKeywords()=="") parametros += "¦¦¦" + "×";
		else parametros += "¦¦¦" + top.ifMapa.mapa.textKeywords();
		if(top.ifMapa.mapa.raiz.nombre=="") parametros += "¦¦¦" + "×";
		else parametros += "¦¦¦" + top.ifMapa.mapa.raiz.nombre;

		top.exportar(parametros);
	}
}

function abrirMapa(pLink)
{
	open(pLink);
}


function verInfoGuardar(pLink)
{
	top.ifContenido.location = "infoGuardar.htm?linkGuardar=" + pLink;
	top.estadoPersistencia = -1;
}

function verErrorGuardar(numError)
{
	var re = /#/gi;
	verResultado(pGTitulo, pGError.replace(re, numError));
	actualizarTitulo(-1)
}

function verErrorImportar(numError)
{
	var re = /#/gi;
	verResultado(pITitulo, pIKoError2.replace(re, numError));
	actualizarTitulo(-1)
}

