var msgEsperaGnral= new Array();
msgEsperaGnral[0]='<div style="width:100%"><center style="font-size: 7pt;"><img src="imagenes/cargando.gif" border=0 align="absmiddle" width="18" height="18">Cargando..</center></div>';
msgEsperaGnral[1]=[
	"<div class='item'>"
	,"<div class='date'>"
	,"<div>&nbsp;</div>"
	,"<span><img src='imagenes/cargando.gif' border=0 align='absmiddle' ></span>"
	,"</div>"
	,"<div class='content'>"
	,"<h1>&nbsp;</h1>"
	,"<div class='body'>"
	,"&nbsp;"
	,"</div>"
	,"</div>"
	,"</div>"
].join('');


var W3CDOM = (document.createElement && document.getElementById);
//debe estar definida la variable largomax
if (!largomax) var largomax=300;
function getElement(id){
	return W3CDOM?document.getElementById(id):document.all[id];
}
function taLimit(objeto,perlargomax)
{
	var finlargomax=largomax;
	if (perlargomax>0) finlargomax=perlargomax
	if (objeto.value.length>=finlargomax) return false;
}
function taCount(objeto, visCnt, perlargomax) {
	var od = getElement(visCnt);

	var finlargomax=largomax;
	if (perlargomax>0) finlargomax=perlargomax

	if (objeto.value.length>finlargomax) objeto.value=objeto.value.substring(0,finlargomax);
	if (od) od.innerHTML=finlargomax-objeto.value.length;
}

Array.prototype.in_array = function(p_val) {
	for(var i = 0, l = this.length; i < l; i++) {
		if(this[i] == p_val) {
			return true;
		}
	}
	return false;
}

function abreventana(url,nombre,caracteristicas) { //v2.0
  window.open(url,nombre,caracteristicas);
}
function visibleobj(id,tipo,idimg,ida)
{
	if (tipo)
	{
		if(id) document.getElementById(id).style.visibility='visible';
		if(id) document.getElementById(id).style.display='block';
		if(idimg) document.getElementById(idimg).src="img/menos_r.gif";
		if(ida) document.getElementById(ida).href="javascript:visibleobj('"+id+"',0,'"+idimg+"','"+ida+"')";
	}
	else
	{
		if(id) document.getElementById(id).style.visibility='hidden';
		if(id) document.getElementById(id).style.display='none';
		if(idimg) document.getElementById(idimg).src="img/mas_r.gif";
		if(ida) document.getElementById(ida).href="javascript:visibleobj('"+id+"',1,'"+idimg+"','"+ida+"')";
	}
}

function confirmar()
{
	if (confirm('¿Estás seguro que deseas eliminar el elemento seleccionado?'))
		return true;
	else
		return false;
}

function presionar_enter(keyc,boton)
{
	if(keyc==13) boton.click();
}
function nuevoAjax()
{
	/* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por
	lo que se puede copiar tal como esta aqui */
	var xmlhttp=false;
	try
	{
		// Creacion del objeto AJAX para navegadores no IE
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			// Creacion del objet AJAX para IE
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(E) { xmlhttp=false; }
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp=new XMLHttpRequest(); }

	return xmlhttp;
}

/** Function Traer Datos
link		: (requerido) enlace donde se hace la petición de datos
querystring	: (requerido) cadena de datos a postear (variable=valor) separado por &
ndiv		: (requerido) nombre del contenedor donde se imprime el resultado entregado por el link
msgespera	: (opcional) mensaje que se imprimirá en el contenedor mientras se recibe la respuesta
**/
function traerDatos(link,querystring,ndiv,msgespera,func_ejec)
{
	if (!link) return;
	if (!querystring) return;
	if (!ndiv) return;
	// Obtendo la capa donde se muestran las respuestas del servidor
	var capa=document.getElementById(ndiv);
	// Creo el objeto AJAX
	var ajax=nuevoAjax();
	// Coloco el mensaje "Cargando..." en la capa
	if (msgespera) capa.innerHTML=msgespera;
	// Abro la conexión, envío cabeceras correspondientes al uso de POST y envío los datos con el método send del objeto AJAX
	ajax.open("POST", link, true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send(querystring);

	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			if (ajax.status == 200)
			{
				// Respuesta recibida. Coloco el texto plano en la capa correspondiente
				if(capa) capa.innerHTML=ajax.responseText;
				if (func_ejec) eval(func_ejec);
			}
			else
				if(capa) capa.innerHTML='Error conexión!!';
		}
	}
}

/** Function Traer Datos
link		: (requerido) enlace donde se hace la petición de datos
querystring	: (requerido) cadena de datos a postear (variable=valor) separado por &

la funcion ejecuta un javascript
**/
function traerScript(link,querystring,func_ejec,ndiv)
{
	if (!link) return;
	if (!querystring) return;

	// Creo el objeto AJAX
	var ajax=nuevoAjax();

	// Abro la conexión, envío cabeceras correspondientes al uso de POST y envío los datos con el método send del objeto AJAX
	ajax.open("POST", link, true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send(querystring);
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			if (ajax.status == 200)
			{
				// Respuesta recibida. ejecuto el javascript
				var ajaxrespuesta=ajax.responseText;
				if(ndiv) if(document.getElementById(ndiv)) document.getElementById(ndiv).innerHTML=ajaxrespuesta;
				eval(ajaxrespuesta);

				if (func_ejec) eval(func_ejec);
			}
		}
	}
}

//comprobar página válida
function verificaPagina(ajax)
{
 	if (ajax.readyState == 4)
 	{
   		if (ajax.status == 200)		alert("URL válida");
   		else if (ajax.status == 404)alert("URL inexistente");
		else if (ajax.status == 404)alert ("URL no encontrado");
       	else if (ajax.status == 403)alert("Acceso Denegado");
   		else 						alert("El estado de conexión es: " + ajax.status);
   	}
}

