var _PRIMER_FISICO = 26;
var _ULTIMO_FISICO = 28;
var _anhoCurrent		= "2009";
var _sepFechas			= " a ";
var _layerMenuLeft		= "albNet__MenuLeft";
var _layerMenuTop		= "albNet__MenuTop";
var _layerMenuBottom	= "albNet__MenuBottom";
var _layerContent		= "albNet__Content";

/* ---------------------------------------- */
/*
	tamDiv : El tamaño en pixeles o porcentaje de la capa que vamos a cambiar
	tamMenu: El tamaño en pixeles o porcentaje de la capa menu, la que se oculta o muestra
	bSum	: Indica si se suma o se resta : Para el width se suma si estamos ocultando el menu
					pero para el left debemos restar
*/
function calculeDimension(tamDiv,tamMenu,bSum)
{
	var newTam = "";
	var win = document.body.clientWidth;
	if(WpGetBrowser() == 0) //Internet Explorer ( % )
	{
		
		tamDiv	= tamDiv.split("%");
		tamMenu	= tamMenu.split("%");
		
		
		/*
		var widthLeftArray	= tempLeftWidth.split("%");
			var leftLeftArray	= tempLeftLeft.split("%");
			var rightLeftArray	= tempLeftRight.split("%");

			var widthRightArray = tempRightWidth.split("%");
			var leftRightArray	= tempRightLeft.split("%");
			var rightRightArray = tempRightRight.split("%");

			var leftSplitArray	= tempSplitLeft.split("%");
			var rightSplitArray	= tempSplitRight.split("%");

			//x = win * 19 / 100

			leftWidth	= parseInt((win*widthLeftArray[0])/100);
			leftLeft	= parseInt((win*leftLeftArray[0])/100);
			leftRight	= parseInt((win*rightLeftArray[0])/100);

			rightWidth	= parseInt((win*widthRightArray[0])/100);
			rightLeft	= parseInt((win*leftRightArray[0])/100);
			rightRight	= parseInt((win*rightRightArray[0])/100);

			splitLeft	= parseInt((win*leftSplitArray[0])/100);
			splitRight	= parseInt((win*rightSplitArray[0])/100);
		*/
	}
	else
	{
		tamDiv	= tamDiv.split("p");
		tamMenu	= tamMenu.split("p");
		/*
			var widthLeftArray	= tempLeftWidth.split("p");
			var leftLeftArray	= tempLeftLeft.split("p");
			var rightLeftArray	= tempLeftRight.split("p");

			var widthRightArray = tempRightWidth.split("p");
			var leftRightArray	= tempRightLeft.split("p");
			var rightRightArray = tempRightRight.split("p");

			var leftSplitArray	= tempSplitLeft.split("p");
			var rightSplitArray	= tempSplitRight.split("p");
			//Set the current width.
			leftWidth	= parseInt(widthLeftArray[0]);
			leftLeft	= parseInt(leftLeftArray[0]);
			leftRight	= parseInt(rightLeftArray[0]);

			rightWidth	= parseInt(widthRightArray[0]);
			rightLeft	= parseInt(leftRightArray[0]);
			rightRight	= parseInt(rightRightArray[0]);

			splitLeft	= parseInt(leftSplitArray[0]);
			splitRight	= parseInt(rightSplitArray[0]);
			*/

	}
	newTam = bSum ? (parseInt(tamDiv[0]) - parseInt(tamMenu[0])) : (parseInt(tamDiv[0]) + parseInt(tamMenu[0]))
	if(WpGetBrowser() == 0) //Internet Explorer ( % )
		newTam =  parseInt((win*newTam)/100);
	else
		newTam = parseInt(newTam);
	return (parseInt(newTam));
}

/* oculta el menu lateral */
function onOcultarMenu()
{
	var oMenu		= $(_layerMenuLeft);
	var oTop		= $(_layerMenuTop);
	var oBottom		= $(_layerMenuBottom);
	var oContent	= $(_layerContent);
	if(oMenu && oTop && oBottom && oContent)
	{
		alert("CAL");
		/* dimensiones del menu */
		var menuWidth		= oMenu.getStyle("width");
		var menuHeight		= oMenu.getStyle("height");
		var menuTop			= oMenu.getStyle("top");
		var menuLeft		= oMenu.getStyle("left");
		/* dimensiones del top */
		var topWidth		= oTop.getStyle("width");
		var topHeight		= oTop.getStyle("height");
		var topTop			= oTop.getStyle("top");
		var topLeft			= oTop.getStyle("left");
		/* dimensiones del bottom */
		var bottomWidth		= oBottom.getStyle("width");
		var bottomHeight	= oBottom.getStyle("height");
		var bottomTop		= oBottom.getStyle("top");
		var bottomLeft		= oBottom.getStyle("left");
		/* dimensiones del content */
		var cntWidth		= oContent.getStyle("width");
		var cntHeight		= oContent.getStyle("height");
		var cntTop			= oContent.getStyle("top");
		var cntLeft			= oContent.getStyle("left");
		if(oMenu.visible())
		{
			/* el menu esta visible : se oculta */
			oTop.setStyle({'width':calculeDimension(topWidth,menuWidth,true)});
			oTop.setStyle({'left':calculeDimension(topLeft,menuLeft,false)});

		}
		/* cambio la visibilidad de la capa menu */
		oMenu.toggle();

	}
	else
		alert("algo falla");
}




