//-----------------------------------------------------------------------------------//
function CambiarCapa(nom_capa)
{
        var Divs = document.body.getElementsByTagName("DIV");
        for(var i = 0; i < Divs.length; i++)
        {
        	if(Divs[i].id == 'botones' && nom_capa == 'internet')
             		Divs[i].style.top = '330px';
             	if(Divs[i].id == 'botones' && nom_capa == 'edicion')
             		Divs[i].style.top = '';
             	if(Divs[i].id != nom_capa && Divs[i].id != 'botones')
             	{
               		Divs[i].style.visibility = 'hidden';
             	}
             	else
             	{
               		Divs[i].style.visibility = 'visible';
               		if(Divs[i].id == 'internet')
               			Divs[i].style.top = '120px';
               }
		}
        if(nom_capa == 'internet')
        {
        	document.getElementById('pestanainternet').className='pestanaresaltada';
              	document.getElementById('pestanaedicion').className='pestana';
        }
        else
        {
           	document.getElementById('pestanainternet').className='pestana';
              	document.getElementById('pestanaedicion').className='pestanaresaltada';
        }
}
//--------------------------------------------------------------
function ComprobarTamano(campo, campo2, nom_div)
{
	if(document.getElementById(campo).value.length == 4 && document.getElementById(campo).value.charAt(0) == '0')
	{
		
		document.getElementById(campo).value = document.getElementById(campo).value.charAt(1) + document.getElementById(campo).value.charAt(2) + document.getElementById(campo).value.charAt(3)   ;
		
	}
	if(document.getElementById(campo).value.length > 2)
	{
		if(parseInt(document.getElementById(campo).value) > 100)
		{
			document.getElementById(nom_div).style.visibility = 'visible';			
		}
		else
		{
			document.getElementById(campo2).value  = document.getElementById(campo).value;
			document.getElementById(nom_div).style.visibility = 'hidden';
		}
	}
	else
	{
		document.getElementById(campo2).value  = document.getElementById(campo).value;	
		document.getElementById(nom_div).style.visibility = 'hidden';
	}
}
//-----------------------------------------------------------------------------------//
function EnviarDatos(accion, validar,clase)
{   
	var confirmacion = new Boolean(true);
	
	if(accion=='eliminar'){
		confirmacion = confirm('Confirmar eliminacion');	
	}
	if(confirmacion){
		if(validar)
		{
			if(ValidarFormulario(document.getElementById('formulario')))
			{
				document.getElementById('accion').value = accion;
				document.getElementById('clase').value=clase;
				document.formulario.submit();
				return true;
			}
			else
			{	
				alert('Debe completar los campos con *');
				return false;
			}
		}
		else
		{   
			document.getElementById('accion').value = accion;
			document.getElementById('clase').value = clase;
			document.formulario.submit();
			return true;
		}
	}
}
//-----------------------------------------------------------------------------------//
function ComprobarCampos(accion,validar,clase)
{
	var elemento;
        var encontrado = false;
  	for (i = 0; i < document.getElementById('formulario').length && !encontrado; i++)
	{
        	elemento = document.getElementById('formulario').elements[i];
                if ((Trim(elemento.value).length) > 0 && elemento.type != 'hidden')
                {
                  var encontrado = true
                }
	}
        if(encontrado)
		EnviarDatos(accion,validar,clase);
        else
        	alert('Debe introducir alg?n campo')
}
//-----------------------------------------------------------------------------------//
function reloj()
{
	var Digital=new Date()
	var day=Digital.getDate()
	var month=Digital.getMonth()+1
	var year=Digital.getFullYear()
	var hours=Digital.getHours()
	var minutes=Digital.getMinutes()
	var seconds=Digital.getSeconds()

	if (hours==0)   { hours=12; }
	if (minutes<=9) { minutes="0"+minutes }
	if (seconds<=9) { seconds="0"+seconds }
	if (day<=9)     { day="0"+day }
	if (month<=9)   { month="0"+month }

	var cdate=day+' - '+mes(month)+' - '+year
	var ctime=hours+":"+minutes+":"+seconds
	document.getElementById("reloj").innerHTML=""+cdate+" "+ctime+""
	setTimeout("reloj()",1000)
}
//-----------------------------------------------------------------------------------//
function mes(strMes)
{
	if(strMes==1)  { return "Enero" }
	if(strMes==2)  { return "Febrero" }
	if(strMes==3)  { return "Marzo" }
	if(strMes==4)  { return "Abril" }
	if(strMes==5)  { return "Mayo" }
	if(strMes==6)  { return "Junio" }
	if(strMes==7)  { return "Julio" }
	if(strMes==8)  { return "Agosto" }
	if(strMes==9)  { return "Septiembre" }
	if(strMes==10) { return "Octubre" }
	if(strMes==11) { return "Noviembre" }
	if(strMes==12) { return "Diciembre" }
}
//-----------------------------------------------------------------------------------//
function AdaptarResolucion()
{
	var ancho=screen.width;
      	var alto=screen.height;

	switch (ancho)
	{
		case (640):
			alto = 200;
		break;
		default:
			alto = alto*0.65;
	}
	return alto;
}
//------------------------------------------------------------------------------------------
function MostrarImagen(fra_imagen, fra_texto)
{
  try
  {
        //alert('file imagen ->' + document.getElementById('formulario').files.options[document.getElementById('formulario').files.selectedIndex].text +' ; file texto ->' + document.getElementById('formulario').files.options[document.getElementById('formulario').files.selectedIndex].value );
        //AbrirVentanaTarget(document.getElementById('formulario').files.options[document.getElementById('formulario').files.selectedIndex].text,600,600,fra_texto);
        //AbrirVentanaTarget(document.getElementById('formulario').files.options[document.getElementById('formulario').files.selectedIndex].value,600,600,fra_imagen);
        //var a = document.getElementById(fra_imagen);
        //a.innerHTML = '<iframe id="frameImagen" frameborder="1" name="frameImagen" src="file://c:\\004.jpg" height="350" width="100%"></iframe>';
	document.getElementById(fra_imagen).src = 'file://' +  document.getElementById('formulario').files.options[document.getElementById('formulario').files.selectedIndex].value;
	document.getElementById(fra_texto).src = 'file://' +  document.getElementById('formulario').files.options[document.getElementById('formulario').files.selectedIndex].id;
	//alert('file imagen ->' + document.getElementById(fra_imagen).src +' ; file texto ->' + document.getElementById(fra_texto).src );
        indice = document.getElementById('formulario').files.selectedIndex;
       	document.getElementById('siguiente').href="javascript:SiguienteImagen('frameImagen','frameTexto');";
       	document.getElementById('anterior').href="javascript:AnteriorImagen('frameImagen','frameTexto');";
        Visibilidad(document.getElementById('siguiente'),true);
        Visibilidad(document.getElementById('anterior'),true);
        Visibilidad(document.getElementById('files'),true);
        Visibilidad(document.getElementById('ficheros'),true);
        Visibilidad(document.getElementById('img_descargar'),false);
  }
  catch(e)
  {
    alert(e.message);
  }
}
//------------------------------------------------------------------------------------------
function SiguienteImagen(fra_imagen, fra_texto)
{
	indice++;
	if(indice < document.getElementById('formulario').files.options.length)
	{
		document.getElementById(fra_imagen).src = 'file://' +  document.formulario.files.options[indice].value;
		document.getElementById(fra_texto).src = 'file://' +  document.formulario.files.options[indice].id	;
	}
	else
	{
		alert('Ha llegado al final de la lista');
		indice = 0;
		document.getElementById(fra_imagen).src = 'file://' +  document.getElementById('formulario').files.options[indice].value;
		document.getElementById(fra_texto).src = 'file://' +  document.getElementById('formulario').files.options[indice].id;
	}
	document.getElementById('formulario').files.options[indice].selected = true;
}
//------------------------------------------------------------------------------------------
function AnteriorImagen(fra_imagen, fra_texto)
{
  if(indice > 0)
  {
	indice--;
	if(indice < document.getElementById('formulario').files.options.length)
	{
		document.getElementById(fra_imagen).src = 'file://' +  document.formulario.files.options[indice].value;
		document.getElementById(fra_texto).src = 'file://' +  document.formulario.files.options[indice].id;
	}
	document.getElementById('formulario').files.options[indice].selected = true;
  }
}
//------------------------------------------------------------------------------------------
function addFile(fileImagen,fileTexto)
{
  	//alert('file imagen = ' + fileImagen + ' , file texto = ' + fileTexto + ' , length = ' +document.formulario.files.length);
	document.getElementById('formulario').files.options[document.formulario.files.length] = new Option(fileImagen.substring(fileImagen.lastIndexOf('\\') + 1,fileImagen.length) ,fileImagen,false,true);
      	document.getElementById('formulario').files.options[document.formulario.files.length - 1].id = fileTexto;
	document.getElementById('formulario').files.options[0].selected = true;
}
//------------------------------------------------------------------------------------------
function clearFiles()
{
	Visibilidad(document.getElementById('img_descargar'),true);
	document.getElementById('formulario').files.options.length = 0;
}
//------------------------------------------------------------------------------------------
function numFiles(num)
{
	if(document.getElementById('formulario').files.length <= num)
        {
        	document.getElementById('formulario').files.size = document.formulario.files.length;
        }
	else
	{
		document.getElementById('formulario').files.size = num;
	}
       	document.getElementById('siguiente').href="javascript:SiguienteImagen('frameImagen','frameTexto');";
       	document.getElementById('anterior').href="javascript:AnteriorImagen('frameImagen','frameTexto');";
       // Visibilidad(document.getElementById('siguiente'),true);
        //Visibilidad(document.getElementById('anterior'),true);
}
//------------------------------------------------------------------------------------------
function CambiarTamano(tam_actual)
{
	if(tam_actual == '1%')
	{
		return '25%';
	}
	else
	{
		return '1%';
	}
}