/**
 *
 * @access public
 * @return void
 **/
function objtabulador()
{
	//numero total de pestañas
	this.tab_pestanas=0;

	//imagen pestaña
	this.tab_img='';

	//imagen pestaña seleccionada
	this.tab_img_seleccion='';

	//nombre pestaña (div, span) html de tabuladores (tabs, tab)
	//por defecto 'tabs'
	//nombres div en html deben quedar como matriz
	//Ej. las pestañas son <div id='tabs[0]'>Tab0</div>, <div id='tabs[1]'>Tab1</div>
	this.tab_nombre='tabs';

	//nombre etiqueta html que contiene los datos (pags, pag, etc)
	//por defecto 'pags'
	//nombres div en html deben quedar como matriz
	//Ej. Las páginas de contenido son <div id='pags[0]'>datos 1</div>, <div id='pags[1]'>datos 2</div>
	this.tab_nombre_pag='pags';

	//desabilitar la tabulación completa (0 no; 1 si)
	this.tab_deshabilitar=0;

	//invisible los deshabilitados
	this.tab_invisible_deshabilitar=0;

	//color de fuente de pestañas
	this.tab_color='#000'

	//color de fuente de pestaña seleccionada
	this.tab_color_seleccionada='#000';

	//indica o define el tabulador actual
	this.tab_actual=0;

	//visibilidad de la pestaña
	//se despliegan u ocultan las pestañas (0 visible, 1 invisible)
	//individualmente en la accion tabular e inicializar
	this.tab_invisible_individual=new Array();

	//funciones ligadas a cada click en pestaña
	//Las funciones ligadas se ejecutan despues de tabular
	//y se ejecuta sólo la funcion ligada a la pestaña seleccionada
	//Ej. objtab.tab_funcion[0]='alert("Hola mundo")';
	//Se envía el mensaje 'Hola mundo' al hacer click en la pestaña 0 [tabs[0]]
	this.tab_funcion=new Array();

	//funciones gatillo ligadas a cada click en pestaña
	//Las funciones gatillo ligadas se ejecutan antes o despues de tabular
	//y se ejecuta sólo la funcion ligada a la pestaña seleccionada
	//Ej. objtab.tab_funcion[0]='retorna_booleano("Hola mundo");';
	//Se activa la pestaña seleccionada sólo se la funcion "retorna_booleano" devuelve TRUE
	this.tab_funcion_pregatillo=new Array();
	this.tab_funcion_posgatillo=new Array();

	//Deshabilitacion individual de tabs  (0 no; 1 si)
	//Nota: No tabula ni ejecuta función individual
	//Ej. objtab.tab_deshabilitar_individual[0]=1;
	// se deshabilita la pestaña 0 (tabs[0])
	this.tab_deshabilitar_individual=new Array();



	//Mensaje deshabilitado general
	//Envía un mensaje al hacer click sobre cualquier pestaña
	//deshabilitada
	this.tab_mensaje=0;

	//Mensaje deshabilitado individual
	//Envía un mensaje al hacer click sobre una pestaña
	//deshabilitada
	this.tab_mensaje_individual=new Array();

	//Ancho de tabuladores general e individual
	//Dimensiona el ancho de las pestañas
	this.tab_ancho='';
	this.tab_ancho_individual=new Array();

	this.validar_objeto= function()
	{
		if(!this.tab_nombre) {alert('Error: Objeto tabulador no tiene nombre'); return false;}
		if(!this.tab_pestanas) {alert('Error: Objeto tabulador no tiene maximo de pestañas'); return false;}
		if(!this.tab_nombre_pag) {alert('Error: Objeto tabulador no tiene definido las etiquetas tabuladoras contenedoras de datos'); return false;}
		return true;
	}

	this.ajustar_seleccion= function(id_seleccion)
	{
		//pestaña seleccionada
		var idaux=this.tab_nombre+'['+id_seleccion+']';
		//pagina contenedora seleccionada
		var idauxpag=this.tab_nombre_pag+'['+id_seleccion+']';

		//indicamos tabulador actual
		this.tab_actual=id_seleccion;

		if (document.getElementById(idaux)) document.getElementById(idaux).style.display='';

		//fuente en negrita
		document.getElementById(idaux).style.fontWeight='bold';

		//si se configuro el ancho de pestañas o el ancho individual
		if (this.tab_ancho_individual[id_seleccion])
		{
			document.getElementById(idaux).style.width=this.tab_ancho_individual[id_seleccion]+'px';
		}
		else if (this.tab_ancho)
		{
			document.getElementById(idaux).style.width=this.tab_ancho+'px';
		}

		//si se configuro el color de fuente le damos el color determinado
		//si no, por defecto le damos el color negro
		if (!this.tab_color_seleccionada)
			document.getElementById(idaux).style.color='#000';
		else
			document.getElementById(idaux).style.color=this.tab_color_seleccionada;

		//si existe imagen para la pestaña seleccionada
		//cambiamos la imagen y la alineamos a la derecha
		if (this.tab_img_seleccion)
		{
			document.getElementById(idaux).style.background='url('+this.tab_img_seleccion+')  no-repeat';
			document.getElementById(idaux).style.backgroundPosition='top right';
		}

		//hacemos visible el contenedor correspondiente a la pestaña i
		if (document.getElementById(idauxpag)) document.getElementById(idauxpag).style.display='';
	}

	this.ajustar_deseleccion= function(id)
	{

		//pestaña seleccionada
		var idaux=this.tab_nombre+'['+id+']';
		//pagina contenedora seleccionada
		var idauxpag=this.tab_nombre_pag+'['+id+']';

		//fuente en normal
		document.getElementById(idaux).style.fontWeight='normal';

		//si se configuro el ancho de pestañas o el ancho individual
		if (this.tab_ancho_individual[id])
		{
			document.getElementById(idaux).style.width=this.tab_ancho_individual[id]+'px';
		}
		else if (this.tab_ancho)
		{
			document.getElementById(idaux).style.width=this.tab_ancho+'px';
		}

		//alert(document.getElementById(idaux).style.display);
		//verificamos si el tabulador esta deshabilitado
		// si es asi, le damos un color plomo a la fuente
		//en caso contrario verificamos si se configuro el color para pestañas
		//no seleccionadas, si es asi le damos el color determinado, de lo contrario,
		//el color negro por defecto
		if (this.tab_deshabilitar || this.tab_deshabilitar_individual[id]==1)
		{
			document.getElementById(idaux).style.color='#999999';
			if (this.tab_invisible_deshabilitar==1)
			{
				if (document.getElementById(idaux)) document.getElementById(idaux).style.display='none';
			}
			else
			{
				if (document.getElementById(idaux))
				{
					if (this.tab_invisible_individual[id]==1)
						document.getElementById(idaux).style.display='none';
					else
						document.getElementById(idaux).style.display='';
				}
			}
		}
		else
		{
			if (!this.tab_color)
				document.getElementById(idaux).style.color='#000';
			else
				document.getElementById(idaux).style.color=this.tab_color;

			if (document.getElementById(idaux))
			{
				if (this.tab_invisible_individual[id]==1)
					document.getElementById(idaux).style.display='none';
				else
					document.getElementById(idaux).style.display='';
			}

		}

		//alert(document.getElementById(idaux).style.display);

		//si se configuro la imagen para pestañas no seleccionadas
		//se la asignamos y alineamos a la derecha
		if (this.tab_img)
		{
			document.getElementById(idaux).style.background='url('+this.tab_img+')  no-repeat';
			document.getElementById(idaux).style.backgroundPosition='top right';
		}

		//hacemos invisible el contenedor correspondiente a la pestaña i
		if (document.getElementById(idauxpag)) document.getElementById(idauxpag).style.display='none';
	}

	this.ejecutar_funciones=function(tabfuncion)
	{
		if (this.tab_funcion[this.tab_actual]) eval(this.tab_funcion[this.tab_actual]);
		if (tabfuncion) eval(tabfuncion);
	}
	this.tabular=function(tabid,tabfuncion)
	{
		var idx_tab=-1;
		var retorno;
		for(var j=0; j<this.tab_pestanas ; j++)
		{
			if(this.tab_nombre+'['+j+']'==tabid) idx_tab=j;
		}

		if (idx_tab<0) return false;

		if (idx_tab==this.tab_actual) return true;

		//ejecutamos la funcion de gatillo posterior
		if (this.tab_funcion_posgatillo[this.tab_actual])
		{
			eval('retorno='+this.tab_funcion_posgatillo[this.tab_actual]);
			if (!retorno) return;
		}

		//ejecutamos la funcion de gatillo anterior
		if (this.tab_funcion_pregatillo[idx_tab])
		{
			eval('retorno='+this.tab_funcion_pregatillo[idx_tab]);
			if (!retorno) return;
		}

		if (!this.tab_deshabilitar)
		{

			if (idx_tab<0) return false;
			//recorrer pestañas
			for(var i=0; i<this.tab_pestanas ; i++)
			{

				//pestaña seleccionada
				var idaux=this.tab_nombre+'['+i+']';
				//pagina contenedora seleccionada
				var idauxpag=this.tab_nombre_pag+'['+i+']';

				//verificamos si existe la pestaña i
				if (document.getElementById(idaux))
				{
					//cambiamos el puntero del mouse dependiendo de la opcion tab_deshabilitar
					if (this.tab_deshabilitar || this.tab_deshabilitar_individual[i]==1)
						document.getElementById(idaux).style.cursor='default';
					else
						document.getElementById(idaux).style.cursor='pointer';

					//verificamos si la pestaña i es igual a la pestaña seleccionada
					if (idaux==tabid)
					{
						if (!this.tab_deshabilitar_individual[idx_tab]==1)
							this.ajustar_seleccion(i);
						else
							if (this.tab_mensaje_individual[idx_tab]) if (idx_tab!=this.tab_actual) alert(this.tab_mensaje_individual[idx_tab]);
					}
					else
					{
						if (!this.tab_deshabilitar_individual[idx_tab]==1) this.ajustar_deseleccion(i);
					}
				}
			}
			if (!this.tab_deshabilitar_individual[idx_tab]==1) this.ejecutar_funciones(tabfuncion);
		}
		else if (this.tab_mensaje) if (idx_tab!=this.tab_actual) alert(this.tab_mensaje);
	}

	this.tabularnum=function(numid)
	{
		this.tabular(this.tab_nombre+'['+numid+']');
	}

	this.inicializar = function(tabfuncion)
	{
		if (this.validar_objeto())
		{
			//recorrer pestañas
			for(var i=0; i<this.tab_pestanas ; i++)
			{
				//pestaña seleccionada
				var idaux=this.tab_nombre+'['+i+']';
				//pagina contenedora seleccionada
				var idauxpag=this.tab_nombre_pag+'['+i+']';

				//verificamos si existe la pestaña i
				if (document.getElementById(idaux))
				{
					//cambiamos el puntero del mouse dependiendo de la opcion tab_deshabilitar
					if (this.tab_deshabilitar || this.tab_deshabilitar_individual[i]==1)
						document.getElementById(idaux).style.cursor='default';
					else
						document.getElementById(idaux).style.cursor='pointer';

					//verificamos si la pestaña i es igual a la pestaña seleccionada
					if (i==this.tab_actual)
						this.ajustar_seleccion(i);
					else
						this.ajustar_deseleccion(i);
				}
			}
		}
		this.ejecutar_funciones(tabfuncion);
	}

	this.fztabular=function(tabid,tabfuncion)
	{
		var idx_tab=-1;
		var retorno;
		for(var j=0; j<this.tab_pestanas ; j++)
		{
			if(this.tab_nombre+'['+j+']'==tabid) idx_tab=j;
		}

		if (idx_tab<0) return false;

		if (idx_tab==this.tab_actual) return true;

		//ejecutamos la funcion de gatillo posterior
		if (this.tab_funcion_posgatillo[this.tab_actual])
		{
			eval('retorno='+this.tab_funcion_posgatillo[this.tab_actual]);
			if (!retorno) return;
		}

		//ejecutamos la funcion de gatillo anterior
		if (this.tab_funcion_pregatillo[idx_tab])
		{
			eval('retorno='+this.tab_funcion_pregatillo[idx_tab]);
			if (!retorno) return;
		}

		this.tab_actual=idx_tab;

		this.inicializar(tabfuncion);
	}

	this.fztabularnum=function(numid,tabfuncion)
	{
		this.fztabular(this.tab_nombre+'['+numid+']',tabfuncion);
	}
}