/*
	Comprueba que ciertos+  datos esten rellenos en algunos 
	formularios
*/

function checkForm(form)
{
	var ret = false;
	oForm = window.f11.document.forms[form];
	if(oForm != null)
	{
		if(form == "PETICION")
		{
			var iUser		= oForm.COD_USER.value;
			var oRadio		= oForm.PETICION;//1:Consulta 0:Prestamo
			//var iTipo		= oForm.PETICION.value;		
			var sFechaIni	= oForm.PET_FECHA_DESDE.value;
			var sFechaFin   = oForm.PET_FECHA_HASTA.value;
			if(parseInt(iUser) > 0)
			{
				if(oRadio[0].checked == true)
					iTipo = 1;
				else if(oRadio[1].checked == true)
					iTipo = 0;
				else
					iTipo = -1;

				if(iTipo == 1) //CONSULTA
				{
					if(sFechaIni != "")
						ret = true;
					else
						alert(WpGetFrameset().msgError[102]);
				}
				else if(iTipo == 0)	//PRESTAMO
				{
					if(sFechaIni != "" && sFechaFin != "")
						ret = true;
					else
						alert(WpGetFrameset().msgError[101]);
				}
			}
			else
				alert(WpGetFrameset().msgError[100]);
		}
		else if(form == "GESTION_TRANSFERENCIAS")
		{
			var oRadio		= oForm.COD_TIPO.value;		//0:Nueva transferencia 1:Añadir a transferencia antigua
			var sNombre		= oForm.NOMBRE_TRANSFERENCIA.value;		
			//var iOldTrans	= oForm.ANTIG_TRANSF.value;
			var iOldTrans   = 0;
			var iEmisor		= oForm.COAR_EMISOR.value;
			var iReceptor   = oForm.COAR_RECEPTOR.value;
			if((parseInt(oRadio) == 0) || (parseInt(oRadio) == 1))
			{
				if(parseInt(oRadio) == 0) // Nueva transferencia
				{
					if((parseInt(iEmisor) > 0) && (parseInt(iReceptor) > 0))
					{
						if(parseInt(iEmisor) != parseInt(iReceptor))
						{
							if(sNombre != "")
								ret = true;
							else
								alert(WpGetFrameset().msgError[114]);//Debe rellenar el nombre
						}
						else
							alert(WpGetFrameset().msgError[113]);//El archivo emisor y receptor deben ser distintos
					}
					else
						alert(WpGetFrameset().msgError[112]);//Debe elegir un archivo receptor
				}
				else	//Elegir una transferencia
				{
					if(parseInt(iOldTrans) > 0)
						ret = true;
					else
						alert(WpGetFrameset().msgError[111]);//Debe seleccionar una tranferencia anterior

				}
			}
			else
				alert(WpGetFrameset().msgError[110]);
		}
		else if(form == "FORM_IIDD")
		{
		    var oOperacion 	= oForm.OPERACION.value;
        var oIddUser 		= parseInt(oForm.IDD_USER.value);
        var oAppUser 		= parseInt(oForm.APP_USER.value);
		    if(oOperacion == "DELETE")
		    {
		        if(oIddUser == oAppUser)
		            ret = true;
		        else
		        {
		            ret = false;
		            alert(theApp.m_oJS.msgError[138]);
		        }
		    }
		    else
		    {
		        if(oOperacion == "MODIFICAR" && (oIddUser != oAppUser))
		        {
				    		ret = false;
		            alert(theApp.m_oJS.msgError[138]);        
		        }
		        else
		        {
		            var oTipoID = oForm.TIPO_ID.value;
			        if(oTipoID == "CATALOGO")
			        {
		    		    var oCoar = parseInt(oForm.COAR.value);
		    		    var oFoid = parseInt(oForm.FOID.value);
	    			    var oNica = parseInt(oForm.NICA.value);
	    			    var oNoid = oForm.NOID.value;
	    			    if(oCoar > 0)
	    			    {
		    			    if((oFoid > 0) && (oFoid < 14))
		    			    {
			    			    if((oNica > 0) && (oNica < 10))
			    			    {
			    				    if(oNoid != "")
			    					    ret = true;
			    				    else
			    					    alert(theApp.m_oJS.msgError[133]);
			    			    }
			    			    else
			    				    alert(theApp.m_oJS.msgError[132]);
				    	    }
			    		    else 
				    		    alert(theApp.m_oJS.msgError[131]);
				        }
				        else
					        alert(theApp.m_oJS.msgError[130]);//Debe seleccionar un archivo
			        }
			        else if(oTipoID == "ETIQUETAS")
			        {
				        var oCoar = parseInt(oForm.COAR.value);
				        var oFoid = parseInt(oForm.FOID.value);
				        var oNica = parseInt(oForm.NICA.value);
				        var oNoid = oForm.NOID.value;
				        if(oCoar > 0)
				        {
					        if((oFoid > 0) && (oFoid < 14))
					        {
						        if((oNica > 0) && (oNica < 10))
						        {
							        if(oNoid != "")
								        ret = true;
							        else
								        alert(theApp.m_oJS.msgError[133]);
						        }
						        else
							        alert(theApp.m_oJS.msgError[132]);
					        }
					        else 
						        alert(theApp.m_oJS.msgError[131]);
				        }
				        else
					        alert(WpGetFrameset().msgError[130]);//Debe seleccionar un archivo
			        }
			        else if(oTipoID == "INVENTARIO")
			        {
				        var oCoar = parseInt(oForm.COAR.value);
				        var oFoid = parseInt(oForm.FOID.value);
				        var oIngu = parseInt(oForm.INGU.value);
				        var oNoid = oForm.NOID.value;
				        if(oCoar > 0)
				        {
					        if((oFoid > 0) && (oFoid < 14))
					        {
						        if((oIngu >= 0) && (oIngu < 3))
						        {
							        if(oNoid != "")
								        ret = true;
							        else
								        alert(theApp.m_oJS.msgError[134]);
						        }
						        else
							        alert(theApp.m_oJS.msgError[132]);
					        }
					        else 
						        alert(theApp.m_oJS.msgError[131]);
				        }
				        else
					        alert(theApp.m_oJS.msgError[130]);//Debe seleccionar un archivo
			        } 
			        else if(oTipoID == "GUIA")
			        {
			        	var oCoar = parseInt(oForm.COAR.value);
				        var oNoid = oForm.NOID.value;
				        var oFoid = parseInt(oForm.FOID.value);
				        if(oCoar > 0)
				        {
					        if((oFoid > 0) && (oFoid < 14))
					        {
						        if(oNoid != "")
							        ret = true;
						        else
							        alert(theApp.m_oJS.msgError[134]);
					        }
					        else 
						        alert(theApp.m_oJS.msgError[131]);
				        }
				        else
					        alert(theApp.m_oJS.msgError[130]);//Debe seleccionar un archivo
			      	}

			        //Debemos recorrernos la lista de unidades insertadas para generar una lista tal que asim:: 1,2,3,4,5
			        var oLstUds = oForm.IDLC_LST;
			        var rdo = "";
			        for(i = 0 ; i < oLstUds.options.length ; i++)
			        {
				        rdo += oLstUds.options[i].value;
				        if(i < (oLstUds.length-1))
					        rdo += ",";
			        }
			        oForm.elements['IDLC_AMBU'].value = rdo;
			    }
			}
		}
		else if(form == "USERS")
		{
			var oNdni = oForm.NDNI.value;
			var oNomb = oForm.NOMB.value;
			var oNpin = oForm.NPIN.value;
			var oClus = oForm.CLUS.value;
			var oTius = oForm.TIUS.value;
			var oCoar = oForm.COAR.value;
	
			if(oNdni != "")
			{
				if(oNomb != "")
				{
					if(oNpin != "")
					{
						if(oClus != "" && oClus != "0")
						{
							if(oTius != "" && oTius != "0")
							{
								if(oCoar != "" && oCoar != "0")
									ret = true;
								else
									alert(msgError[35]);
							}
							else
								alert(msgError[34]);
						}
						else
							alert(msgError[33]);
					}
					else
						alert(msgError[32]);
				}
				else
					alert(msgError[31]);
			}
			else
				alert(msgError[30]);
		}
		else if(form == "ISAR")
		{
			var oTA01 = oForm.TA01.value;
			var oTA03 = oForm.TA03.value;
			var oTA04 = oForm.TA04.value;
			var oTA05 = oForm.TA05.value;
			if(oTA01 != "0" && oTA01 != "")
			{
			    if(oTA03 != "0" && oTA03 != "")
			    {
			        if(oTA04 != "0" && oTA04 != "")
			        {
    			        if(oTA05 != "0" && oTA05 != "")
                			ret = true;
			            else
			                alert(msgError[143]);			
			        }
			        else
			            alert(msgError[142]);			
			    }
			    else
			        alert(msgError[141]);
			}
			else
			    alert(msgError[140]);
		}
		else if(form == "ISAD")
		{
			var oCommando  = oForm.COMMAND.value;
			var oOperacion = oForm.OPERACION.value;
			if(oOperacion == "DELETE"){
				return true;
			}			
			var bGrid = false;
			if(oCommando == "GESTION_GRID_ISAD")
				bGrid = true;
			var array = new Array();
			var sCamposObligatorios = oForm.LST_CAMPOS_OBLIGATORIOS.value;
			sCamposObligatorios = trim(sCamposObligatorios);

			var value = "";
			var bOk = true;
			//Los campos obligatorios
			if(sCamposObligatorios != "")
			{
				array  = sCamposObligatorios.split(",");
				if(array.length > 0)
				{
					if(bGrid)
					{
						bOk = true;
					}
					else
					{
						for(i = 0 ; i < array.length ; i++)
						{
							if(oForm.elements[array[i]])
							{
								value = oForm.elements[array[i]].value;
								value = trim(value);
								if(value == "")
								{
									alert(msgGeneral[4] + "'" + msgCampos[array[i]] + "'" + msgGeneral[5]);
									bOk = false;
								}
							}
							else
							{
									alert(msgGeneral[4] + "'" + msgCampos[array[i]] + "'" + msgGeneral[8]);
									bOk = false;							
							}
						}
					}
				}
			}
			//Los campos presentes en la ordenacion
			var sCamposOrden = oForm.LST_CAMPOS_ORDENACION.value;
			sCamposOrden = trim(sCamposOrden);
			if(sCamposOrden != "")
			{
				array  = sCamposOrden.split(",");
				if(array.length > 0)
				{
					if(bGrid)
					{
						bOk = true;
					}
					else
					{					
						for(i = 0 ; i < array.length ; i++)
						{
							if(oForm.elements[array[i]])
							{
								value = oForm.elements[array[i]].value;
								value = trim(value);
								if(value == "")
								{
									alert(msgGeneral[4] + "'" + msgCampos[array[i]] + "'" + msgGeneral[6]);
									bOk = false;
								}
							}
							else
							{
									alert(msgGeneral[4] + "'" + msgCampos[array[i]] + "'" + msgGeneral[7]);
									bOk = false;							
							}
						}
					}
				}
			}
			
			if(bOk)
			{
					var leng 			= 75;//75 signaturas ??
					for(var tr = 1 ; tr < leng ; tr++){
						var bLleno 	= false;
						var bSelect = false;
						var bUi			= false;
						var bVacio	= true;
						for(var td = 1; td <= 9 ; td++){
							var oInput = oForm.elements["GRID_TI06_L"+tr+"_C"+td];
							if(oInput){
								if(td == 7){
									if(oInput.value != ""){
										bUi 		= true;
										bVacio 	= false;
									}									
								}else if(td == 6){
									if(oInput.selectedIndex > 0){
										bSelect = true;
										bVacio 	= false;
									}
									else{
										//en la modificacion
										for(var y = 0 ; y < oInput.options.length ; y++){
											var oOpt = oInput.options[y];
											if(oOpt){
												if(oOpt.selected && oOpt.value != ""){
													bSelect = true;
													bVacio 	= false;													
												}
											}
										}
									}
								}
								else{
									if(oInput.value != ""){
										bLleno = true;
										bVacio 	= false;
									}
								}
							}
						}
						if(!bVacio){
							if(!bSelect || !bUi){
									alert(msgGeneral[9]);
									return false;
							}
							else
								bOk = true;
						}
						else
							bOk = true;
					}
			}
			if(bOk){
					var leng 			= 75;//25 signaturas ??
					for(var tr = 1 ; tr < leng ; tr++){
						var bSelect = false;
						var bNum	= false;
						var bVacio	= true;
						for(var td = 1; td <= 2 ; td++){
							var oInput = oForm.elements["L"+tr+"_C"+td+"_TI14"];
							if(oInput){
								if(td == 1){
									if(oInput.value != ""){
										bNum	= true;
										bVacio 	= false;
									}									
								}else if(td == 2){
									if(oInput.selectedIndex > 0){
										bSelect = true;
										bVacio 	= false;
									}
									else{
										//en la modificacion
										for(var y = 0 ; y < oInput.options.length ; y++){
											var oOpt = oInput.options[y];
											if(oOpt){
												if(oOpt.selected && oOpt.value != ""){
													bSelect = true;
													bVacio 	= false;													
												}
											}
										}
									}									
								}
							}
						}
						if(!bVacio){
							if(!bSelect || !bNum){
									alert(msgGeneral[10]);
									return false;
							}
							else
								bOk = true;
						}
						else
							bOk = true;
					}

			}
			
			ret = bOk;
		}
	}
	return ret;
}