//------------------------------------------------------------------------------------------
function AnadirDatoDefecto (nom_campo, codigoDato)
{
  AbrirVentana2('../dato_defecto.jsp?clase=es.intecna.xml.estructura.DatoDefecto&cod_dato=' +codigoDato + '&nom_campo=' + nom_campo +'&accion=&emergente=true', 500, 150);
}
//------------------------------------------------------------------------------------------
function SeleccionarDatoDefecto (nom_campo, codigoDato)
{
  AbrirVentana2('../lista_datos_defecto.jsp?clase=es.intecna.xml.estructura.Dato&cod_dato=' +codigoDato + '&nom_campo=' + nom_campo +'&accion=leer&emergente=true', 600, 500);
}
//------------------------------------------------------------------------------------------
function FuncionLista(valor, nom_campo)
{
  window.opener.RellenarCampo(nom_campo,valor);
  Cerrar();
}
//------------------------------------------------------------------------------------------
function seleccionarTodos(nom_checkbox)
{
	for (var i=0; i < document.getElementById('formulario').length; i++)
        {
          	var elemento = document.getElementById('formulario').elements[i];
                if(elemento.type == 'checkbox' && elemento.name.toString().indexOf(nom_checkbox) >= 0)
                {
                	elemento.checked = true;
        	}
	}
}
//------------------------------------------------------------------------------------------
function desseleccionarTodos(nom_checkbox)
{
	for (var i=0; i < document.getElementById('formulario').length; i++)
        {
          	var elemento = document.getElementById('formulario').elements[i];
                if(elemento.type == 'checkbox' && elemento.name.toString().indexOf(nom_checkbox) >= 0)
                {
                	elemento.checked = false;
        	}
	}
}
//------------------------------------------------------------------------------------------
function Selector(nom_checkbox)
{
	if(document.getElementById('selector').checked)
        	seleccionarTodos(nom_checkbox);
        else
        	desseleccionarTodos(nom_checkbox);
}
//------------------------------------------------------------------------------------------
function CambiaPermiso(imagen, hast, tipoOperacion, codigoTipoOperacionEnte)
{
  var permisosTipoEnte = hast.get(tipoOperacion);
  if(permisosTipoEnte[2] == '1')
  	permisosTipoEnte[2] = '0'
  else
	permisosTipoEnte[2] = '1'
  permisosTipoEnte[3] = codigoTipoOperacionEnte;
  if(permisosTipoEnte[0] == '0')
  {
    permisosTipoEnte[0] = '1';
    hast.put(tipoOperacion, permisosTipoEnte);
    imagen.src = 'img/ok.gif';
    imagen.alt = 'Permiso concedido';
  }
  else
  {
    permisosTipoEnte[0] = '0';
    hast.put(tipoOperacion, permisosTipoEnte);
    imagen.src = 'img/denegar.gif';
    imagen.alt = 'Permiso denegado';
  }
  //alert(hast.toString());
  return hash;
}
//------------------------------------------------------------------------------------------
function GuardarPermisos(hash, accion)
{
  var codigoUsuario = document.getElementById('cod_usuario').value;
  var codigoGrupo = document.getElementById('cod_grupo').value;
  var codigosTiposOperaciones = hash.keys();
  var numeroAlteraciones = 0;
  document.getElementById('cod_tip_operacion').value = '';
  document.getElementById('cod_usu_tip_ope_ente').value = '';
  document.getElementById('cod_tip_ente').value = '';
  document.getElementById('cod_ente').value = '';
  document.getElementById('per_denegados').value = '';
  document.getElementById('cod_usuario').value = '';
  document.getElementById('cod_grupo').value = '';

  for(var i = 0; i < codigosTiposOperaciones.length; i++)
  {
    var permisoTipoEnte = hash.get(codigosTiposOperaciones[i])
    if(permisoTipoEnte[2] == '1')
    {
      numeroAlteraciones++;
      document.getElementById('cod_tip_operacion').value += codigosTiposOperaciones[i] + '/~/'
      document.getElementById('cod_tip_ente').value += permisoTipoEnte[1] + '/~/'
      document.getElementById('cod_ente').value += permisoTipoEnte[4] + '/~/'
      document.getElementById('cod_usu_tip_ope_ente').value += permisoTipoEnte[3] + '/~/'
      document.getElementById('cod_gru_tip_ope_ente').value += permisoTipoEnte[3] + '/~/'
      document.getElementById('cod_usuario').value += codigoUsuario + '/~/';
      document.getElementById('cod_grupo').value += codigoGrupo + '/~/';
    }
  }
  if(numeroAlteraciones > 0)
  {
    if (codigoUsuario > 0)
    {
	document.getElementById('clase').value = 'es.intecna.administracion.estructura.UsuarioTipoOperacionEnte';
	document.getElementById('cla_padre').value = 'es.intecna.administracion.estructura.UsuarioTipoOperacionEnte';
    }
    else
    {
      	document.getElementById('clase').value = 'es.intecna.administracion.estructura.GrupoTipoOperacionEnte';
	document.getElementById('cla_padre').value = 'es.intecna.administracion.estructura.GrupoTipoOperacionEnte';
    }

    document.getElementById('accion').value = accion;

  /*alert('TipoOperacion: ' + document.getElementById('cod_tip_operacion').value);
  alert('TipoEnte: ' + document.getElementById('cod_tip_ente').value);
  alert('CodigoEnte: ' + document.getElementById('cod_ente').value);
  alert('Id_USU: ' + document.getElementById('cod_usu_tip_ope_ente').value);
  alert('Id_gru: ' + document.getElementById('cod_usu_tip_ope_ente').value);
  alert('CodigoUsuario: ' + document.getElementById('cod_usuario').value);
  alert('Codigogrupo: ' + document.getElementById('cod_grupo').value);*/


    document.getElementById('formulario').submit();
  }
  else
  {
    document.getElementById('cod_usuario').value = codigoUsuario;
    document.getElementById('cod_grupo').value = codigoGrupo;
    alert('No se ha alterado ningún permiso');
  }
}
//------------------------------------------------------------------------------------------
function CambiaPermisoEnte(imagen, hast, tipoOperacion, codigoTipoOperacionEnte, condigoEnte)
{
  var permisosTipoEnte = hast.get(tipoOperacion+'-'+condigoEnte);
  if(permisosTipoEnte[2] == '1')
  	permisosTipoEnte[2] = '0'
  else
	permisosTipoEnte[2] = '1'
  permisosTipoEnte[3] = codigoTipoOperacionEnte;
  if(permisosTipoEnte[0] == '0')
  {
    permisosTipoEnte[0] = '1';
    hast.put(tipoOperacion+'-'+condigoEnte, permisosTipoEnte);
    imagen.src = 'img/ok.gif';
    imagen.alt = 'Permiso concedido';
  }
  else
  {
    permisosTipoEnte[0] = '0';
    hast.put(tipoOperacion+'-'+condigoEnte, permisosTipoEnte);
    imagen.src = 'img/denegar.gif';
    imagen.alt = 'Permiso denegado';
  }
  //alert(hast.toString());
  return hash;
}
//------------------------------------------------------------------------------------------
function GuardarPermisosEnte(hash, accion)
{
  var codigoUsuario = document.getElementById('cod_usuario').value;
  var codigoGrupo = document.getElementById('cod_grupo').value;
  var codigosTiposOperaciones = hash.keys();
  var numeroAlteraciones = 0;
  document.getElementById('cod_tip_operacion').value = '';
  document.getElementById('cod_usu_tip_ope_ente').value = '';
  document.getElementById('cod_tip_ente').value = '';
  document.getElementById('cod_ente').value = '';
  document.getElementById('per_denegados').value = '';
  document.getElementById('cod_usuario').value = '';
  document.getElementById('cod_grupo').value = '';

  for(var i = 0; i < codigosTiposOperaciones.length; i++)
  {
    var permisoTipoEnte = hash.get(codigosTiposOperaciones[i])
    if(permisoTipoEnte[2] == '1')
    {
      numeroAlteraciones++;
      document.getElementById('cod_tip_operacion').value += codigosTiposOperaciones[i].split('-')[0] + '/~/'
      document.getElementById('cod_tip_ente').value += permisoTipoEnte[1] + '/~/'
      document.getElementById('cod_ente').value += permisoTipoEnte[4] + '/~/'
      document.getElementById('cod_usu_tip_ope_ente').value += permisoTipoEnte[3] + '/~/'
      document.getElementById('cod_gru_tip_ope_ente').value += permisoTipoEnte[3] + '/~/'
      document.getElementById('cod_usuario').value += codigoUsuario + '/~/';
      document.getElementById('cod_grupo').value += codigoGrupo + '/~/';
    }
  }
  if(numeroAlteraciones > 0)
  {
    if (codigoUsuario > 0)
    {
	document.getElementById('clase').value = 'es.intecna.administracion.estructura.UsuarioTipoOperacionEnte';
	document.getElementById('cla_padre').value = 'es.intecna.administracion.estructura.UsuarioTipoOperacionEnte';
    }
    else
    {
      	document.getElementById('clase').value = 'es.intecna.administracion.estructura.GrupoTipoOperacionEnte';
	document.getElementById('cla_padre').value = 'es.intecna.administracion.estructura.GrupoTipoOperacionEnte';
    }

    document.getElementById('accion').value = accion;
    document.getElementById('formulario').submit();
  }
  else
  {
    document.getElementById('cod_usuario').value = codigoUsuario;
    document.getElementById('cod_grupo').value = codigoGrupo;
    alert('No se ha alterado ningún permiso');
  }
}
//------------------------------------------------------------------------------------------
function RellenarIdioma(nom_input)
{

  var idiomas = '';
  var campo = eval("document.getElementById('"+nom_input+"')");
  campo.value = '';
  for(var i = 0; i < campo.options.length; i++)
  {
    //alert('entro->' + campo.options[i].text + ', selected ->' + campo.options[i].selected);
    if(campo.options[i].selected == true)
    {
	    idiomas += campo.options[i].value + ',';
            campo.options[i].selected = true;
    }
  }
  if(idiomas.length > 0)
  	idiomas = idiomas.substring(0,idiomas.length -1);
  document.getElementById('idiomas').value = idiomas;
  //alert(document.getElementById('idiomas').value);

}
//------------------------------------------------------------------------------------------
function Seleccionar (id, nombre, apellidos, nom_cam_nombre, nom_cam_codigo)
{

  if(window.opener != null)
  {
    if(window.opener.document.getElementById(nom_cam_nombre) != null && window.opener.document.getElementById(nom_cam_codigo) != null)
    {
      if(Trim(window.opener.document.getElementById(nom_cam_nombre).value).length > 0)
      {
      	window.opener.document.getElementById(nom_cam_nombre).value += '; ' + nombre + ' ' + apellidos;
      }
      else
      {
        window.opener.document.getElementById(nom_cam_nombre).value = nombre + ' ' + apellidos;
      }
      window.opener.document.getElementById(nom_cam_codigo).value += '/~/ ' + id;
    }
  }
}
//------------------------------------------------------------------------------------------
function SeleccionarDestinatario(email, nom_cam_email)
{
 if(window.opener != null)
  {
    if(window.opener.document.getElementById(nom_cam_email) != null)
    {
      if(Trim(window.opener.document.getElementById(nom_cam_email).value).length > 0)
      {
      	if(email != 'null')
      		window.opener.document.getElementById(nom_cam_email).value += '; ' + email;
      }
      else
      {
      	if(email != 'null')
        	window.opener.document.getElementById(nom_cam_email).value = email;
      }
    }
  }
}
//------------------------------------------------------------------------------------------
function NextFile()
{

	var coll = document.getElementsByName("file"+indice);
      	indice++;
      	var LatestFile = coll[coll.length - 1];
      	var objBr = document.createElement("<br>");
      	LatestFile.insertAdjacentElement("afterEnd", objBr);
      	var objFile = document.createElement('<input type="file" name="file'+indice+'" onchange="NextFile()" size="63" ID="file'+indice+'">');
      	objBr.insertAdjacentElement("afterEnd", objFile);
      	document.getElementById("num_adjuntos").value = indice;
}
//------------------------------------------------------------------------------------------
function Responder(cod_mensaje, receptor, cod_receptor, asunto)
{
    	AbrirVentana2('mensaje.jsp?accion=&cla_padre=es.intecna.mensajeria.estructura.Mensaje&mos_formulario=true&relacion=cod_mensaje&clase=es.intecna.mensajeria.estructura.Mensaje&cod_mensaje=0&id_padre='+ cod_mensaje + '&noms_usuarios=' + receptor + '&cod_receptores=' + cod_receptor + '&asunto=RE: ' + asunto ,600,600);
}
//-----------------------------------------------------------------------------------//
function OcultarMostrarRecurso(n_idiomas, new_idioma, cod_idioma)
{

		// Establecemos pesta?a resaltada junto a visibilidad del formulario
		for(var i=0; i<=n_idiomas; i++){
			Visibilidad(document.getElementById('div'+i), false);
			document.getElementById('pestana'+i).className = "pestana";
			document.getElementById('pestana'+i).style.cursor = "pointer";
		}
		Visibilidad(document.getElementById('div'+new_idioma), true);
		document.formulario.cod_idioma_aux.value = cod_idioma;
		document.getElementById('pestana'+new_idioma).className = "pestanaresaltada";
		document.getElementById('pestana'+new_idioma).style.cursor = "default";


		// Establecimiento de campos obligatorios
		if (cod_idioma == 0){
			document.getElementById('nom_recurso_aux_0').etiqueta="*Nombre";
			document.getElementById('ruta_aux_0').etiqueta="*Ruta";
			document.getElementById('cod_tip_recurso_aux_0').etiqueta="*Tipo de recurso";

			for(var i=1; i<=n_idiomas; i++){
				document.getElementById('nom_recurso_aux_'+i).etiqueta="Nombre";
				document.getElementById('ruta_aux_'+i).etiqueta="Ruta";
				document.getElementById('cod_tip_recurso_aux_'+i).etiqueta="Tipo de recurso";
			}
		}
		else if  (cod_idioma>0){
			document.getElementById('nom_recurso_aux_0').etiqueta="Nombre";
			document.getElementById('ruta_aux_0').etiqueta="Ruta";
			document.getElementById('cod_tip_recurso_aux_0').etiqueta="Tipo de recurso";
			for(var i=1; i<=n_idiomas; i++){
				document.getElementById('nom_recurso_aux_'+i).etiqueta="*Nombre";
				document.getElementById('ruta_aux_'+i).etiqueta="*Ruta";
				document.getElementById('cod_tip_recurso_aux_'+i).etiqueta="*Tipo de recurso";
			}
		}
}
//-----------------------------------------------------------------------------------//
function CopiarEntradas(n_idiomas, cod_idiomas) {

    	// Declaraciones
    	var temp = new Array();
        var cod_recurso;
	var id_recurso;
    	var fec_alta;
    	var cod_estado;

	// Compruebo si anteriormente se ha producido una concatenacion
        temp = (document.getElementById('cod_recurso').value).split('/~/');

    	// Si no se ha producido concatenacion anterior la realizo para los campos no introducidos en formulario
    	if(temp.length==1)
        {
    		cod_recurso = document.getElementById('cod_recurso').value;
    		id_recurso = document.getElementById('id_recurso').value;
    		fec_alta = document.getElementById('fec_alta').value;
    		cod_estado = document.getElementById('cod_estado').value;

    		for (var i=2; i<=n_idiomas; i++)
                {
    			document.getElementById('cod_recurso').value=document.getElementById('cod_recurso').value+"/~/"+cod_recurso;
    			document.getElementById('id_recurso').value=document.getElementById('id_recurso').value+"/~/"+id_recurso;
    			document.getElementById('fec_alta').value=document.getElementById('fec_alta').value+"/~/"+fec_alta;
    			document.getElementById('cod_estado').value=document.getElementById('cod_estado').value+"/~/"+cod_estado;
    		}
    	}
    	document.getElementById('cod_idioma').value = cod_idiomas;

    	// Concateno los campos introducidos dependiendo del idioma
    	if(document.formulario.cod_idioma_aux.value==0)
        {
    		// Seleccionada la pesta?a 'Todos'
    		document.getElementById('nom_recurso').value=document.getElementById('nom_recurso_aux_0').value;
    		document.getElementById('ruta').value=document.getElementById('ruta_aux_0').value;
    		document.getElementById('cod_tip_recurso').value=document.getElementById('cod_tip_recurso_aux_0').value;

    		for (var i=2; i<=n_idiomas; i++)
                {
    			document.getElementById('nom_recurso').value=document.getElementById('nom_recurso').value+"/~/"+
    			document.getElementById('nom_recurso_aux_0').value;
    			document.getElementById('ruta').value=document.getElementById('ruta').value+"/~/"+
    			document.getElementById('ruta_aux_0').value;
    			document.getElementById('cod_tip_recurso').value=document.getElementById('cod_tip_recurso').value+"/~/"+
    			document.getElementById('cod_tip_recurso_aux_0').value;
    		}
    	}
    	else
        {
    		// Seleccionada la pesta?a de un idioma
    		document.getElementById('nom_recurso').value=document.getElementById('nom_recurso_aux_1').value;
    		document.getElementById('ruta').value=document.getElementById('ruta_aux_1').value;
    		document.getElementById('cod_tip_recurso').value=document.getElementById('cod_tip_recurso_aux_1').value;

    		for (var i=2; i<=n_idiomas; i++)
                {
    			document.getElementById('nom_recurso').value=document.getElementById('nom_recurso').value+"/~/"+
    			document.getElementById('nom_recurso_aux_'+i).value;
    			document.getElementById('ruta').value=document.getElementById('ruta').value+"/~/"+
    			document.getElementById('ruta_aux_'+i).value;
    			document.getElementById('cod_tip_recurso').value=document.getElementById('cod_tip_recurso').value+"/~/"+
    			document.getElementById('cod_tip_recurso_aux_'+i).value;
    		}
    	}
}
//-----------------------------------------------------------------------------------//

