/**
 * @package	GeoDatum
 * Proyecto	:	GeoDatum - Sistema de Informaciï¿½n Territorial
 * Archivo	:	enc.js
 *
 * @link http://www.siigsa.cl
 * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
 * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
 * @since 04-02-2010
 * @version 1.0.18
 *
 * Archivo JS del sistema INICIO, se cargan funciones y prototipos genericos para todos
 * los formularios y paginas del sistema.
 *
 * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
 * @since 17-12-2008
 * @version 11
 * redir_popup();
 *
 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
 * @since 17-03-2009
 * @version 12
 * seleccionarDeseleccionarBuscarContenido()
 *
 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
 * @since 23-04-2009
 * @version 13
 * setFormatoNumero()
 *
 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
 * @since 27-04-2009
 * @version 14
 * setFormatoNumero()
 *
 * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
 * @since 01-07-2009
 * @version 15
 * redir()
 *
 * @author Gonzalo Arenas Flores
 * @since 05-08-2009
 * @version 16
 * seleccionarDeseleccionarCHK()
 *
 * @author Gonzalo Arenas Flores
 * @since 12-08-2009
 * @version 17
 * expandirContraerDivisor()
 *
 * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
 * @since 04-02-2010
 * @version 18
 * redir()
 *
 * @author Jose Meneses Gonzalez <jmeneses@siigsa.cl>
 * @since 14-04-2011
 * @version 1.1.19
 * redir_popup()
 *
 * @author Gonzalo A. Arenas Flores <garenas@siigsa.cl>
 * @since 14-11-2011
 * @version 1.2.0
 * redir_popup()
 */

/*INSTANCIADO DE CLASES JS*/
var oTenc 			= new Tag();
var oNavegador 	= new Navegador();