function OnOcultarFrame(idDiv){
	var col	= document.getElementById("finicio");
	var img	= window.f0.document.getElementById("logo_baratz");
	var obj = window.f0.document.getElementById("uno");
	if(col){
		if(img && img.tagName == "IMG" && img.getAttribute("srcChange")){
			if(obj && obj.getAttribute("isOpen")){
				var srcClose	= img.getAttribute("srcChange");
				var srcOpen		= img.src;
				var txtClose	= img.alt;
				var txtOpen		= img.getAttribute("openTextInfo");
				if(obj.getAttribute("isOpen") == "true"){//si esta abierto, cerramos la capa
					img.src		= srcClose;
					img.setAttribute("srcChange",srcOpen);
					img.alt		= txtOpen;
					img.title	= txtClose;
					obj.zIndex	= 200;
					obj.setAttribute("isOpen","false");
					col.cols = '15,*';/ * la imagen ocupa 15 px * /
				}
				else{
				//if(obj.getAttribute("isOpen") == "false"){//si esta cerrado, abrimos la capa
					img.src = srcClose;
					img.setAttribute("srcChange",srcOpen);
					img.alt		= txtOpen;
					img.title	= txtClose;
					obj.zIndex	= 200;
					obj.setAttribute("isOpen","true");
					col.cols = '20%,*';
				}
			}
		}
	}
}