function AnadirDocumentoRelacionado(cod_documento, url)
{
	AbrirEnVentana(url+'&id_relacion=&accion=crear&clase=es.intecna.documento.estructura.DocumentoRelacionado&id_doc_relacionado='+cod_documento);
}
//------------------------------------------------------------------------------
function AnadirParticipanteRelacionado(parametros, url)
{
	var parametrosResultantes = parametros.split('/~/');
	if(parametrosResultantes[4]=='null')
		parametrosResultantes[4] = '';
	if(parametrosResultantes[1]=='null')
		parametrosResultantes[1] = '';
	if(parametrosResultantes[2]=='null')
		parametrosResultantes[2] = '';
	if(parametrosResultantes[3]=='null')
		parametrosResultantes[3] = '';
	if(parametrosResultantes[5] =='null')
		parametrosResultantes[5]='';
	AbrirEnVentana(url+'&clase=es.intecna.proyecto.estructura.Participante&nom_participante='+parametrosResultantes[1]+'&ape_participante='+parametrosResultantes[2]+'&entidad='+parametrosResultantes[3]+'&email='+parametrosResultantes[4]+'&telefono='+parametrosResultantes[5]);
	//AbrirEnVentana(url+'&cod_gru_tra_participante=&accion=crear&clase=es.intecna.proyecto.estructura.GrupoTrabajoParticipante&cod_participante='+cod_participante);
}
//------------------------------------------------------------------------------
function AnadirTareaIntegrante(cod_tarea, url)
{
	AbrirEnVentana(url+'&accion=crear&cod_tar_integrante=&clase=es.intecna.proyecto.estructura.TareaIntegrante&cod_tarea='+cod_tarea);
}
//------------------------------------------------------------------------------
function AnadirTareaPredecesora(cod_tarea, url)
{
	AbrirEnVentana(url+'&accion=crear&cod_rel_tar_predecesora=&clase=es.intecna.proyecto.estructura.TareaPredecesora&cod_tar_predecesora='+cod_tarea);
}
//------------------------------------------------------------------------------
function AnadirIntegranteRelacionado(parametros, url)
{
	var parametrosResultantes = parametros.split('/~/');
	if(parametrosResultantes[0]=='null')
		parametrosResultantes[0] = '';
	if(parametrosResultantes[1]=='null')
		parametrosResultantes[1] = '';
	if(parametrosResultantes[2]=='null')
		parametrosResultantes[2] = '';
	AbrirEnVentana(url+'&clase=es.intecna.proyecto.estructura.Integrante&cod_participante='+parametrosResultantes[0]+'&nombre='+parametrosResultantes[1]+'&apellidos='+parametrosResultantes[2]+'&entidad='+parametrosResultantes[3]);
}
//--------------------------------------------------------------------------------
function AnadirParticipanteLdap(parametros)
{
	var parametrosResultantes = parametros.split('/~/');
	window.opener.document.formulario.nom_participante.value=parametrosResultantes[0];
	if(parametrosResultantes[1]!='null')
		window.opener.document.formulario.ape_participante.value=parametrosResultantes[1];
	if(parametrosResultantes[2]!='null')
		window.opener.document.formulario.telefono.value=parametrosResultantes[2];
	if(parametrosResultantes[3] !='null')
		window.opener.document.formulario.email.value=parametrosResultantes[3];
	window.opener.document.formulario.nom_participante.focus();
/*	if(parametrosResultantes[1].length > 0)
	{
		var cadena = parametrosResultantes[0].toLowerCase()+'.'+parametrosResultantes[1].toLowerCase();
		cadena = ReplaceAll(cadena," ",".");
		window.opener.document.formulario.usu_ldap.value=cadena;
	}
	else
	{
		var cadena = parametrosResultantes[0].toLowerCase();
		cadena = ReplaceAll(cadena," ",".");
		window.opener.document.formulario.usu_ldap.value=cadena;
	}*/
	self.close();
}