/*****************************************************
 *													 *
 *					VALIDACION DE NAVEGADORES		 *
 *													 *
 *****************************************************/

	oNavegador.validarNavegador();

	/**
 	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @since 20-05-2008
	 * @version 1.0.8
	 *
	 * Prototipo que verifica espacios en Blanco
	 *
	 * @param string $string	:	texto con espacios
	 * @return string
	 *
	 */
	String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };


	/**
	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @since 20-05-2008
	 * @version 1.0.2
	 *
	 * Prototipo que valida valores numericos
   *
   * @param string $string	:	texto con valores numericos
   * @return boolean
   *
   */
	String.prototype.isNumeric = function() {
		var RegExp = /^[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?$/;
		var result = this.match(RegExp);
		if (result==null) result = false;
		else result = true;

		return result;
	};


	/**
	 * @link http://www.siigsa.cl
 	 * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
 	 * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @since 20-05-2008
	 * @version 1.0.2
	 *
   * Prototipo que valida si un valor se encuentra en un arreglo
   *
   * @param mixed $obj	:	arreglo de entrada
   * @return boolean
   *
   */
	Array.prototype.in_array = function ( obj ) {
		var len = this.length;
		for ( var x = 0 ; x <= len ; x++ ) {
			if ( this[x] == obj ) return true;
		}
		return false;
	}


	/**
	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @since 20-05-2008
	 * @version 1.0.2
	 *
   * Protitpo que retorna el indice de un arreglo segun un valor
   *
   * @param mixed $obj	:	arreglo de entrada
   * @return mixed
   *
   */
	Array.prototype.array_key = function ( obj ) {
		var len = this.length;
		for ( var x = 0 ; x <= len ; x++ ) {
			if ( this[x] == obj ) return x;
		}
		return false;
	}


	/**
	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @since 20-05-2008
	 * @version 1.0.1
	 *
   * Deshabilitacion del clack del mouse
   *
   * @return false
   */
//	document.oncontextmenu = function() { return false; };


	/**
	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @since 20-05-2008
	 * @version 1.0.1
	 *
	 * Impide teclear valores no numericos
	 *
	 *@param object $e	:	evento
	 *@param string	$objeto	:	referencia a objeto de html
	 *@param string	$tipo_dato	:	Si el 3er parametro (dato) es "float" se permite ingresar un punto para el valor decimal.
	 *
	 * Ejemplo uso onkeypress="return validarNumeros(event, this,'')"
	 *
	 */
	function validarNumeros(e, objeto, tipo_dato){

	  tecla = (document.all) ? e.keyCode : e.which;
	  teclasPermitidas = {0:0, 8:0, 13:0, 22:0, 37:0, 39:0};
	  teclasCTRLPermitidas = {c:0, x:0};
	  te = String.fromCharCode(tecla);

	  if ( (tecla in teclasPermitidas) || (e.ctrlKey && (te in teclasCTRLPermitidas))) return true;

	  expresion = "\\d";

	  if (objeto.value.length == 0) {
			expresion += "|-";
	  }

	  if (objeto.value.substr(0,1) == "-")
	  	posPermitirPunto = 1;
	  else
	  	posPermitirPunto = 0;

//	  if(tipo_dato == "float" && objeto.value.indexOf(".") == -1 && objeto.value.length > posPermitirPunto) {
//			expresion += "|.";
//	  }

		_obj = objeto.value.split(".");
	  if(tipo_dato == "float" && tecla == 46 && tecla != 44 && _obj.length < 2){
			expresion += "|.";
	  }

	  patron = new RegExp(expresion);
	  return patron.test(te);
	}


	/**
	 * @link 			http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author 		Jose Meneses Gonzalez <jmeneses@siigsa.cl>
	 * @since 		01-10-2009
	 * @version 	1.0.1
	 *
	 * Funcion que valida en ingreso de fecha a mano
	 *
	 * @param event		e			:	Evento HTML
	 * @param object	_obj	:	Objeto HTML

	 * Ejemplo uso onkeypress = "return enc_validarFecha(event,this)"
	 *
	 */
	function enc_validarFecha(e, _obj) {

		tecla = (document.all) ? e.keyCode : e.which;

		teclasPermitidas 	= {8:0, 48:0, 49:0, 50:0, 51:0, 52:0, 53:0, 54:0, 55:0, 56:0, 57:0};

		if (tecla != 8){

			_largo = _obj.value.split('');


			/***************************************/
			/** VALIDACION POR DIAS, MESES Y Aï¿½OS **/
			/***************************************/

			/*VALIDACION DE DIAS*/
			if (_largo[0]+_largo[1] == 00 || _largo[0]+_largo[1] > 31){
				alert("No existe el dia. Digite la Fecha nuevamente");
				_obj.value = '';
				return false;
			}

			/*VALIDACION DE MESES*/
			if (_largo[3]+_largo[4] == 00 || _largo[3]+_largo[4] > 12){
				alert("No existe el mes. Digite la Fecha nuevamente");
				_obj.value = '';
				return false;
			}

			/********************************************/
			/** VALIDACION DE CANTIDAD DE DIAS POR MES **/
			/********************************************/

			/*VALIDACION MES FEBRERO*/
			if (_largo[0]+_largo[1] > 29 && _largo[3]+_largo[4] == 2){
				alert("El mes de Febrero no puede tener mas de 29 dias");
				_obj.value = '';
				return false;
			}

			/*VALIDACION MES ABRIL*/
			if (_largo[0]+_largo[1] > 30 && _largo[3]+_largo[4] == 4){
				alert("El mes de Abril no puede tener mas de 30 dias");
				_obj.value = '';
				return false;
			}

			/*VALIDACION MES JUNIO*/
			if (_largo[0]+_largo[1] > 30 && _largo[3]+_largo[4] == 6){
				alert("El mes de Junio no puede tener mas de 30 dias");
				_obj.value = '';
				return false;
			}

			/*VALIDACION MES JUNIO*/
			if (_largo[0]+_largo[1] > 30 && _largo[3]+_largo[4] == 9){
				alert("El mes de Septiembre no puede tener mas de 30 dias");
				_obj.value = '';
				return false;
			}

			/*VALIDACION MES JUNIO*/
			if (_largo[0]+_largo[1] > 30 && _largo[3]+_largo[4] == 11){
				alert("El mes de Noviembre no puede tener mas de 30 dias");
				_obj.value = '';
				return false;
			}

			/****************/
			/** AUTO-GUION **/
			/****************/

			if (_largo.length == 2 || _largo.length == 5){ _obj.value = _obj.value + '-'; }

		}

		if ((tecla in teclasPermitidas)){ return true; }
		else { return false; }

	}

	/**
	 * @copyright 2008 - SIIGSA
	 * @author Oscar Cardenas Albornoz <ocardenas@siigsa.cl>
	 * @since 04-11-2009
	 * @version 1.0.0
	 *
	 * Valida que el largo de la fecha sea de 10 digitos
	 */
	function validaLargoFecha(_obj){

		if(_obj.value.trim().length < 10 && _obj.value.trim() != ""){
			alert("Formato de fecha incorrecto. Ingrese nuevamente");
			_obj.value = "";
		}

	}


	/**
	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @since 20-05-2008
	 * @version 1.0.1
	 *
	 * Formatea un numero con decimales
	 *
	 *@param string	expr	:	valores numericos
	 *@param string decplaces	:	cantidad de decimaes del numero a mostrar
	 *
	 */
	function FormatNumber(expr, decplaces) {

		var str = "" + Math.round(eval(expr) * Math.pow(10,decplaces));
		while (str.length <= decplaces) {
			str = "0" + str;
		}

		var decpoint = str.length - decplaces;

		return str.substring(0,decpoint) + "," + str.substring(decpoint, str.length);

	}




	/**
	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
   * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
   * @since 27-04-2009
   * @version 1.0.1
   *
   * Da formato a un nï¿½mero.
   *
   * @param String	$numero			:		Nï¿½mero a formatear
   * @param String	$sep_miles	:		Separador de miles
   * @param String	$sep_dec		:		Separador de decimales
   * @param String	$num_dec		:		Nï¿½mero de decimales.
   *
   * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
   * @since 27-04-2009
   * @version 1.0.1
   * toLocaleString();
	 */
	function setFormatoNumero(numero, sep_miles, sep_dec, num_dec){

		if(typeof(numero) == "undefined")		{alert("Debe especificar un numero para aplicar el formato");return false;}
		if(typeof(sep_miles) == "undefined"){sep_miles = ".";}
		if(typeof(sep_dec) == "undefined")	{sep_dec = ",";}

		var num = '';
		numero += '';
		if(numero != 0){
			num = numero.split(".");
		}

		if(num.length > 1){
			return implode(num,'');
		}else{

			//Transforma el string del numero a un formato numï¿½rico
			//luego lo formatea al definido de forma local en el equipo
			numero_tmp = Number(numero).toLocaleString();
			if(isNaN(parseInt(numero_tmp))){return numero;}

			var num_tmp = '';
			num_tmp = numero_tmp.split(",");

			var entero = replace(num_tmp[0],',','.');

			if(num_dec > 0){
				numero = entero + sep_dec + num_tmp[1];
			}else{
				numero = entero;
			}

			return numero;

		}

	}


	/**
	 * @link http://www.siigsa.cl
	 * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
	 * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @since 04-02-2010
	 * @version 1.0.14
	 *
   * Redirecciona pagina segun parametros de query desde GET a POST
   *
   * @param string $parametros	:	parametros de valores
   * @param string $cual	: si es ventana o popup
   *
	 * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @since 28-04-2009
	 * @version 12
	 * Se agrega "/" en el action del form para que regrese siempre al inicio del sistema sin parametros de GET
	 *
	 * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @since 01-07-2009
	 * @version 13
	 * Se modifica el codigo para que sea validado por la W3C
	 *
	 * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @since 04-02-2010
	 * @version 14
	 * Se modifica el codigo para que al volver atras con el boton del browser
	 * vuelva a la pagina desde donde fue llamado y no al formulario intermedio,
	 * de esta forma queda solucionado el doble click atras.
	 * 2010-03-23 No funciono la solucion para internet Explorer
   */
	function redir(parametros, _cual, _pf){

		if (isNaN(_cual)) _cual = 1;

		var _param	= parametros.split('#');
		var _form		= "";
		var _var		= "";
		//var oDenc		= new Divisor();

		_form += "<div style='position:relative;border:0px solid red;text-align:center;width:100%;height:20px;top:25%;'><img src='" + GC_WEB_IMG + "/load_rss.gif' class='img' alt='Cargando...' title='Cargando...' />Cargando...</div>";
		_form += "<form method='post' action='/' style='visibility:hidden;display:none' name='frm_redir' id='frm_redir'><p>";

		for (i=0;i<_param.length;i++){
			_var = _param[i].split('=');
			_form += "<input type='hidden' name='" + _var[0] + "' value='" + _var[1] + "' />";
		}

		_form += "<input type='submit' value='Cargando' /></p>";
		_form += "</form>";

		if (_cual == 1){

			oDenc.posicionAuto = false;
			oDenc.crearDivisor('',GC_BULEANO_F);
			oDenc.setContenido("","",_form);
			document.getElementById('frm_redir').submit();

		}else if (_cual == 2){

			if (!window.opener){

				oDenc.posicionAuto = false;
				oDenc.crearDivisor('',GC_BULEANO_F);
				oDenc.setContenido("","",_form);
				document.getElementById('frm_redir').submit();

			}else{

				if (_pf == 1){

					var oVp = enc_getUltimaVentana();

					if (oVp!=null){
						oVp.oDenc.posicionAuto = false;
						oVp.oDenc.crearDivisor('',GC_BULEANO_F);
						oVp.oDenc.setContenido("","",_form);
						oVp.document.getElementById('frm_redir').submit();
					}else{
						window.opener.oDenc.posicionAuto = false;
						window.opener.oDenc.crearDivisor('',GC_BULEANO_F);
						window.opener.oDenc.setContenido("","",_form);
						window.opener.document.getElementById('frm_redir').submit();
					}

				}else{
					window.opener.oDenc.posicionAuto = false;
					window.opener.oDenc.crearDivisor('',GC_BULEANO_F);
					window.opener.oDenc.setContenido("","",_form);
					window.opener.document.getElementById('frm_redir').submit();
				}

			}

		}


	}


	/**
	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @since 05-06-2008
	 * @version 1.0.3
	 *
   * Abre una ventana segun parametros de definiciï¿½n
   *
   * @param string $_url
   * @param string $_target
   * @param string $_conf
   */
	function ventana(_url, _target, _conf){

		if (_target=="" || typeof(_target) == "undefined" )	var _target = "_blank";
		if (_conf=="" ||  typeof(_conf) == "undefined" )	  var _conf		= "toolbar=yes,location=yes,directories=yes,menubar=yes,status=yes,resizable=yes,scrollbars=yes,left=50,top=50,width=640,height=480";

		window.open(_url, _target, _conf);

//		return true;

	}


	/**
	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @since 20-05-2008
	 * @version 1.0.1
	 *
   * Deja visible o invisible un elemento con ID
   *
   * @param string $_ele	:	elemento HTML
   *
   */
	function ver(_ele){


		if (document.getElementById(_ele).style.visibility !=""){

			if (document.getElementById(_ele).style.visibility!="hidden"){
				document.getElementById(_ele).style.visibility = "hidden";
			}else{
				document.getElementById(_ele).style.visibility = "visible";
			}

		}else{

			if (document.getElementById(_ele).style.display!="none"){
				document.getElementById(_ele).style.display = "none";
			}else{
				document.getElementById(_ele).style.display = "";
			}

		}

	}


	/**
	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @since 20-05-2008
	 * @version 1.0.3
	 *
   * Llama a la direccion del RSS para leer su contenido
   *
   * @param string _url			:	URL de donde leer el RSS
   * @param string _param		:	Parametros de filtro
   * @param string _div			:	Divisor en donde poner el contenido
   *
   * @author Jose Meneses Gonzalez <jmeneses@siigsa.cl>
	 * @since 13-01-2010
	 * @version 4
	 * @param string _titulo	:	Titulo del divisor de listado de contenidos
	 *
   */
	function cargarContenido (_url, _param, _div, _titulo){

		_param = _param.replace(/#/g,"&");

		document.getElementById(_div).innerHTML = "<img src='" + GC_WEB_IMG + "/load_rss.gif' class='img' alt='Cargando...' /><b>Cargando...</b><br /><br />";

		ajax = ObjAjax();
		ajax.open("POST", _url, true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
		ajax.send(_param);

		ajax.onreadystatechange=function(){

			leerRSS(ajax, _div, undefined, GC_BULEANO_V, _titulo);

		}

	}


	/**
	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @author Cristiï¿½n Gï¿½mez Mamani <cgomez@siigsa.cl>
	 * @author Jose Meneses Gonzalez <jmeneses@siigsa.cl>
	 * @since 27-08-2009
	 * @version 1.0.21
	 *
   * Lee el contenido del rss, lo estructura y lo deja en un contenedor determinado
   *
   * @param object $ajax	  :	Objeto ajax creado en la funcion "cargarContendido"
   * @param string $_div	  :	Divisor en donde poner el contenido
   * @param string $buscar	:	Si este parï¿½metro es distinto de vacï¿½o
   * @param string $vermas	:	Parametro que permite saber si el listado de contenidos proviene del ver mas de los divisores
   *
   *
   * @author Jose Meneses Gonzalez <jmeneses@siigsa.cl>
	 * @since 27-08-2009
	 * @version 19
	 * Recate del tag <img></img> para poder colocar en los resultados la imagen correspondiente al contenido que se esta listando
	 *
	 * @author Jose Meneses Gonzalez <jmeneses@siigsa.cl>
	 * @since 02-12-2009
	 * @version 20
	 * Se agrego el parametro "vermas" que permite saber que el listado que se esta desplegando es de los contenidos que aparecen en el "ver mas" de
	 * los divisores de listados de contenidos
	 *
	 * @author Jose Meneses Gonzalez <jmeneses@siigsa.cl>
	 * @since 26-02-2010
	 * @version 21
	 * Se cambio la estructura de los contenidos para una mejor visualizacion dentro de divisores de contenidos como de lectores de rss
	 *
   */
	function leerRSS (ajax, _div, buscar, vermas, titulo){

		var _cont 		= "";

		if (ajax.readyState==4){

			if (ajax.status==200){

//				oDenc.debug('','',ajax.responseText);
//				alert(ajax.responseText);

				var _xml = ajax.responseXML;
				var _its = _xml.getElementsByTagName("item").length;

				if (_xml.getElementsByTagName("ficha").item(0) && _xml.getElementsByTagName("ficha").item(0).firstChild != null){
					var _ficha	= _xml.getElementsByTagName("ficha").item(0).firstChild.data;
				}else{ var _ficha = ""; }
				if (_xml.getElementsByTagName("divdesccont").item(0) && _xml.getElementsByTagName("divdesccont").item(0).firstChild != null){
					var _divdesccont	= _xml.getElementsByTagName("divdesccont").item(0).firstChild.data;
				}else{ var _divdesccont = ""; }
				if (_xml.getElementsByTagName("divlist").item(0) && _xml.getElementsByTagName("divlist").item(0).firstChild != null){
					var _divlist = _xml.getElementsByTagName("divlist").item(0).firstChild.data;
				}else{ var _divlist = ""; }
				if (_xml.getElementsByTagName("divext").item(0) && _xml.getElementsByTagName("divext").item(0).firstChild != null){
					var _divext = _xml.getElementsByTagName("divext").item(0).firstChild.data;
				}else{ var _divext = ""; }
				if (_xml.getElementsByTagName("catalogo").item(0) && _xml.getElementsByTagName("catalogo").item(0).firstChild != null){
					var _catalogo = _xml.getElementsByTagName("catalogo").item(0).firstChild.data;
				}else{ var _catalogo = ""; }

				if (typeof(titulo) != 'undefined' ){
					_cont += '<table style="width:98%;text-align:justify;">';
					_cont += '<tr><td><label class="titulo2">'+ titulo +'</label></td></tr>';
					_cont += '</table>';
				}

				if (typeof(buscar) != 'undefined' && _its == 0){
					_cont += '<table style="width:98%;text-align:center;">';
					_cont += '<tr><td><b>No se encontraron contenidos para el texto ingresado en el sistema .</b></td></tr>';
					_cont += '</table>';
				}

				if (typeof(buscar) != 'undefined' && _its > 0){
					_cont += '<table style="width:98%;text-align:left;">';
					_cont += '<tr><td class="fondo_oscuro" ><label><b>&nbsp;&nbsp;&nbsp;'+ _its +' Resultado(s) a su B&uacute;squeda<br /></b></label></td></tr>';
					_cont += '</table><br />';
				}

				if (typeof(vermas) != 'undefined' && _its > 0){
					_cont += '<table style="width:98%;text-align:left;">';
					_cont += '<tr><td class="fondo_oscuro" >&nbsp;</td></tr>';
					_cont += '</table><br />';
				}

				for (i=1;i<=_its;i++){

					if (_xml.getElementsByTagName("title").item(i) && _xml.getElementsByTagName("title").item(i).firstChild != null){
						var title = _xml.getElementsByTagName("title").item(i).firstChild.data;
					}else{ var title = "";}
					if (_xml.getElementsByTagName("link").item(i) && _xml.getElementsByTagName("link").item(i).firstChild != null){
						var url = _xml.getElementsByTagName("link").item(i).firstChild.data;
					}else{ var url = ""; }
					if (_xml.getElementsByTagName("pubDate").item(i) && _xml.getElementsByTagName("pubDate").item(i).firstChild != null){
						var pubDate	= _xml.getElementsByTagName("pubDate").item(i).firstChild.data;
					}else{ var pubDate	= "";}
					if (_xml.getElementsByTagName("guid").item(i) && _xml.getElementsByTagName("guid").item(i).firstChild != null){
						var guid = _xml.getElementsByTagName("guid").item(i).firstChild.data;
					}else{ var guid = "";}

					/*Exijo una explicaciï¿½n del i-1*/
					if (_xml.getElementsByTagName("caccion").item(i-1) && _xml.getElementsByTagName("caccion").item(i-1).firstChild != null){
						var _caccion = _xml.getElementsByTagName("caccion").item(i-1).firstChild.data;
					}else{ var _caccion = ""; }
					if (_xml.getElementsByTagName("modulo").item(i-1) && _xml.getElementsByTagName("modulo").item(i-1).firstChild != null){
						var _modulo = _xml.getElementsByTagName("modulo").item(i-1).firstChild.data;
					}else{ var _modulo = ""; }
					if (_xml.getElementsByTagName("divficlis").item(i-1) && _xml.getElementsByTagName("divficlis").item(i-1).firstChild != null){
						var _divficlis = _xml.getElementsByTagName("divficlis").item(i-1).firstChild.data;
					}else{ var _divficlis = ""; }
					if (_xml.getElementsByTagName("divid").item(i-1) && _xml.getElementsByTagName("divid").item(i-1).firstChild != null){
						var _divid = _xml.getElementsByTagName("divid").item(i-1).firstChild.data;
					}else{ var _divid = ""; }
					if (_xml.getElementsByTagName("divficpor").item(i-1) && _xml.getElementsByTagName("divficpor").item(i-1).firstChild != null){
						var _divficpor = _xml.getElementsByTagName("divficpor").item(i-1).firstChild.data;
					}else{ var _divficpor = ""; }

					if(i == 1){
						if (_xml.getElementsByTagName("divficporpricon").item(i-1) && _xml.getElementsByTagName("divficporpricon").item(i-1).firstChild != null){
							var _divficporpricon = _xml.getElementsByTagName("divficporpricon").item(i-1).firstChild.data;
						}else{ var _divficporpricon = ""; }
					}

					if (_xml.getElementsByTagName("img").item(i-1) && _xml.getElementsByTagName("img").item(i-1).firstChild != null){
						var _img = _xml.getElementsByTagName("img").item(i-1).firstChild.data;
					}else{ var _img = ""; }
//					alert(_modulo);
					/*TAGS DE MAPAS*/
					if (_xml.getElementsByTagName("wms").item(i-1) && _xml.getElementsByTagName("wms").item(i-1).firstChild != null){
						var _wms = _xml.getElementsByTagName("wms").item(i-1).firstChild.data
					}else{ var _wms = "";	}

					if (_divlist	==	GC_BULEANO_F){
						if (_catalogo){
							if (typeof(buscar) != 'undefined' && _its > 0){
								_cont += "<div style='text-align:justify; float:left; width:100px; height:100px; padding-right:5px; padding-left:10px; padding-bottom:150px; padding-top:0px; border:0px solid red; '>";
							}else{
								_cont += "<div style='text-align:justify; float:left; width:100px; height:100px; padding-right:" + GC_PADDING_RIGHT_CATALOGO_RSS + "; padding-left:" + GC_PADDING_LEFT_CATALOGO_RSS + "; padding-bottom:" + GC_PADDING_BOTTOM_CATALOGO_RSS + "; padding-top:" + GC_PADDING_TOP_CATALOGO_RSS + "; border:0px solid red; '>";
							}
						}else{
							if (typeof(buscar) != 'undefined' && _its > 0){
								_cont += "<div style='text-align:justify; float:left; width:100px; height:100px; padding-right:5px; padding-left:10px; padding-bottom:150px; padding-top:0px; border:0px solid blue; '>";
							}else{
								_cont += "<div style='text-align:justify; float:left; width:100px; height:100px; padding-right:5px; padding-left:10px; padding-bottom:30px; padding-top:0px; border:0px solid blue; '>";
							}
						}
					}

					if ((typeof(buscar) != 'undefined') || (typeof(vermas) != 'undefined' && _its > 0)){
						if (GC_RSS_NT == GC_BULEANO_V) title = "<H3 style=\'color:orange;\'>" + title + "</H3>";
					}else{
						if (GC_RSS_NT == GC_BULEANO_V) title = "<b>" + title + "</b>";
					}

//					if (_divdesccont == GC_BULEANO_V){
//						var description = _xml.getElementsByTagName("description").item(i).firstChild.data;
//					}else{
//						var description = "";
//					}
//					console.log("_divdesccont : %s",_divdesccont);
					if (_divdesccont == "true"){
						var description = _xml.getElementsByTagName("description").item(i).firstChild.data;
					}
					else if(_divdesccont == "false"){
					     var description = "";
					}
					else if(_divdesccont.trim() == ""){
						if(_divext == "true"  || _divext=="false" ){
							 var description = "";
						}else if(_divext == ""){
						var description = _xml.getElementsByTagName("description").item(i).firstChild.data;
					   }

					}


					/*Id objeto*/
					if (typeof(buscar) != 'undefined' || typeof(vermas) != 'undefined'){
						if (GC_OBJETO_ID_RSS == GC_BULEANO_V){
							var _idobj = "<b>"+guid+" </b><br />";
						}else{
							var _idobj = "";
						}
					}else{
//						if (GC_OBJETO_ID_RSS == GC_BULEANO_V){
//							var _idobj = "<b>"+guid+"kk</b><br />";
//						}else{
//							var _idobj = "";
//						}
						/*nreyes*/
					  if (GC_OBJETO_ID_RSS == GC_BULEANO_V && _divext.trim() != ""){
							var _idobj = "<b>"+guid+"</b><br />";
						}else{
							var _idobj = "";
						}
						/*nreyes*/
					}

					pubDate = pubDate.split(" -");
					pubDate = pubDate[0];

					if (GC_OBJETO_FICHA == GC_BULEANO_V){
						if (_divext == GC_BULEANO_V){
							title = "<label style='cursor:pointer' onclick=\"ventana('" + url + "','_blank')\" >" + title + " </label>";
						}

						/*nreyes*/
						else if (_divext.trim() == ""){

									title = "<a href='javascript:;'  onclick=\"ventana('"+ url +"','_blank')\" ><label style='cursor:pointer'>" + title + " </label></a>";/*LA LECTURA NORMAL*/
						}
						/*nreyes*/
						else if(_divext == GC_BULEANO_F ){
							if (typeof(buscar) != 'undefined' || typeof(vermas) != 'undefined'){
								if (_divficpor == GC_BULEANO_V){
									if (_divficporpricon == GC_BULEANO_V){
										document.getElementById('oid_'+_divid).value = guid;
										document.getElementById('fp_form_'+_divid).submit();
										_divficporpricon = GC_BULEANO_F;
									}
									title = "<a href='javascript:;' style='cursor:pointer' onclick=\"document.getElementById('oid_"+_divid+"').value = " + guid + "; document.getElementById('fp_form_"+_divid+"').submit();\" ><label>" + title + "</label></a>";/*LA LECTURA NORMAL*/
								}else{
									title = "<a href='javascript:;' style='cursor:pointer' onclick=\"redir_popup('/exp/ficha.php','oid=" + guid + "#cont_desde_bus="+ GC_BULEANO_V +"',2)\" ><label>" + title + "</label></a>";/*LA LECTURA NORMAL*/
								}
							}

							else{
								if (_divficpor == GC_BULEANO_V){
									if (_divficporpricon == GC_BULEANO_V){
										document.getElementById('oid_'+_divid).value = guid;
										document.getElementById('fp_form_'+_divid).submit();
										_divficporpricon = GC_BULEANO_F;
									}
									title = "<label style='cursor:pointer' onclick=\"document.getElementById('oid_"+_divid+"').value = " + guid + "; document.getElementById('fp_form_"+_divid+"').submit();\" >" + title + "</label>";/*LA LECTURA NORMAL*/
								}else{
									title = "<label style='cursor:pointer' onclick=\"redir_popup('/exp/ficha.php','oid=" + guid + "',2)\" >" + title + "</label>";/*LA LECTURA NORMAL*/
								}
							}
						}
					}else if (GC_OBJETO_FICHA == GC_BULEANO_F){
						if (_divext == GC_BULEANO_V){
							title = "<label style='cursor:pointer' onclick=\"ventana('" + url + "','_blank')\" >" + title + "  </label>";
						}else{
							title = "<label style='cursor:pointer' onclick=\"redir('oid=" + guid + "#modaccion=visualizar_ficha')\" >" + title + " </label>";
						}
					}

					var _verficha 	= "";
					if (_ficha == GC_BULEANO_V){
						if (_divext == GC_BULEANO_V){
							_verficha += "<a href=\"javascript:;\" onclick=\"ventana('" + url + "','_blank')\" >" + GC_VER_FICHA + " </a>";
							if (_wms.trim() != "" && _divficlis == "true"){
								_verficha += "&nbsp;" + GC_SEPARADOR_FICHA_MAPA_RSS + "&nbsp;<a href='javascript:;' onclick='redir(\"modulo=0x397x86#oid="+GC_MAPA_XML+"#cugid="+GC_MAPA_UG+"#wm_wms="+_wms+"\")' >" + GC_VER_MAPA + "</a>";
							}else{
								if (_caccion.trim() != '' && _divficlis == "true"){
									_verficha += "&nbsp;" + GC_SEPARADOR_FICHA_MAPA_RSS + "&nbsp;" + _caccion;
								}
							}
						}else{
							if (_divficpor == GC_BULEANO_V){
								if (_divficporpricon == GC_BULEANO_V){
									document.getElementById('oid_'+_divid).value = guid;
									document.getElementById('fp_form_'+_divid).submit();
									_divficporpricon = GC_BULEANO_F;
								}
								_verficha += "<br/><a href=\"javascript:;\" onclick=\"document.getElementById('oid_"+_divid+"').value = " + guid + "; document.getElementById('fp_form_"+_divid+"').submit();\" >" + GC_VER_FICHA + "</a>";
							}else{
								if(description==""){ //salto de linea cuando la descripcion esta inactiva
								_verficha += "<br/><a href=\"javascript:;\" onclick=\"redir_popup('/exp/ficha.php','oid=" + guid + "',2)\" >" + GC_VER_FICHA + "</a>";
								}else{
								_verficha += "<a href=\"javascript:;\" onclick=\"redir_popup('/exp/ficha.php','oid=" + guid + "',2)\" >" + GC_VER_FICHA + "</a>";
								}
							}
							if (_caccion.trim() != '' && _divficlis == "true"){
								_verficha += "&nbsp;" + GC_SEPARADOR_FICHA_MAPA_RSS + "&nbsp;" + _caccion;
							}
						}
					}else if (_ficha == GC_BULEANO_F){
						if (_divext == GC_BULEANO_V){
							_verficha += "<a href=\"javascript:;\" onclick=\"ventana('" + url + "','_blank')\" >" + GC_VER_FICHA + "</a>";
							if (_wms.trim() != "" && _divficlis == "true"){
								_verficha += "&nbsp;" + GC_SEPARADOR_FICHA_MAPA_RSS + "&nbsp;<a href='javascript:;' onclick='redir(\"modulo=0x397x86#oid="+GC_MAPA_XML+"#cugid="+GC_MAPA_UG+"#wm_wms="+_wms+"\")' >" + GC_VER_MAPA + "</a>";
							}else{
								if (_caccion.trim() != '' && _divficlis == "true"){
									_verficha += "&nbsp;" + GC_SEPARADOR_FICHA_MAPA_RSS + "&nbsp;" + _caccion;
								}
							}
						}else{
							_verficha += "<a href=\"javascript:;\" onclick=\"redir('oid=" + guid + "#modaccion=visualizar_ficha')\" >" + GC_VER_FICHA + "</a>";
							if (_caccion.trim() != '' && _divficlis == "true"){
								_verficha += "&nbsp;" + GC_SEPARADOR_FICHA_MAPA_RSS + "&nbsp;" + _caccion;
							}
						}
					}

					/*GARENAS*/
					if (_modulo != '') {
						_verficha += "&nbsp;" + GC_SEPARADOR_FICHA_MAPA_RSS + "&nbsp;" + _modulo;
					}

					if (typeof(buscar) != 'undefined' || typeof(vermas) != 'undefined'){ _br = ""; }
					else{	 _br = "<br />"; }

					if (_divext.trim() != ""){
						if (_catalogo == GC_BULEANO_V){
							if (GC_RSS_FECHA == GC_BULEANO_V){
								if (description != ""){
									if (_divlist	==	GC_BULEANO_V){
										_cont += "<table style='width:90%;' ><tr><td style='vertical-align:top;'>" + _img + "</td><td style='width:100%;text-align:justify;vertical-align:top;'>" + pubDate + "<br />" + _idobj + title + _br + description + _verficha + "</td></tr></table>";
									}else{
										_cont += "<table style='width:90%;' ><tr><td style='vertical-align:top;'>" + _img + "</td></tr><tr><td style='width:100%;text-align:justify;vertical-align:top;'>" + pubDate + "<br />" + _idobj + title + _br + description + _verficha + "</td></tr></table>";
									}
									if (typeof(buscar) != 'undefined' || typeof(vermas) != 'undefined'){ _cont += GC_SEPARADOR_LISTADO_CONTENIDOS_RSS; }else{ _cont += "<br />"; }
								}else{
									if (_divlist	==	GC_BULEANO_V){
										_cont += "<table style='width:90%;' ><tr><td style='vertical-align:top;'>" + _img + "</td><td style='width:100%;text-align:justify;vertical-align:top;'>" + pubDate + "<br />" + _idobj + title + _verficha + "</td></tr></table>";
									}else{
										_cont += "<table style='width:90%;' ><tr><td style='vertical-align:top;'>" + _img + "</td></tr><tr><td style='width:100%;text-align:justify;vertical-align:top;'>" + pubDate + "<br />" + _idobj + title + _verficha + "</td></tr></table>";
									}
									if (typeof(buscar) != 'undefined' || typeof(vermas) != 'undefined'){ _cont += GC_SEPARADOR_LISTADO_CONTENIDOS_RSS; }else{ _cont += "<br />"; }
								}
							}else{
								if (description != ""){
									if (_divlist	==	GC_BULEANO_V){
										_cont += "<table style='width:90%;' ><tr><td style='vertical-align:top;'>" + _img + "</td><td style='width:100%;text-align:justify;vertical-align:top;'>" + _idobj + title + _br + description + _verficha + "</td></tr></table>";
									}else{
										_cont += "<table style='width:90%;' ><tr><td style='vertical-align:top;'>" + _img + "</td></tr><tr><td style='width:100%;text-align:justify;vertical-align:top;'>" + _idobj + title + _br + description + _verficha + "</td></tr></table>";
									}
									if (typeof(buscar) != 'undefined' || typeof(vermas) != 'undefined'){ _cont += GC_SEPARADOR_LISTADO_CONTENIDOS_RSS; }else{ _cont += "<br />"; }
								}else{
									if (_divlist	==	GC_BULEANO_V){
										_cont += "<table style='width:90%;' ><tr><td style='vertical-align:top;'>" + _img + "</td><td style='width:100%;text-align:justify;vertical-align:top;'>" + _idobj + title + _verficha + "</td></tr></table>";
									}else{
										_cont += "<table style='width:90%;' ><tr><td style='vertical-align:top;'>" + _img + "</td></tr><tr><td style='width:100%;text-align:justify;vertical-align:top;'>" + _idobj + title + _verficha + "</td></tr></table>";
									}
									if (typeof(buscar) != 'undefined' || typeof(vermas) != 'undefined'){ _cont += GC_SEPARADOR_LISTADO_CONTENIDOS_RSS; }else{ _cont += "<br />"; }
								}
							}
						}else{
							if (GC_RSS_FECHA == GC_BULEANO_V){
								if (description != ""){
									if (_divlist	==	GC_BULEANO_V){
										_cont += "<table style='width:90%;' ><tr><td style='vertical-align:top;'>" + _img + "</td><td style='width:100%;text-align:justify;vertical-align:top;'>" + pubDate + "<br />" + _idobj + title + _br + description + _verficha + "</td></tr></table>";
									}else{
										_cont += "<table style='width:90%;' ><tr><td style='vertical-align:top;'>" + _img + "</td></tr><tr><td style='width:100%;text-align:justify;vertical-align:top;'>" + pubDate + "<br />" + _idobj + title + _br + description + _verficha + "</td></tr></table>";
									}
									if (typeof(buscar) != 'undefined' || typeof(vermas) != 'undefined'){ _cont += GC_SEPARADOR_LISTADO_CONTENIDOS_RSS; }else{ _cont += "<br />"; }
								}else{
									if (_divlist	==	GC_BULEANO_V){
										_cont += "<table style='width:90%;' ><tr><td style='vertical-align:top;'>" + _img + "</td><td style='width:100%;text-align:justify;vertical-align:top;'>" + pubDate + "<br />" + _idobj + title + _verficha + "</td></tr></table>";
									}else{
										_cont += "<table style='width:90%;' ><tr><td style='vertical-align:top;'>" + _img + "</td></tr><tr><td style='width:100%;text-align:justify;vertical-align:top;'>" + pubDate + "<br />" + _idobj + title + _verficha + "</td></tr></table>";
									}
									if (typeof(buscar) != 'undefined' || typeof(vermas) != 'undefined'){ _cont += GC_SEPARADOR_LISTADO_CONTENIDOS_RSS; }else{ _cont += "<br />"; }
								}
							}else{
								if (description != ""){
									if (_divlist	==	GC_BULEANO_V){
										_cont += "<table style='width:90%;' ><tr><td style='vertical-align:top;'>" + _img + "</td><td style='width:100%;text-align:justify;vertical-align:top;'>" + _idobj + title + _br + description + _verficha + "</td></tr></table>";
									}else{
										_cont += "<table style='width:90%;' ><tr><td style='vertical-align:top;'>" + _img + "</td></tr><tr><td style='width:100%;text-align:justify;vertical-align:top;'>" + _idobj + title + _br + description + _verficha + "</td></tr></table>";
									}
									if (typeof(buscar) != 'undefined' || typeof(vermas) != 'undefined'){ _cont += GC_SEPARADOR_LISTADO_CONTENIDOS_RSS; }else{ _cont += "<br />"; }
								}else{
									if (_divlist	==	GC_BULEANO_V){
										_cont += "<table style='width:90%;' ><tr><td style='vertical-align:top;'>" + _img + "</td><td style='width:100%;text-align:justify;vertical-align:top;'>" + _idobj + title + _verficha + "</td></tr></table>";
									}else{
										_cont += "<table style='width:90%;' ><tr><td style='vertical-align:top;'>" + _img + "</td></tr><tr><td style='width:100%;text-align:justify;vertical-align:top;'>" + _idobj + title +  _verficha + "</td></tr></table>";
									}
									if (typeof(buscar) != 'undefined' || typeof(vermas) != 'undefined'){ _cont += GC_SEPARADOR_LISTADO_CONTENIDOS_RSS; }else{ _cont += "<br />"; }
								}
							}
						}
					}else{
						_cont += "<table style='width:90%;'><tr><td style='vertical-align:top;'>" + pubDate +"<br/>"+ title +  "</label></td></tr>";
						_cont += "<tr><td style='width:100%;text-align:justify;vertical-align:top;'>" + description + "</td></tr></table><br />";
					}
					_cont += "</div>";
				}

				document.getElementById(_div).innerHTML = _cont;

			}else{
				document.getElementById(_div).innerHTML = "<img src='" + GC_WEB_IMG + "/atencion.gif' class='img' alt='Atenci&oacute;n' /><b>La informaci&oacute;n no ha podido ser recepcionada.</b>";
			}
		}else{

			document.getElementById(_div).innerHTML = "<img src='" + GC_WEB_IMG + "/load_rss.gif' class='img' alt='Cargando...' />Cargando...";

		}

	}


	/**
	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @since 10-12-2008
	 * @version 1.2.0
	 *
	 * Funcion que llama a una pï¿½gina en formato de popup
	 *
	 * @param string $pag					:	URL destino
	 * @param string $parametros	:	Parametros del redireccionamiento
	 * @param array $re_conf			: Arreglo con los nuevos parámetros de configuración de la ventana
	 *															array	[0]=resizable
	 *														     		[1]=scrollbars
	 *														     		[2]=left
	 *														     		[3]=top
	 *														     		[4]=width
	 *														     		[5]=height
	 *
	 * @author Gonzalo A. Arenas Flores <garenas@siigsa.cl>
	 * @since 14-11-2011
	 * @version 1.2.0
	 * Parámetro $re_conf para redefinir la configuración de la ventana
	 */
	/*function redir_popup(pag, parametros, _cual, frametarget){*/
	function redir_popup(pag, parametros, _cual, re_conf){

		if (isNaN(_cual)) _cual = 1;

		var _param	= parametros.split('#');
		var _form	= "";
		var _var	= "";

		_form += "<div style='position:absolute;border:0px solid red;text-align:center;width:98%;height:0%;top:200px;'><img src='" + GC_WEB_IMG + "/cargando_datos.gif' border='0' alt='Cargando Datos...' /></div>";
		_form += "<form method='post' action='" + GC_WEB_DIR + pag + "' style='visibility:hidden'>";

		/*_form += "<form method='post' action='" + GC_WEB_DIR + pag + "' target='_self' style='visibility:hidden'>";*/
		/*_form += "<form method='post' action='" + GC_WEB_DIR + pag + "' target='_top' style='visibility:hidden'>";*/
		/*_form += "<form method='post' action='" + GC_WEB_DIR + pag + "' target='_parent' style='visibility:hidden'>";*/
		/*_form += "<form method='post' action='" + GC_WEB_DIR + pag + "' target='fp_101' style='visibility:hidden'>";*/


		for (i=0;i<_param.length;i++){
			_var = _param[i].split('=');
			_form += "<input type='hidden' name='" + _var[0] + "' value='" + _var[1] + "' />";
		}

		_form += "<input type='submit' value='Cargando' />";

		if (oNavegador.isIE){
			_form += "</form><script type='text/javascript'>setTimeout(\"document.forms[0].submit();\",2000);</script>";
		}else{
			_form += "</form>";
		}

		/*Si es un arreglo*/
		var _op = "";
		if (typeof(re_conf) != "undefined" && typeof(re_conf)=='object' && (re_conf instanceof Array)) {

			_op = "toolbar=no,location=no,directories=no,menubar=no,status=yes";

			if (re_conf[0] != '') {_op += ",resizable="+re_conf[0];} 	else {_op += ",resizable=yes"}	/*resizable*/
			if (re_conf[1] != '') {_op += ",scrollbars="+re_conf[1];} else {_op += ",scrollbars=yes";}/*scrollbars*/
			if (re_conf[2] != '') {_op += ",left="+re_conf[2];} 			else {_op += ",left=200";}			/*left*/
			if (re_conf[3] != '') {_op += ",top="+re_conf[3];} 				else {_op += ",top=200";}				/*top*/
			if (re_conf[4] != '') {_op += ",width="+re_conf[4];} 			else {_op += ",width=640";}			/*width*/
			if (re_conf[5] != '') {_op += ",height="+re_conf[5];} 		else {_op += ",height=600";}		/*height*/

		} else {

			_op = "toolbar=no,location=no,directories=no,menubar=no,status=yes,resizable=yes,scrollbars=yes,left=200,top=200,width=640,height=600";

		}

		if  (_cual == 1){

			if (window.opener){

				document.write(_form);
				document.forms[0].submit();

			}else{

				var _wo= window.open("",'',_op);
				_wo.focus();
				_wo.document.write(_form);
				_wo.document.forms[0].submit();

			}

		}else if (_cual == 2){

				var _wo= window.open("",'',_op);
				_wo.focus();
				_wo.document.write(_form);
				_wo.document.forms[0].submit();

		}else if (_cual == 3){ /*//nueva opcion para ventanas dentro de iframe pci 2011-09-29*/

			if (window.parent){

				document.write(_form);
				document.forms[0].submit();

			}else{

				var _wo= window.open("",'',_op);
				_wo.focus();
				_wo.document.write(_form);
				_wo.document.forms[0].submit();

			}

		}

	}


	/**
	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @since 20-05-2008
	 * @version 1.0.13
	 *
	 * Funciï¿½n para setear los valores del objeto ajax
	 *
	 * @param string $direc	:	direcciï¿½n de las operaciones
	 * @param string $parametros	:	valores de los parametros a setear
	 *
	 */
	function setoAjax(direc,parame){

		var _res;
		var _oAjax = new ObjAjax();
		_oAjax.open("POST", direc , true);
		_oAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		_oAjax.send(parame);
		_oAjax.onreadystatechange=function(){

			if (_oAjax.readyState==4 && _oAjax.status==200){
				return 1;
			}

		}
		if (_oAjax.onreadystatechange == 1){
		 alert(_oAjax);
		}

	}


	/**
	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 20-05-2008
	 * @version 1.0.2
	 *
	 * Funciï¿½n que recibe un arreglo y retorna sus datos concatenados
	 * con el separador enviado por parï¿½metros
	 *
	 * @param array $arreglo	:	Arreglo a transformar
	 * @param string $separador	:	texto separa los datos del arreglo
	 *
	 */
	function implode(arreglo,separador){
  	this.arreglo = new Array(arreglo);
  	var s_resultado = '';

  	for(i=0;i<arreglo.length;i++){

  		if(s_resultado == ''){

  			s_resultado = arreglo[i];

  		}else{

  			s_resultado += separador + arreglo[i];

  		}

  	}

  	return s_resultado;

  }


	/**
	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @since 20-05-2008
	 * @version 1.0.2
	 *
	 * Funcion que convierte un hex a numero entero
	 *
	 * @param string $Hex	:	Hexadecimal a transformar
	 * @return string $Value
	 *
	 */
	function GiveDec(Hex){

	   if(Hex == "A")
	      Value = 10;
	   else
	   if(Hex == "B")
	      Value = 11;
	   else
	   if(Hex == "C")
	      Value = 12;
	   else
	   if(Hex == "D")
	      Value = 13;
	   else
	   if(Hex == "E")
	      Value = 14;
	   else
	   if(Hex == "F")
	      Value = 15;
	   else
	      Value = eval(Hex);

	   return Value;

	}


	/**
	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @since 20-05-2008
	 * @version 1.0.2
	 *
	 * Funcion que convierte un hex a RGB decimal separado por comas
	 *
	 * @param string 	$Hex	:	Hexadecimal a transformar
	 * @return string
	 *
	 */
	function HexToDec(Hex){

		Input = Hex;
		Input = Input.toUpperCase();

		a = GiveDec(Input.substring(0, 1));
		b = GiveDec(Input.substring(1, 2));
		c = GiveDec(Input.substring(2, 3));
		d = GiveDec(Input.substring(3, 4));
		e = GiveDec(Input.substring(4, 5));
		f = GiveDec(Input.substring(5, 6));

		x = (a * 16) + b;
		y = (c * 16) + d;
		z = (e * 16) + f;

		return x + "," + y + "," + z;

	}


	/**
	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @author Jose Meneses <jmeneses@siigsa.cl>
	 * @since 20-05-2008
	 * @version 1.0.2
	 *
 	 * Validar correo electronico
   *
   * @param string $objeto : Input que traigo desde el HTML
   *
   * @see http://javascript.espaciolatino.com/lengjs/jsobjetos/obj_expreg.htm
   * @see http://javascript.espaciolatino.com/lengjs/jsobjetos/expreg/test.htm
   * @see http://www.elcodigo.net/tutoriales/jsavanzado/jsavanzado5.html
   * @see http://www.programacion.net/html/tutorial/js/16/
   * @see http://usuarios.lycos.es/barfak/noticia.php?id=42
   *
   */
	function validar_correo(objeto) {

		var s = objeto;
		//var filtro=/[A-Za-z][A-Za-z0-9_]@[A-Za-z0-9_]+\.[A-Za-z0-9_]+[A-za-z]$/;		Primera propuesta
		//var filtro=/^(.+\@.+\..+)$/;																								Segunda Propuesta
		//var filtro=/^[A-Za-z0-9._-]*@[A-Za-z0-9_]+\.[A-Za-z0-9_]+[A-za-z]$/;				Tercera Propuesta
		var filtro=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

		if (filtro.test(s)) {
			return true;
		}	else {
			alert("Ingrese una direccion de correo valida");
			return false;
		}
	}


	/**
	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 27-08-2008
	 * @version 1.0.3
	 *
 	 * Funciï¿½n que chequea o deschequea un elemento dependiendo del estado que llegue por parametro(true o false)
 	 *
 	 * @param string  $id      			:   ID del objeto a cambiar
 	 * @param string  $name    			:   Nombre en comun de los objeto a cambiar
 	 * @param boolean $estado  			:   Estado final del elemento
 	 * @param boolean $primero_sel  :   Estado final del elemento
 	 *
	 */
	function seleccionaDeseleccionar(id,name,estado,primero_sel){

	  if(id != ''){

	    document.getElementById(id).checked = estado;

	  }else if(name != ''){

	    var listado = document.getElementsByName(name);

	    if(listado.length > 0){

	    	listado[0].checked = true;

	    	if(typeof(primero_sel) != "undefined"){
		    	for(i=1;i<listado.length;i++){listado[i].checked = estado;}
	    	}else{
	    		for(i=0;i<listado.length;i++){listado[i].checked = estado;}
	    	}

	    }

	  }

	}


	/**
	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 17-03-2009
	 * @version 1.0.0
	 *
 	 * Funciï¿½n que chequea o deschequea un elemento dependiendo del estado que llegue por parametro(true o false)
 	 *
 	 * @param string  $tcs     			:   ID de los objetos a cabiar de estado
 	 * @param boolean $estado  			:   Estado final del elemento
 	 *
	 */
	function seleccionarDeseleccionarBuscarContenido(tcs,estado){

		var array_tcs  = tcs.split(",");
		for(i=0;i<array_tcs.length;i++){

    	document.getElementById("tc_"+array_tcs[i]).checked = estado;

		}

	}


	/**
	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 20-05-2008
	 * @version 1.0.2
	 *
   * Expande o Contrae los divisores de acuerdo a la norma establecida en la empresa
   *
   * @param string id	:	ID del divisor en la base de datos
   * @param pxs     	:	valor del alto del divisor de posiciï¿½n
   * @param unidad  	:	unidad de medida del alto del parametro "pxs"
   *
   */
  function expandirContraerDivisorParcial(id,pxs,unidad,id_img){

   var img	= '';// imagen de fondo
   if(typeof(id_img) != 'undefined'){img = document.getElementById(id_img);}

   var div1 = document.getElementById("D"+id);//Divisor posiciï¿½n
   var div2 = document.getElementById("subD"+id);//Divisor rounded
   var div3 = document.getElementById("divisor"+id);//Divisor contenido

    if(div1.style.height == "20px"){//Si elige expandir

      div1.style.height = pxs+unidad;
      div2.style.height = (pxs-10)+unidad;
      div3.style.height = (pxs-40)+unidad;
      if(typeof(id_img) != 'undefined'){img.style.height = (pxs-8)+unidad;}

    }else{//Si elige contraer

      div1.style.height = "20px";
      div2.style.height = "20px";
      div3.style.height = "0px";
      if(typeof(id_img) != 'undefined'){img.style.height = "21px";}

    }

  }


  /**
	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 20-05-2008
	 * @version 1.0.0
	 * @see http://lineadecodigo.com/2007/08/07/funcion-replace-en-javascript/
	 *
	 * Dado que el REPLACE de javascript solo reemplaza la primera coincidencia,
	 * busquï¿½ esta otra funciï¿½n.
	 */
	 function replace(texto,busqueda,reemplazo){
		return texto.split(busqueda).join(reemplazo);
	 }


 /**
	* @link http://www.siigsa.cl
  * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
  * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	* @author Cristiï¿½n Gï¿½mez <garenas@siigsa.cl>
	* @since 20-05-2008
	* @version 1.0.1
	* @see http://snippets.dzone.com/posts/show/1480
	*
	* repite n veces un determinado caracter
	*
	* @param l string	:	Cantidad de veces que se desea repetir el caracter
	*
	* @return string
	*/
	String.prototype.repeat = function(l) {
		return new Array(l+1).join(this);
	};


 /**
	* @link http://www.siigsa.cl
  * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
  * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	* @author Jose Meneses Gonzalez <jmeneses@siigsa.cl>
	* @since 18-07-2008
	* @version 1.0.0
	*
	* Detecta el navegador en el cual nos encontramos. Si el Navegador es Microsoft Internet Explorer 'IE' la variable quedara en buleano verdadero.
	* Sin embargo si el navegador es distinto de 'IE' la variable sera buleano falso.
	*
	* @param buleano qNav	:	Variable que contiene en primera instancia el nombre del Navegador y que definitivamente se convierte en buleano
	*												y con valor determinado segun navegador que sea
	*
	* @return string
	*/
	var qNav = navigator.appName;

	if (qNav == "Microsoft Internet Explorer"){ qNav = true; }
	else{ qNav = false; }


 /**
	* @link http://www.siigsa.cl
  * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
  * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	* @author Jose Meneses Gonzalez <jmeneses@siigsa.cl>
	* @since 22-01-2009
	* @version 1.0.1
	* @see http://www.webtaller.com/construccion/lenguajes/javascript/lecciones/fecha-hora-javascript.php
	*
	* Funcion que retorna la fecha actual
	*
	* @param int _formato : Formato de Salida de Fecha. Si el formato de la fecha es '', la fecha sera '01-01-2000'; en cambio, si el formato
	*												de la fecha es '1', la fecha de sera 'Lunes 01 de Enero del 2000'
	*
	* @return date
	*
	*/
	function getFechaActual(_formato){

		var fecha = new Date();

  	/*FECHA*/
  	var _dia	= fecha.getDate();
  	var _mes	= fecha.getMonth() + 1;
		var _anio	= fecha.getFullYear();

		if (_dia < "10"){ _dia = "0" + _dia;	}
		if (_mes < "10"){ _mes = "0" + _mes;	}

		/*SABER EL DIA*/
		var _dias = new Array("Domingo", "Lunes", "Martes", "Mi&eacute;rcoles", "Jueves",	"Viernes", "Sabado");
		_dianomb = _dias[fecha.getDay()];

		/*SABER EL MES*/
		var _meses = new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo",	"Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
		_mesnomb = _meses[fecha.getMonth()];

		if (_formato == ""){
			fecha_actual = _dia + "-" + _mes + "-" + _anio;
		}else if (_formato == 1){
			fecha_actual = _dianomb + " " + _dia + " de " + _mesnomb + " del " + _anio;
		}else{
			fecha_actual = _dia + "-" + _mes + "-" + _anio;
		}

		return fecha_actual;

	}


	/**
	* @link http://www.siigsa.cl
  * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
  * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	* @author Jose Meneses Gonzalez <jmeneses@siigsa.cl>
	* @since 22-01-2009
	* @version 1.0.1
	* @see http://www.webtaller.com/construccion/lenguajes/javascript/lecciones/fecha-hora-javascript.php
	*
	* Funcion que retorna la hora actual
	*
	* @return date
	*/
	function getHoraActual(){

		var fecha = new Date();

		/*HORA*/
		var _hora = fecha.getHours();
		var _min	= fecha.getMinutes();
		var _seg	= fecha.getSeconds();

		if (_hora < "10")	{	_hora = "0" + _hora;	}
		if (_min < "10")	{	_min = "0" + _min;		}
		if (_seg < "10")	{	_seg = "0" + _seg;		}

		hora_actual = _hora + ":" + _min + ":" + _seg;

		return hora_actual;

	}

	/**
 * Advierte que se debe elegir una opcion a lo menos
 * y deja checkeada la ï¿½ltima opciï¿½n en operaciï¿½n
 *
 * @param $nomb    :    Nombre de los TAG HTML que contienen las opciones
 * @param $obj     :    Objeto que gatilla la funciï¿½n
 *
 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
 * @since 06-12-2007
 */
function debeElegirUno(nomb,obj){

  var sel = document.getElementsByName(nomb);
  var sel_chk = '';
  for(i=0;i<sel.length;i++){

    if(sel[i].checked == true){

      sel_chk = 1;

    }

  }

  if(sel_chk == ''){

    alert("Debe elegir una region a lo menos");
    obj.checked = true;

  }
 
}

  /**
	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @author Cristiï¿½n Gï¿½mez Mamani <cgomez@siigsa.cl>
	 * @since 15-12-2008
	 * @version 1.0.0
	 *
	 * Verificar el RUT ingresado en el formulario
	 *
	 *
	 * @param rut    :    RUT ingresado
	 * @param dv     :    Digito Verificador. Si se omite este parï¿½metro la funciï¿½n devolverï¿½ el digito verificador del rut ingresado
	 *
	 * @return mixed
	 */
	function verificarRUT(rut,dv){

	 	var i = 0;
		var largo_rut = rut.length-1;
		var producto_tmp = 0;
	 	var caracter_actual = "";
	 	var factor = 2;
	 	var total_suma_factores = 0;

	 	for ( i=(rut.length-1); i>=0; i--) {
	 	  producto_tmp = factor * parseInt(rut.charAt(i));
		 	total_suma_factores += producto_tmp;
	 		if(factor == 7) {
	 			factor = 1;
	 		}
	 		factor++;
	 	}

	 	resto_modulo_11 = total_suma_factores % 11;
		resultado_final_tmp = 11 - resto_modulo_11;

		if(resultado_final_tmp == '11'){
			resultado_final = '0';
		}else if(resultado_final_tmp == '10'){
			resultado_final = "K";
		}else{
			resultado_final = resultado_final_tmp;
		}

		if (typeof(rut) != 'undefined' && typeof(dv) != 'undefined'){
			if(resultado_final == dv.toUpperCase()){
				return true;
			}else{
				return false;
			}
	 	}else if(typeof(rut) != 'undefined'){
			return resultado_final;
	 	}
	}


	/**
	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @author Cristiï¿½n Gï¿½mez Mamani <cgomez@siigsa.cl>
	 * @since 16-12-2008
	 * @version 1.0.0
	 *
	 * Verificar la existencia de un RUT en la base de datos
	 *
	 * @param tabla  :    Tabla Base de Datos
	 * @param rut    :    RUT ingresado
	 * @param dv     :    Digito Verificador.
	 * @param url    :    url donde se debe dirigir para realizar la peticiï¿½n PHP a travï¿½s de AJAX.
	 * @param pid    :    Id de Persona (si existe en el modaccion de PHP se filtra este id para no considerar el RUT de dicho ID)
	 *
	 * @return string
	 */
	function verificarExistenciaRUT(tabla,rut,dv,url,pid){
		_pid = '';
		if(typeof(pid) != 'undefined') {
			_pid = pid;
		}
		var oAjax 	= new ObjAjax();
		_param = "modaccion=verif_existencia_rut&tabla=" + tabla + "&rut=" + rut + "&dv=" + dv + "&pid=" + _pid;

		oAjax.open("POST", GC_WEB_DIR + "/" + url , false);
		oAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

		oAjax.onreadystatechange=function() {
			if (oAjax.readyState==4 && oAjax.status==200) {
				_res = oAjax.responseText;
				document.getElementById('existe_rut').value = _res;
				return;
			}
		}
		oAjax.send(_param);
	}


	/**
	 * @link http://www.siigsa.cl
   * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
   * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
	 * @author Cristiï¿½n Gï¿½mez Mamani <cgomez@siigsa.cl>
	 * @since 16-12-2008
	 * @version 1.0.0
	 *
	 * Verificar la existencia de un Cï¿½digo Institucional en la base de Datos segï¿½n su tipo de objeto
	 *
	 * @param tabla  :    Tabla Base de Datos
	 * @param rut    :    RUT ingresado
	 * @param dv     :    Digito Verificador.
	 * @param url    :    url donde se debe dirigir para realizar la peticiï¿½n PHP a travï¿½s de AJAX.
	 *
	 * @return string
	 */
	function verificarExistenciaCodigoInst(c_i,t_o,cid,desde_ficha,pre_sub_ficha){

		var oAjax 	= new ObjAjax();

		if(typeof(cid) != 'undefined') {
			_cid = cid;
		}

		_param = "modaccion=verif_existencia_codigo&" + "&c_i=" + c_i.value.trim() + "&t_o=" + t_o + "&cid=" + _cid;

		oAjax.open("POST", GC_WEB_DIR + "/adm/adm_contenido.php" , true);
		oAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oAjax.send(_param);

		oAjax.onreadystatechange=function() {
			if (oAjax.readyState==4 && oAjax.status==200){
				_res = oAjax.responseText;

				if(_res == 't'){
					alert('Codigo Institucional ya existe para este tipo de Contenido. Ingrese otro');
					c_i.value = '';
					c_i.focus();
					document.getElementById('guardar_objeto_codigo').innerHTML = '';
					return false;
				}else{
					if(typeof(desde_ficha) != 'undefined'){ficha_mostrarGuardar(pre_sub_ficha+'guardar_objeto_codigo','objeto_codigo',pre_sub_ficha);}
				}
			}
		}

	}


	/**
	 * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 05-08-2009
	 * @version 1.0.0
	 *
	 * Selecciona o deselecciona un conjunto de checkboxs, el gatillador de la funciï¿½n debe ser un checkbox.
	 * La funciï¿½n rescata el value del gatillador y busca todos los objeto con este como nombre, por lo que solo los checkbox
	 * que se desea operar deben tener dicho texto en sus respectivos NAMEs.
	 *
	 * @param String $gatillador	:	CHK que detona la funcion
	 */
	function seleccionarDeseleccionarCHK(gatillador){

		var chks = oTenc.getTags(2,gatillador.value);

		for(i=0;i<chks.length;i++){
			chks[i].checked = gatillador.checked;
		}

	}


	/**
	 * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 12-08-2009
	 * @version 1.0.0
	 *
	 * expande o contrae un divisor al tamaï¿½o indicado en parï¿½metros.
	 * EJ: 	si desea expandir -> $ancho = 100px; $alto = 100px
	 * EJ: 	si desea contraer -> $ancho = 0px; $alto = 10px
	 *
	 * si no se indica un valor para $alto o $ancho, al momento de expandir, este se asumira como 100%.
	 *
	 * @param String $ancho		:	valor que determina el ancho al contraer o expandir, sea este en PX o %.
	 * @param String $alto		:	valor que determina el alto al contraer o expandir, sea este en PX o %.
	 * @param String $id_div	:	ID del tag divisor que se desea trabajar.
	 */
	function expandirContraerDivisor(id_div,ancho,alto){

		var div_ec = oTenc.getTags(1,id_div); //Rescate del divisor

		if(typeof(ancho) == "undefined" || ancho == ''){ancho = "100%";}
		if(typeof(alto) == "undefined" || alto == ''){alto = "100%";}

		oTenc.setEstiloTag(div_ec,"width",ancho); //Seteo del ancho
		oTenc.setEstiloTag(div_ec,"height",alto); //Seteo del alto


	}


	/**
	 * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 20-08-2009
	 * @version 1.0.0
	 *
	 * Imprime un sector
	 *
	 * @param String $id_sector		:	ID del Tag HTML (div,table, etc...)
	 */
	function imprimirSector(id_sector){

		var sector = oTenc.getTags(1,id_sector); //Rescate
		var ventimp = window.open('','');
			  ventimp.document.write( sector.innerHTML );
			  ventimp.document.close();
			  ventimp.print( );
			  ventimp.close();

	}


	/**
	 * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
	 * @author Jose Meneses Gonzalez
	 * @since 01-04-2010
	 * @version 1.0.1
	 *
	 * Permite saber si el valor entregado como parametro es un valor con decimales
	 *
	 * @param numeric value : valor numerico a validar
	 */
	function isFloat(value){

		if(isNaN(value) || value.indexOf(".") < 0){
	  	return false;
	 	}else{
	 		if(parseFloat(value)){
	 			return true;
	 		}else{
	 			return false;
	 		}
		}

	}


	/**
	 * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
	 * @author Jose Meneses Gonzalez
	 * @since 26-05-2010
	 * @version 1.0.1
	 *
	 * Permite guardar la posicion actual del divisor en tiempo real
	 *
	 * @param object _objdiv	: Objeto divisor
	 * @param string _divid		: Id del Divisor
	 * @param string _divcr		: Centros de Responsabilidad del Divisor
	 *
	 */
	function enc_guardarPosicionActual(_objdiv, _divid, _divcr, _divmodnomb){

		var oAjax		= new ObjAjax();

		/*posicion*/
		var _objtop		=	_objdiv.style.top;
		var _objleft	=	_objdiv.style.left;

		/*tamaño*/
		var _objwidth	=	_objdiv.style.width;
		var _objheight	=	_objdiv.style.height;

		if (_divmodnomb == "divisor_link"){ _objwidth = parseInt(_objdiv.style.width) - 40 + 'px'; }

		_param = "modaccion=guardar_posicion&" + "&divtop=" + parseInt(_objtop) + "&divleft=" + parseInt(_objleft) + "&divid=" + _divid + "&divcr=" + _divcr + "&divwidth=" + parseInt(_objwidth) + "&divheight=" + parseInt(_objheight);

		oAjax.open("POST", GC_WEB_DIR + "/exp/exp_modulo111.php" , true);
		oAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oAjax.send(_param);

		oAjax.onreadystatechange=function(){
			if (oAjax.readyState == 4){
				if (oAjax.status == 200){
					if (oAjax.responseText == GC_BULEANO_V){
//						if (_actdiv == GC_BULEANO_V){
//							alert("Se ha guardado la posiciï¿½n exitï¿½samente y se actualizarï¿½ la pï¿½gina");
//							$('#div_posi_' + _divid).hide();
//							redir('modulo=0x0');
//						}else{
							alert("Se ha guardado la posicion exitosamente");
							$('#div_posi_' + _divid).hide();
//						}
					}
				}
			}
		}

	}


	/**
	 * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
	 * @author Jose Meneses Gonzalez
	 * @since 25-06-2010
	 * @version 1.0.1
	 *
	 * Permite retornar un html como resultado
	 *
	 * @param string archivophp		: Nombre de Archivo php sin extension donde va a realizar el retorno de HTML
	 * @param string divisor			: Id del divisor
	 * @param string parametros		: Parametros necesarios para el retorno del HTML
	 * @param string letra_actual	: Letra con la que va a empezar el listado de registros de un listado
	 *
	 */
	function enc_paginadoAdministracion(archivophp, divisor, parametros, letra_actual){

		try {

			if (letra_actual != '' && typeof(letra_actual) != 'undefined'){
				parametros += '&letra_actual='+letra_actual;
			}

			var enc_oAjax	= new ObjAjax();
			document.getElementById(divisor).innerHTML = "<img src='" + GC_WEB_IMG + "/load_rss.gif' class='img' alt='Cargando...' title='Cargando...' />Cargando...";
			enc_oAjax.open("POST", GC_WEB_DIR + "/adm/"+archivophp+".php" , true);
			enc_oAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			enc_oAjax.send(parametros);
			enc_oAjax.onreadystatechange=function(){
				if (enc_oAjax.readyState == 4){
					if (enc_oAjax.status == 200){
						document.getElementById(divisor).innerHTML = enc_oAjax.responseText;
					}
				}
			}

		}catch(e){

			alert(e.name + " - " + e.message);

		}

	}


	/**
	 * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
	 * @author Jose Meneses Gonzalez
	 * @since 15-02-2010
	 * @version 1.0.1
	 *
	 * Permite retornar un html como resultado
	 *
	 * @param string archivophp		: Nombre de Archivo php sin extension donde va a realizar el retorno de HTML
	 * @param string divisor			: Id del divisor
	 * @param string parametros		: Parametros necesarios para el retorno del HTML
	 *
	 */
	function enc_paginadoNumericoAdministracion(archivophp, divisor, parametros){

		try {

			var enc_oAjax	= new ObjAjax();
			document.getElementById(divisor).innerHTML = "<img src='" + GC_WEB_IMG + "/load_rss.gif' class='img' alt='Cargando...' title='Cargando...' />Cargando...";
			enc_oAjax.open("POST", GC_WEB_DIR + "/adm/"+archivophp+".php" , true);
			enc_oAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			enc_oAjax.send(parametros);
			enc_oAjax.onreadystatechange=function(){
				if (enc_oAjax.readyState == 4){
					if (enc_oAjax.status == 200){
						document.getElementById(divisor).innerHTML = enc_oAjax.responseText;
					}
				}
			}

		}catch(e){

			alert(e.name + " - " + e.message);

		}

	}


	/**
	 * @copyright	ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
	 * @author		Jose Meneses Gonzalez
	 * @since			15-07-2010
	 * @version		1.0.1
	 *
	 * Permite cambiar la imagen para expandir o contraer algun tag de html
	 *
	 * @param string _tagid	: Id del objeto HMTL
	 *
	 */
	function enc_expandirColapsar(_tagid){

		$('#'+_tagid).toggleClass("menos");

	}


	/**
	 * @copyright	ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
	 * @author		Jose Meneses Gonzalez
	 * @since			25-02-2011
	 * @version		1.1.1
	 *
	 * Permite mover los iconos como guardar modificaciones, editar, rss y ayuda cuando se modifica el tamaï¿½o del divisor en el portal
	 *
	 * @param object objdiv			: Objeto HTML del divisor principal
	 * @param object objguardar	: Objeto HTML del divisor que tiene el icono guardar posicion
	 * @param object objeditar	: Objeto HTML del divisor que tiene el icono editar divisor
	 * @param object objrss			: Objeto HTML del divisor que tiene el icono RSS
	 * @param object objayuda		: Objeto HTML del divisor que tiene el icono ayuda
	 *
	 */
	function enc_moverIconosDivisor(objdiv, objguardar, objeditar, objrss, objayuda){

		objguardar.css('left', parseInt(objdiv.css('width')) - 54 + "px");
		objeditar.css('left', parseInt(objdiv.css('width')) - 37 + "px");
		objrss.css('left', parseInt(objdiv.css('width')) - 20 + "px");
		objayuda.css('left', parseInt(objdiv.css('width')) - 20 + "px");

	}


	/**
	 * @copyright	ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
	 * @author		Jose Meneses Gonzalez <jmeneses@siigsa.cl>
	 * @since			28-02-2011
	 * @version		1.1.1
	 *
	 * Permite transformar los colores rgb a hexadecimal
	 *
	 * @param string str	:	String con los rgb extraidos desde el atributo background-color de css
	 *
	 */
	function rgbConvert(str){

		str = str.replace(/rgb\(|\)/g, "").split(",");
		str[0] = parseInt(str[0], 10).toString(16).toLowerCase();
		str[1] = parseInt(str[1], 10).toString(16).toLowerCase();
		str[2] = parseInt(str[2], 10).toString(16).toLowerCase();
		str[0] = (str[0].length == 1) ? '0' + str[0] : str[0];
		str[1] = (str[1].length == 1) ? '0' + str[1] : str[1];
		str[2] = (str[2].length == 1) ? '0' + str[2] : str[2];

		return str.join("");

	}


	/**
	 * @copyright	ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
	 * @author		Jose Meneses Gonzalez <jmeneses@siigsa.cl>
	 * @since			14-03-2011
	 * @version		1.1.1
	 *
	 * Permite identificar si una variable es un arreglo
	 *
	 * @param object testObject :	Objeto Arreglo
	 *
	 */
	function isArray(testObject){

		return testObject && !(testObject.propertyIsEnumerable('length')) && typeof testObject === 'object' && typeof testObject.length === 'number';

	}


	/*************************************************************************************
	 *************************************************************************************

	INICIO DE FUNCIONES PARA DESPLEGAR EL FORMULARIO DE FILTRADO DE UNIDADES GEOGRï¿½FICAS

	 *************************************************************************************
	 *************************************************************************************
	*/

	/**
	 * @copyright	ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
	 * @author		Jose Meneses Gonzalez <jmeneses@siigsa.cl>
	 * @since		14-03-2011
	 * @version		1.1.0
	 *
	 * Funciï¿½n que despliega un divisor con filtros para seleccionar unidades geogrï¿½ficas.
	 * Este retorna el cï¿½digo HTML que componbe una tabla con checkbox's y los nombres de las UGs.
	 *
	 * @param object 	$reloug_id 		:	ID de la relaciï¿½n UG.
	 * @param String 	$id_div_car 	:	ID del div HTML donde se cargarï¿½ la respuesta.
	 * @param String 	$name_chk		:	nombre que tendrï¿½n los chekbox de la respuesta.
	 * @param int 		$tug_fil 		:	ID del tipo de UG de bï¿½squeda.
	 *
	 */
	function enc_filtrarUG(reloug_id, id_div_car, name_chk, tug_fil) {

		oDenc.set('ancho',"700px");
		oDenc.set('alto',"400px");
		oDenc.crearDivisor('Filtrar Unidades Geogrï¿½ficas');
		oDenc.setContenido("/exp/exp_modulo163.php","modaccion=em163_car_ugs&em163_id_rel_ug=" + reloug_id + "&id_div_car=" + id_div_car + "&name_chk=" + name_chk + "&tug_fil=" + tug_fil);

	}

	/**
	 * @copyright	ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
	 * @author 		Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 		04-04-2011
	 * @version 	1.1.0
	 *
	 * Funciï¿½n para rescatar los filtros de unidad geogrï¿½fica para desplegar las UG disponibles.
	 *
	 */
	function enc_desplegarUGFiltradas() {

		//
		// Mostrar Cargando
		//
		var em163_div_ug_dis = oTenc.getTags(1,'em163_div_ug_dis');
		em163_div_ug_dis.innerHTML = "<img src='" + GC_WEB_IMG + "/load_rss.gif' class='img' alt='Cargando...' title='Cargando...' />Cargando...";

		//
		// Rescate del Tipo UG busqueda
		//
		var em163_sel_tip_ug_bus = oTenc.getTags(1,'em163_sel_tip_ug_bus').value;

		//
		// Rescate de las UG de filtro
		//
		var em163_ug_fil = new Array();
		var em163_chk_ug_fil = oTenc.getTags(2,'em163_chk_ug_fil');
		for (em163_chk_ug_fil_i=0;em163_chk_ug_fil_i<em163_chk_ug_fil.length;em163_chk_ug_fil_i++) {

			if (em163_chk_ug_fil[em163_chk_ug_fil_i].checked) {

				em163_ug_fil.push(em163_chk_ug_fil[em163_chk_ug_fil_i].value);

			}

		}

		var oAjax 	= new ObjAjax();
		_param 		= "modaccion=em163_rescatar_ugs&em163_sel_tip_ug_bus=" + em163_sel_tip_ug_bus + "&em163_ug_fil=" + em163_ug_fil;
		oAjax.open("POST", GC_WEB_DIR + "/exp/exp_modulo163.php" , true);
		oAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oAjax.send(_param);
		oAjax.onreadystatechange=function(){

			if (oAjax.readyState==4 && oAjax.status==200){

				//
				// Recepciï¿½n y evaluaciï¿½n de la respuesta
				//
				var em163_lis_ug = eval(oAjax.responseText);

				//
				// Armado del HTML que se cargarï¿½ como respuesta
				//
				var enc_html  = '<table style="width:100%;">';
					enc_html += '	<tr>';
					enc_html += '		<td style="background-color:#CCCCCC;">';
					enc_html += '			<input type="checkbox" id="em163_chk_sel_des_ug_dis" name="em163_chk_sel_des" value="em163_chk_ug_dis" onclick="seleccionarDeseleccionarCHK(this)"/>';
					enc_html += '		</td>';
					enc_html += '		<td style="background-color:#CCCCCC;">ID</td>';
					enc_html += '		<td style="background-color:#CCCCCC;">Unidad Geogr&aacute;fica</td>';
					enc_html += '	</tr>';
									for (em163_lis_ug_i=0;em163_lis_ug_i<em163_lis_ug.length;em163_lis_ug_i++) {
					enc_html += '	<tr>';
					enc_html += '		<td>';
					enc_html += '			<input type="checkbox" id="em163_chk_ug_dis_'+em163_lis_ug[em163_lis_ug_i][0]+'" name="em163_chk_ug_dis" value="'+em163_lis_ug[em163_lis_ug_i][0]+'" />';
					enc_html += '		</td>';
					enc_html += '		<td>'+em163_lis_ug[em163_lis_ug_i][0]+'</td>';
					enc_html += '		<td>'+em163_lis_ug[em163_lis_ug_i][1]+'</td>';
					enc_html += '	</tr>';
									}
					enc_html += '</table>';

				//
				// Cargamos la respuesta en el DIV
				//
				em163_div_ug_dis.innerHTML = enc_html;

			}

		}

	}

	/**
	 * @copyright	ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
	 * @author 		Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 		04-04-2011
	 * @version 	1.1.0
	 *
	 * Funciï¿½n para modificar las UGs filtros de acuerdo al tipo especificado en "Filtrar por" .
	 *
	 * @param Object $em163_sel_fil_tip_ug_pad	:	objeto HTML del select que contiene los Tipos de UG para filtro.
	 */
	function enc_filtrarUGfiltro(em163_sel_fil_tip_ug_pad) {

		//
		// Deshabilitamos el select
		//
		em163_sel_fil_tip_ug_pad.disabled = true;

		//
		// Mostrar Cargando
		//
		var em163_div_ug_fil = oTenc.getTags(1,'em163_div_ug_fil');
		em163_div_ug_fil.innerHTML = "<img src='" + GC_WEB_IMG + "/load_rss.gif' class='img' alt='Cargando...' title='Cargando...' />Cargando...";

		var oAjax 	= new ObjAjax();
		_param 		= "modaccion=em163_rescatar_ugs&em163_sel_tip_ug_bus=" + em163_sel_fil_tip_ug_pad.value;
		oAjax.open("POST", GC_WEB_DIR + "/exp/exp_modulo163.php" , true);
		oAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oAjax.send(_param);
		oAjax.onreadystatechange=function(){

			if (oAjax.readyState==4 && oAjax.status==200){

				//
				// Recepciï¿½n y evaluaciï¿½n de la respuesta
				//
				var em163_lis_ug = eval(oAjax.responseText);

				//
				// Armado del HTML que se cargarï¿½ como respuesta
				//
				var enc_html  = '<table style="width:100%;">';
					enc_html += '	<tr>';
					enc_html += '		<td style="background-color:#CCCCCC;">';
					enc_html += '			<input type="checkbox" id="em163_chk_sel_des_ug_fil" name="em163_chk_sel_des" value="em163_chk_ug_fil" onclick="seleccionarDeseleccionarCHK(this)" checked="checked" />';
					enc_html += '		</td>';
					enc_html += '		<td style="background-color:#CCCCCC;">ID</td>';
					enc_html += '		<td style="background-color:#CCCCCC;">Unidad Geogr&aacute;fica</td>';
					enc_html += '	</tr>';
									for (em163_lis_ug_i=0;em163_lis_ug_i<em163_lis_ug.length;em163_lis_ug_i++) {
					enc_html += '	<tr>';
					enc_html += '		<td>';
					enc_html += '			<input type="checkbox" id="em163_chk_ug_fil_'+em163_lis_ug[em163_lis_ug_i][0]+'" name="em163_chk_ug_fil" value="'+em163_lis_ug[em163_lis_ug_i][0]+'" checked="checked" />';
					enc_html += '		</td>';
					enc_html += '		<td>'+em163_lis_ug[em163_lis_ug_i][0]+'</td>';
					enc_html += '		<td>'+em163_lis_ug[em163_lis_ug_i][1]+'</td>';
					enc_html += '	</tr>';
									}
					enc_html += '</table>';

				//
				// Cargamos la respuesta en el DIV
				//
				em163_div_ug_fil.innerHTML = enc_html;

				//
				// Habilitamos el select
				//
				em163_sel_fil_tip_ug_pad.disabled = false;

			}

		}

	}


	/**
	 * @copyright	ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
	 * @author 		Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 		04-04-2011
	 * @version 	1.1.0
	 *
	 * Funciï¿½n para retornar la respuesta te las UGs filtradas
	 *
	 * @param Object $em163_sel_fil_tip_ug_pad	:	objeto HTML del select que contiene los Tipos de UG para filtro.
	 */
	function enc_retornarUGS(id_div_car,name_chk) {

		//
		// Mostrar Cargando
		//
		var id_div_car = oTenc.getTags(1,id_div_car);
		id_div_car.innerHTML = "<img src='" + GC_WEB_IMG + "/load_rss.gif' class='img' alt='Cargando...' title='Cargando...' />Cargando...";

		//
		// Rescate de las UGs seleccionadas
		//
		var enc_arr_ugs = new Array();
		var enc_chk_ug_dis = oTenc.getTags(2,'em163_chk_ug_dis');
		for (enc_chk_ug_dis_i=0;enc_chk_ug_dis_i<enc_chk_ug_dis.length;enc_chk_ug_dis_i++) {

			if (enc_chk_ug_dis[enc_chk_ug_dis_i].checked) {

				enc_arr_ugs.push(enc_chk_ug_dis[enc_chk_ug_dis_i].value);

			}

		}
		var oAjax 	= new ObjAjax();
		_param 		= "modaccion=em163_rescatar_ugs&em163_ugs_ids=" + implode(enc_arr_ugs,',');
		oAjax.open("POST", GC_WEB_DIR + "/exp/exp_modulo163.php" , true);
		oAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oAjax.send(_param);
		oAjax.onreadystatechange=function(){

			if (oAjax.readyState==4 && oAjax.status==200){

				//
				// Recepciï¿½n y evaluaciï¿½n de la respuesta
				//
				var em163_lis_ug = eval(oAjax.responseText);

				//
				// Armado del HTML que se cargarï¿½ como respuesta
				//
				var enc_html  = '<table style="width:100%;">';
					enc_html += '	<tr>';
					enc_html += '		<td style="background-color:#CCCCCC;">';
					enc_html += '			<input type="checkbox" name="enc_chk_sel_des" value="'+name_chk+'" onclick="seleccionarDeseleccionarCHK(this)" checkbox="chekbox" />';
					enc_html += '		</td>';
					enc_html += '		<td style="background-color:#CCCCCC;">ID</td>';
					enc_html += '		<td style="background-color:#CCCCCC;">Unidad Geogr&aacute;fica</td>';
					enc_html += '	</tr>';
									for (em163_lis_ug_i=0;em163_lis_ug_i<em163_lis_ug.length;em163_lis_ug_i++) {
					enc_html += '	<tr>';
					enc_html += '		<td>';
					enc_html += '			<input type="checkbox" id="enc_chk_ug_dis_'+em163_lis_ug[em163_lis_ug_i][0]+'" name="'+name_chk+'" value="'+em163_lis_ug[em163_lis_ug_i][0]+'" checkbox="chekbox" />';
					enc_html += '		</td>';
					enc_html += '		<td>'+em163_lis_ug[em163_lis_ug_i][0]+'</td>';
					enc_html += '		<td>'+em163_lis_ug[em163_lis_ug_i][1]+'</td>';
					enc_html += '	</tr>';
									}
					enc_html += '</table>';

				//
				// Cargamos la respuesta en el DIV
				//
				id_div_car.innerHTML = enc_html;

			}

		}



	}

	/*************************************************************************************
	 *************************************************************************************

	FINAL DE FUNCIONES PARA DESPLEGAR EL FORMULARIO DE FILTRADO DE UNIDADES GEOGRï¿½FICAS

	 *************************************************************************************
	 *************************************************************************************
	*/


	/*Haciendo pruebas solamente - no borrar - Jose Meneses 08-04-2011*/
	/*modo 1*/
//	enc_array			= new Array();
//	enc_array[0]	= 1;
//	enc_array[1]	= 2;
//	enc_array[2]	= 3;
//	enc_array[3]	= 4;
//	enc_array[4]	= 5;
//	enc_array[5]	= 6;
//	enc_array[6]	= 7;
//	enc_array[7]	= 8;
//	enc_array[8]	= 9;
	/*modo 2*/
//	enc_array			= new Array();
//	enc_array[0]	= new Array();
//	enc_array[0][0] = 1;
//	enc_array[0][1] = 2;
//	enc_array[0][2] = 3;
//	enc_array[1]	= new Array();
//	enc_array[1][0] = 4;
//	enc_array[1][1] = 5;
//	enc_array[1][2] = 6;
//	enc_array[2]	= new Array();
//	enc_array[2][0] = 7;
//	enc_array[2][1] = 8;
//	enc_array[2][2] = 9;

	function enc_arrayAPHP(enc_array, modo){

		if (modo == 1){

			var strphp	=	"array(";
			var iflag 	= GC_BULEANO_F;
			for (i in enc_array){
				if ((i != "in_array") && (i != "array_key") && (i != "remove")){
					if (iflag == GC_BULEANO_F){
						strphp += "'"+enc_array[i]+"'";
						iflag		=	GC_BULEANO_V;
					}else if (iflag == GC_BULEANO_V){
						strphp += ",'"+enc_array[i]+"'";
					}
				}
			}
			strphp += ");";

		}else if (modo == 2){

			var strphp	=	"array(";
			var iflag 	= GC_BULEANO_F;
			for (i in enc_array){
				if ((i != "in_array") && (i != "array_key") && (i != "remove")){
					if (isArray(enc_array[i])){
						if (iflag == GC_BULEANO_F){
							strphp += "'"+i+"' => array(";
							iflag		=	GC_BULEANO_V;
						}else if (iflag == GC_BULEANO_V){
							strphp += ",'"+i+"' => array(";
						}
						var jflag = GC_BULEANO_F;
						for (j in enc_array[i]){
							if ((j != "in_array") && (j != "array_key") && (j != "remove")){
								if (isArray(enc_array[i][j])){
									if (jflag == GC_BULEANO_F){
										strphp += "'"+j+"' => array(";
										jflag		=	GC_BULEANO_V;
									}else if (jflag == GC_BULEANO_V){
										strphp += ",'"+j+"' => array(";
									}
								}else{
									if (jflag == GC_BULEANO_F){
										strphp += "'"+enc_array[i][j]+"'";
										jflag		=	GC_BULEANO_V;
									}else if (jflag == GC_BULEANO_V){
										strphp += ",'"+enc_array[i][j]+"'";
									}
								}
							}
						}
						strphp += ")";
					}
				}
			}
			strphp += ");";

		}else if (modo == 3){

		}

		return strphp;

	}



	function enc_retornarValor(){

		var strphp = enc_arrayAPHP(enc_array, 1);

		var oAjax 	= new ObjAjax();
		oAjax.open("POST", GC_WEB_DIR + "/exp/exp_modulo99.php" , true);
		oAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oAjax.send("modaccion=arreglo&arreglo=" + strphp);

		oAjax.onreadystatechange=function(){
			if (oAjax.readyState==4 && oAjax.status==200){
				alert(oAjax.responseText);
			}
		}

	}


	/**
	 * @copyright	ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
	 * @author 		Jose Meneses Gonzalez <jmeneses@siigsa.cl>
	 * @since 		18-05-2011
	 * @version 	1.1.1
	 *
	 * Funcion que permite cambiar las clases CSS de un objeto HTML
	 *
	 * @param Object obj		:	objeto HTML al cual se le cambiaran las clases
	 * @param string clsCss1:	string con la clase numero 1
	 * @param string clsCss2:	string con la calse numero 2
	 *
	 */
	function enc_cambioClaseCSS(obj, clsCss1, clsCss2){

		if (obj.className == clsCss1){
			//$(obj).toggleClass(clsCss1, clsCss2);
			$(obj).removeClass(clsCss1).addClass(clsCss2);
		}else if (obj.className == clsCss2){
			//$(obj).toggleClass(clsCss2, clsCss1);
			$(obj).removeClass(clsCss2).addClass(clsCss1);
		}

	}



/*
 * @link http://www.siigsa.cl
 * @copyright 2011- Nicolas Abraham Reyes Inostroza
 * @author Nicolas Abraham Reyes I<nreyes@siigsa.cl>
 * @since 09-08-2011
 * @version 1.2.0
 *
 * @var ent : String((,)separate)NOMBE DE LOS INPUT(checkbox) QUE REQUIEREN ESTAR EN ESTADO (EST)
 * @var est : boolean ESTADO QUE QUIERO QUE TENGAN LOS INPUT
 */
function _selDes(ent,est){

	var i;
	var name_chk = ent.split(",");

		for(i=0; i < name_chk.length; i++){
			$('input[type=checkbox][name='+name_chk[i]+']').attr("checked",est);
		}
}

/**
 |
 | @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
 | @author Nicolas Abraham Reyes I <nreyes@siigsa.cl>
 | @since 18-07-2011
 | @version 1.2.0
 |
 | selDesContEnt(true,\"em112_ent_tc_\",{-$em112_ent[l].entorno_id-},\"em112_\")
 |
 | param 1 boolean : true or false
 | param 2 String  : sufijo que corresponde al name del de los tipos de contenidos  (em112_ent_tc_)
 | param 3 int     : id del entorno
 | param 4 String  : parametro name del entorno
 |
 |		seleccionar/deseleccionar arbol
 |		selDesEntCont(atributo name de entorno,buleano,atributo name de contenidos(sin {--},solo el patrï¿½n), en blanco para seleccionar arbol completo 2 niveles(entorno->contenido))
 |
 |seleccionar deseleccionar entorno por contenido
 */
	function selDesEntCont(ent_name,ent_chk,cont_name,selDes_cont){
//		console.info("1 ent_name  : %s",ent_name);
//		console.info("2 ent_chk  : %s",ent_chk);
//		console.info("3 cont_name  : %s",cont_name);
//		console.info("4 selDes_cont  : %s",selDes_cont);

		if(selDes_cont == ""){
			arr_ent  = new Array();//entornos array
			arr_cont = new Array();//entornos array
			arr_ent  = $('input[type=checkbox][name='+ent_name+']'); //array de los entornos

				for(i =0 ;i < arr_ent.length ; i++){
//					console.info("5 arr_ent[%i].id (id entorno)",i,arr_ent[i].id);
				 	numero_entorno = getIntEntorno(arr_ent[i].id);
//					console.info("6 id  entorno de forma entenera :%i",numero_entorno);

					$('#'+arr_ent[i].id).attr('checked', ent_chk);
					if($('#'+arr_ent[i].id).is(":checked")){
						checked = true;
					}else{
						checked = false;
					}

						name_chk_cont = cont_name+numero_entorno;
//						console.info("7 name_contenido : %s",name_chk_cont);
						arr_cont = $('input[type=checkbox][name='+name_chk_cont+']');

						for(j = 0 ; j < arr_cont.length ; j++){
//							console.log("8 id del contenido : %s ",arr_cont[j].id);
						    $("#"+arr_cont[j].id).attr('checked',checked);
						}
				}
	  }else if(selDes_cont != ""){
//	  	    console.info("5 seleccionando entorno x contenido");
				id_entorno = getIntEntorno(selDes_cont);
				id_entorno = ent_name+id_entorno;
//			console.info("6 id del entorno : %s ",id_entorno);
			if($('#'+id_entorno).is(":checked")){
				checked = true;
			}else{
				checked = false;
			}
			/*formo el name de los contenidos pertenecientes al 'x' entorno(name_contenidos_)*/
	  	    name_cont = cont_name+getIntEntorno(id_entorno);
//	  	    console.info("7 name de los contenidos perc al entorno : %s",name_cont);
	  	    arr_cont  = $('input[type=checkbox][name='+name_cont+']');

	  	    $.each(arr_cont,function(p,val){
	  	    	/*console.debug(val);*/
	  	    	$("#"+arr_cont[p].id).attr('checked',checked);
	  	    });
	  }
	}

	function getIntEntorno(entorno){

	  	if(typeof(entorno)=="string"){
		  	num_ent = entorno.split("_"); // separo para obtener el id del entorno
		 	id_entorno = num_ent[num_ent.length-1];

	  	}else if(typeof(entorno)=="number"){
			id_entorno = entorno;
	  	}
//	  	console.debug("id entorno getIntEntorno : %s",id_entorno);
	 	return id_entorno;
	  }

/**
 |
 | @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
 | @author Nicolas Abraham Reyes I <nreyes@siigsa.cl>
 | @since 22-07-2011
 | @version 1.2.0
 |
 | param 1 int    : id del entorno
 | param 2 String : sufijo del atributo name del contenido em112_ent_tc_{-$entorno_id-}
 | ejemplo : archivo exp_modulo 112 en name de los contenidos es em112_ent_tc_{-$em112_tcs[listado].entorno_id-} por lo tanto en la funcion debes
 | pasar como 2ï¿½ parametro \"em112_ent_tc_\"
 |
 | param 3 String : atributo name de entorno (em112_), fijarce que el id del entorno es em112_{-$em112_ent[listado].entorno_id-}
 |
 |	SELECCIONA LOS TIPOS DE CONTENIDOS
 |	PARAM 1 BULEANO: true OR false
 |	PARAM 2 String : name de los tipos de contenidos
 |	PARAM 3 String : id del entorno ej : ent_{-$entorno_id-} ->html
 |
 | selDesEntCont(\"em112_\",true, \"em112_ent_tc_\",this.id)
 | selDesEntCont(\"em112_\",false,\"em112_ent_tc_\",this.id)
 |
 | SELECCIONAR / DESELECCIONAR (PARTE CONTENIDOS)
 */
	function selDesContEnt(chk_cont ,name_cont,ent_id, name_ent){
		int_entorno = getIntEntorno(ent_id);
		array_cont = $('input[type=checkbox][name='+name_cont+int_entorno+']');
//		console.log("cantidad tipo contenidos :%s ",array_cont.length);
//		console.log("name_cont  : %s",name_cont);

         /*true o false el entorno*/
			entorno_id = name_ent+ent_id;
			$('#'+entorno_id).attr('checked',chk_cont);

		$.each(array_cont,function(j){
			$("#"+array_cont[j].id).attr('checked',chk_cont);
		});

	}

/**
 |
 | @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
 | @author Nicolas Abraham Reyes I <nreyes@siigsa.cl>
 | @since 22-07-2011
 | @version 1.2.0
 |
 | param 1 int    : id del entorno
 | param 2 String : sufijo del atributo name del contenido em112_ent_tc_{-$entorno_id-}
 | ejemplo : archivo exp_modulo 112 en name de los contenidos es em112_ent_tc_{-$em112_tcs[listado].entorno_id-} por lo tanto en la funcion debes
 | pasar como 2ï¿½ parametro \"em112_ent_tc_\"
 |
 | param 3 String : atributo name de entorno (em112_), fijarce que el id del entorno es em112_{-$em112_ent[listado].entorno_id-}
 |
 | funcion que se inserta en los checkbox de los contenidos y va contando o descontando para seleccionar o deseleccionar el entorno segun cantidad de contenidos
 */
	function bus_selEntNivel2(id_entorno,suf_nam_cont,sufi_nam_ent){
			var nam_cont   = suf_nam_cont+id_entorno;
			var arr_cont   = $('input[name='+nam_cont+']');/*cambiado debido a que si existe em79_ent_tc_1 y em79_ent_tc_10 cuenta uno +*/
	 		var id_entorno = sufi_nam_ent+id_entorno;
		    var cont = 0;

		    $.each(arr_cont,function(j){
			 	if($("#"+arr_cont[j].id).is(':checked')){
			 		 cont++;
			 	}
			 });
             /*selecciono o deselecciono segï¿½n la cantidad de seleccionados*/
			 if(cont > 0){
				 $('#'+id_entorno).attr('checked',true);
			}else if(cont == 0){
				 $('#'+id_entorno).attr('checked',false);
			}
	}


/*
 * @link http://www.siigsa.cl
 * @copyright ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
 * @author Patricio Cifuentes Ithal <pcifuentes@siigsa.cl>
 * @since 23-08-2011
 * @version 1.2.1
 *
 * @return object oVen	:	objeto ventana final
 *
 */
function enc_getUltimaVentana(){

	var oVen 	= null;
	var oVenP = null;
	var cv = 0;

	oVen = window.opener

	while(oVen!=null){

		//cv = cv + 1;
		//if (confirm("tiene " + cv  + " padre mas, salir?")) return;
		oVenP = oVen;
		oVen = oVen["window"].opener;

	}

	return oVenP

}


/*
 * @link		http://www.siigsa.cl
 * @copyright	ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
 * @author		Jose Meneses Gonzalez <jmeneses@siigsa.cl>
 * @since		29-09-2011
 * @version		1.2.1
 * @see			http://api.jquery.com/jQuery.ajax/
 *

 	TABLA DE DEFINICIONES

 	- async			:	EXPLICACION	:	Determina que la cargada del objeto ajax se sï¿½ncrona o asï¿½ncrona. Por lo general asï¿½ncrona es mï¿½s ï¿½til, ya que la forma sï¿½ncrona
 										puede trabar el navegador hasta que la carga este completa.
 						VALORES		:	Boolean: true por defecto.

 	- beforeSend	:	EXPLICACION	:	Permite llamar una funciï¿½n antes de mandar el objeto ajax.
 						VALORES		:	Funciï¿½n: El unico parametro el el objeto.

 	- complete		:	EXPLICACION	:	Es una funcion que se ejecuta cuando el llamado al ajax esta completo. Permite saber si fue existoso
 						VALORES		:	Funcion: Los valores que retorna son el objeto XMLHttpRequest y un string que indica el resultado.

 	- contentType	:	EXPLICACION	:	Se usa cuando se mandan datos a los servidores a modo de encabezado.
 						VALORES		:	String: "application/x-www-form-urlencoded" funciona perfectamente.

 	- data			:	EXPLICACION	:	Se usa para especificar datos a mandar. Estos tienen la siguiente forma: foo=bar&foo2=bar2;. Si los datos a enviar son un vector(array)
 										jQuery los convierte a varios valores con un mismo nombre (si foo["alt1","alt2"], foo="alt1"&foo="alt2";)
 						VALORES		:	Array / String con la forma antes mencionada.

 	- dataType		:	EXPLICACION	:	Indica el tipo de datos que se van a llamar. Si no se especifica jQuery automaticamente encontrarï¿½ el tipo basado en el header del archivo
 										llamado (pero toma mas tiempo en cargar, asi que especificalo)
 						VALORES		:	"xml"	: Devuelve un documento XML.
										"html"	: Devuelve HTML con texto plano, y respeta las etiquetas.
										"script": Evalua el JavaScript y devuelve texto plano.
										"json"	: Evalua la respuesta JSON y devuelve un objeto Javascript

	- error			:	EXPLICACION	:	Se ejecuta si ocurre un error al llamar el archivo. Devuelve 3 parametros: El objeto, un string con el error, y un objeto adicional de error,
										si este ocurre.
						VALORES		:

	- global		:	EXPLICACION	:	Permite hacer que el objeto ajax obedezca o desobedezca las reglas para objetos ajax que el usuario pone.
						VALORES		:	Boolean: Por defecto true

	- ifModified	:	EXPLICACION	:	Permite que el objeto ajax se active solo si la pagina a cargar se ha modificado.
						VALORES		:	Boolean: Por defecto false

	- processData	:	EXPLICACION	:	Por defecto, cada objeto que no sea un string y sea pasado de otro documento, sera transformado en cadena. Para evitar que esto pase,
										este parametro se puede poner en false
						VALORES		:	Boolean: Por defecto true.

	- success		:	EXPLICACION	:	Permite ejecutar cï¿½digo al ser exitoso un llamado.
						VALORES		:	Funciï¿½n: Recibe los datos que fueron llamados

	- timeout		:	EXPLICACION	:	Permite definir un tiempo de espera antes de ejecutar un objeto ajax.
						VALORES		:	Nï¿½mero: Un nï¿½mero de milisegundos (ms)

	- type			:	EXPLICACION	:	Indica el mï¿½todo que se va a usar
						VALORES		:	"GET" o "POST"

	- url			:	EXPLICACION	:	Indica la url de la que va a cargar datos el objeto ajax.
						VALORES		:	String: La url local del documento.
 *
 *
 */
function enc_jqueryAjax(){

	/*Funcion en desarrollo*/

	$.ajax({
		type		: "POST",
		url			: GC_WEB_DIR + '/exp/exp_modulo129.php',
		contentType	: "application/x-www-form-urlencoded",
		data		: "modaccion=em129_cargar_geocampos&gtid="+gtid,
		async		: true,
		dataType	: "html",
		global		: true,
		ifModified	: false,
		processData	: true,
		timeout		: 3000,

		beforeSend	: function(objeto){
			alert("Adios, me voy a ejecutar");
		},

		complete	: function(objeto, exito){
			if(exito=="success"){
				alert("Me acabo de completar y con exito");
			}
		},

		error		: function(objeto, quepaso, otroobj){
			alert("Estas viendo esto por que fallo. Paso lo siguiente: "+quepaso);
		},

		success		: function(datos){
			alert(datos);
		}

	});

}


/*
 * @link		http://www.siigsa.cl
 * @copyright	ï¿½SIIGSA - Registro Propiedad Intelectual Nï¿½ 172.560 - Derechos Reservados
 * @author		Jose Meneses Gonzalez <jmeneses@siigsa.cl>
 * @since		29-12-2011
 * @version		1.2.1
 *
 * Funcion que permite maximizar la ventana actual en la que ejecute la funcion
 *
 */
function enc_maximizarVentana(){
	
	window.moveTo(0,0);
	window.resizeTo(screen.width,screen.height);
	
}