function ParserUTF8(txt)
{
	//Sustituyo el & por el $ para poder enviar por URL
	/*----*/
	txt = txt.replace(/%C2%A1/g		,"¡");
	txt = txt.replace(/%C2%A2/g		,"¢");
	txt = txt.replace(/%C2%A3/g		,"£");
	txt = txt.replace(/%C2%A4/g		,"¤");
	txt = txt.replace(/%C2%A5/g		,"¥");
	txt = txt.replace(/%C2%A6/g		,"¦");
	txt = txt.replace(/%C2%A7/g		,"§");
	txt = txt.replace(/%C2%A8/g		,"¨");
	txt = txt.replace(/%C2%A9/g		,"©");
	txt = txt.replace(/%C2%AA/g		,"ª");
	txt = txt.replace(/%C2%AB/g		,"«");
	txt = txt.replace(/%C2%AC/g		,"¬");
	txt = txt.replace(/%C2%AD/g		,"­");
	txt = txt.replace(/%C2%AE/g		,"®");
	txt = txt.replace(/%C2%AF/g		,"¯");
	txt = txt.replace(/%C2%B0/g		,"°");
	txt = txt.replace(/%C2%B1/g		,"±");
	txt = txt.replace(/%C2%B2/g		,"²");
	txt = txt.replace(/%C2%B3/g		,"³");
	txt = txt.replace(/%C2%B4/g		,"´");
	txt = txt.replace(/%C2%B5/g		,"µ");
	txt = txt.replace(/%C2%B6/g		,"¶");
	txt = txt.replace(/%C2%B7/g		,"·");
	txt = txt.replace(/%C2%B8/g		,"¸");
	txt = txt.replace(/%C2%B9/g		,"¹");
	txt = txt.replace(/%C2%BA/g		,"º");
	txt = txt.replace(/%C2%BB/g		,"»");
	txt = txt.replace(/%C2%BC/g		,"¼");
	txt = txt.replace(/%C2%BD/g		,"½");
	txt = txt.replace(/%C2%BE/g		,"¾");
	txt = txt.replace(/%C2%BF/g		,"¿");
	txt = txt.replace(/%C3%80/g		,"À");
	txt = txt.replace(/%C3%81/g		,"Á");
	txt = txt.replace(/%C3%82/g		,"Â");
	txt = txt.replace(/%C3%83/g		,"Ã");
	txt = txt.replace(/%C3%84/g		,"Ä");
	txt = txt.replace(/%C3%85/g		,"Å");
	txt = txt.replace(/%C3%86/g		,"Æ");
	txt = txt.replace(/%C3%87/g		,"Ç");
	txt = txt.replace(/%C3%88/g		,"È");
	txt = txt.replace(/%C3%89/g		,"É");
	txt = txt.replace(/%C3%8A/g		,"Ê");
	txt = txt.replace(/%C3%8B/g		,"Ë");
	txt = txt.replace(/%C3%8C/g		,"Ì");
	txt = txt.replace(/%C3%8D/g		,"Í");
	txt = txt.replace(/%C3%8E/g		,"Î");
	txt = txt.replace(/%C3%8F/g		,"Ï");
	txt = txt.replace(/%C3%90/g		,"Ð");
	txt = txt.replace(/%C3%91/g		,"Ñ");
	txt = txt.replace(/%C3%92/g		,"Ò");
	txt = txt.replace(/%C3%93/g		,"Ó");
	txt = txt.replace(/%C3%94/g		,"Ô");
	txt = txt.replace(/%C3%95/g		,"Õ");
	txt = txt.replace(/%C3%96/g		,"Ö");
	txt = txt.replace(/%C3%97/g		,"×");
	txt = txt.replace(/%C3%98/g		,"Ø");
	txt = txt.replace(/%C3%99/g		,"Ù");
	txt = txt.replace(/%C3%9A/g		,"Ú");
	txt = txt.replace(/%C3%9B/g		,"Û");
	txt = txt.replace(/%C3%9C/g		,"Ü");
	txt = txt.replace(/%C3%9D/g		,"Ý");
	txt = txt.replace(/%C3%9E/g		,"Þ");
	txt = txt.replace(/%C3%9F/g		,"ß");
	txt = txt.replace(/%C3%A0/g		,"à");
	txt = txt.replace(/%C3%A1/g		,"á");
	txt = txt.replace(/%C3%A2/g		,"â");
	txt = txt.replace(/%C3%A3/g		,"ã");
	txt = txt.replace(/%C3%A4/g		,"ä");
	txt = txt.replace(/%C3%A5/g		,"å");
	txt = txt.replace(/%C3%A6/g		,"æ");
	txt = txt.replace(/%C3%A7/g		,"ç");
	txt = txt.replace(/%C3%A8/g		,"è");
	txt = txt.replace(/%C3%A9/g		,"é");
	txt = txt.replace(/%C3%AA/g		,"ê");
	txt = txt.replace(/%C3%AB/g		,"ë");
	txt = txt.replace(/%C3%AC/g		,"ì");
	txt = txt.replace(/%C3%AD/g		,"í");
	txt = txt.replace(/%C3%AE/g		,"î");
	txt = txt.replace(/%C3%AF/g		,"ï");
	txt = txt.replace(/%C3%B0/g		,"ð");
	txt = txt.replace(/%C3%B1/g		,"ñ");
	txt = txt.replace(/%C3%B2/g		,"ò");
	txt = txt.replace(/%C3%B3/g		,"ó");
	txt = txt.replace(/%C3%B4/g		,"ô");
	txt = txt.replace(/%C3%B5/g		,"õ");
	txt = txt.replace(/%C3%B6/g		,"ö");
	txt = txt.replace(/%C3%B7/g		,"÷");
	txt = txt.replace(/%C3%B8/g		,"ø");
	txt = txt.replace(/%C3%B9/g		,"ù");
	txt = txt.replace(/%C3%BA/g		,"ú");
	txt = txt.replace(/%C3%BB/g		,"û");
	txt = txt.replace(/%C3%BC/g		,"ü");
	txt = txt.replace(/%C3%BD/g		,"ý");
	txt = txt.replace(/%C3%BE/g		,"þ");
	txt = txt.replace(/%C3%BF/g		,"ÿ");	
	return ParserHTML(txt);
}