//------------------------------------------------------------------------------
function AnadirResponsableDocumento(url, nom_input)
{

	var elemento;
	var campo;
	campo = eval('document.formulario.' + nom_input);
	campo.value = '';

	for (i = 0; i < document.getElementById('formulario').length; i++)
	{
			elemento = document.getElementById('formulario').elements[i];
			if (elemento.name.length > campo.name.length)
			{
				if (elemento.name.substring(0, campo.name.length) == campo.name && elemento.checked)
					campo.value = campo.value + '/~/' + elemento.value;
			}
   }
   if (campo.value.length > 0)
   {
		campo.value = campo.value.substring(3, campo.value.length);
		AbrirEnVentana(url+'&id_relacion=&accion=crear&clase=es.intecna.documento.estructura.DocumentoResponsable&id_responsable=&id_usuario='+campo.value);
   }
   else
   {
      alert('Debe seleccionar un usuario');
   }

}
//------------------------------------------------------------------------------
function EliminarParticipante(nom_ente, nom_input, cla_padre, paginacion)
{
	var elemento;
	var campo;
	var confirmar;
	campo = eval('document.formulario.' + nom_input);
	campo.value = '';

	for (i = 0; i < document.getElementById('formulario').length; i++)
	{
		elemento = document.getElementById('formulario').elements[i];
		//alert(elemento.name+' '+campo.name);
		if (elemento.name.length > campo.name.length)
		{
			if (elemento.name.substring(0, campo.name.length) == campo.name && elemento.checked)
				campo.value = campo.value + '/~/' + elemento.value;
		}
    }
    if (campo.value.length > 0)
    {
         var mensaje;
		mensaje = '?Est? seguro de eliminar el(los) objeto(s)?';
		confirmar = confirm(mensaje);
		if (confirmar == true)
		{
			mensaje = '?Desea eliminar el participante de todos los grupos de trabajo?'
			confirmar = confirm(mensaje);
			if(confirmar == true)
				document.getElementById('eli_completo').value = true;
			else
				document.getElementById('eli_completo').value = false;
			campo.value = campo.value.substring(3, campo.value.length);
			document.getElementById('accion').value = 'eliminar';
            document.getElementById('clase').value = nom_ente;
            document.getElementById('cla_padre').value = cla_padre;
			document.getElementById(nom_input).value = campo.value;
            document.getElementById(paginacion).value = 0;
			document.formulario.submit();
		}
    }
    else
    {
        alert('Debe seleccionar un objeto');
    }


}
//------------------------------------------------------------------------------
function EliminarDocumento(nom_ente, nom_input, cla_padre, paginacion)
{
	var elemento;
	var campo;
	var confirmar;
	campo = eval('document.formulario.' + nom_input);
	campo.value = '';

	for (i = 0; i < document.getElementById('formulario').length; i++)
	{
		elemento = document.getElementById('formulario').elements[i];
		//alert(elemento.name+' '+campo.name);
		if (elemento.name.length > campo.name.length)
		{
			if (elemento.name.substring(0, campo.name.length) == campo.name && elemento.checked)
				campo.value = campo.value + '/~/' + elemento.value;
		}
    }
    if (campo.value.length > 0)
    {
         var mensaje;
		mensaje = '?Est? seguro de eliminar el(los) objeto(s)?';
		confirmar = confirm(mensaje);
		if (confirmar == true)
		{
			mensaje = '?Desea eliminar el documento de todos los grupos de trabajo?'
			confirmar = confirm(mensaje);
			if(confirmar == true)
				document.getElementById('eli_completo').value = true;
			else
				document.getElementById('eli_completo').value = false;
			campo.value = campo.value.substring(3, campo.value.length);
			document.getElementById('accion').value = 'eliminar';
            document.getElementById('clase').value = nom_ente;
            document.getElementById('cla_padre').value = cla_padre;
			document.getElementById(nom_input).value = campo.value;
            document.getElementById(paginacion).value = 0;
			document.formulario.submit();
		}
    }
    else
    {
        alert('Debe seleccionar un objeto');
    }


}
//------------------------------------------------------------------------------
function IconoTipoElemento(tipoElemento)
{
  if(tipoElemento.value == 3)
  	document.getElementById('img_tip_elemento').src = './img/carpeta.gif';
  else
  	document.getElementById('img_tip_elemento').src = './img/page.gif';
}
//------------------------------------------------------------------------------
function RecargarArbol()
{
	var ventana = eval('window');
        if(ventana.name == 'contenido')
        {
            for(var i = 0; i < ventana.parent.frames.length; i++)
            {
              if(ventana.parent.frames[i].name == 'arbol')
              	ventana.parent.frames[i].location.reload();
            }
        }
        else
        {
	        while (ventana != null && ventana != undefined)
        	{
	          if (ventana.name == 'contenido')
        	  {
	            for(var i = 0; i < ventana.parent.frames.length; i++)
        	    {
	              if(ventana.parent.frames[i].name == 'arbol')
        	      	ventana.parent.frames[i].location.reload();
	            }
        	  }
	          ventana = ventana.opener;
        	}
        }
}
//------------------------------------------------------------------------------
function GuardarDirectorioUsuario(directorio)
{
 	document.getElementById('dir_ficheros').value = directorio;
 	if(window.opener != null && window.opener.document.getElementById('mi_directorio') != null)
	{
    	window.opener.document.getElementById('mi_directorio').alt = 'Mi directorio: ' + directorio + '\\' + window.opener.document.getElementById('dir_contenido').value + '\\';
    }
}
//------------------------------------------------------------------------------
function IrAConfiguracion()
{
	document.location.href = '/pi/fpi/configuracion.jsp?clase=es.intecna.fpi.estructura.ConfiguracionFpi&accion=buscar&cod_usuario=&cod_configuracion=&dir_ficheros=&emergente=true';
	/*var ventana = eval('window');
    while (ventana != null && ventana != undefined)
  	{
     	if (ventana.opener == null)
      	{
      		ventana.parent.document.location.href = '/pi/fpi/configuracion.jsp?clase=es.intecna.fpi.estructura.ConfiguracionFpi&accion=buscar&cod_usuario=&cod_configuracion=&dir_ficheros=';
        }
	    ventana = ventana.opener;
    }
    if(window.document.getElementById('emergente').value = 'true')
	    self.close();*/
}
//------------------------------------------------------------------------------
function AbrirSelector()
{
	AbrirVentana2('/pi/fpi/selector.jsp?clase=es.intecna.fpi.estructura.ConfiguracionFpi&accion=buscar&cod_usuario=&cod_configuracion=&dir_ficheros=&dir_contenido='+ document.getElementById('dir_contenido').value,600,200);
}
//------------------------------------------------------------------------------
function AbrirImagen()
{
	if(document.getElementById('pathlocalimagen').value.length > 0)
		AbrirVentanaRedimensionable('file://' + document.getElementById('mi_directorio').alt.substring(document.getElementById('mi_directorio').alt.indexOf(':',0)+ 2,document.getElementById('mi_directorio').alt.length) + document.getElementById('pathlocalimagen').value, 600,600);

	else
		alert('No hay ning?n archivo seleccionado');
}