function tabulador(tabid,objtab,tabfuncion)
{
	if (!objtab instanceof objtabulador) {alert('Error: Objeto tabulador no definido'); return false;}
	objtab.validar_objeto();
	objtab.tabular(tabid,tabfuncion)
}

function URLEncode(texto)
{
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = texto;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for
	return encoded;
};

function URLDecode(strg)
{
   var HEXCHARS = "0123456789ABCDEFabcdef";
   var encoded = strg;
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
       var ch = encoded.charAt(i);
       if (ch == "+") {
           plaintext += " ";
           i++;
       } else if (ch == "%") {
            if (i < (encoded.length-2)
                    && HEXCHARS.indexOf(encoded.charAt(i+1)) != -1
                    && HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
                plaintext += unescape( encoded.substr(i,3) );
                i += 3;
            } else {
                plaintext += "%[ERROR]";
                i++;
            }
        } else {
           plaintext += ch;
           i++;
        }
    } // while
   return plaintext;
};

function fechaTransform(strFecha,bHr,bMin,bSeg){
	//dd/mm/yyyy hh:mm:ss (formato 24hrs ej. 01/01/1980 23:01)

	var datef={
		dia:parseInt(strFecha.substring(0,2),10)
		,mes:parseInt(strFecha.substring(3,5),10)
		,anio:parseInt(strFecha.substring(6,10),10)
		,hora:parseInt(strFecha.substring(11,13),10)
		,min:parseInt(strFecha.substring(14,16),10)
		,seg:parseInt(strFecha.substring(17,19),10)
	}

	var anio;
	anio=datef.anio<10 ? '0' + datef.anio : datef.anio;
	anio=datef.anio<100 ? '0' + anio : anio;
	anio=datef.anio<1000 ? '0' + anio : anio;

	var d = datef.mes<10 ? '0' + datef.mes : datef.mes;
	d+='/';
	d+=datef.dia<10 ? '0' + datef.dia : datef.dia;
	d+='/';
	d+=anio;

	d= bHr ? d + ' ' +  (datef.hora<10 ? '0' + datef.hora : datef.hora) : d;
	d= bMin ? d + ':' +  (datef.min<10 ? '0' + datef.min : datef.min) : d;
	d= bSeg ? d + ':' +  (datef.seg<10 ? '0' + datef.seg : datef.seg) : d;

	return d;
}