function ParserHTML(txt)
{
	//Sustituyo el & por el $ para poder enviar por URL
	/*----*/
	txt = txt.replace(/À/g, "$Agrave;"); 	
	txt = txt.replace(/Á/g, "$Aacute;");	
	txt = txt.replace(/Â/g, "$Acirc;"); 	
	txt = txt.replace(/Ã/g, "$Atilde;"); 	
	txt = txt.replace(/Ä/g, "$Auml;"); 		
	txt = txt.replace(/Å/g, "$Aring;"); 	
	txt = txt.replace(/Æ/g, "$AElig;"); 	
	txt = txt.replace(/Ç/g, "$Ccedil;"); 	
	txt = txt.replace(/È/g, "$Egrave;"); 	
	txt = txt.replace(/É/g, "$Eacute;"); 	
	txt = txt.replace(/Ê/g, "$Ecirc;"); 	
	txt = txt.replace(/Ë/g, "$Euml;"); 		
	txt = txt.replace(/Ì/g, "$Igrave;"); 	
	txt = txt.replace(/Í/g, "$Iacute;"); 	
	txt = txt.replace(/Î/g, "$Icirc;"); 	
	txt = txt.replace(/Ï/g, "$Iuml;"); 		
	txt = txt.replace(/Ð/g, "$ETH;"); 		
	txt = txt.replace(/Ñ/g, "$Ntilde;"); 	
	txt = txt.replace(/Ò/g, "$Ograve;"); 	
	txt = txt.replace(/Ó/g, "$Oacute;"); 	
	txt = txt.replace(/Ô/g, "$Ocirc;"); 	
	txt = txt.replace(/Õ/g, "$Otilde;"); 	
	txt = txt.replace(/Ö/g, "$Ouml;"); 		
	txt = txt.replace(/Ø/g, "$Oslash;"); 	
	txt = txt.replace(/Ù/g, "$Ugrave;"); 	
	txt = txt.replace(/Ú/g, "$Uacute;"); 	
	txt = txt.replace(/Û/g, "$Ucirc;"); 	
	txt = txt.replace(/Ü/g, "$Uuml;"); 		
	txt = txt.replace(/Ý/g, "$Yacute;"); 	
	txt = txt.replace(/Þ/g, "$THORN;"); 	
	txt = txt.replace(/ß/g, "$szlig;"); 	
	txt = txt.replace(/à/g, "$agrave;"); 	
	txt = txt.replace(/á/g, "$aacute;"); 	
	txt = txt.replace(/â/g, "$acirc;"); 	
	txt = txt.replace(/ã/g, "$atilde;"); 	
	txt = txt.replace(/ä/g, "$auml;"); 		
	txt = txt.replace(/å/g, "$aring;"); 	
	txt = txt.replace(/æ/g, "$aelig;"); 	
	txt = txt.replace(/ç/g, "$ccedil;"); 	
	txt = txt.replace(/è/g, "$egrave;"); 	
	txt = txt.replace(/é/g, "$eacute;"); 	
	txt = txt.replace(/ê/g, "$ecirc;"); 	
	txt = txt.replace(/ë/g, "$euml;"); 		
	txt = txt.replace(/ì/g, "$igrave;"); 	
	txt = txt.replace(/í/g, "$iacute;"); 	
	txt = txt.replace(/î/g, "$icirc;"); 	
	txt = txt.replace(/ï/g, "$iuml;"); 		
	txt = txt.replace(/ð/g, "$eth;"); 		
	txt = txt.replace(/ñ/g, "$ntilde;"); 	
	txt = txt.replace(/ò/g, "$ograve;"); 	
	txt = txt.replace(/ó/g, "$oacute;"); 	
	txt = txt.replace(/ô/g, "$ocirc;"); 	
	txt = txt.replace(/õ/g, "$otilde;"); 	
	txt = txt.replace(/ö/g, "$ouml;"); 		
	txt = txt.replace(/ø/g, "$oslash;"); 	
	txt = txt.replace(/ù/g, "$ugrave;"); 	
	txt = txt.replace(/ú/g, "$uacute;"); 	
	txt = txt.replace(/û/g, "$ucirc;"); 	
	txt = txt.replace(/ü/g, "$uuml;"); 		
	txt = txt.replace(/ý/g, "$yacute;"); 	
	txt = txt.replace(/þ/g, "$thorn;"); 	
	txt = txt.replace(/ÿ/g, "$yuml;"); 		
	txt = txt.replace(/¡/g, "$iexcl;"); 	
	txt = txt.replace(/¢/g, "$cent;"); 		
	txt = txt.replace(/£/g, "$pound;"); 	
	txt = txt.replace(/¤/g, "$curren;"); 	
	txt = txt.replace(/¥/g, "$yen;"); 		
	txt = txt.replace(/¦/g, "$brvbar;"); 	
	txt = txt.replace(/§/g, "$sect;"); 		
	txt = txt.replace(/¨/g, "$uml;"); 		
	txt = txt.replace(/©/g, "$copy;"); 		
	txt = txt.replace(/ª/g, "$ordf;"); 		
	txt = txt.replace(/«/g, "$laquo;"); 	
	txt = txt.replace(/¬/g, "$not;"); 		
	txt = txt.replace(/­/g, "$shy;"); 		
	txt = txt.replace(/®/g, "$reg;"); 		
	txt = txt.replace(/¯/g, "$macr;"); 		
	txt = txt.replace(/°/g, "$deg;"); 		
	txt = txt.replace(/±/g, "$plusmn;"); 	
	txt = txt.replace(/²/g, "$sup2;"); 		
	txt = txt.replace(/³/g, "$sup3;"); 		
	txt = txt.replace(/´/g, "$acute;"); 	
	txt = txt.replace(/µ/g, "$micro;"); 	
	txt = txt.replace(/¶/g, "$para;"); 		
	txt = txt.replace(/·/g, "$middot;"); 	
	txt = txt.replace(/¸/g, "$cedil;"); 	
	txt = txt.replace(/¹/g, "$sup1;"); 		
	txt = txt.replace(/º/g, "$ordm;"); 		
	txt = txt.replace(/»/g, "$raquo;"); 	
	txt = txt.replace(/¼/g, "$frac14;"); 	
	txt = txt.replace(/½/g, "$frac12;"); 	
	txt = txt.replace(/¾/g, "$frac34;"); 	
	txt = txt.replace(/¿/g, "$iquest;"); 	
	txt = txt.replace(/×/g, "$times;"); 	
	txt = txt.replace(/÷/g, "$divide;"); 	
	return txt;
}