function AbrirImagen2(){

	var ancho;
	var alto;
	var factor_alto;
	var factor_ancho;
	var nombre;

	nombre = document.getElementById('fotonombre').value;

	if(nombre.length > 0){
		if(nombre.toLowerCase().indexOf(".jpg")>=0){
			ancho = document.getElementById('fotoancho').value;
			alto = document.getElementById('fotoalto').value

			factor_alto = 600 / alto;
			factor_ancho = 600 / ancho;

			if((factor_alto < 1) || (factor_ancho < 1)) {
				// alto o ancho mayor que 600 --> redimensionar
				if(factor_alto < factor_ancho){
					// Mas alta que ancha
					alto = 600;
					ancho = ancho * factor_alto;
				}
				else {
					// Mas ancha que alta
					ancho = 600;
					alto = alto * factor_ancho;
				}
			}

			AbrirVentanaRedimensionable('file://' + document.getElementById('archivonombre').value, ancho, alto);
		}
		else
			AbrirVentanaRedimensionable('file://' + document.getElementById('archivonombre').value, 600, 600);
	}
	else
		alert('No hay ning?n archivo seleccionado');
}

//------------------------------------------------------------------------------
function GuardarPathFichero(nombre)
{
	var ini = nombre.indexOf(document.getElementById('dir_contenido').value, 0) + document.getElementById('dir_contenido').value.length + 1;
	var width = 0;
	var img_obj = new Image();
	var nombre2;

	var cadena = nombre.substring(ini, nombre.length);
	window.opener.document.getElementById('pathlocalimagen').value = cadena;
	window.opener.document.getElementById('pathservidorimagen').value = cadena;

	//window.document.getElementById('accion').value = 'crear';
       	//window.document.getElementById('clase').value = 'es.intecna.dinainf.estructura.Recurso';

        window.document.getElementById('nom_recurso').setAttribute('value', cadena);


        nombre2=nombre.toLowerCase();
	if (nombre2.indexOf(".jpg")>=0){

        	do {
        		img_obj.src = nombre;
        		window.opener.window.parent.document.getElementById('fotoancho').value=img_obj.width;
        		window.opener.window.parent.document.getElementById('fotoalto').value=img_obj.height;
        		window.opener.window.parent.document.getElementById('archivonombre').value=nombre;
        		window.opener.window.parent.document.getElementById('frameImagen').src="/pi/fpi/include/fotopdffpi.jsp?nombre=" + nombre + "&ancho=" + img_obj.width + "&alto=" + img_obj.height;
       		}
       		while(img_obj.width==0)
       	}
       	else if (nombre2.indexOf(".pdf")>=0){
		window.opener.window.parent.document.getElementById('fotoancho').value=0;
       		window.opener.window.parent.document.getElementById('fotoalto').value=0;
      		window.opener.window.parent.document.getElementById('archivonombre').value=nombre;
        	window.opener.window.parent.document.getElementById('frameImagen').src=nombre;
       	}
       	else {
       		window.opener.window.parent.document.getElementById('fotoancho').value=0;
       		window.opener.window.parent.document.getElementById('fotoalto').value=0;
       		window.opener.window.parent.document.getElementById('archivonombre').value="";
        	window.opener.window.parent.document.getElementById('frameImagen').src="";
       		alert("Formato de archivo incorrecto");

       	}
	/*var coll = document.getElementsByName("ruta1");
      	var LatestFile = coll[coll.length - 1];
      	var objBr = document.createElement("<br>");
      	LatestFile.insertAdjacentElement("afterEnd", objBr);
      	var objFile = document.createElement('<input type="file" name="ruta" size="63" id="ruta" value="' + nombre +'">');
      	objBr.insertAdjacentElement("afterEnd", objFile);     */


        //window.document.getElementById('formulario').submit();

//	self.close();
}
//------------------------------------------------------------------------------
function AbrirDocumento(documento)
{
	AbrirVentanaRedimensionable(document.getElementById('dir_contenido').value + documento,600,600);
}
//------------------------------------------------------------------------------