function getEventTrigger(evt)
{

  	if (!evt) {
		if (window.event) evt = window.event;
		else return;
	}
	if (typeof(evt.keyCode) == 'number') {
		key = evt.keyCode; // DOM
	}
	else if (typeof(evt.which) == 'number') {
		key = evt.which; // NS4
	}
	else if (typeof(evt.charCode) == 'number') {
		key = evt.charCode; // NS 6+, Mozilla 0.9+
	}
	else return;

	x=evt.target;

  	if (key==8)
	  	if (!x.id)
			return false;
		else{
			if (x.value) {
				return true;
			}
			else
				return false;

		}

	else
		return true;
}






////////////WEB///////////
function verificar_usuario(){
//verificar usuario
var querystr;
querystr='pusu_email='+document.getElementById('pusu_email').value;
querystr+='&mision=0XHvu1';
traerScript('modulos/aplicaciones/webadmin/usuarios_opciones.php',querystr);
}
function enviar_consulta(){
	var querystr='';

	var con_correo=URLEncode(document.getElementById('pcon_correo').value);
	var con_nombre=URLEncode(document.getElementById('pcon_nombre').value);
	var con_asunto=URLEncode(document.getElementById('pcon_asunto').value);
	var con_mensaje=URLEncode(document.getElementById('pcon_mensaje').value);

	if (!con_nombre) {alert('Ingrese NOMBRE'); return;}
	if (!con_correo) {alert('Ingrese CORREO'); return;}
	if (!con_asunto) {alert('Ingrese ASUNTO'); return;}
	if (!con_mensaje) {alert('Ingrese MENSAJE'); return;}

	querystr='pcon_correo='+con_correo;
	querystr+='&pcon_nombre='+con_nombre;
	querystr+='&pcon_asunto='+con_asunto;
	querystr+='&pcon_mensaje='+con_mensaje;
	querystr+='&mision=0XHin2';
	querystr+='&silencio=1';
	traerScript('modulos/aplicaciones/webadmin/contactos_opciones.php',querystr,'','');
}
function actualizar_datos_usuario(){
	//actualizar_datos_usuario
	var querystr='';

	var usu_rut=document.getElementById('pusu_rut').value;
	var usu_dv=URLEncode(document.getElementById('pusu_dv').value);
	var usu_ap_paterno=URLEncode(document.getElementById('pusu_ap_paterno').value);
	var usu_ap_materno=URLEncode(document.getElementById('pusu_ap_materno').value);
	var usu_nombres=URLEncode(document.getElementById('pusu_nombres').value);
	var usu_telefono=URLEncode(document.getElementById('pusu_telefono').value);
	var usu_celular=URLEncode(document.getElementById('pusu_celular').value);
	var usu_region=document.getElementById('pusu_region').value;
	var usu_ciudad=URLEncode(document.getElementById('pusu_ciudad').value);

	if (!usu_ap_paterno) {alert('Error: ingrese AP PATERNO'); return;}
	if (!usu_ap_materno) {alert('Error: ingrese AP MATERNO'); return;}
	if (!usu_nombres) {alert('Error: ingrese NOMBRES'); return;}
	if (!usu_telefono && !usu_celular) {alert('Error: ingrese TELEFONO o CELULAR'); return;}
	if (!usu_region) {alert('Error: ingrese REGION'); return;}
	if (!usu_ciudad) {alert('Error: ingrese CIUDAD'); return;}

	querystr='pusu_rut='+usu_rut;
	querystr+='&pusu_dv='+usu_dv;
	querystr+='&pusu_ap_paterno='+usu_ap_paterno;
	querystr+='&pusu_ap_materno='+usu_ap_materno;
	querystr+='&pusu_nombres='+usu_nombres;
	querystr+='&pusu_telefono='+usu_telefono;
	querystr+='&pusu_celular='+usu_celular;
	querystr+='&pusu_region='+usu_region;
	querystr+='&pusu_ciudad='+usu_ciudad;
	querystr+='&mision=0XHac3';
	traerScript('modulos/aplicaciones/webadmin/usuarios_opciones.php',querystr,'','');
	return false;
}
function actualizar_clave_usuario(){
	//actualizar_clave_usuario

	var querystr='';
	var usu_claveactual=URLEncode(document.getElementById('pusu_claveactual').value);
	var usu_clave=URLEncode(document.getElementById('pusu_clave').value);
	var confirmacion=URLEncode(document.getElementById('pconfirmacion').value);


	if (!usu_claveactual) {alert('ingrese CLAVE ACTUAL'); return;}
	if (!usu_clave) {alert('ingrese NUEVA CLAVE'); return;}
	if (!confirmacion) {alert('ingrese CONFIRMACION DE NUEVA CLAVE'); return;}
	if (usu_clave!=confirmacion) {alert('Error: NUEVA CLAVE y CONFIRMACION DE NUEVA CLAVE no coinciden'); return;}


	querystr='pusu_claveactual='+usu_claveactual;
	querystr+='&pusu_clave='+usu_clave;
	querystr+='&pconfirmacion='+confirmacion;
	querystr+='&mision=0XHac3c';
	traerScript('modulos/aplicaciones/webadmin/usuarios_opciones.php',querystr,'','');
	return false;
}
function listar_documentos(){
	//listar_documentos
	var querystr;
	var msgespera='<center style="font-size: 7pt;"><img src="imagenes/cargando.gif" border=0 align="absmiddle">Buscando..</center>';

	var doc_numero=URLEncode(document.getElementById('pdoc_numero').value);
	var doc_nombre_propietario=URLEncode(document.getElementById('pdoc_nombre_propietario').value);

	if (!doc_numero  && !doc_nombre_propietario) {alert('Debes ingresar el número de documento o el nombre del propietario del documento');return}

	querystr='pdoc_numero='+doc_numero;
	querystr+='&pdoc_nombre_propietario='+doc_nombre_propietario;
	querystr+='&mision=0XHbu1';

	objtabb.tab_deshabilitar_individual[1]=0;
	objtabb.fztabularnum(1);
	traerDatos('modulos/aplicaciones/webadmin/documentos_opciones.php',querystr,'dvresultado_documentos',msgespera,'');
}
function reportar_documentos(){
	//reportar_documentos

	var querystr='';
	var id_tidoc=document.getElementById('pid_tidoc').value;
	var doc_region=document.getElementById('pdoc_region').value;
	var doc_ciudad=document.getElementById('pdoc_ciudad').value;
	var doc_estado=document.getElementById('pdoc_estado').value;
	var doc_otro_tipo=URLEncode(document.getElementById('pdoc_otro_tipo').value);
	var doc_numero=URLEncode(document.getElementById('pdoc_numero').value);
	var doc_nombres_propietario=URLEncode(document.getElementById('pdoc_nombres_propietario').value);
	var doc_paterno_propietario=URLEncode(document.getElementById('pdoc_paterno_propietario').value);
	var doc_materno_propietario=URLEncode(document.getElementById('pdoc_materno_propietario').value);
	var doc_fecha=URLEncode(document.getElementById('pdoc_fecha').value);
	var id_lugar=document.getElementById('pid_lugar').value;
	var doc_paradero=URLEncode(document.getElementById('pdoc_paradero').value);
	var doc_telefono_contacto=URLEncode(document.getElementById('pdoc_telefono_contacto').value);
	var doc_correo_contacto=URLEncode(document.getElementById('pdoc_correo_contacto').value);
	var doc_nombre_contacto=URLEncode(document.getElementById('pdoc_nombre_contacto').value);

	if (!id_tidoc) {alert('Ingrese TIPO DE DOCUMENTO'); return;}
	if (id_tidoc==5) if (!doc_otro_tipo) {alert('Ingrese OTRO TIPO DE DOCUMENTO'); return;}
	if (!doc_numero) {alert('Ingrese NUMERO DE DOCUMENTO'); return;}
	if (!doc_nombres_propietario) {alert('Ingrese NOMBRES DEL PROPIETARIO'); return;}
	if (!doc_paterno_propietario) {alert('Ingrese PATERNO DEL PROPIETARIO'); return;}
	if (!doc_materno_propietario) {alert('Ingrese MATERNO DEL PROPIETARIO'); return;}
	if (!doc_fecha) {alert('Ingrese FECHA DE HALLAZGO O PERDIDA'); return;}
	if (doc_estado>0) if (!doc_region) {alert('Ingrese REGION PARADERO ACTUAL DEL DOCUMENTO'); return;}
	if (doc_estado>0) if (!doc_ciudad) {alert('Ingrese CIUDAD PARADERO ACTUAL DEL DOCUMENTO'); return;}
	if (doc_estado>0) if (!id_lugar) if (!doc_paradero) {alert('Ingrese PARADERO PARTICULAR ACTUAL DEL DOCUMENTO'); return;}
	if (!id_lugar) if (!doc_nombre_contacto) {alert('Ingrese NOMBRE CONTACTO'); return;}
	if (!id_lugar) if (!doc_telefono_contacto) {alert('Ingrese TELEFONO CONTACTO'); return;}
	if (!id_lugar) if (!doc_correo_contacto) {alert('Ingrese CORREO CONTACTO'); return;}

	querystr+='pid_tidoc='+id_tidoc;
	querystr+='&pdoc_region='+doc_region;
	querystr+='&pdoc_ciudad='+doc_ciudad;
	querystr+='&pdoc_estado='+doc_estado;
	querystr+='&pdoc_otro_tipo='+doc_otro_tipo;
	querystr+='&pdoc_numero='+doc_numero;
	querystr+='&pdoc_nombres_propietario='+doc_nombres_propietario;
	querystr+='&pdoc_paterno_propietario='+doc_paterno_propietario;
	querystr+='&pdoc_materno_propietario='+doc_materno_propietario;
	querystr+='&pdoc_fecha='+doc_fecha;
	querystr+='&pid_lugar='+id_lugar;
	querystr+='&pdoc_paradero='+doc_paradero;
	querystr+='&pdoc_nombre_contacto='+doc_nombre_contacto;
	querystr+='&pdoc_telefono_contacto='+doc_telefono_contacto;
	querystr+='&pdoc_correo_contacto='+doc_correo_contacto;
	querystr+='&mision=0XHin2';
	traerScript('modulos/aplicaciones/webadmin/documentos_opciones.php',querystr,'','');
}
function verificar_registrar(){
if (window.event.keyCode==13)
{
	registrar_usuario();
    return false;
}
}
function registrar_usuario(){
//registrar_usuario
//alert('Este servicio aún no se encuentre disponible');
var querystr='';
var usu_email=URLEncode(document.getElementById('pusu_email').value);
var usu_clave=URLEncode(document.getElementById('pusu_clave').value);
var confirmacion=URLEncode(document.getElementById('pconfirmacion').value);
var usu_rut=document.getElementById('pusu_rut').value;
var usu_dv=URLEncode(document.getElementById('pusu_dv').value);
var usu_ap_paterno=URLEncode(document.getElementById('pusu_ap_paterno').value);
var usu_ap_materno=URLEncode(document.getElementById('pusu_ap_materno').value);
var usu_nombres=URLEncode(document.getElementById('pusu_nombres').value);
var usu_telefono=URLEncode(document.getElementById('pusu_telefono').value);
var usu_celular=URLEncode(document.getElementById('pusu_celular').value);
var usu_region=document.getElementById('pusu_region').value;
var usu_ciudad=URLEncode(document.getElementById('pusu_ciudad').value);

if (!usu_email) {alert('ingrese EMAIL'); return;}
if (!usu_clave) {alert('ingrese CLAVE'); return;}
if (!confirmacion) {alert('ingrese CONFIRMACION DE CLAVE'); return;}
if (usu_clave!=confirmacion) {alert('Error: CLAVE y CONFIRMACION DE CLAVE no coinciden'); return;}
if (!usu_ap_paterno) {alert('Error: ingrese AP PATERNO'); return;}
if (!usu_ap_materno) {alert('Error: ingrese AP MATERNO'); return;}
if (!usu_nombres) {alert('Error: ingrese NOMBRES'); return;}
if (!usu_telefono && !usu_celular) {alert('Error: ingrese TELEFONO o CELULAR'); return;}
if (!usu_region) {alert('Error: ingrese REGION'); return;}
if (!usu_ciudad) {alert('Error: ingrese CIUDAD'); return;}



querystr+='pusu_email='+usu_email;
querystr+='&pusu_clave='+usu_clave;
querystr+='&pconfirmacion='+confirmacion;
querystr+='&pusu_rut='+usu_rut;
querystr+='&pusu_dv='+usu_dv;
querystr+='&pusu_ap_paterno='+usu_ap_paterno;
querystr+='&pusu_ap_materno='+usu_ap_materno;
querystr+='&pusu_nombres='+usu_nombres;
querystr+='&pusu_telefono='+usu_telefono;
querystr+='&pusu_celular='+usu_celular;
querystr+='&pusu_region='+usu_region;
querystr+='&pusu_ciudad='+usu_ciudad;
querystr+='&mision=0XHin2';
traerScript('modulos/aplicaciones/webadmin/usuarios_opciones.php',querystr,'','');
return false;
}
function selector_ciudades(iregion,iciudad,idselector,adicional,dvselector){
	// selector_ciudades -> iregion,iciudad,idselector,adicional,dvselector
	var querystr='';
	var msgespera='<img src="imagenes/cargando.gif" border=0 align="absmiddle" width="16" height="16">';

    if (!document.getElementById(idselector)) return;
    if (!document.getElementById(dvselector)) return;
    document.getElementById(idselector).disabled=true;

    msgespera=document.getElementById(dvselector).innerHTML+msgespera;

	querystr='pid_region='+iregion;
	querystr+='&pid_ciudad='+iciudad;
	querystr+='&pid_selector='+idselector;
	querystr+='&padicional='+adicional;
	traerDatos('modulos/aplicaciones/webadmin/selector_ciudades.php',querystr,dvselector,msgespera,'activar_estado_documento()');
}
function selector_lugares(iregion,ilugar,idselector,adicional,dvselector){
	// selector_lugares -> iregion,ilugar,idselector,adicional,dvselector
	var querystr='';
	var msgespera='<img src="imagenes/cargando.gif" border=0 align="absmiddle" width="16" height="16">';

    if (!document.getElementById(idselector)) return;
    if (!document.getElementById(dvselector)) return;
    document.getElementById(idselector).disabled=true;

    msgespera=document.getElementById(dvselector).innerHTML+msgespera;

	querystr='pid_region='+iregion;
	querystr+='&pid_lugar='+ilugar;
	querystr+='&pid_selector='+idselector;
	querystr+='&padicional='+adicional;
	traerDatos('modulos/aplicaciones/webadmin/selector_lugares.php',querystr,dvselector,msgespera,'activar_estado_documento()');
}
function activar_otro_tipo(){
	//activar_otro_tipo
	document.getElementById('pdoc_otro_tipo').readOnly=(document.getElementById('pid_tidoc').value!=5);
	document.getElementById('pdoc_otro_tipo').value=(document.getElementById('pid_tidoc').value!=5) ? '' : document.getElementById('pdoc_otro_tipo').value;
}
function activar_otro_paradero(){
	//activar_otro_paradero
	var breadOnly=true;
	var querystr;
	if (document.getElementById('pid_lugar').value=='') breadOnly=false;
	document.getElementById('pdoc_paradero').readOnly=breadOnly;
	document.getElementById('pdoc_nombre_contacto').readOnly=breadOnly;
	document.getElementById('pdoc_telefono_contacto').readOnly=breadOnly;
	document.getElementById('pdoc_correo_contacto').readOnly=breadOnly;
	if (breadOnly)
	{
		document.getElementById('pdoc_paradero').value='';
		document.getElementById('pdoc_nombre_contacto').value='';
		document.getElementById('pdoc_telefono_contacto').value='';
		document.getElementById('pdoc_correo_contacto').value='';

		querystr='pid_lugar='+document.getElementById('pid_lugar').value;
		querystr+='&mision=0XHdp7';
		traerScript('modulos/aplicaciones/webadmin/documentos_opciones.php',querystr);
	}
}
function activar_estado_documento(){
	//activar_estado_documento
	var bdisabled=true;
	var querystr;
	if (document.getElementById('pdoc_estado').value>0) bdisabled=false;
	document.getElementById('pdoc_region').disabled=bdisabled;
	document.getElementById('pdoc_ciudad').disabled=bdisabled;
	document.getElementById('pdoc_paradero').disabled=bdisabled;
	document.getElementById('pid_lugar').disabled=bdisabled;

	if (bdisabled)
	{
		document.getElementById('pdoc_region').value='';
		document.getElementById('pdoc_ciudad').value='';
		document.getElementById('pdoc_paradero').value='';
		document.getElementById('pid_lugar').value='';

	}
}
function registrar_usuarios(){
	//registrar_usuarios
	var querystr;
	var msgespera='<center style="font-size: 7pt;"><img src="imagenes/cargando.gif" border=0 align="absmiddle">Cargando..</center>';
	querystr='i=1';
	traerDatos('modulos/aplicaciones/webadmin/fragmentos_registrar_usuarios.php',querystr,'dvresultado',msgespera);
}
function generar_novedades(modelo){

	ocultar_acceso();
	//generar_novedades
	var querystr;
	var msgespera;
	modelo = modelo ? modelo :  0;
	msgespera=msgEsperaGnral[modelo];

	querystr='pidp=1';
	querystr+='&mision=0XHgn6';
	querystr+='&modelo='+modelo;
	traerDatos('modulos/aplicaciones/webadmin/novedades_opciones.php',querystr,'dvresultado',msgespera);
}
function administrar(){
	window.open("modulos/aplicaciones/webadmin/adminsys.php");
}
function mostrar_panel(){
	//mostrar_panel
	var querystr;
	var msgespera='<center style="font-size: 7pt;"><img src="imagenes/cargando.gif" border=0 align="absmiddle">Cargando..</center>';
	querystr='pidp=1';
	traerDatos('modulos/aplicaciones/webadmin/fragmentos_panel_de_control.php',querystr,'dvresultado',msgespera);
}
function generar_secciones()
{
	var querystr;
	var msgespera='<center style="font-size: 7pt;"><img src="imagenes/cargando.gif" border=0 align="absmiddle" width="18" height="18">Cargando..</center>';
	querystr='mision=0XHds7';
	traerDatos('modulos/aplicaciones/webadmin/secciones_opciones.php',querystr,'dvSecciones',msgespera);
}
function desplegar_seccion(id_seccion,modelo)
{
	ocultar_acceso();

	var querystr;
	var msgespera;
	modelo = modelo ? modelo :  0;
	msgespera=msgEsperaGnral[modelo];

	querystr='pid_seccion='+id_seccion;
	querystr+='&mision=0XHdp6';
	querystr+='&modelo='+modelo;
	traerDatos('modulos/aplicaciones/webadmin/secciones_opciones.php',querystr,'dvresultado',msgespera);
}
function generar_servicios()
{

	var querystr;
	var msgespera='<center style="font-size: 7pt;"><img src="imagenes/cargando.gif" border=0 align="absmiddle" width="18" height="18">Cargando..</center>';
	querystr='mision=0XHds6';
	traerDatos('modulos/aplicaciones/webadmin/servicios_opciones.php',querystr,'dvServicios',msgespera);
}
function desplegar_contacto(modelo)
{
	ocultar_acceso();

	var querystr;
	var msgespera;
	modelo = modelo ? modelo :  0;
	msgespera=msgEsperaGnral[modelo];

	querystr='ctt=1';
	querystr='&modelo='+modelo;
	traerDatos('modulos/aplicaciones/webadmin/fragmentos_contacto.php',querystr,'dvresultado',msgespera);
}