function UnParserXML(txt)
{
	//Sustituyo el & por el $ para poder enviar por URL
	/*----*/
	txt = txt.replace(/&Agrave;/g,	"À"); 	
	txt = txt.replace(/&Aacute;/g,	"Á");	
	txt = txt.replace(/&Acirc;/g,	"Â"); 	
	txt = txt.replace(/&Atilde;/g,	"Ã"); 	
	txt = txt.replace(/&Auml;/g,	"Ä"); 		
	txt = txt.replace(/&Aring;/g,	"Å"); 	
	txt = txt.replace(/&AElig;/g,	"Æ"); 	
	txt = txt.replace(/&Ccedil;/g,	"Ç"); 	
	txt = txt.replace(/&Egrave;/g,	"È"); 	
	txt = txt.replace(/&Eacute;/g,	"É"); 	
	txt = txt.replace(/&Ecirc;/g,	"Ê"); 	
	txt = txt.replace(/&Euml;/g,	"Ë"); 		
	txt = txt.replace(/&Igrave;/g,	"Ì"); 	
	txt = txt.replace(/&Iacute;/g,	"Í"); 	
	txt = txt.replace(/&Icirc;/g,	"Î"); 	
	txt = txt.replace(/&Iuml;/g,	"Ï"); 		
	txt = txt.replace(/&ETH;/g,		"Ð"); 		
	txt = txt.replace(/&Ntilde;/g,	"Ñ"); 	
	txt = txt.replace(/&Ograve;/g,	"Ò"); 	
	txt = txt.replace(/&Oacute;/g,	"Ó"); 	
	txt = txt.replace(/&Ocirc;/g,	"Ô"); 	
	txt = txt.replace(/&Otilde;/g,	"Õ"); 	
	txt = txt.replace(/&Ouml;/g,	"Ö"); 		
	txt = txt.replace(/&Oslash;/g,	"Ø"); 	
	txt = txt.replace(/&Ugrave;/g,	"Ù"); 	
	txt = txt.replace(/&Uacute;/g,	"Ú"); 	
	txt = txt.replace(/&Ucirc;/g,	"Û"); 	
	txt = txt.replace(/&Uuml;/g,	"Ü"); 		
	txt = txt.replace(/&Yacute;/g,	"Ý"); 	
	txt = txt.replace(/&THORN;/g,	"Þ"); 	
	txt = txt.replace(/&szlig;/g,	"ß"); 	
	txt = txt.replace(/&agrave;/g,	"à"); 	
	txt = txt.replace(/&aacute;/g,	"á"); 	
	txt = txt.replace(/&acirc;/g,	"â"); 	
	txt = txt.replace(/&atilde;/g,	"ã"); 	
	txt = txt.replace(/&auml;/g,	"ä"); 		
	txt = txt.replace(/&aring;/g,	"å"); 	
	txt = txt.replace(/&aelig;/g,	"æ"); 	
	txt = txt.replace(/&ccedil;/g,	"ç"); 	
	txt = txt.replace(/&egrave;/g,	"è"); 	
	txt = txt.replace(/&eacute;/g,	"é"); 	
	txt = txt.replace(/&ecirc;/g,	"ê"); 	
	txt = txt.replace(/&euml;/g,	"ë"); 		
	txt = txt.replace(/&igrave;/g,	"ì"); 	
	txt = txt.replace(/&iacute;/g,	"í"); 	
	txt = txt.replace(/&icirc;/g,	"î"); 	
	txt = txt.replace(/&iuml;/g,	"ï"); 		
	txt = txt.replace(/&eth;/g,		"ð"); 		
	txt = txt.replace(/&ntilde;/g,	"ñ"); 	
	txt = txt.replace(/&ograve;/g,	"ò"); 	
	txt = txt.replace(/&oacute;/g,	"ó"); 	
	txt = txt.replace(/&ocirc;/g,	"ô"); 	
	txt = txt.replace(/&otilde;/g,	"õ"); 	
	txt = txt.replace(/&ouml;/g,	"ö"); 		
	txt = txt.replace(/&oslash;/g,	"ø"); 	
	txt = txt.replace(/&ugrave;/g,	"ù"); 	
	txt = txt.replace(/&uacute;/g,	"ú"); 	
	txt = txt.replace(/&ucirc;/g,	"û"); 	
	txt = txt.replace(/&uuml;/g,	"ü"); 		
	txt = txt.replace(/&yacute;/g,	"ý"); 	
	txt = txt.replace(/&thorn;/g,	"þ"); 	
	txt = txt.replace(/&yuml;/g,	"ÿ"); 		
	txt = txt.replace(/&iexcl;/g,	"¡"); 	
	txt = txt.replace(/&cent;/g,	"¢"); 		
	txt = txt.replace(/&pound;/g,	"£"); 	
	txt = txt.replace(/&curren;/g,	"¤"); 	
	txt = txt.replace(/&yen;/g,		"¥"); 		
	txt = txt.replace(/&brvbar;/g,	"¦"); 	
	txt = txt.replace(/&sect;/g,	"§"); 		
	txt = txt.replace(/&uml;/g,		"¨"); 		
	txt = txt.replace(/&copy;/g,	"©"); 		
	txt = txt.replace(/&ordf;/g,	"ª"); 		
	txt = txt.replace(/&laquo;/g,	"«"); 	
	txt = txt.replace(/&not;/g,		"¬"); 		
	txt = txt.replace(/&shy;/g,		"­"); 		
	txt = txt.replace(/&reg;/g,		"®"); 		
	txt = txt.replace(/&macr;/g,	"¯"); 		
	txt = txt.replace(/&deg;/g,		"°"); 		
	txt = txt.replace(/&plusmn;/g,	"±"); 	
	txt = txt.replace(/&sup2;/g,	"²"); 		
	txt = txt.replace(/&sup3;/g,	"³"); 		
	txt = txt.replace(/&acute;/g,	"´"); 	
	txt = txt.replace(/&micro;/g,	"µ"); 	
	txt = txt.replace(/&para;/g,	"¶"); 		
	txt = txt.replace(/&middot;/g,	"·"); 	
	txt = txt.replace(/&cedil;/g,	"¸"); 	
	txt = txt.replace(/&sup1;/g,	"¹"); 		
	txt = txt.replace(/&ordm;/g,	"º"); 		
	txt = txt.replace(/&raquo;/g,	"»"); 	
	txt = txt.replace(/&frac14;/g,	"¼"); 	
	txt = txt.replace(/&frac12;/g,	"½"); 	
	txt = txt.replace(/&frac34;/g,	"¾"); 	
	txt = txt.replace(/&iquest;/g,	"¿"); 	
	txt = txt.replace(/&times;/g,	"×"); 	
	txt = txt.replace(/&divide;/g,	"÷"); 	
	return txt;
}