function AmpliarReducirFoto(accion)
{
	var factor;
	var ancho;
	var alto;
	var nombre;
	var nombre2;

	nombre=window.document.getElementById('archivonombre').value;
	nombre2=nombre.toLowerCase();

	if(nombre2.indexOf(".jpg")>=0){

		if (accion == 0)
			factor = 0.7;
		else if (accion == 1)
			factor = 1.3;

		ancho = window.document.getElementById('fotoancho').value;
        	alto = window.document.getElementById('fotoalto').value;

       		ancho = ancho * factor;
       		alto = alto * factor;

       		window.document.getElementById('fotoancho').value=ancho;
        	window.document.getElementById('fotoalto').value=alto;

        	window.document.getElementById('frameImagen').src="/pi/fpi/include/fotopdffpi.jsp?nombre=" + nombre + "&ancho=" + ancho + "&alto=" + alto;
	}
}

//------------------------------------------------------------------------------
function FormatoFechas()
{
	if(document.getElementById('mes') != null && document.getElementById('mes').value.length > 0)
        {
        	if(document.getElementById('mes').value.length == 1)
                {
                	document.getElementById('mes').value = '0' + document.getElementById('mes').value;
                }
                else
                {
                	if(document.getElementById('mes').value.length > 2)
                        {
                      		document.getElementById('mes').value = document.getElementById('mes').value.substring(0,2);
                        }
                }
                if(parseInt(document.getElementById('mes').value) < 1 || parseInt(document.getElementById('mes').value) > 12)
                {
                	document.getElementById('mes').value = '1';
		}
        }
        if(document.getElementById('dia') != null && document.getElementById('dia').value.length > 0)
        {
        	if(document.getElementById('dia').value.length == 1)
                {
                	document.getElementById('dia').value = '0' + document.getElementById('dia').value;
		}
                else
                {
                	if(document.getElementById('dia').value.length > 2)
                        {
                        	document.getElementById('dia').value = document.getElementById('dia').value.substring(0,2);
                        }
                }
                if(parseInt(document.getElementById('dia').value) < 1 || parseInt(document.getElementById('dia').value) > 31)
                {
                	document.getElementById('dia').value = '1';
                }
        }
}
//------------------------------------------------------------------------------
function Comprar()
{
  if(document.getElementById('id_producto') != null && document.getElementById('id_producto').value.length > 0 && document.getElementById('id_producto').value != '0')
  	AbrirVentana2('http://www.fpabloiglesias.es/shopAlt/detail.aspx?id=' + document.getElementById('id_producto').value,600,600);
  else
  	alert('El producto aun no est? disponible');
}
//------------------------------------------------------------------------------
function AbrirFicha(url)
{
  if(document.getElementById('cod_tip_contenido').value == '2')
  {
  	AbrirEnVentana(url);
  }
  else
  {
    window.parent.AbrirEnVentana(url);
  }
}
//------------------------------------------------------------------------------
function ListarEventos(fecha)
{
  window.parent.document.getElementById('eventos').src = 'eventos.jsp?publicable=&cod_rel_eve_recurso=&eventosdia=true&titulo=&precio1=&precio2=&cod_continente=&fec_fin=&cod_tema=&datos=&direccion=&descripcion=&inf_inscripcion=&pla_inscripcion=&calendario=true&accion=buscar&cod_evento=&fec_inicio=' + fecha +'&cod_tip_evento=&clase=es.intecna.fpi.estructura.Evento';
}
//------------------------------------------------------------------------------
function SeleccionarUsuario(parametros, nom_campo1, nom_campo2)
{
  var arrayParametros = parametros.split('/~/');
  window.opener.document.getElementById(nom_campo2).value = arrayParametros[0];
  window.opener.document.getElementById(nom_campo1).value = arrayParametros[1] + ' ' + arrayParametros[2];
  window.close();
}
//------------------------------------------------------------------------------
function SeleccionarCiudadano(parametros, nom_campo1, nom_campo2)
{
  var arrayParametros = parametros.split('/~/');
  window.opener.document.getElementById(nom_campo2).value = arrayParametros[0];
  window.opener.document.getElementById(nom_campo1).value = arrayParametros[1] + ' ' + arrayParametros[2];
  window.close();
}
//------------------------------------------------------------------------------
function SeleccionarOficina(parametros, nom_campo1, nom_campo2)
{
  var arrayParametros = parametros.split('/~/');
  window.opener.document.getElementById(nom_campo2).value = arrayParametros[0];
  window.opener.document.getElementById(nom_campo1).value = arrayParametros[1];
  window.close();
}
//------------------------------------------------------------------------------
function SeleccionarDepartamento(parametros, nom_campo1, nom_campo2)
{
  var arrayParametros = parametros.split('/~/');
  window.opener.document.getElementById(nom_campo2).value = arrayParametros[0];
  window.opener.document.getElementById(nom_campo1).value = arrayParametros[1];
  window.close();
}
//------------------------------------------------------------------------------
function SeleccionarReceptor(parametros, nom_campo1, nom_campo2, tipoReceptor)
{
  	var arrayParametros = parametros.split('/~/');
 
  	if (arrayParametros[2]=="null"){
  		arrayParametros[2]=" ";
	}
  	if (window.opener.document.getElementById(nom_campo1).value!=0){
		window.opener.document.getElementById(nom_campo2).value = window.opener.document.getElementById(nom_campo2).value+','+window.opener.document.getElementById(tipoReceptor).value+'/' + arrayParametros[0];	
		window.opener.document.getElementById(nom_campo1).value = window.opener.document.getElementById(nom_campo1).value + ',' + arrayParametros[1] + ' ' + arrayParametros[2];
		
	 }
	else {
	  	window.opener.document.getElementById(nom_campo2).value = window.opener.document.getElementById(tipoReceptor).value+'/'+arrayParametros[0];	
		window.opener.document.getElementById(nom_campo1).value = arrayParametros[1]+ ' ' + arrayParametros[2];
	}
  	window.close();
}

