/**
 * @package	GeoDatum
 * Proyecto	:	GeoDatum - Sistema de Información Territorial
 * Archivo	:	Tag.class.js
 *
 * @link http://www.siigsa.cl
 * @copyright ©SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
 * @author Cristian Gómez <cgomez@siigsa.cl>
 * @since 30-12-2008
 * @version 1.0.8
 * 
 * Clase que crea tags de html en forma dinámica.
 * EJ:
 *			<input type="button"		id="" name="" value="" />
 *			<input type="checkbox"	id="" name="" value="" />
 *			<div id="" name=""></div>
 *			<textarea id="" name=""></textarea>
 *			<br>
 *			<table></table>
 *			etc...
 *
 *
 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
 * @since 30-12-2008
 * @version 6
 * eliminarAtributoTag()
 *
 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
 * @since 05-08-2009
 * @version 7
 * getEstiloTag()
 *
 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
 * @since 27-08-2009
 * @version 8
 * setClassTag()
 */

/**
 * @copyright ©SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
 * @since 25-06-2008
 * @version 1.0.1
 *
 * Constructor de la clase de tags
 * 
 */
function Tag(){
	
	//////////////////
	//   PUBLICOS   //
	//////////////////
	
	/**
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 24-06-2008
     * 
     * Object tag	:	Representa el objeto creado y en proceso actual
     */
	this.tag	=	'';
	
	/**
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 26-06-2008
     * 
     * String tag_id	:	Array que contendrá el ID del tag
     */
	this.tag_id	=	new Array();
	
	/**
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 26-06-2008
     * 
     * String tag_name	:	Array que contendrá el nombre del tag
     */
	this.tag_name	=	new Array();
	
	/**
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 26-06-2008
     * 
     * String tag_tipo	:	Array que contendrá el tipo del tag (input, textarea, div, etc...)
     */
	this.tag_tipo	=	new Array();
	
	/**
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 26-06-2008
     * 
     * String tag_pag	:	Array que contendrá la pagina que contiene el destino de las funciones hechas en AJAX
     */
	this.tag_pag	=	new Array();
	
	/**
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 26-06-2008
   * 
   * 	String tag_param	:	Arreglo que contendrá los parámetros que se pasen a las funciones creadas por
   *										la función "crearFuncion". 
   *
   *	Observación:	Los valores de los parametros contenidos en este arreglo, deben
   *								ir en el mismo orden en que se necesiten en la función creada.
   */
	this.tag_param	=	new Array(new Array());
	
	//////////////////
	//   PRIVADOS   //
	//////////////////
	
	/**
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 24-06-2008
     * 
     * Object oTag
     */
	var oTag 	= 	this;
	
	/**
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 25-06-2008
     * 
     * Object oAjax	:	Objeto ajax
     */
	var oAjax	=	new ObjAjax();
	
	
	
	/**
	 * @copyright ©SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 09-07-2008
	 * @version 1.0.3
   * 
   * Crea un tag y lo asigna al objeto padre
   * 
   * @param String _tipo_tag	:	Nombre del tipo de tag a crear (buttom, checkbox, submit, radio, etc)
   * @param Object _obj_padre	:	Objeto que contendrá al nuevo tag creado
   */
	this.crearTag = function(_tag, _tipo, _obj_padre){
		
		try{
			
			this.tag = document.createElement(_tag);						//Creamos el tag y lo asignamos al atributo "tag"
			
			switch(_tag){													//Validamos que tag es el creado
				
				case 'input':												//Si el tag es INPUT le asignamos el tipo asignado por parámetro
					this.setAtributoTag(this.get("tag"),"type",_tipo);
				break;
				
			}
			
			var list_tags = document.getElementsByTagName(_tag);			//Rescatamos todos los tag del mismo tipo del creado
			
			var tag_dato = _tag + "_" + (list_tags.length + 1);
			this.set("tag_id",tag_dato,tag_dato);							//Creamos el ID del tag (tipo + _ + [cantidad de tags del mismo tipo +1]) en el atributo tag_id
			this.set("tag_name",tag_dato,tag_dato);							//Creamos el NAME del tag con el mismo valor de su ID en el atributo tag_name
			this.set("tag_tipo",_tag,tag_dato);								//Definimos el tipo del tag (input, textarea, div, etc...) en el atributo tag_tipo
			
			this.setTag(tag_dato);											//Cargamos los valores delos atributos al tag

			if (typeof(_obj_padre)!="undefined"){							//En el caso de enviar el padre por parámetro se asiga el tag a este
				
				_obj_padre.appendChild(this.get("tag"));
				
			}else{															//En el caso de no asignar padre, el tag se crea en el BODY
				
				document.body.appendChild(this.get("tag"));
				
			}
			
//			return this.get("tag");											//Retornamos el tag creado como objeto
			return tag_dato;												//Retornamos el ID del tag
		
		}catch(e){
				
			alert(e.name + " - " + e.message);
			
		}
		
	}
		
		
	/**
	 * @copyright ©SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 09-07-2008
	 * @version 1.0.1
     * 
     * asigna valores a los atributos del tag
     *
     * @param String $tag_id	:	ID del tag creado
     * 
     */
	this.setTag = function(tag_id){
		
		try{
			
			this.setAtributoTag(this.get("tag"),'id',this.get("tag_id",tag_id));				//Cargamos el valor del ID del tag obteniéndolo del atributo publico "tag_id"
			this.setAtributoTag(this.get("tag"),'name',this.get("tag_name",tag_id));			//Cargamos el valor del NAME del tag obteniéndolo del atributo publico "tag_name"
			
		}catch(e){
				
			alert(e.name + " - " + e.message);
			
		}
		
	}
	
	
	/**
	 * @copyright ©SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 09-07-2008
	 * @version 1.0.0
     * 
     * Funcion que recupera 1 o N tags de acuerdo a su ID, Name o Type
     *
     * OPCIONES:
     * 1 = Recupera 1 tag de acuerdo a su ID (retorna un objeto)
     * 2 = Recupera N tags del mismo name (retorna arreglo de objetos)
     * 3 = Recupera N tags del mismo type (retorna arreglo de objetos)
     *
     * @param String $opcion		:	Opcion de la búsqueda
     * @param String $busqueda	:	ID, name o Type a buscar
     * 
     */
	this.getTags = function(opcion, busqueda, padre){
		
		try{
			
			if(typeof(padre) == 'undefined'){
				padre = document;
			}
			
			switch(opcion){
				
				case 1: //Opcion = 1 retorna el objeto encontrado con dicho ID
					return padre.getElementById(busqueda);
				break;							
				
				case 2: //Opcion = 2 retonra un arreglo con los objeto con el mismo name
					return padre.getElementsByName(busqueda);
				break;
										
				case 3: //Opcion = 3 retonra un arreglo con los objeto con el mismo type
					return padre.getElementsByTagName(busqueda);
				break;				
				
			}
			
			
		}catch(e){	
			alert(e.name + " - " + e.message);
		}
		
	}
	
	
	/**
	 * @copyright ©SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 26-06-2008
	 * @version 1.0.1
     * 
     * Asigna funciones a los tags, como los eventos (onclick,onblur,...)
     *	
     *	Observaciones:
     *			Como los navegadores se comportan diferente entre si, sobre todo IEXPLORER,
     *			es necesario validar el gatillador antes de asignarlo a la función.
     *			
     *			IEXPLORER no reconoce la función "addEventListener" por esto debemos usar
     *			la "attachEvent". El problema es que estas 2 funciones no reconocen el 
     *			gatillador (onclick,onblur,...) de la misma forma. Por esto es que el gatillador
     *			se debe enviar sin la preposición inglesa "ON". EJ: onclick => click.
     *			
     *			Esto porque la función "addEventListener" debe recibirlo sin la preposición, y 
     *			en caso de usar "attachEvent" se el concatenará el ON automaticamente.
     *			
     */
	this.crearFuncion = function(_tag, gatillo, funcion){

		try{
			
			if (_tag.addEventListener){											//Si el objeto soporta la instrucción addEventListener se procede con esa instrucción
				
				_tag.addEventListener(gatillo, funcion, true);
				
			}else{																//Si no soporta addEventListener se procede con attachEvent (IEXPLORER)
				
				_tag.attachEvent("on"+gatillo, funcion);
				
			}
		
		}catch(e){
				
			alert(e.name + " - " + e.message);
			
		}
		
	}
	
	
	/**
	 * @copyright ©SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
	 * @author Jose Meneses Gonzalez <jmeneses@siigsa.cl>
	 * @since 06-06-2008
	 * @version 1.0.0
	 *
	 * Funcion que permite setear el estilo propios de los tags
	 *
	 * Observaciones: Para setear ciertos estilos es necesario respetar algunas normas. (http://www.comptechdoc.org/independent/web/cgi/javamanual/javastyle.html)
	 *								- text-align = textAlign
	 * 
	 * @param objeto _obj  : objeto divisor
	 * @param string _nomb : nombre del estilo a setear
	 * @param string _val  : valor que se le asigna al estilo a setear
	 *
	 * @see Divisor.class.js  -> setEstiloObjeto();
	 */
	this.setEstiloTag = function(_obj, _nomb, _val){
		
		try{
			
			_obj.style[_nomb] = _val;
			
		}catch(e){
			
			alert(e.name + " - " + e.message);
			
		}

	}
	
	
	/**
	 * @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
	 *
	 * Funcion que permite obtener el estilo propios de los tags
	 * 
	 * @param objeto _obj  : objeto
	 * @param string _nomb : nombre del estilo
	 *
	 */
	this.getEstiloTag = function(_obj, _nomb){
		
		try{
			
			return _obj.style[_nomb];
			
		}catch(e){
			
			alert(e.name + " - " + e.message);
			
		}

	}
	
	
	/**
	 * @copyright ©SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
	 * @author Jose Meneses Gonzalez <jmeneses@siigsa.cl>
	 * @since 06-06-2008
	 * @version 1.0.0
	 *
	 * Funcion que permite setear los atributos propios de los tags
	 *
	 * Observaciones : Para setear ciertos atributos es necesario respetar normas :
	 *									- colspan = colSpan
	 *									- class = className(IE) y class (otros navegadores)
	 * 
	 * @param objeto _obj  : objeto divisor
	 * @param string _nomb : nombre del atributo a setear
	 * @param string _val  : valor que que se le asigna al atributo a setear 
	 *
	 * @see Divisor.class.js  ->  setAtributoObjeto();
	 */
	this.setAtributoTag = function(_obj, _nomb, _val){
		
		try{
			
			switch (_nomb){
				
				default :
					_obj.setAttribute( _nomb , _val);
				break;
				
			}

		}catch(e){
			
			alert(e.name + " - " + e.message);
			
		}

	}
		
	
	/**
	 * @copyright ©SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 30-12-2008
	 * @version 1.0.0
	 *
	 * Funcion que permite eliminar los atributos propios de los tags
	 * 
	 * @param objeto _obj  : objeto divisor
	 * @param string _nomb : nombre del atributo a setear
	 *
	 */
	this.eliminarAtributoTag = function(_obj, _nomb){
		
		try{
			
			_obj.removeAttribute(_nomb);

		}catch(e){
			
			alert(e.name + " - " + e.message);
			
		}

	}
	
	
	/**
	 * @copyright ©SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 10-07-2008
   	 * @version 1.0.0
	 *
	 * Funcion que permite rescatar los atributos propios de los tags
	 * 
	 * @param objeto _obj  : objeto tag
	 * @param string _nomb : nombre del atributo a rescatar
	 *
	 */
	this.getAtributoTag = function(_obj, _nomb){
		
		try{
			
			switch (_nomb){
				
				case "value":
					return _obj.value;
				break;
				default :
					return _obj.getAttribute(_nomb);
				break;
								
			}
		
		}catch(e){
			
			alert(e.name + " - " + e.message);
			
		}

	}
	
	
	/**
	 * @copyright ©SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 10-07-2008
   	 * @version 1.0.0
   	 * 
   	 * Crea un texto en el padre indicado. Si no ingresa un padre, se le hereda al BODY
   	 * 
   	 * @param string $_texto	:	String que servirá de texto
   	 * @param Object $obj_padre	:	Objeto al cual se le heredará el texto creado
   	 * 
   	 */
	this.crearTexto = function(_texto, obj_padre){
		
		try{
			
			var texto = document.createTextNode(_texto);					//Creamos el Texto
			
			if (typeof(obj_padre)!="undefined"){							//En el caso de enviar el padre por parámetro se asiga el tag a este
				
				obj_padre.appendChild(texto);
				
			}else{															//En el caso de no asignar padre, el texto se crea en el BODY
				
				document.body.appendChild(texto);
				
			}
			
		}catch(e){
			
			alert(e.name + " - " + e.message);
			
		}
		
	}
	
	
	/**
	 * @copyright ©SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
	 * @author 		Jose Meneses Gonzalez <jmeneses@siigsa.cl>
	 * @since 		14-08-2008
 	 * @version 	1.0.2
 	 * 
 	 * Establece un valor determinado a una variable (propiedad) de la clase
 	 * 
 	 * @param object $_select 			:	Objeto select contenedor de los options (<select>)
 	 * @param array $array_valores	:	Arreglo con los valores de los options ordenados por valor, nombre.
 	 * 
 	 *
 	 * @copyright SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
	 * @author 		Jose Meneses Gonzalez <jmeneses@siigsa.cl>
	 * @since 		02-10-2009
 	 * @version 	2
 	 * 
 	 * La modificacion la hize ya que cuando se crea un <select> dejaba el primer indice con un valor en "" y su texto en "". Modificacion
 	 * relizada : _select.options[0] = null;
 	 *
 	 * @copyright SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
	 * @author 		Jose Meneses Gonzalez <jmeneses@siigsa.cl>
	 * @since 		02-10-2009
 	 * @version 	3
 	 * 
 	 * La modificacion realizada fue cambiar en falso el cloneNode de TRUE a FALSE
 	 *
 	 * @copyright SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
	 * @author 		Jose Meneses Gonzalez <jmeneses@siigsa.cl>
	 * @since 		05-11-2010
 	 * @version 	4
 	 * 
 	 * La modificacion realizada fue comentar el if si es que vienen valores en vacio ""
 	 *
 	 */
	this.crearSelect = function(_select, array_valores) {
		
		var _opt	= this.crearTag("option","",_select);
		var opt 	= this.getTags(1,_opt);
		
		for(i=0;i<array_valores.length;i++){
			
			obj_opt = opt.cloneNode(false);
			var valores = array_valores[i].split(",");
			
//			if (valores[1].trim() != ""){
				var _text			= document.createTextNode(valores[1]);
				obj_opt.value	= valores[0];
				obj_opt.appendChild(_text);
				_select.appendChild(obj_opt);
//			}
		
		}
		
		_select.options[0] = null;
		
	}

	
	
	
	/**
	 * @copyright ©SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
	 * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 09-07-2008
   	 * @version 1.0.1
   	 * 
   	 * Establece un valor determinado a una variable (propiedad) de la clase
   	 * 
   	 * @param string $propiedad Nombre de la Propiedad
   	 * @param mixed Valor de la Propiedad
   	 * @param String $indice representa el indice del arreglo donde se asignará el valor
   	 * 
   	 * @see Divisor.class.js
   	 */
	this.set = function (propiedad, valor, indice){
		
		try{
			if(typeof(indice)!="undefined"){								//Si especifica un indice interpreta que se refiere a un atributo de tipo arreglo
				
				var arreglo = eval('this.' + propiedad);					//Recupera el atributo
				arreglo[indice] = valor;									//Le asiga el valor al arreglo en la posicion especificada como indices
				
			}else{
				
				eval('this.' + propiedad + ' = "' + valor + '"');			//Si no se trata de un arreglo setea el atributo de forma directa
				
			}
			
			
		}catch(e){
			
			alert(e.name + " - " + e.message);
			
		}
		
	}
 	

	/**
	 * @copyright ©SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
   * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 09-07-2008
   * @version 1.0.1
   * 
   * Retorna el valor actual de una variable (propiedad) de la clase
   * 
   * @param string $propiedad Nombre de la Propiedad
   * @param String $indice representa el indice del arreglo donde se asignará el valor
   * 
   * @return mixed Valor de la Propiedad
   * 
   * @see Divisor.class.js
   */
	this.get = function (propiedad, indice){
		
		try{
			
			if(typeof(indice)!="undefined"){							//Si especifica un indice interpreta que se refiere a un atributo de tipo arreglo
				
				var arreglo = eval('this.' + propiedad);				//Recupera el atributo
				return arreglo[indice];									//Retorna el valor contenido en el arreglo con posición indice
				
			}else{
				
				return eval('this.' + propiedad);						//Si no es arreglo retorna directamente
				
			}			
			
		}catch(e){
			
			alert(e.name + " - " + e.message);
			
		}
		
	}
	
	
	/**
	 * @copyright ©SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
   * @author Jose Meneses Gonzalez <jmeneses@siigsa.cl>
	 * @since 03-09-2008
   * @version 1.0.0
   * 
   * Metodo que elimina un tag a traves de su id. A traves del id del tag que se quiera eliminar, se busca al padre que lo contenga
   * y lo desvincula de el mismo para despues eliminarlo
   * 
   * @param string $obj_id	: ID del tag a eliminar
   * @param object $hijo		: Objeto del tag a eliminar
   * 
   */
	this.eliminarTag = function (obj_id, hijo){
		
//		if (obj_id.trim() != ""){
		if (obj_id != "undefined" && obj_id != ""){
			var hijo	= document.getElementById(obj_id);
		}
		
		var padre	= hijo.parentNode;

		padre.removeChild(hijo);
		
	}
	
	
	/**
	 * @copyright ©SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
   * @author Jose Meneses Gonzalez <jmeneses@siigsa.cl>
	 * @since 03-09-2008
   * @version 1.0.0
   * 
   * Metodo que elimina todos los tag que tenga un padre
   * 
   * @param string $obj_id : ID del padre de los tag
   * 
   */
	this.eliminarTagsHijos = function (obj_padre_id){
	
		try{
		
			/*var obj_padre		= document.getElementById(obj_padre_id);
			var cant_hijos	= obj_padre.childNodes.length;
			if (cant_hijos > 0){
				for (i=0;i<cant_hijos;i++){
					this.eliminarTag("",obj_padre.childNodes[i]);
				}
			}*/
			
			var obj_padre		= document.getElementById(obj_padre_id);
			
			obj_padre.innerHTML = "";
			
			
		}catch(e){
			
			alert(e.name + " - " + e.message);
			
		}
		
	}
	
	
	/**
	 * @copyright ©SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
   * @author Jose Meneses Gonzalez <jmeneses@siigsa.cl>
	 * @since 04-09-2008
   * @version 1.0.0
   * 
   * Metodo que permite insertar texto a un tag
   * 
   * @param object $obj_padre	: Objeto padre tag
   * @param string $texto 		: Cadena de caracteres
   * 
   */
	this.setTextoTag = function (obj_padre, texto){
		
		var txt	= document.createTextNode(texto);
		
		obj_padre.appendChild(txt);
		
	}
	
	/**
	 * @copyright ©SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
   * @author Cristián Gómez M. <cgomez@siigsa.cl>
	 * @since 29-09-2008
   * @version 1.0.0
   * 
   * Metodo que obtiene todos los tag que tenga un padre
   * 
   * @param string $obj_id : ID del padre de los tag
   * 
   */
	this.getTagsHijos = function (obj_padre_id){
		
		try{
			array_hijos = new Array();
			var obj_padre		= document.getElementById(obj_padre_id);
			var cant_hijos	= obj_padre.childNodes.length;

			if (cant_hijos > 0) {
				for (i=0;i<cant_hijos;i++){
					array_hijos[i] = obj_padre.childNodes[i];
				}
			}
			
			return array_hijos;
		}catch(e){
			
			alert(e.name + " - " + e.message);
			
		}
		
	}
	
	
	/**
	 * @copyright ©SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
   * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 29-09-2008
   * @version 1.0.0
   * 
   * Retorna un divisor que cumple la función de select multiple.
   * 
   * @param int 		$che_rad			:		Si es 1 desplegaran checkbox, si es 2 radiobuttom
   * @param String 	$str_valores	:		String con los valores en el siguiente formato => id1///name1///value1///texto1@@@id2///name2///value2///texto2.....
   * @param Object	$obj_padre		:		Objeto padre (div, table, etc) donde se desplegará el divisor de selecciones
   * @param String 	$ancho				:		String con el valor del ancho que tendrá el divisor de seleccion.
   * @param String 	$alto					:		String con el valor del alto que tendrá el divisor de seleccion.
   *
   */
	this.generarDivisorDeSeleccion = function(chk_rad, str_valores, obj_padre, ancho, alto){
		
		try{
			
			/*------------------------*/
			/*--  DIVISOR SELECTOR  --*/
			/*------------------------*/
			var id_div_sel = this.crearTag("div","",obj_padre);
			var div_sel = this.getTags(1,id_div_sel);
			if(typeof(ancho) != 'undefined'){this.setEstiloTag(div_sel,"width",ancho);}
			if(typeof(alto) != 'undefined'){this.setEstiloTag(div_sel,"height",alto);}
			this.setEstiloTag(div_sel,"overflow","auto");
			this.setEstiloTag(div_sel,"background","#FFF");
			this.setEstiloTag(div_sel,"scrollbar-track-color","#CCC");
			this.setEstiloTag(div_sel,"border","1px solid #777777");
			
			/*--------------------------*/
			/*-- CREACION DE OPCIONES --*/
			/*--------------------------*/
			var id_tabla = this.crearTag("table","",div_sel);  																	// Creación de la tabla
			var tabla = this.getTags(1,id_tabla);
			
			var id_tbody = this.crearTag("tbody","",tabla);																			//Creación del TBODY
			var tbody = this.getTags(1,id_tbody);
			
			var array_sv_sp3a = str_valores.split("@@@");
			for(i=0;i<array_sv_sp3a.length;i++){
				
				tbody.insertRow(i);																																//Creación de una fila
				
				var array_sv_sp3s = array_sv_sp3a[i].split("///");
				
				tbody.rows[i].insertCell(0);																											//Creación de una celda
				tbody.rows[i].insertCell(1);																											//Creación de una celda
				
				var obj_sel = '';
				
				if(chk_rad == 1){//Checkbox
					
					var id_chk = this.crearTag("input","checkbox",tbody.rows[i].cells[0]);
					obj_sel = this.getTags(1,id_chk);
					
				}else if(chk_rad == 2){//Radio
					
					var id_chk = this.crearTag("input","radio",tbody.rows[i].cells[0]);
					obj_sel = this.getTags(1,id_chk);
					
				}
				
				this.setAtributoTag(obj_sel,"id",array_sv_sp3s[0]);
				this.setAtributoTag(obj_sel,"name",array_sv_sp3s[1]);
				this.setAtributoTag(obj_sel,"value",array_sv_sp3s[2]);
				
				this.setTextoTag(tbody.rows[i].cells[1],array_sv_sp3s[3]);
				
			}
			
		}catch(e){
			
			alert(e.name + " - " + e.message);
			
		}
		
	}
	
	
	/**
	 * @copyright ©SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
   * @author Jose Meneses Gonzalez
	 * @since 19-05-2009
   * @version 1.0.1
   * 
   * Permite setear el source de un tag de imagen
   * 
   * @param string	$id_img		:	Id del tag img
   * @param string 	$src_img	:	Ruta que reemplazada por la existente anteriormente
   *
   */
	this.setSRCIMG = function (id_img, src_img){
		
		document.getElementById(id_img).src = src_img;
		
	}
	
	
	/**
	 * @copyright ©SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
   * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 10-08-2009
   * @version 1.0.0
   * 
   * Crea un divisor sobre todo de tamaño 100% X 100% con la imagen del cargando
   * 
   * @param buleano $op	:	si es GC_BULEANO_V abre el divisor, si es GC_BULEANO_F cierra el divisor
   */
	this.cargando = function (op){
		
		if(op == GC_BULEANO_V){
			
			var div_cargando = this.crearTag("div");
			var div_cargando = this.getTags(1,div_cargando);

			this.setAtributoTag(div_cargando,"id","div_cargando");

			this.setClassTag(div_cargando,"fondo_oscuro");
			
			this.setEstiloTag(div_cargando,"width","100%");
			this.setEstiloTag(div_cargando,"height","100%");
			this.setEstiloTag(div_cargando,"opacity",".9");
			this.setEstiloTag(div_cargando,"filter","alpha(Opacity=60)");
			this.setEstiloTag(div_cargando,"position","absolute");
			
			div_cargando.innerHTML = "<img src='" + GC_WEB_IMG + "/cargando_datos.gif' border='0' alt='Cargando Datos...' />";
			
		}else if(op == GC_BULEANO_F){
			
			var div_cargando = this.getTags(1,"div_cargando");
			
			document.body.removeChild(div_cargando);
			
		}else{
			
			alert("Debe especificar si desea abrir o cerrar el divisor CARGANDO...");
			return false;
			
		}
		
	}
	
	
	/**
	 * @copyright ©SIIGSA - Registro Propiedad Intelectual Nº 172.560 - Derechos Reservados
   * @author Gonzalo Arenas Flores <garenas@siigsa.cl>
	 * @since 27-08-2009
   * @version 1.0.0
   * 
   * Setea uan clase CSS para un tag
   * 
   * @param Object	$_obj	:	Objeto a modificar
   * @param String	$_val	:	valor a asignar
   */
	this.setClassTag = function (_obj, _val){
		
		try{
			
			this.setAtributoTag(_obj,"className",_val);						/*Seteamos el atributo CLASS para IE*/
			this.setAtributoTag(_obj,"class",_val);								/*Seteamos el atributo CLASS para los demás navegadores*/
		
		}catch(e){
			
			alert(e.name + " - " + e.message);
			
		}
		
	}

}