function isDatable(sDate)
{
	var bRet = true;
	sDate 	 = sDate.replace(" ", "");
	for(var i = 0 ; i < sDate.length ; i++)
	{
		var cChar = sDate.charAt(i);
		if(cChar != "1" && cChar != "2" && cChar != "3" && cChar != "4"
				&& cChar != "5" && cChar != "6" && cChar != "7" && cChar != "8"
				&& cChar != "9" && cChar != "0" && cChar != "/")
				bRet = false;		
	}
	return bRet;
}

function CheckISADDates(objDate,curAnho,bGrid)
{
	if(objDate == null)
		return false;
	var sValue = objDate.value;
	var sName  = objDate.name;
	if(bGrid)
	{
		//Los nombres del grid son L1_TIXX
		var ar = sName.split("_");
		sName = ar[1];
	}
	sValue 		 = sValue.replace(" ", "");
	nLong 		 = sValue.length;	
	var nCont  = 0;
	var cChar  = "";
	var bRet 	 = true;
	
	if(sName == "TI11" || sName == "TI12" || sName == "TI18" || sName == "TI19")
	{
		if(sName == "TI11" || sName == "TI18")
		{
			if(isDatable(sValue))
			{
				switch(nLong)
				{
					case 4:			objDate.value = "01/01/" + sValue;								break;
					case 1:			objDate.value = "0" + sValue + "/01/" + curAnho;	break;
					case 2:			objDate.value = sValue + "/01/" + curAnho;				break;
					case 10:		objDate.value = sValue;														break;
					default:		objDate.value = "01/01/" + curAnho;								break;
				}
			}
			else
				bRet = false;
		}
		if(sName == "TI12" || sName == "TI19")
		{
			if(isDatable(sValue))
			{
				switch(nLong)
				{
					case 4:			objDate.value = "31/12/" + sValue;								break;
					case 1:			objDate.value = "0" + sValue + "/12/" + curAnho;	break;
					case 2:			objDate.value = sValue + "/12/" + curAnho;				break;
					case 10:		objDate.value = sValue;														break;
					default:		objDate.value = "31/12/" + curAnho;								break;
				}				
			}
			else
				bRet = false;
		}		
	}
	return bRet;
}