//-------------------------------------------------------------------------------

function AsignarCiudadano(parametros,nom_cam_id, nom_cam_nombre, nom_cam_apellidos, nom_cam_identificador, nom_cam_completo, iframe, div, url)
{

	var arrayParametros = parametros.split('/~/');
  	window.opener.document.getElementById(nom_cam_id).value = arrayParametros[0];
  	window.opener.document.getElementById(nom_cam_nombre).value = arrayParametros[1];
  	window.opener.document.getElementById(nom_cam_apellidos).value = arrayParametros[2];
  	window.opener.document.getElementById(nom_cam_identificador).value = arrayParametros[3];
  	window.opener.document.getElementById(nom_cam_completo).value = arrayParametros[1]+' '+arrayParametros[2]+'('+arrayParametros[3]+')';
  	
  	window.opener.document.getElementById(iframe).src=url+'&cod_ciudadano='+arrayParametros[0];
		if(window.opener.document.getElementById(div).style.visibility == 'hidden')
		{
			window.opener.document.getElementById(div).style.visibility = 'visible';
		}
  	window.close();
}

function AsignarUsuario(parametros,nom_cam_id, nom_cam_nombre, iframe)
{
	var arrayParametros = parametros.split('/~/');
  	window.opener.document.getElementById(nom_cam_id).value = arrayParametros[0];
  	window.opener.document.getElementById(nom_cam_nombre).value = arrayParametros[1];
  	
  	window.close();
}


//--------------------------------------------------------------------------------

function AsignarCiudadanoBusqueda(parametros,nom_cam_id, nom_cam_nombre, nom_cam_apellidos, nom_cam_identificador, nom_cam_completo)
{

	var arrayParametros = parametros.split('/~/');
  	window.opener.document.getElementById(nom_cam_id).value = arrayParametros[0];
  	window.opener.document.getElementById(nom_cam_nombre).value = arrayParametros[1];
  	window.opener.document.getElementById(nom_cam_apellidos).value = arrayParametros[2];
  	window.opener.document.getElementById(nom_cam_identificador).value = arrayParametros[3];
  	window.opener.document.getElementById(nom_cam_completo).value = arrayParametros[1]+' '+arrayParametros[2]+'('+arrayParametros[3]+')';
  	window.close();
}
//------------------------------------------------------------------------------
function AsignarUsuario(parametros,nom_cam_id, nom_cam_nombre, nom_cam_apellidos, nom_cam_completo)
{
	var arrayParametros = parametros.split('/~/');
  	window.opener.document.getElementById(nom_cam_id).value = arrayParametros[0];
  	if(arrayParametros[1] != 'null')
  		window.opener.document.getElementById(nom_cam_nombre).value = arrayParametros[1];
  	if(arrayParametros[2] != 'null')
  		window.opener.document.getElementById(nom_cam_apellidos).value = arrayParametros[2];
  	if(arrayParametros[1] != 'null' && arrayParametros[2]!='null')
  		window.opener.document.getElementById(nom_cam_completo).value = arrayParametros[1]+' '+arrayParametros[2];
  	else
  		if(arrayParametros[1] != 'null')
  			window.opener.document.getElementById(nom_cam_completo).value = arrayParametros[1];
  		else
  			if(arrayParametros[2] != 'null')
  				window.opener.document.getElementById(nom_cam_completo).value = arrayParametros[2];
  	window.close();
}
//------------------------------------------------------------------------------
function ComprobarTipo(tipoSelect)
{
	if(tipoSelect != null && tipoSelect != 0)
	{
		if(document.getElementById('cod_tip_html').type == 'select-one')
		{
			if(tipoSelect == document.getElementById('cod_tip_html').options[document.getElementById('cod_tip_html').selectedIndex].value)
			{ 
				if(document.getElementById('div_opciones') != null)
				{
					document.getElementById('div_opciones').style.visibility = 'visible';
				}
				else
				{
					alert('Una vez creado este campo de tipo "Lista" podrá editarlo y añadirle las opciones');
				}
			}
			else
			{
				if(document.getElementById('div_opciones') != null)
				{
					document.getElementById('div_opciones').style.visibility = 'hidden';			
				}
			}
		}
		else
		{
			if(tipoSelect == document.getElementById('cod_tip_html').value)
			{
				if(document.getElementById('div_opciones') != null)
				{
					document.getElementById('div_opciones').style.visibility = 'visible';
				}		
			}
			else
			{
				if(document.getElementById('div_opciones') != null)
				{
					document.getElementById('div_opciones').style.visibility = 'hidden';			
				}
			}			
		}
	}
}
	