function desplegar_documentos()
{
	var querystr;
	var msgespera='<center style="font-size: 7pt;"><img src="imagenes/cargando.gif" border=0 align="absmiddle" width="18" height="18">Cargando..</center>';
	querystr='mision=0XHld6';
	traerDatos('modulos/aplicaciones/webadmin/documentos_opciones.php',querystr,'dvltdocumentos',msgespera);
	return true;
}

function desplegar_datos_personales()
{
	//desplegar_datos_personales
	var querystr;
	var msgespera='<center style="font-size: 7pt;"><img src="imagenes/cargando.gif" border=0 align="absmiddle">Buscando..</center>';

	querystr='mision=0XHdp6';

	traerDatos('modulos/aplicaciones/webadmin/fragmentos_datos_personales.php?gid=895&gmision=0XHdp6',querystr,'dvPanelCuerpo',msgespera,'');
}

function desplegar_cambio_clave()
{
	//desplegar_datos_personales
	var querystr;
	var msgespera='<center style="font-size: 7pt;"><img src="imagenes/cargando.gif" border=0 align="absmiddle">Buscando..</center>';

	querystr='mision=0XHdp6';

	traerDatos('modulos/aplicaciones/webadmin/fragmentos_cambio_clave.php?gid=895&gmision=0XHdp6',querystr,'dvPanelCuerpo',msgespera,'');
}

