var xmlHttp = null;
/**
	 * Objeto para el manejo de solicitudes XMLHttpRequest.
	 */
function AjaxRequest() {
	var asynchronous;
	/**
		 * Retorna el objeto tipo XMLHttpRequest
		 */
	function init(asynchronousValue) {
		if(asynchronousValue){
			if(asynchronousValue == "false"){
				this.asynchronous = false;
			}
			else{
				this.asynchronous = true;
			}
		}
		else{
			this.asynchronous = true;
		}
		if (xmlHttp) {
		} else {
			try {
				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e) {
				try {
					xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (E) {
					xmlHttp = false;
				}
			}
			if (!xmlHttp && typeof XMLHttpRequest != "undefined") {
				xmlHttp = new XMLHttpRequest();
			}
		}
		document.ajaxRequest = this;
	}	
	/**
		 * Retorna un objeto de xmlHTTPRequest
		 */
	function getXMLHttpRequest() {
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (exception) {
			try {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (exception2) {
				xmlHttp = false;
			}
		}
		if (!xmlHttp && typeof XMLHttpRequest != "undefined") {
			xmlHttp = new XMLHttpRequest();
		}
		return xmlHttp;
	}
	/**
		 * Registra la actividad ajax en la ventana. Para control del timeout.
		 */
	function registryActivity() {
		if (top.window.timerInactiveSession) {
			top.window.timerInactiveSession = 0;
		}
	}
	/**
		 * Aplica los cambios en la forma de acuerdo a la respuesta XML de la solicitud ajax
		 */
	function setXMLDataHandler() {
		var field;
		var name;
		var value;
		var optionsField;
		var options;
		var option;
		var label;
		var valueOption;
		var titleOption;
		var fieldDocument;
		var content;
		var showField;
		var colorField;
		var borderField;
		var classField;
		var disabledField;
		var inParent;
		var inFrame;
		var frameName;
		var frame;
		var documentFrame;
		var eventListener;
		var checked;
		if (xmlHttp.readyState == 4) { // Complete
			if (xmlHttp.status == 200) { // OK response
				if (xmlHttp.responseXML && xmlHttp.responseXML.documentElement) {
					var response = xmlHttp.responseXML.documentElement;
					var fields = response.getElementsByTagName("field");
					
					for (i = 0; i < fields.length; i++) {						
						fieldDocument = null;
						field = fields[i];
						name = field.getAttribute("name");
						value = field.getAttribute("value");
						defaultValue = field.getAttribute("defaultValue");
						inParent = field.getAttribute("parent");
						inFrame = field.getAttribute("frame");
		  					//Si esta en el parent
						if (inParent && inParent == "true") {
							if (parent.document.getElementById(name)) {
								fieldDocument = parent.document.getElementById(name); // Caso Java Server Faces
							} else {
								if (parent.document.getElementsByName(name)) {
									fieldDocument = parent.document.getElementsByName(name)[0];
								}
							}
							//Si esta en un frame de la ventana
						} else {
							if (inFrame && inFrame == "true") {
								frameName = field.getAttribute("frameName");
								if (frameName) {
									frame = document.getElementById(frameName);
									documentFrame = null;
									if (document.all && document.frames(frameName)) {
										documentFrame = document.frames(frameName).document;
									} else {
										documentFrame = frame.contentDocument;
									}
									if (documentFrame && documentFrame.getElementById(name)) {
										fieldDocument = documentFrame.getElementById(name); // Caso Java Server Faces
									} else {
										if (documentFrame && documentFrame.getElementsByName(name)) {
											fieldDocument = documentFrame.getElementsByName(name)[0];
										}
									}
								}
							} else {
								if (document.getElementById(name)) {
									fieldDocument = document.getElementById(name); // Caso Java Server Faces
								} else {
									if (document.getElementsByName(name)[0]) {
										fieldDocument = document.getElementsByName(name)[0];
									}
								}
							}
						}
						
							//Se evalua si se cambian las opciones en los casos de los selects
						if (fieldDocument && fieldDocument.type && (fieldDocument.type == "select-one" || fieldDocument.type == "select-multiple")) {
							optionsField = field.getElementsByTagName("options");
							if (optionsField.length > 0 && optionsField[0] != null) {
								for (j = 0; fieldDocument.options.length; j++) { //Eliminar las opciones del select
									fieldDocument.remove(0);
								}
								options = optionsField[0].childNodes;
								for (j = 0; j < options.length; j++) {
									option = options[j];
									label = option.getAttribute("label");
									valueOption = option.getAttribute("value");
									titleOption = option.getAttribute("title");
									
									var newOption = new Option(label, valueOption);
									newOption.title = titleOption;
									
									fieldDocument.options.add(newOption);
								}
							}
							else {
								optionsField = field.getElementsByTagName("options-cdata");
								if (optionsField.length > 0 && optionsField[0] != null) {
									for (j = 0; fieldDocument.options.length; j++) { //Eliminar las opciones del select
										fieldDocument.remove(0);
									}
									options = optionsField[0].childNodes;
									for (j = 0; j < options.length; j++) {
										option = options[j];
										var valueNode = option.childNodes[0];
										var labelNode = option.childNodes[1];
										var newOption = new Option(labelNode.firstChild.data, valueNode.firstChild.data);
										newOption.title = titleOption;
										
										fieldDocument.options.add(newOption);
									}
								}
							}
						}
						if (fieldDocument && fieldDocument.type && ((fieldDocument.type == "radio" && field.getAttribute("multiple") && field.getAttribute("multiple") == "true"))) {
							var checkboxes = document.getElementsByName(name);							
							optionsField = field.getElementsByTagName("options");
							if (optionsField.length > 0 && optionsField[0] != null) {
								options = optionsField[0].childNodes;								
								var checkboxesParentCol1 = checkboxes[0].parentNode;
								var checkboxesParentCol2 = checkboxes[checkboxes.length-1].parentNode;
								
								//Borra todos los hijos que no son checkbox y radio button de la primera columna
								//tiene en cuenta no borrar la casilla de texto para los checkbox 099
								for (j=checkboxesParentCol1.childNodes.length-1; j >= 0;j--) {												
									if((checkboxesParentCol1.childNodes[j].type != 'radio')){
										checkboxesParentCol1.removeChild(checkboxesParentCol1.childNodes[j]);
									}
									else{
										//Inhabilita todos los checkboxes y radio buttons y los oculta
										checkboxesParentCol1.childNodes[j].setAttribute("value", "");
										checkboxesParentCol1.childNodes[j].style.display = "none";
										checkboxesParentCol1.childNodes[j].checked = false;
									}
								}									
								//Borra todos los hijos que no son checkbox y radio buttons de la segunda columna
								//tiene en cuenta no borrar la casilla de texto para los checkbox 099
								for (k=checkboxesParentCol2.childNodes.length-1; k >= 0; k--) {								
									if((checkboxesParentCol2.childNodes[k].type != 'radio')){
										checkboxesParentCol2.removeChild(checkboxesParentCol2.childNodes[k]);
									}
									else{
										//Inhabilita todos los checkboxes y radio buttons y los oculta
										checkboxesParentCol2.childNodes[k].setAttribute("value", valueOption);
										checkboxesParentCol2.childNodes[k].style.display = "none";										
										checkboxesParentCol2.childNodes[k].checked = false;
									}
								}
								
								var colsLeft = 2;
								var totalChk = 0;
								var itemsLeft = options.length;
								var itemsLeftThisIteration = 0;
								//Referencia de la columna actual de trabajo
								var checkboxesParent = null;
								//Variable para el checkbox
								var newNode;
								
								for (l = 0; l < options.length; l++) {
									//Obtiene los valores de la nueva opcion
									option = options[l];
									label = option.getAttribute("label");
									valueOption = option.getAttribute("value");										
									eventListener = option.getAttribute("onclick");
									checked = option.getAttribute("checked");
									
									//Variables para el label y el br										
									var newLabel;
									var newBr;
									
									if(itemsLeftThisIteration == 0){											
										//Toma la referencia de la primera columna
										checkboxesParent = checkboxesParentCol1;																						
										itemsLeftThisIteration = parseInt((itemsLeft  + colsLeft - 1) / colsLeft);
																				
										if(colsLeft==1){
											//Toma la referencia de la segunda columna
											checkboxesParent = checkboxesParentCol2;
										}				
										//Toma la referencia del primer checkbox o radio button
										newNode = checkboxesParent.firstChild;
										colsLeft--;							
									}
									else{
										//Toma la referencia del siguiente checkbox o radio button										
										newNode = newNode.nextSibling;	
										while(newNode.type != 'radio'){
											newNode = newNode.nextSibling;
										}
									}																													
									newNode.setAttribute("value", valueOption);
									newNode.setAttribute("name", name);
									newNode.style.display = "";
									newNode.disabled = false;
									if(eventListener){
										newNode.onclick = function (event) { eval(eventListener); };
									}
									
									//Si tiene la propiedad checked chequea el checkbox o radio button
									if(checked){
										if(checked == 'true'){
											newNode.checked = true;
										}
									}
									
									//Crea el label
									newLabel = document.createElement("label");
									newLabel.appendChild(document.createTextNode(label));
									
									//Crea el br
									newBr = document.createElement("br");
									
									//Aņade los nuevos nodos si existe la casilla para un checkbox 099
									//tiene en cuenta esto para ingresar adecuadamente los nuevos elementos
									if(newNode.nextSibling && newNode.nextSibling.type && newNode.nextSibling.type == 'text'){
										checkboxesParent.insertBefore(newBr,newNode.nextSibling.nextSibling);
										checkboxesParent.insertBefore(newLabel, newBr.previousSibling);
									}
									else{
										checkboxesParent.insertBefore(newBr,newNode.nextSibling);
										checkboxesParent.insertBefore(newLabel, newBr);
									}
									
									itemsLeftThisIteration--;
									itemsLeft--;
									totalChk ++;
								}
							}							
							else{	
								showField = field.getAttribute("show");					
								disabledField = field.getAttribute("disabled");
								for (var iter=0; iter< checkboxes.length; iter++){
									
									if (showField) {
										if (showField == "true") {
											checkboxes[iter].style.display = "";
										} else {
											if (showField == "false") {
												checkboxes[iter].style.display = "none";
											}
										}
									}								
									if (disabledField) {
										if (disabledField == "true") {
											checkboxes[iter].disabled = true;
										} else {
											if (disabledField == "false") {
												checkboxes[iter].disabled = false;
											}
										}
									}
									if ((value || value == "")) {
										if(checkboxes[iter].value == value){
											checkboxes[iter].checked = true;
										}									
									}
								}
							}
						}
						//Si es un checkbox
						else if (fieldDocument && fieldDocument.type && fieldDocument.type == "checkbox" ) {
							/************************************************************************
							************************************************************************/
							/***************** Ajax compatible con internet explorer 6 *************
							************************************************************************/
							//Aqui crea de nuevo los valores de los checkbox y radio buttons de acuerdo a lo que se envia
							//en options se generan los valores tal y como esta en la plantilla MSREG01 y MAREG04
							//input checkbox o radio button - label - br
							var checkboxes = document.getElementsByName(name);							
							optionsField = field.getElementsByTagName("options");							
							if (optionsField.length > 0 && optionsField[0] != null) {
								options = optionsField[0].childNodes;								
								var checkboxesParentCol1 = checkboxes[0].parentNode;

								if(checkboxesParentCol1.nodeName!="FIELDSET"){
									//Borra todos los hijos que no son checkbox y radio button de la primera columna
									//tiene en cuenta no borrar la casilla de texto para los checkbox 099
									for (j=checkboxesParentCol1.childNodes.length-1; j >= 0;j--) {
										if((checkboxesParentCol1.childNodes[j].type != 'checkbox' 
											&& checkboxesParentCol1.childNodes[j].type != 'radio')
											&& !(checkboxesParentCol1.childNodes[j].id 
													&& checkboxesParentCol1.childNodes[j].id.match('text-') 
													&& checkboxesParentCol1.childNodes[j].type == 'text')
											&& !(checkboxesParentCol1.childNodes[j].id 
													&& checkboxesParentCol1.childNodes[j].id.match('table-'))){
											checkboxesParentCol1.removeChild(checkboxesParentCol1.childNodes[j]);
											
										}
										else{
											//Inhabilita todos los checkboxes y radio buttons y los oculta
											checkboxesParentCol1.childNodes[j].setAttribute("value", "");
											checkboxesParentCol1.childNodes[j].style.display = "none";
											checkboxesParentCol1.childNodes[j].checked = false;
											//Si son tables elimina sus nombres e ids
											if(checkboxesParentCol1.childNodes[j].id 
													&& checkboxesParentCol1.childNodes[j].id.match('checkboxtext-table-')){													
												checkboxesParentCol1.childNodes[j].setAttribute("id", "checkboxtext-table-"+j);
												var spanTextChild = checkboxesParentCol1.childNodes[j].getElementsByTagName("input")[0];
												spanTextChild.disabled = true;
											}
										}
									}
								
									//Referencia de la columna actual de trabajo
									var checkboxesParent = checkboxesParentCol1;
									//Variable para el checkbox
									var newNode;
									
									for (l = 0; l < options.length; l++) {
										//Obtiene los valores de la nueva opcion
										option = options[l];
										label = option.getAttribute("label");
										valueOption = option.getAttribute("value");
										eventListener = option.getAttribute("onclick");
										checked = option.getAttribute("checked");
										
										//Variables para el label y el br										
										var newLabel;
										var newBr;
										
										//Toma la referencia del siguiente checkbox o radio button
										newNode = checkboxes[l];
		
										newNode.setAttribute("value", valueOption);
										newNode.setAttribute("name", name);
										newNode.style.display = "";
										newNode.disabled = false;
										if(eventListener){
											newNode.onclick = function (event) { eval(eventListener); };
										}
										
										//Si tiene la propiedad checked chequea el checkbox o radio button
										if(checked){
											if(checked == 'true'){
												newNode.checked = true;
											}
										}
										
										//Crea el label
										newLabel = document.createElement("label");
										newLabel.appendChild(document.createTextNode(label));
										
										//Crea el br
										newBr = document.createElement("br");
										
										//Ingresa los ids a los componentes								
										if(newNode.nextSibling && newNode.nextSibling.id 
												&& newNode.nextSibling.id.match('checkboxtext-table-')){													
											newNode.nextSibling.setAttribute("id", name.replace("checkbox-","checkboxtext-table-")+"-"+valueOption);
											var spanTextChild = newNode.nextSibling.getElementsByTagName("input")[0];
											spanTextChild.setAttribute("id", name.replace("checkbox-","checkboxtext-")+"-"+valueOption);
											spanTextChild.setAttribute("name", name.replace("checkbox-","checkboxtext-")+"-"+valueOption);
										}
										
										//Aņade los nuevos nodos si existe la casilla para un checkbox 099
										//tiene en cuenta esto para ingresar adecuadamente los nuevos elementos
										if(newNode.nextSibling && 
											((newNode.nextSibling.type && newNode.nextSibling.type == 'text') ||
											(newNode.nextSibling.nodeName && newNode.nextSibling.nodeName == 'SPAN'))){											
											checkboxesParent.insertBefore(newBr,newNode.nextSibling.nextSibling);
											checkboxesParent.insertBefore(newLabel, newBr.previousSibling);
										}
										else{
											checkboxesParent.insertBefore(newBr,newNode.nextSibling);
											checkboxesParent.insertBefore(newLabel, newBr);
										}									
									}
								}
								else if(checkboxesParentCol1.nodeName=="FIELDSET"){
									var fieldset = new Array();
									fieldset[0] = checkboxesParentCol1;									
									for(n=1;checkboxesParentCol1.nextSibling;n++){
										if(checkboxesParentCol1.nextSibling.nodeName=="FIELDSET"){
											fieldset[n] = checkboxesParentCol1.nextSibling;
										}
										else{
											n--;
										}										
										checkboxesParentCol1 = checkboxesParentCol1.nextSibling;										
									}
									for(m=0;m<fieldset.length;m++){
										checkboxesParentCol1 = fieldset[m];
										checkboxesParentCol1.style.display = "none";
										for (j=checkboxesParentCol1.childNodes.length-1; j >= 0;j--) {
											if((checkboxesParentCol1.childNodes[j].type != 'checkbox')
												&& !(checkboxesParentCol1.childNodes[j].id
														&& checkboxesParentCol1.childNodes[j].id.match('text-') 
														&& checkboxesParentCol1.childNodes[j].type == 'text')
												&& !(checkboxesParentCol1.childNodes[j].id 
													&& checkboxesParentCol1.childNodes[j].id.match('table-'))){
												checkboxesParentCol1.removeChild(checkboxesParentCol1.childNodes[j]);
											}
											else{
												//Inhabilita todos los checkboxes y radio buttons y los oculta
												checkboxesParentCol1.childNodes[j].setAttribute("value", "");
												checkboxesParentCol1.childNodes[j].style.display = "none";
												checkboxesParentCol1.childNodes[j].checked = false;
												//Si son tables elimina sus nombres e ids												
												if(checkboxesParentCol1.childNodes[j].id 
														&& checkboxesParentCol1.childNodes[j].id.match('checkboxtext-table-')){													
													checkboxesParentCol1.childNodes[j].setAttribute("id", "checkboxtext-table-"+j);
													var spanTextChild = checkboxesParentCol1.childNodes[j].getElementsByTagName("input")[0];
													spanTextChild.disabled = true;
												}
											}
										}
									}
										
										var checkboxesParent = null;
										//Variable para el checkbox
										var newNode;
										//Variable para el grupo actual
										var groupAct = 0;
										//Variable para iteracion de los fieldset
										var f = 0;
										//Variable para iteracion de de los checkbox
										var c = 0;
										for (l = 0; l < options.length; l++, c++) {
											//Obtiene los valores de la nueva opcion
											option = options[l];
											label = option.getAttribute("label");
											valueOption = option.getAttribute("value");
											eventListener = option.getAttribute("onclick");
											checked = option.getAttribute("checked");
											//variable que contiene el id del grupo
											var group = option.getAttribute("group");						
											
											//Chequea que el grupo de la opcion sea igual a el grupo
											//actual si no lo es cambia el parent
											if(group && groupAct!=group){
												groupAct=group;
												checkboxesParent = fieldset[f];
												checkboxesParent.style.display = "";
												//inserta el legend en el fieldset
												var newLegend;
												newLegend = document.createElement("legend");
												newLegend.appendChild(document.createTextNode(group));
												checkboxesParent.insertBefore(newLegend,checkboxesParent.firstChild);
												f++;
											}
											
											//Variables para el label y el br										
											var newLabel;
											var newBr;
											
											//Toma la referencia del siguiente checkbox o radio button
											newNode = checkboxes[c];
											while(newNode.parentNode != checkboxesParent){
												c++;
												newNode = checkboxes[c];
											}
											if(valueOption=='099' && !newNode.onclick){												
												c++;
												newNode = checkboxes[c];
											}
			
											newNode.setAttribute("value", valueOption);
											newNode.setAttribute("name", name);
											newNode.style.display = "";
											newNode.disabled = false;
											if(eventListener){
												newNode.onclick = function (event) { eval(eventListener); };
											}
											
											//Si tiene la propiedad checked chequea el checkbox o radio button
											if(checked){
												if(checked == 'true'){
													newNode.checked = true;
												}
											}
											
											//Crea el label
											newLabel = document.createElement("label");
											newLabel.appendChild(document.createTextNode(label));
											
											//Crea el br
											newBr = document.createElement("br");
											
											//Ingresa ids a los componentes																																	
											if(newNode.nextSibling && newNode.nextSibling.id 
													&& newNode.nextSibling.id.match('checkboxtext-table-')){													
												newNode.nextSibling.setAttribute("id", name.replace("checkbox-","checkboxtext-table-")+"-"+valueOption);
												var spanTextChild = newNode.nextSibling.getElementsByTagName("input")[0];
												spanTextChild.setAttribute("id", name.replace("checkbox-","checkboxtext-")+"-"+valueOption);
												spanTextChild.setAttribute("name", name.replace("checkbox-","checkboxtext-")+"-"+valueOption);
											}
											
											//Aņade los nuevos nodos si existe la casilla para un checkbox 099
											//tiene en cuenta esto para ingresar adecuadamente los nuevos elementos
											if(newNode.nextSibling && 
												((newNode.nextSibling.type && newNode.nextSibling.type == 'text') ||
												(newNode.nextSibling.nodeName && newNode.nextSibling.nodeName == 'SPAN'))){
												checkboxesParent.insertBefore(newBr,newNode.nextSibling.nextSibling);
												checkboxesParent.insertBefore(newLabel, newBr.previousSibling);
											}
											else{
												checkboxesParent.insertBefore(newBr,newNode.nextSibling);
												checkboxesParent.insertBefore(newLabel, newBr);
											}											
										}									

								}
							}							
							else{	
								showField = field.getAttribute("show");					
								disabledField = field.getAttribute("disabled");
								for (var iter=0; iter< checkboxes.length; iter++){
									
									if (showField) {
										if (showField == "true") {
											checkboxes[iter].style.display = "";
										} else {
											if (showField == "false") {
												checkboxes[iter].style.display = "none";
											}
										}
									}								
									if (disabledField) {
										if (disabledField == "true") {
											checkboxes[iter].disabled = true;
										} else {
											if (disabledField == "false") {
												checkboxes[iter].disabled = false;
											}
										}
									}
									if ((value || value == "")) {
										if(checkboxes[iter].value == value){
											checkboxes[iter].checked = true;
										}									
									}
								}
							}
						} 
						else if (fieldDocument && fieldDocument.type 
									&& (fieldDocument.type == "radio" 
									&& (!field.getAttribute("multiple") 
									|| field.getAttribute("multiple")=="false"))) {
							var radios = document.getElementsByName(name);
							var radiosParent = radios[0].parentNode;

							showField = field.getAttribute("show");					
							disabledField = field.getAttribute("disabled");							
							
							optionsField = field.getElementsByTagName("options");
							//Ingresa las opciones solo dos porque no tiene el atributo multiple
							//entonces se asume un radio button con opcion si no
							if (optionsField.length > 0 && optionsField[0] != null) {								
								options = optionsField[0].childNodes;
								
								//Borra todos los hijos que no son radio button 
								//evitando borrar u ocultar el label con la descripcion de la pregunta
								//tambien evita borrar el elemento span (*) que indica que la pregunta
								//es requerida
								for (j=radiosParent.childNodes.length-1; j >= 0;j--) {		
									if(radiosParent.childNodes[j].type != 'radio'
										&& radiosParent.childNodes[j].nodeName != 'SPAN'
										&& !(radiosParent.childNodes[j].id 
										&& radiosParent.childNodes[j].id.match('label-'))){											
											radiosParent.removeChild(radiosParent.childNodes[j]);
									}
									else if (radiosParent.childNodes[j].type == 'radio'){
										//Inhabilita todos los radio buttons y los oculta
										radiosParent.childNodes[j].setAttribute("value", "");
										radiosParent.childNodes[j].style.display = "none";
										radiosParent.childNodes[j].checked = false;
									}
								}
								
								for(var iter=0; iter < options.length && iter<2 ;iter++){
									option = options[iter];										
									label = option.getAttribute("label");
									valueOption = option.getAttribute("value");
									
									radios[iter].setAttribute("value", valueOption);
									radios[iter].setAttribute("name", name);
									
									//Crea el label
									var newLabel = document.createElement("label");
									newLabel.appendChild(document.createTextNode(label));
									
									//Aņade los nuevos nodos si existe la casilla para un checkbox 099
									//tiene en cuenta esto para ingresar adecuadamente los nuevos elementos
									radiosParent.insertBefore(newLabel,radios[iter].nextSibling);
								}
							}
							
							for (var iter=0; iter< radios.length; iter++){								
								if (showField) {
									if (showField == "true") {
										radios[iter].style.display = "";
									} else {
										if (showField == "false") {
											radios[iter].style.display = "none";
										}
									}
								}

								if (disabledField) {
									if (disabledField == "true") {
										radios[iter].disabled = true;
									} else {
										if (disabledField == "false") {
											radios[iter].disabled = false;
										}
									}
								}
																
								if ((value || value == "")) {
									if(radios[iter].value == value){
										radios[iter].checked = true;
									}
								}
							}
						}
						else {
							//Se tiene valor por defecto y el valor actual este en blanco cambia el valor del campo del documento.
							//Para elementos diferentes a label
							if (defaultValue && !(value || value == "") && fieldDocument && fieldDocument.value == "") {
								fieldDocument.value = defaultValue;
							}

							//Se cambia el valor del campo del documento.
							if ((value || value == "") && fieldDocument) {
								fieldDocument.value = value;
							}							

							showField = field.getAttribute("show");
							if (fieldDocument && showField) {
								if (showField == "true") {
									fieldDocument.style.display = "";
								} else {
									if (showField == "false") {
										fieldDocument.style.display = "none";
									}
								}
							}
						
							/********* PROPIEDADES DE ESTILOS ********/	
							colorField = field.getAttribute("color");
							if (fieldDocument && colorField) {
								fieldDocument.style.color = colorField;
							}
							
							borderField = field.getAttribute("border");
							if (fieldDocument && borderField) {
								fieldDocument.style.border = borderField;								
							}
							
							classField = field.getAttribute("class");
							if (fieldDocument && classField) {
								fieldDocument.className = classField;								
							}
							
							/******************************************/
							
							disabledField = field.getAttribute("disabled");
							if (fieldDocument && disabledField) {
								if (disabledField == "true") {
									fieldDocument.disabled = true;
								} else {
									if (disabledField == "false") {
										fieldDocument.disabled = false;
									}
								}
							}
							readonlyField = field.getAttribute("readonly");
							if (fieldDocument && readonlyField) {
								if (readonlyField == "true") {
									fieldDocument.readOnly = true;
								} else {
									if (readonlyField == "false") {
										fieldDocument.readOnly = false;
									}
								}
							}
							focusField = field.getAttribute("focus");
							if (fieldDocument && focusField) {
								if (focusField == "true") {
									fieldDocument.focus();
								}
							}
							titleField = field.getAttribute("title");
							if (fieldDocument && titleField) {
								fieldDocument.title = titleField;
							}							
		
								//Se cambia el contenido(HTML) del campo en el documento
							if (fieldDocument && field.getElementsByTagName("content").length > 0 && field.getElementsByTagName("content")[0].firstChild && field.getElementsByTagName("content")[0].firstChild.data != undefined) {
								content = field.getElementsByTagName("content")[0].firstChild.data;
								fieldDocument.innerHTML = content;
							}
						}
					}
					document.ajaxRequest.printMessages(response);
					document.ajaxRequest.executeJavaScript(response);
	
					//Se verifica que no haya existido ningun error
					var errors = response.getElementsByTagName("error");
					if (errors && errors.length > 0 && errors[0]) {
						return false;
					}
					return true;
				}
				return true;
			} else {
				alert(xmlHttp.statusText);
				return false;
			}
		}
		return false;
	}
	/**
		 * Envia la solititud XMLHttpRequest al url especifico.
		 * Forma los parametros con la bandera de ajaxRequest=true idComponente=<nombre/id_Input> y <nombre/id_Input>=input.value
		 */
	function send(url, input, optionalValue) {
		this.registryActivity();
			//Codigo para solucionar bug de Mozilla
		if (window.XMLHttpRequest) {
			xmlHttp = null;
			this.init(this.asynchronous.toString());
		}
		xmlHttp.open("POST", url, this.asynchronous);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		var inputId = "";
		if (input.id) {
			inputId = input.id;
		} else {
			if (input.name) {
				inputId = input.name;
			}
		}
		var inputValue = "";
		if (input.value && input.type != "checkbox") {
			inputValue = input.value;
		}		
		else if(input.type == "checkbox"){
			inputValue = input.checked;
		}
		var params = "ajaxRequest=true&idComponent=" + inputId + "&" + inputId + "=" + escape(inputValue);
		if (optionalValue != null && optionalValue != '') {
			params = params + "&" + inputId + "OptionalValue=" + escape(optionalValue);
		}
		
		xmlHttp.send(params);
		if (this.asynchronous) {
			xmlHttp.onreadystatechange = this.setXMLDataHandler;
		} else {
			return this.setXMLDataHandler();
		}
	}
	/**
		 * Envia la solititud XMLHttpRequest al url especifico.
		 * Forma los parametros con la bandera de ajaxRequest=true idComponente=<nombre/id_InputAction> y  listado de inputs values con <nombre/id_Input>=input.value
		 */
	function sendActionValues(url, inputAction, values) {
		this.registryActivity();
			//Codigo para solucionar bug de Mozilla
		if (window.XMLHttpRequest) {
			xmlHttp = null;
			this.init(this.asynchronous.toString());
		}
		var xmlHttp = this.getXMLHttpRequest();
		xmlHttp.open("POST", url, this.asynchronous);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		var inputIdAction = "";
		if (inputAction.id) {
			inputIdAction = inputAction.id;
		} else {
			if (inputAction.name) {
				inputIdAction = inputAction.name;
			}
		}
		var inputId;
		var input;
		var inputValue;
		var paramsValues = "";
		for (i = 0; i < values.length; i++) {
			input = values[i];
			inputId = "";
			if (input.id) {
				inputId = input.id;
			} else {
				if (input.name) {
					inputId = inputA.name;
				}
			}
			inputValue = "";
			if (input.value) {
				inputValue = input.value;
			}
			paramsValues += "&" + inputId + "=" + escape(inputValue);
		}
		var params = "ajaxRequest=true&idComponent=" + inputIdAction + paramsValues;
		xmlHttp.send(params);
		if (this.asynchronous) {
			xmlHttp.onreadystatechange = this.setXMLDataHandler;
		} else {
			return this.setXMLDataHandler();
		}
	}
	/**
		 * Envia la solititud XMLHttpRequest al url especifico.
		 * Forma los parametros con la bandera de ajaxRequest=true paramProcess=<paramProcess> y <nombre/id_Input>=input.value
		 */
	function sendAction(url, paramProcess, input) {
		this.registryActivity();
			//Codigo para solucionar bug de Mozilla
		if (window.XMLHttpRequest) {
			xmlHttp = null;
			this.init(this.asynchronous.toString());
		}
		var xmlHttp = this.getXMLHttpRequest();
		xmlHttp.open("POST", url, this.asynchronous);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		var inputId = "";
		if (input.id) {
			inputId = input.id;
		} else {
			if (input.name) {
				inputId = input.name;
			}
		}
		var inputValue = "";
		if (input.value) {
			inputValue = input.value;
		}
		var params = "ajaxRequest=true&paramProcess=" + paramProcess + "&" + "&idComponent=" + inputId + "&" + inputId + "=" + escape(inputValue);
		xmlHttp.send(params);
		if (this.asynchronous) {
			xmlHttp.onreadystatechange = this.setXMLDataHandler;
		} else {
			return this.setXMLDataHandler();
		}
	}
	/**
		 * Envia la solititud XMLHttpRequest al url especifico.
		 * Forma los parametros con la bandera de ajaxRequest=true idComponente=<nombre/id_Input> y <nombre/id_Input>=input.value
		 * Se pasa por parametro functionHandler la funcion que atiende la solicitud.
		 */
	function sendHandler(url, input, functionHandler) {
		this.registryActivity();
			//Codigo para solucionar bug de Mozilla
		if (window.XMLHttpRequest) {
			xmlHttp = null;
			this.init(this.asynchronous.toString());
		}
		var xmlHttp = this.getXMLHttpRequest();
		xmlHttp.open("POST", url, this.asynchronous);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		var inputId = "";
		if (input.id) {
			inputId = input.id;
		} else {
			if (input.name) {
				inputId = input.name;
			}
		}
		var params = "ajaxRequest=true&idComponent=" + inputId + "&" + inputId + "=" + escape(input.value);
		xmlHttp.send(params);
		if (this.asynchronous) {
			xmlHttp.onreadystatechange = functionHandler;
		} else {
			return eval(functionHandler);
		}
	}
	/**
		 * Envia la solititud XMLHttpRequest al url especifico.
		 * Se recibe los parametros enviados al URL
		 */
	function sendParams(url, params) {
		this.registryActivity();
			//Codigo para solucionar bug de Mozilla
		if (window.XMLHttpRequest) {
			xmlHttp = null;
			this.init(this.asynchronous.toString());
		}
		var xmlHttp = this.getXMLHttpRequest();
		xmlHttp.open("POST", url, this.asynchronous);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send("ajaxRequest=true&" + params);
		if (this.asynchronous) {
			xmlHttp.onreadystatechange = this.setXMLDataHandler;
		} else {
			return this.setXMLDataHandler();
		}
	}
	/**
		 * Envia la solititud XMLHttpRequest al url especifico.
		 * Se recibe los parametros enviados al URL
		 * Se pasa por parametro functionHandler la funcion que atiende la solicitud.
		 */
	function sendParamsHandler(url, params, functionHandler) {
		this.registryActivity();
			//Codigo para solucionar bug de Mozilla
		var asy = this.asynchronous;
		if (window.XMLHttpRequest) {
			xmlHttp = null;
			this.init(this.asynchronous.toString());
			this.asynchronous = asy;
		}
		var xmlHttp = this.getXMLHttpRequest();
		xmlHttp.open("POST", url, this.asynchronous);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send("ajaxRequest=true&" + params);
		if (this.asynchronous) {
			xmlHttp.onreadystatechange = functionHandler;
		} else {
			return eval(functionHandler);
		}
	}
	/**
		 * Imprime los mensajes que tenga la respuesta XML.
		 */
	function printMessages(response) {
		var messages = "";
		var summary;
		var detail;
		var message;
		var messagesNodes = response.getElementsByTagName("message");
		for (i = 0; i < messagesNodes.length; i++) {
			message = messagesNodes[i];
			summary = "";
			detail = "";
			for (j = 0; j < message.childNodes.length; j++) {
				if (message.childNodes[j].nodeName == "summary" && message.childNodes[j].firstChild) {
					summary = message.childNodes[j].firstChild.data;
				} else {
					if (message.childNodes[j].nodeName == "detail" && message.childNodes[j].firstChild) {
						detail = message.childNodes[j].firstChild.data;
					}
				}
			}
			if (summary != "") {
				messages += summary + "\n";
			}
			if (detail != "") {
				messages += detail + "\n";
			}
		}
		if (messages && messages != "") {
			alert(messages);
		}
	}
	/**
		 * Ejecuta los javaScript que tenga la respuesta XML.
		 */
	function executeJavaScript(response) {
		var javaScript;
		var javaScriptNode;
		var javaScriptNodes = response.getElementsByTagName("javaScript");
		for (i = 0; i < javaScriptNodes.length; i++) {
			javaScriptNode = javaScriptNodes[i];
			if (javaScriptNode.firstChild && javaScriptNode.firstChild.data) {
				javaScript = javaScriptNode.firstChild.data;
				if (javaScript != null && javaScript != "") {
					eval(javaScript);
				}
			}
		}
	}
	this.init = init;
	this.getXMLHttpRequest = getXMLHttpRequest;
	this.registryActivity = registryActivity;
	this.send = send;
	this.sendAction = sendAction;
	this.sendActionValues = sendActionValues;
	this.sendHandler = sendHandler;
	this.sendParams = sendParams;
	this.sendParamsHandler = sendParamsHandler;
	this.setXMLDataHandler = setXMLDataHandler;
	this.printMessages = printMessages;
	this.executeJavaScript = executeJavaScript;
}