//------------------------------------------------------------------------------
function AnadirOpcionCampoDefinicionTramite(cod_cam_def_tramite)
{
	AbrirVentana2('opcion_campo_definicion_tramite.jsp?clase=es.intecna.ps.estructura.OpcionCampoDefinicionTramite&accion=&cod_cam_def_tramite=' + cod_cam_def_tramite + '&nom_campo=opciones',600,200);
}
//------------------------------------------------------------------------------
function AnadirOpcionCampoWorkflowDefinicionTramite(cod_cam_wor_def_tramite)
{
	AbrirVentana2('opcion_campo_workflow_definicion_tramite.jsp?clase=es.intecna.ps.estructura.OpcionCampoWorkflowDefinicionTramite&accion=&cod_cam_wor_def_tramite=' + cod_cam_wor_def_tramite + '&nom_campo=opciones',600,200);
}
//------------------------------------------------------------------------------
function AnadirOpcionCampoDefinicionExpediente(cod_cam_def_expediente)
{
	AbrirVentana2('opcion_campo_definicion_expediente.jsp?clase=es.intecna.ps.estructura.OpcionCampoDefinicionExpediente&accion=&cod_cam_def_expediente=' + cod_cam_def_expediente + '&nom_campo=opciones',600,200);
}
//------------------------------------------------------------------------------
function AnadirOpcionCampoWorkflowDefinicionExpediente(cod_cam_wor_def_expediente)
{
	AbrirVentana2('opcion_campo_workflow_definicion_expediente.jsp?clase=es.intecna.ps.estructura.OpcionCampoWorkflowDefinicionExpediente&accion=&cod_cam_wor_def_expediente=' + cod_cam_wor_def_expediente+ '&nom_campo=opciones',600,200);
}
//------------------------------------------------------------------------------
function EliminarOpcionCampoDefinicionTramite(cod_cam_def_tramite, obligatorio)
{
	var borrados = 0;
	document.getElementById('cod_opc_cam_def_tramite').value = '';
	var selected = false;
	for(var i = 0; i < document.getElementById('opciones').options.length; i++)
	{
		if(document.getElementById('opciones').options[i].selected)
		{
			borrados++;
			if(borrados == document.getElementById('opciones').options.length && obligatorio=='true')
			{
				alert('No se pueden eliminar todas las opciones de un campo obligatorio');
				return;
			}

			selected = true;
			document.getElementById('cod_opc_cam_def_tramite').value = document.getElementById('cod_opc_cam_def_tramite').value + document.getElementById('opciones').options[i].id + '/~/';
			document.getElementById('valor').value = document.getElementById('valor').value + document.getElementById('opciones').options[i].value + '/~/';			
			document.getElementById('texto').value = document.getElementById('texto').value + document.getElementById('opciones').options[i].text + '/~/';						
		}
	}
	if(selected)
	{
		document.getElementById('accion').value = 'eliminar';
		document.getElementById('clase').value = 'es.intecna.ps.estructura.OpcionCampoDefinicionTramite';
		document.getElementById('formulario').submit();
	}
	else
	{
		alert('No existen opciones seleccionadas');
	}
}
//------------------------------------------------------------------------------
function EliminarOpcionCampoDefinicionExpediente(cod_cam_def_expediente, obligatorio)
{
	var borrados = 0;
	document.getElementById('cod_opc_cam_def_expediente').value = '';
	var selected = false;
	for(var i = 0; i < document.getElementById('opciones').options.length; i++)
	{
		if(document.getElementById('opciones').options[i].selected)
		{
			borrados++;
			if(borrados == document.getElementById('opciones').options.length && obligatorio=='true')
			{
				alert('No se pueden eliminar todas las opciones de un campo obligatorio');
				return;
			}
			selected = true;
			document.getElementById('cod_opc_cam_def_expediente').value = document.getElementById('cod_opc_cam_def_expediente').value + document.getElementById('opciones').options[i].id + '/~/';
			document.getElementById('valor').value = document.getElementById('valor').value + document.getElementById('opciones').options[i].value + '/~/';			
			document.getElementById('texto').value = document.getElementById('texto').value + document.getElementById('opciones').options[i].text + '/~/';						
		}
	}
	if(selected)
	{
		document.getElementById('accion').value = 'eliminar';
		document.getElementById('clase').value = 'es.intecna.ps.estructura.OpcionCampoDefinicionExpediente';
		document.getElementById('formulario').submit();
	}
	else
	{
		alert('No existen opciones seleccionadas');
	}
}
//------------------------------------------------------------------------------
function EliminarOpcionCampoWorkflowDefinicionTramite(cod_cam_wor_def_tramite, obligatorio)
{
	var borrados = 0;
	document.getElementById('cod_opc_cam_wor_def_tramite').value = '';
	var selected = false;
	for(var i = 0; i < document.getElementById('opciones').options.length; i++)
	{
		if(document.getElementById('opciones').options[i].selected)
		{
			borrados++;
			if(borrados == document.getElementById('opciones').options.length)
			{
				alert('No se pueden eliminar todas las opciones de un campo obligatorio');
				return;
			}		
			selected = true;
			document.getElementById('cod_opc_cam_wor_def_tramite').value = document.getElementById('cod_opc_cam_wor_def_tramite').value + document.getElementById('opciones').options[i].id + '/~/';
			document.getElementById('valor').value = document.getElementById('valor').value + document.getElementById('opciones').options[i].value + '/~/';			
			document.getElementById('texto').value = document.getElementById('texto').value + document.getElementById('opciones').options[i].text + '/~/';						
		}
	}
	if(selected)
	{
		document.getElementById('accion').value = 'eliminar';
		document.getElementById('clase').value = 'es.intecna.ps.estructura.OpcionCampoWorkflowDefinicionTramite';
		document.getElementById('formulario').submit();
	}
	else
	{
		alert('No existen opciones seleccionadas');
	}
}
//------------------------------------------------------------------------------
function EliminarOpcionCampoWorkflowDefinicionExpediente(cod_cam_wor_def_expediente, obligatorio)
{
	var borrados = 0;
	document.getElementById('cod_opc_cam_wor_def_expediente').value = '';
	var selected = false;
	for(var i = 0; i < document.getElementById('opciones').options.length; i++)
	{
		if(document.getElementById('opciones').options[i].selected)
		{
			borrados++;
			if(borrados == document.getElementById('opciones').options.length)
			{
				alert('No se pueden eliminar todas las opciones de un campo obligatorio');
				return;
			}		
			selected = true;
			document.getElementById('cod_opc_cam_wor_def_expediente').value = document.getElementById('cod_opc_cam_wor_def_expediente').value + document.getElementById('opciones').options[i].id + '/~/';
			document.getElementById('valor').value = document.getElementById('valor').value + document.getElementById('opciones').options[i].value + '/~/';			
			document.getElementById('texto').value = document.getElementById('texto').value + document.getElementById('opciones').options[i].text + '/~/';						
		}
	}
	if(selected)
	{
		document.getElementById('accion').value = 'eliminar';
		document.getElementById('clase').value = 'es.intecna.ps.estructura.OpcionCampoWorkflowDefinicionExpediente';
		document.getElementById('formulario').submit();
	}
	else
	{
		alert('No existen opciones seleccionadas');
	}
}
//------------------------------------------------------------------------------
function ComprobarNombreXML()
{
	var caracter = '';
	var cadena=document.getElementById('cam_xml').value;
	caracter = cadena.charAt(0);
	if((caracter >= '0' && caracter <= '9'))
	{
		document.getElementById('cam_xml').value = '';
		alert('El nombre del campo XML no puede empezar por un numero');
	}
	for(var i=0; i< cadena.length; i++)
	{
		caracter = cadena.charAt(i);
		if(caracter == ' ')
		{
			document.getElementById('cam_xml').value = document.getElementById('cam_xml').value.replace(' ','') ;
			alert('El nombre del campo XML no puede contener espacios en blanco');
		}
	}
}

//------------------------------------------------------------------------------
function ExpandirContraer()
{
	
	if(contraido)
	{
		document.getElementById('tpv_producto').style.visibility = 'visible';
		document.getElementById('expandir').src = 'img/ocultar.gif';
		contraido = false;	
	}
	else
	{
		document.getElementById('tpv_producto').style.visibility = 'hidden';	
		document.getElementById('expandir').src = 'img/expandir.gif';
		contraido = true;		
	}
}
//------------------------------------------------------------------------------
function ObtenerContrasena(longitud, extra, numero, minuscula, mayuscula, otra)
{
	var contrasena = "";
    for (var i = 0; i < longitud; ++i)
	{
		contrasena = contrasena + ObtenerCaracterAleatorio(numero, minuscula, mayuscula, otra, extra);
	}
	return contrasena;
}
//------------------------------------------------------------------------------
function ObtenerCaracterAleatorio(numero, minuscula, mayuscula, otro, extra)
{
	var numeros = "0123456789";
	var letrasMinusculas = "abcdefghijklmnopqrstuvwxyz";
	var letrasMayusculas = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var otras = "`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/? ";
	var caracter = extra;

	if (numero == true)
		caracter += numeros;

	if (minuscula == true)
		caracter += letrasMinusculas;

	if (mayuscula == true)
		caracter += letrasMayusculas;

	if (otro == true)
		caracter += otras;

	return caracter.charAt(ObtenerNumeroAleatorio(0, caracter.length));
}
//------------------------------------------------------------------------------
function ObtenerNumeroAleatorio(minimo, maximo)
{
  	return (Math.floor(Math.random() * (maximo - minimo)) + minimo);
}
//------------------------------------------------------------------------------
function xShowModalDialog( sURL, width, height ) 
{ 
	Features = 'dialogHeight:' + height + 'px; dialogWidth: ' + width + 'px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: No; resizable: No; status: Yes;';//default features     
	
/*	if (typeof window.showModalDialog != 'undefined') 
	{ 
		alert('fas');
	    window.showModalDialog ( sURL + '&emergente=true', '', Features ); 
	    modalWin=window.open(String(sURL) + '&emergente=true','',Features); 
	    return false; 
	} */
    Features = 'directories=0,menubar=0,titlebar=0,toolbar=0,' + Features; 
    Features = ReplaceAll(Features,':',"=");
	Features = ReplaceAll(Features,';',",");
    Features = ReplaceAll(Features,'dialogHeight','height');
    Features = ReplaceAll(Features,'dialogWidth','width');	    
    //alert(Features);
    Features += 'screenY=' + ((screen.availHeight-height)/2) + ',screenX=' + ((screen.availWidth-width)/2);
    modalWin=window.open(String(sURL) + '&emergente=true','',Features); 
} 
//------------------------------------------------------------------------------	
function checkFocus() 
{ 
    if (typeof window.showModalDialog == 'undefined') 
    { 
		if (modalWin!=null && !modalWin.closed)
		{
		   self.blur();
		}
    } 
    else if(modalWin != "")
    {	
    	try
    	{
	    	modalWin.focus();
	    }
	    catch(e){
	    	modalWin = "";
	    }
    }
}  

//-----------------------------------------------------------------------------------
function ActualizarPadre(clase,accion)
{
		var enviado = EnviarDatos(accion,true,clase);
		if(window.parent!= null && enviado)
			window.parent.document.formulario.submit();
} 