function desplegar_mis_documentos()
{
	var querystr;
	var msgespera='<center style="font-size: 7pt;"><img src="imagenes/cargando.gif" border=0 align="absmiddle" width="18" height="18">Cargando..</center>';
	querystr='mision=0XHld6';
	traerDatos('modulos/aplicaciones/webadmin/documentos_opciones.php',querystr,'dvPanelCuerpo',msgespera);
	return true;
}

function desplegar_recuperar_clave()
{
	//desplegar_recuperar_clave
	var querystr;
	var msgespera='<center style="font-size: 7pt;"><img src="imagenes/cargando.gif" border=0 align="absmiddle">Buscando..</center>';

	querystr='idxci=1542';
	traerDatos('modulos/aplicaciones/webadmin/fragmentos_recuperar_clave.php',querystr,'dvresultado',msgespera,'');
}

function recuperar_clave_usuario()
{
	//recuperar_clave_usuario
	var querystr='';

	var usu_email=URLEncode(document.getElementById('pusu_email').value);
	var usu_ap_materno=URLEncode(document.getElementById('pusu_ap_materno').value);
	var usu_region=document.getElementById('pusu_region').value;

	if (!usu_email) {alert('Ingrese EMAIL'); return;}
	if (!usu_ap_materno) {alert('Ingrese APELLIDO MATERNO'); return;}
	if (!usu_region) {alert('Ingrese REGION'); return;}

	querystr+='pusu_email='+usu_email;
	querystr+='&pusu_ap_materno='+usu_ap_materno;
	querystr+='&pusu_region='+usu_region;
	querystr+='&mision=0XHrc7';
	traerScript('modulos/aplicaciones/webadmin/usuarios_opciones.php',querystr,'','');

}
function buscar_doctos_index(){
//buscar_doctos
var querystr;
var msgespera='<center style="font-size: 7pt;"><img src="imagenes/cargando.gif" border=0 align="absmiddle">Cargando..</center>';
querystr='i=1';
objtabb.tab_deshabilitar_individual[1]=1;
objtabb.tab_actual=0;
traerDatos('modulos/aplicaciones/webadmin/fragmentos_buscar_doctos.php',querystr,'dv_buscadocs',msgespera,'objtabb.inicializar(0)');
}
function buscar_estandar(mision_buscar,pagina)
{
	var valor;
	var msgespera='<center style="font-size: 7pt;"><img src="imagenes/cargando.gif" border=0 align="absmiddle">Buscando..</center>';

	querystr='ptexto_busca='+document.getElementById('ptexto_busca').value;
	querystr+='&mision='+mision_buscar;
	traerDatos(pagina,querystr,'resultado',msgespera);
}
function editar_estandar(num_frame, id,id_tab,pagina,mision)
{
	if (window.parent.document.getElementById('f'+num_frame))
	{
		window.parent.document.getElementById('f'+num_frame).src='blank.php';
		window.parent.objtab.tab_actual=id_tab;
		window.parent.objtab.inicializar();
		window.parent.document.getElementById('f'+num_frame).src=pagina + '?gmision='+mision+'&gid='+id;
	}
}
function eliminar_estandar(nombreid,id,pagina,funcion)
{
	var querystr='';
	if (!confirm('¿Estás seguro que deseas eliminar?')) return;

	querystr=nombreid + '='+id;
	querystr+='&mision=0XHel4';
	traerScript(pagina,querystr,funcion);
}
function FixCalcX(el)
{
    if(typeof(el.offsetParent) == "undefined")
        return [70, 4000];
	var a = new Array(0, -70);
	while(el)
	{
		a[0] += el.offsetLeft || 0;
		a[1] += el.offsetTop || 0;
		el = el.offsetParent || null;
	}
	return a[0];
}
function FixCalcY(el)
{
    if(typeof(el.offsetParent) == "undefined")
        return [70, 4000];
	var a = new Array(0, -70);
	while(el)
	{
		a[0] += el.offsetLeft || 0;
		a[1] += el.offsetTop || 0;
		el = el.offsetParent || null;
	}
	return a[1];
}

function FixCalcXY(el)
{
    if(typeof(el.offsetParent) == "undefined")
        return [70, 4000];
	var a = new Array(0, -70);
	while(el)
	{
		a[0] += el.offsetLeft || 0;
		a[1] += el.offsetTop || 0;
		el = el.offsetParent || null;
	}
	return a;
}


////////////FIN WEB///////////
