﻿
function clickHandler(oEvent,targetId)
{oElem=document.getElementById(targetId);if(oElem!=null)
{if(oElem.style.display=="")oElem.style.display="none";else oElem.style.display="";}
if(NavegadorIE())
{oEvent.cancelBubble=true;oEvent.returnValue=false;}
else
{oEvent.stopPropagation();oEvent.preventDefault();}}
function clickHandlerCheck(oEvent,targetId,checkId)
{oElem=document.getElementById(targetId);oElemCheck=document.getElementById(checkId);if(oElem!=null)
{if(oElemCheck.checked==false)
{oElem.style.display="none";}
else
{oElem.style.display="";}
TratarDatosSolicitante(oElemCheck.checked)}}
function TratarDatosSolicitante(bTratar)
{var oSolicitante,oRepresentante;var oSolicitante2,oRepresentante2;oSolicitante=ObtenerObjetoControl('WTGNOMBRE','WTXNOMBRE');oRepresentante=document.getElementById('WTXIPRNOM');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);oSolicitante=ObtenerObjetoControl('WTGAPELL1','WTXAPELL1');oRepresentante=document.getElementById('WTXIPRAP1');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);oSolicitante=ObtenerObjetoControl('WTGAPELL2','WTXAPELL2');oRepresentante=document.getElementById('WTXIPRAP2');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);oSolicitante=ObtenerObjetoControl('WTXIPSRAS','WTXRSDSOL');oRepresentante=document.getElementById('WTXRSDREP');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);oSolicitante=ObtenerObjetoControl('WTXIPSTDO','WTXIPSTDO');oRepresentante=document.getElementById('WTXREPTDO');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);oSolicitante=ObtenerObjetoControl('WTGNUMDOC','WTXNUMDOC');oRepresentante=document.getElementById('WTXREPNDO');if(oRepresentante==null)
oRepresentante=document.getElementById('WTXIPRDNI');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);oSolicitante=ObtenerObjetoControl('WTXLETDNI','WTXLETDNI');oRepresentante=document.getElementById('WTXLDNIRE');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);oSolicitante=ObtenerObjetoControl('WTXIPSDO0','WTXIPSTDO0');oRepresentante=document.getElementById('WTXIPRDO0');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);oSolicitante=ObtenerObjetoControl('WTXIPSDO1','WTXIPSDO1');oRepresentante=document.getElementById('WTXIPRDO1');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);oSolicitante=ObtenerObjetoControl('WTXIPSDO2','WTXIPSDO2');oRepresentante=document.getElementById('WTXIPRDO2');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);oSolicitante=ObtenerObjetoControl('WTXIPSDO3','WTXIPSDO3');oRepresentante=document.getElementById('WTXIPRDO3');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);oSolicitante=ObtenerObjetoControl('WTXIPSDO4','WTXIPSDO4');oRepresentante=document.getElementById('WTXIPRDO4');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);oSolicitante=ObtenerObjetoControl('WTXIPSDO5','WTXIPSDO5');oRepresentante=document.getElementById('WTXIPRDO5');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);oSolicitante=ObtenerObjetoControl('WTXIPSDO6','WTXIPSDO6');oRepresentante=document.getElementById('WTXIPRDO6');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);oSolicitante=ObtenerObjetoControl('WTXIPSDO7','WTXIPSDO7');oRepresentante=document.getElementById('WTXIPRDO7');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);oSolicitante=ObtenerObjetoControl('WTXIPSDO8','WTXIPSDO8');oRepresentante=document.getElementById('WTXIPRDO8');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);oSolicitante=ObtenerObjetoControl('WTXIPSDO9','WTXIPSDO9');oRepresentante=document.getElementById('WTXIPRDO9');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);oSolicitante=ObtenerObjetoControl('WTXIPSDOA','WTXIPSDOA');oRepresentante=document.getElementById('WTXIPRDOA');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);oSolicitante=ObtenerObjetoControl('WTXIPSMU0','WTXIPSMN0');oRepresentante=document.getElementById('WTXIPRMU0');oSolicitante2=ObtenerObjetoControl('WTXIPSMU1','WTXIPSMN1');oRepresentante2=document.getElementById('WTXIPRMU1');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);EstablecerComportamientoControles(oSolicitante2,oRepresentante2,bTratar);oSolicitante=ObtenerObjetoControl('WTXIPSCPO','WTXIPSCPO');oRepresentante=document.getElementById('WTXIPRCPO');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);oSolicitante=ObtenerObjetoControl('WTGTELEF1','WTXTELEF1');oRepresentante=document.getElementById('WTXIPRTE1');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);oSolicitante=ObtenerObjetoControl('WTXIPSTE2','WTXIPSTE2');oRepresentante=document.getElementById('WTXIPRTE2');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);oSolicitante=ObtenerObjetoControl('WTXNUMFAX','WTXNUMFAX');oRepresentante=document.getElementById('WTXIPRFAX');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);oSolicitante=ObtenerObjetoControl('WTGDIRMAI','WTXDIRMAI');oRepresentante=document.getElementById('WTXIPRDEM');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);oSolicitante=ObtenerObjetoControl('WTXIPSCIF','WTXIPSCIF');oRepresentante=document.getElementById('WTXIPRCIF');EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar);}
function ObtenerObjetoControl(sNombreCtl,sNombreAux)
{var oControl;oControl=document.getElementById(sNombreCtl);if((oControl==null)&&(sNombreAux!='')){oControl=document.getElementById(sNombreAux);}
return oControl;}
function EstablecerComportamientoControlesMulti(oSol1,oRep1,oSol2,oRep2,bTratar)
{var oValor;if((oRep1!=null)&&(oRep2!=null)&&(oSol1!=null)&&(oSol2!=null)){if(bTratar){var sSol1Seleccionada=oSol1.value.split("-");var sSol2Seleccionada=oSol2.value.split("-");oRep1.options[1]=new Option(sSol1Seleccionada[1],oSol1.value);oRep2.options[1]=new Option(sSol1Seleccionada[2],oSol2.value);oRep1.selectedIndex=1;oRep2.selectedIndex=1;oValor=(oSol2.value.length-1)-(oSol2.value.lastIndexOf('-'));if((oSol1.value.length>0)&&(oValor>0)){if(typeof aDinCmp[oRep1.id]=="undefined")
LlenarListaAsociada(oRep2,'_LPRO',oRep1,false,false);oRep2.value=oSol2.value;}
if(oSol1.readOnly==true)opt.readOnly=true;if(oSol2.readOnly==true)oRep2.readOnly=true;oSol1.readOnly=false;oSol2.readOnly=false;}
else{oSol1.value=oRep1.value;oValor=(oRep2.value.length-1)-(oRep2.value.lastIndexOf('-'));if((oRep1.value.length>0)&&(oValor>0)){if(typeof aDinCmp[oSol1.id]=="undefined")
LlenarListaAsociada(oSol2,'_LPRO',oSol1,false,false)
oSol2.value=oRep2.value;}
oRep1.value='';oRep2.value='';if(oRep1.readOnly==true)oSol1.readOnly=true;else oSol1.readOnly=false;if(oRep2.readOnly==true)oSol2.readOnly=true;else oSol2.readOnly=false;oRep1.readOnly=false;oRep2.readOnly=false;}}}
function EstablecerComportamientoControles(oSolicitante,oRepresentante,bTratar)
{if((oSolicitante!=null)&&(oRepresentante!=null)){if(bTratar){if(oSolicitante.tagName!="SELECT"||oRepresentante.tagName!="SELECT"){oRepresentante.value=oSolicitante.value;oSolicitante.value='';}else{EliminarElementosSubListaMenosBlanco(oRepresentante);for(var j=0;j<oSolicitante.options.length;j++)
{if(oSolicitante.options[j].value!='')
{oOption=document.createElement("OPTION");oOption.text=oSolicitante.options[j].text;oOption.value=oSolicitante.options[j].value;if(NavegadorIE())oRepresentante.add(oOption);else oRepresentante.appendChild(oOption);}}
oRepresentante.value=oSolicitante.value;oSolicitante.value="";}
if(oSolicitante.readOnly==true){oRepresentante.readOnly=true;}
oSolicitante.readOnly=false;}
else{if(oSolicitante.tagName!="SELECT"||oRepresentante.tagName!="SELECT"){oSolicitante.value=oRepresentante.value;oRepresentante.value='';if(oRepresentante.readOnly==true){oSolicitante.readOnly=true;}
else{oSolicitante.readOnly=false;}
oRepresentante.readOnly=false;}else{EliminarElementosSubLista(oSolicitante);for(var j=0;j<oRepresentante.options.length;j++)
{if(oRepresentante.options[j].value!='')
{oOption=document.createElement("OPTION");oOption.text=oRepresentante.options[j].text;oOption.value=oRepresentante.options[j].value;if(NavegadorIE())oSolicitante.add(oOption);else oSolicitante.appendChild(oOption);}}
oSolicitante.value=oRepresentante.value;oRepresentante.value="";}}}
else{if((oSolicitante!=null)&&(bTratar))oSolicitante.value='';if((oRepresentante!=null)&&(!bTratar))oRepresentante.value='';}}
function ValidarDatos(){var coll=document.all;if(coll!=null){for(i=0;i<coll.length;i++)
alert(coll.item(i).tagName);}}
function numAdjuntos(theForm)
{var input;var i=0;var numadjuntos=0;var idAdjunto=parseInt(-1);if(theForm.name!=""){input=theForm.getElementsByTagName("input");while(i<input.length){if(input[i].type=="hidden"&&(input[i].id.substring(0,10)=="fileAttach"||input[i].name.substring(0,10)=="fileAttach"))
{if(!isNaN(input[i].name.substring(10))){if(idAdjunto!=parseInt(input[i].name.substring(10))){numadjuntos++;idAdjunto=parseInt(input[i].name.substring(10));}}}
i++;}}
return numadjuntos;}
function comprobarMinimoFicherosAdjuntos(theForm,cmpMinArchivos){var numFicAdj;numFicAdj=numAdjuntos(theForm);var minArchv;minArchv=parseInt(document.getElementsByName(cmpMinArchivos)[0].value);if(numFicAdj<minArchv){alert(strMsgMinimoFichAdj);return false;}else{return true;}}
function showElements(oEvent,theForm){var oCampo,value,name,sDescripcion,sTipoCampo,lLongitud,sOblig,j,bError,sMensajeError,oBtnAceptar,oBtnAtras,oSpanImg;if((theForm!=null)&&(oEvent!=null))
{if(typeof ActualizaBeforeShowError!='undefined')
{ActualizaBeforeShowError(theForm.id);}
oBtnAceptar=theForm['btnAceptar'];oBtnAtras=theForm['btnAtras'];if(oBtnAceptar!=null)oBtnAceptar.disabled=true;if(oBtnAtras!=null)oBtnAtras.disabled=true;value=theForm.elements[0].value;for(i=0;i<theForm.length;i++)
{if((name!=theForm.elements[i].name)&&(theForm.elements[i].name!='btn_'+name))
{oCampo=theForm.elements[i];name=theForm.elements[i].name;value=theForm.elements[i].value;j=0;bError=false;if((theForm.elements[i].style.color=='Red')||(theForm.elements[i].style.color=='red'))
{bError=true;sMensajeError=strCampoIncorrectoRojo;}
if(name!=undefined&&value!=undefined&&!bError)
{switch(theForm.elements[i].type.substr(0,6))
{case'select':if((theForm.elements[i].onblur+' ').indexOf('CampoObligatorio')>=0&&theForm.elements[i].selectedIndex<0)
{bError=true;sMensajeError=strCampoObligatorio;}
else
{if((theForm.elements[i].onblur+' ').indexOf('CampoObligatorio')<0&&theForm.elements[i].options.length<1)
{theForm.elements[i].options[0]=new Option("");theForm.elements[i].options[0].value="";value="";}}
break;case'hidden':if((name.length!=0)&&document.getElementById(name)&&document.getElementById(name+'0')&&document.getElementById(name+'1')&&name.indexOf("fileAttach")>0)
{var sNew;sNew=ActualizarFechaHora(theForm.elements[i].name);if(value!=sNew&&sNew.length>0)
value=sNew;}
break;case'textar':if((theForm.elements[i].onblur+' ').indexOf('CampoObligatorio')>=0)
{if(theForm.elements[i].className==theForm.elements[i].name)
{var ed=tinyMCE.get(theForm.elements[i].name);value=ed.getContent();theForm.elements[i].value=value;}
else
{if(value.length==0)
{bError=true;sMensajeError=strCampoObligatorio;}}}
break;case'checkb':if(theForm.elements[i].checked){theForm.elements[i].value='S';value=theForm.elements[i].value;}
if((theForm.elements[i].onblur+' ').indexOf('CampoObligatorio')>=0&&value.length==0)
{bError=true;sMensajeError=strCampoObligatorio;}
break;default:if((theForm.elements[i].onblur+' ').indexOf('CampoObligatorio')>=0&&value.length==0)
{bError=true;sMensajeError=strCampoObligatorio;}
break;}
if(bError)
{if(oCampo.type!='hidden'&&sMensajeError==strCampoObligatorio)
{oCampo.focus();alert(sMensajeError);if(typeof colorAvisoCampoVacio!='undefined'){pintaFondoCampo(oCampo)}}
if(oBtnAceptar!=null)oBtnAceptar.disabled=false;if(oBtnAtras!=null)oBtnAtras.disabled=false;if(NavegadorIE())
{oEvent.cancelBubble=true;oEvent.returnValue=false;}
else
{oEvent.stopPropagation();oEvent.preventDefault();}
break;}else{if(typeof colorAvisoCampoVacio!='undefined'){pintaFondoCampo(oCampo,true)}}}}
else
{var iOffset;if(j==1)
{if(theForm.elements[i].name=='btn_'+name)
{i++;}
sTipoCampo=theForm.elements[i].value;}
else
{if(j==2)lLongitud=theForm.elements[i].value;else
{if(j==3)sDescripcion=theForm.elements[i].value;else
{if(j==5)
{if(sTipoCampo=='date')
{var sNew;sNew=ActualizarFechaHora(theForm.elements[i].name);if(value!=sNew&&sNew.length>0)
value=sNew;}
sOblig=theForm.elements[i].value;if((theForm.elements[i].value=="not null")&&((value.length==0)||(value=="<p>&nbsp;</p>")))
{bError=true;sMensajeError=strCampoObligatorio;}
else
{if(sTipoCampo=='date')
{if(document.getElementById(theForm.elements[i].name+'0')&&document.getElementById(theForm.elements[i].name+'1'))
{var sData,sHora;sData=document.getElementById(theForm.elements[i].name+'0').value;sHora=document.getElementById(theForm.elements[i].name+'1').value;if((sData.length==0&&sHora.length!=0))
{bError=true;sMensajeError=strCampoIncorrecto;document.getElementById(theForm.elements[i].name+'0').focus();}
else if((sData.length!=0&&sHora.length==0))
{bError=true;sMensajeError=strCampoIncorrecto;document.getElementById(theForm.elements[i].name+'1').focus();}
else if(sData.length>0&&!Validar_Data(sData))
{bError=true;sMensajeError=strCampoIncorrecto;document.getElementById(theForm.elements[i].name+'0').focus();}
else if(sHora.length>0&&!Validar_Hora(sHora))
{bError=true;sMensajeError=strCampoIncorrecto;document.getElementById(theForm.elements[i].name+'1').focus();}}
else if(!Validar_Data(value))
{bError=true;sMensajeError=strCampoIncorrecto;}}
if((sTipoCampo=='decimal')&&(!Validar_Numero(value,lLongitud)))
{bError=true;sMensajeError=strCampoIncorrecto;}}
if(bError)
{if(oCampo.type!='hidden')
{try
{oCampo.focus();}
catch(err)
{}}
alert(sMensajeError);pintaFondoCampo(oCampo,true)
if(oBtnAceptar!=null)oBtnAceptar.disabled=false;if(oBtnAtras!=null)oBtnAtras.disabled=false;if(NavegadorIE())
{oEvent.cancelBubble=true;oEvent.returnValue=false;}
else
{oEvent.stopPropagation();oEvent.preventDefault();}
break;}}
else
{if(j==9)
{if(sTipoCampo=='varchar'&&theForm.elements[i].value=='|WTCESIMAG=S|')
{oSpanImg=document.getElementById('spanAttachText'+name);if(oSpanImg)
{if(sOblig=='not null'&&TrimNoTxt(oSpanImg.innerHTML)=='')
{bError=true;if(sDescripcion!='')
sMensajeError='"'+sDescripcion+'": '+strCampoObligatorio;else
sMensajeError=strCampoObligatorio;alert(sMensajeError);document.getElementById('linkAttachImg'+name).focus();if(oBtnAceptar!=null)oBtnAceptar.disabled=false;if(oBtnAtras!=null)oBtnAtras.disabled=false;if(NavegadorIE())
{oEvent.cancelBubble=true;oEvent.returnValue=false;}
else
{oEvent.stopPropagation();oEvent.preventDefault();}
break;}}}}}}}}}
j++;}
var HayAlgunError=false;if(i<(theForm.length))
{HayAlgunError=true;if(typeof ActualizaAfterShowError!='undefined')
{ActualizaAfterShowError(theForm.id,HayAlgunError);}}
if(!bError)
{if(winAttachEDF)
{if(!winAttachEDF.closed)winAttachEDF.close();}
var bSeccConsulta=((theForm.onsubmit+'').indexOf('return false;')>=0)
if(bSeccConsulta)
{var TipoSecc=theForm.elements.namedItem('TIPO_SECCION').value
if(TipoSecc=="busqueda")
{CargarSeccionBusqueda('c'+theForm.elements.namedItem('ID_SECCION').value,theForm);if(NavegadorIE())
{oEvent.cancelBubble=true;oEvent.returnValue=false;}
else
{oEvent.stopPropagation();oEvent.preventDefault();}
if(oBtnAceptar!=null)oBtnAceptar.disabled=false;if(oBtnAtras!=null)oBtnAtras.disabled=false;}
else
{CargarSeccionConsulta('c'+theForm.elements.namedItem('ID_SECCION').value,theForm);if(NavegadorIE())
{oEvent.cancelBubble=true;oEvent.returnValue=false;}
else
{oEvent.stopPropagation();oEvent.preventDefault();}
if(oBtnAceptar!=null)oBtnAceptar.disabled=false;if(oBtnAtras!=null)oBtnAtras.disabled=false;}}
else
{var minArchivos="minArchivos"
if(typeof document.getElementsByName(minArchivos)[0]!='undefined')
{var ficOk;ficOk=comprobarMinimoFicherosAdjuntos(theForm,minArchivos);if(!ficOk)
{if(oBtnAceptar!=null)oBtnAceptar.disabled=false;if(NavegadorIE())
{oEvent.cancelBubble=true;oEvent.returnValue=false;}
else
{oEvent.stopPropagation();oEvent.preventDefault();}
return false;}}
if(hayElementoFirma(theForm))
{if(!firmar(theForm,oEvent))
{alert('Error Firmando');}
if(NavegadorIE())
{oEvent.cancelBubble=true;oEvent.returnValue=false;}
else
{oEvent.stopPropagation();oEvent.preventDefault();}}
else
{remplazoEuros(theForm);theForm.submit();}}}}}
function remplazoEuros(theForm)
{var i;for(i=0;i<theForm.length;i++)
{if((name!=theForm.elements[i].name)&&(theForm.elements[i].name!='btn_'+name))
{theForm.elements[i].value=theForm.elements[i].value.replace(/€/g,"&euro;")}}}
function TrimNoTxt(s)
{if((s==null)||(typeof(s)!='string')||!s.length)return'';return s.replace(/^\s+/,'').replace(/\s+$/,'')}
function generarDocumentoTramite(theForm,plantilla,nombre,firmado)
{var sURL,sParams,sIdioma;var value,name,oCampo;var sIdEntidad,sNomTab,idFile;if(theForm.elements.namedItem('WTGCODENT'))
{sIdEntidad=theForm.elements.namedItem('WTGCODENT').value;}
if(theForm.elements.namedItem('WTGIDIOMA'))
{sIdioma=theForm.elements.namedItem('WTGIDIOMA').value;}
var inputs="";for(i=0;i<theForm.length;i++)
{if((name!=theForm.elements[i].name)&&(theForm.elements[i].name!='btn_'+name))
{oCampo=theForm.elements[i];name=theForm.elements[i].name;value=theForm.elements[i].value;inputs+=name+"#"+value+"|"}}
sParams="sIdEntidad="+sIdEntidad+"&sNomTab="+plantilla+"&sIdioma="+sIdioma+"&sInputs="+inputs;sURL="../src/asp/selecFicheros/CreacionFicheroTramite.asp"
idFile=makePOSTRequest(sURL,sParams);var i=0;var Existe=false;while(document.getElementsByName("fileAttach"+i).length>0)
{if(document.getElementsByName("fileAttach"+i)[0].value==idFile)
{Existe=true;}
i++;}
if(!Existe)
{oCampo=crearCampoForm('INPUT','fileAttach'+i);oCampo.setAttribute('id','fileAttach'+i);oCampo.setAttribute('type','hidden');oCampo.setAttribute('value',idFile);theForm.appendChild(oCampo)
oCampo=crearCampoForm('INPUT','fileAttach'+i);oCampo.setAttribute('id','fileAttach'+i);oCampo.setAttribute('type','hidden');oCampo.setAttribute('value',"0");theForm.appendChild(oCampo)
oCampo=crearCampoForm('INPUT','fileAttach'+i);oCampo.setAttribute('id','fileAttach'+i);oCampo.setAttribute('type','hidden');oCampo.setAttribute('value',plantilla+"_TRAM");theForm.appendChild(oCampo)
oCampo=crearCampoForm('INPUT','fileAttach'+i);oCampo.setAttribute('id','fileAttach'+i);oCampo.setAttribute('type','hidden');oCampo.setAttribute('value',"");theForm.appendChild(oCampo)
oCampo=crearCampoForm('INPUT','fileAttachFirma'+i);oCampo.setAttribute('id','fileAttachFirma'+i);oCampo.setAttribute('type','hidden');if(firmado)
{oCampo.setAttribute('value',"true");}
else
{oCampo.setAttribute('value',"true");}
theForm.appendChild(oCampo)}}
function FormatearDecimal(sValue,iNumDecimales)
{var sParteEntera="";var sParteDecimal="";var aDecimal=new Array();var k;iNumDecimales=parseInt(iNumDecimales);if(iNumDecimales>0)
{if((sValue.indexOf(',')==-1)&&(sValue.indexOf('.')==-1))
{sParteEntera=sValue;if(sParteEntera=="")
{sParteEntera="0";}
for(k=0;k<iNumDecimales;k++)
{sParteDecimal+="0"}}
else
{sValue=sValue.replace(",",".");aDecimal=sValue.split('.');sParteEntera=aDecimal[0];if(sParteEntera=="")
{sParteEntera="0";}
if(aDecimal.length>1)
{sParteDecimal=aDecimal[1];}
iNumDecimales=iNumDecimales-sParteDecimal.length;for(k=0;k<iNumDecimales;k++)
{sParteDecimal+="0"}}
if((sParteEntera!="")&&(sParteDecimal!=""))
sValue=sParteEntera+'.'+sParteDecimal;}
return sValue;}
function MascaraData(oEvent,oText){var iNumero,iKeyCode,sData;iKeyCode=ObtenerTeclaPulsada(oEvent);sDataHora=oText.value.split(" ");sData=sDataHora[0].split("/");if((iKeyCode<47)||(iKeyCode>57))
{if(!TeclaFuncional(iKeyCode)||iKeyCode==46||iKeyCode==44)iKeyCode=-1;}
else{if(iKeyCode==47){if((oText.value.length!=1)&&(oText.value.length!=2)&&(oText.value.length!=4)&&(oText.value.length!=5))
iKeyCode=-1;else{if(oText.value.length==1)
if(sData[0]==0)iKeyCode=-1;else oText.value="0"+oText.value;else if(oText.value.length==4)
if(sData[1]==0)iKeyCode=-1;else oText.value=sData[0]+"/0"+sData[1];}}
else{if((oText.value.length==2)||(oText.value.length==5))
oText.value=oText.value+"/";iNumero=iKeyCode-48;switch(oText.value.length){case 0:if(iNumero>3)oText.value="0"+oText.value;break;case 1:if((sData[0]==0)&&(iNumero==0))
iKeyCode=-1;else if((sData[0]==3)&&(iNumero>1))
oText.value="0"+sData[0]+"/0";break;case 3:if(iNumero>1){if((sData[0]==31)&&((iNumero==2)||(iNumero==4)||(iNumero==6)||(iNumero==9)))
iKeyCode=-1;else if((sData[0]==30)&&(iNumero==2))
iKeyCode=-1;else oText.value=sData[0]+"/0";}
break;case 4:if((sData[1]==0)&&(iNumero==0))
iKeyCode=-1;else if((sData[1]==1)&&(iNumero>2))
iKeyCode=-1;else{if((sData[0]==31)&&(sData[1]==0)&&((iNumero==2)||(iNumero==4)||(iNumero==6)||(iNumero==9)))
iKeyCode=-1;else if((sData[0]==31)&&(sData[1]==1)&&(iNumero==1))
iKeyCode=-1;else if((sData[0]==30)&&(sData[1]==0)&&(iNumero==2))
iKeyCode=-1;}
break;case 6:if((iNumero==0)||((iNumero>2)&&(iNumero<6)))
oText.value=sData[0]+"/"+sData[1]+"/20";else if(iNumero>=6)
oText.value=sData[0]+"/"+sData[1]+"/19";break;case 7:if((sData[2]==1)&&(iNumero<9))iKeyCode=-1;break;case 9:if((sData[0]==29)&&(sData[1]==2)&&(!Traspas(sData[2]+iNumero)))iKeyCode=-1;break;default:}}}
if(iKeyCode==-1)
{if(oEvent.preventDefault)
oEvent.preventDefault();else
oEvent.returnValue=false;}}
function MascaraHora(oEvent,oText)
{var iNumero,iKeyCode,sData;iKeyCode=ObtenerTeclaPulsada(oEvent);sHora=oText.value.split(":");if((iKeyCode<48)||(iKeyCode>58))
{if(!TeclaFuncional(iKeyCode)||iKeyCode==46||iKeyCode==44)iKeyCode=-1;}
else
{if(iKeyCode==58)
{if((oText.value.length!=1)&&(oText.value.length!=2))
iKeyCode=-1;else{if(oText.value.length==1)
{if(sHora[0]==0)iKeyCode=-1;else oText.value="0"+oText.value;}}}
else{if(oText.value.length==2)
oText.value=oText.value+":";iNumero=iKeyCode-48;switch(oText.value.length)
{case 0:if(iNumero>2)oText.value="0"+oText.value;break;case 1:if((sHora[0]>=2)&&(iNumero>=4))
oText.value="0"+sHora[0]+":0";break;case 3:if(iNumero>5)
oText.value=sHora[0]+":0";break;}}}
if(iKeyCode==-1)
{if(oEvent.preventDefault)
oEvent.preventDefault();else
oEvent.returnValue=false;}}
function TeclaFuncional(iKeyCode)
{if((iKeyCode==8)||(iKeyCode==9)||(iKeyCode==46)||(iKeyCode==37)||(iKeyCode==39)||(iKeyCode==36)||(iKeyCode==35))
return true;else return false;}
function tratarOcultar(id){if(document.getElementById)
{var oEle=document.getElementById(id);oEle.style.display=(oEle.style.display=='none')?'block':'none';}}
function SortirData(oText,ColorCorrecte,ColorErroni){if((oText.value.length==0)||(Validar_Data(oText.value)))
{oText.style.color=ColorCorrecte;return(true);}
else
{oText.style.color=ColorErroni;return(false);}}
function SortirHora(oText,ColorCorrecte,ColorErroni){sHora=oText.value.split(":");if(sHora.length==1)
{if(parseInt(sHora[0])>=24)iHora='00';else if(sHora[0].length==1)iHora="0"+sHora[0];else iHora=sHora[0];if(iHora.length>0)
oText.value=iHora+":00"}
if((oText.value.length==0)||(Validar_Hora(oText.value)))
{oText.style.color=ColorCorrecte;return(true);}
else
{oText.style.color=ColorErroni;return(false);}}
function Validar_Data(sData){var bTraspas;var dataTrans;if(sData=='')return true;dataTrans=Transformar_Data(sData);if(dataTrans!=''){tmpData=dataTrans.split(" ");sData=tmpData[0].split("/");if(tmpData.length!=1)sHora=tmpData[1].split(":");else sHora='';}
else
return false;if(sData)
{if(sData.length!=0)
{if(sData.length!=3)
{return(false);}
else
{if((sData[0].length!=2)||(sData[1].length!=2)||(sData[2].length!=4))
{return(false);}
if((sData[2]<1900)||(sData[2]>2100))
{return(false);}
else
{if((sData[1]<1)||(sData[1]>12)){return(false);}
else
{if((sData[1]==1)||(sData[1]==3)||(sData[1]==5)||(sData[1]==7)||(sData[1]==8)||(sData[1]==10)||(sData[1]==12))
{if((sData[0]<1)||(sData[0]>31))
{return(false);}}
else if((sData[1]==4)||(sData[1]==6)||(sData[1]==9)||(sData[1]==11))
{if((sData[0]<1)||(sData[0]>30))
{return(false);}}
else if(sData[1]==2)
{bTraspas=Traspas(sData[2]);if((bTraspas)&&((sData[0]<1)||(sData[0]>29)))
{return(false);}
else if((!bTraspas)&&((sData[0]<1)||(sData[0]>28)))
{return(false);}}}}}}}
return(true);}
function Validar_Hora(sHora){var bTraspas;var horaTrans;horaTrans=Transformar_Hora(sHora);if(horaTrans!='')
return(true);else
return false;}
function Transformar_Data(sData){var iDia;var iMes;var iAny;var iHora,iMinuts,iSegons;if(sData!='')
{tmpData=sData.split(" ");sData=tmpData[0].split("/");if(tmpData.length!=1)sHora=tmpData[1].split(":");else sHora='';if(sData.length!=3)return'';else{if(sData[0].length==1)iDia="0"+sData[0];else iDia=sData[0];if(sData[1].length==1)iMes="0"+sData[1];else iMes=sData[1];if(sData[2].length==2){if(sData[2][0]>=6)iAny="19"+sData[2];else iAny="20"+sData[2];}
else iAny=sData[2];}
if(sHora.length!=3){return(iDia+"/"+iMes+"/"+iAny);}
else{if(parseInt(sHora[0])>24)iHora='00';else if(sHora[0].length==1)iHora="0"+sHora[0];else iHora=sHora[0];if(parseInt(sHora[1])>60)iMinuts='00';else if(sHora[1].length==1)iMinuts="0"+sHora[1];else iMinuts=sHora[1];if(parseInt(sHora[2])>60)iSegons='00';else iSegons=sHora[2];}
return(iDia+"/"+iMes+"/"+iAny+" "+iHora+":"+iMinuts+":"+iSegons);}
else
{return sData;}}
function Transformar_Hora(sHora){var iDia;var iMes;var iAny;var iHora,iMinuts,iSegons;if(sHora!='')
{sHora=sHora.split(":");if(sHora.length!=2)return'';else{if(parseInt(sHora[0])>=24)iHora='00';else if(sHora[0].length==1)iHora="0"+sHora[0];else iHora=sHora[0];if(parseInt(sHora[1])>60)iMinuts='00';else if(sHora[1].length==1)iMinuts="0"+sHora[1];else iMinuts=sHora[1];}
return(iHora+":"+iMinuts);}
else
{return sHora;}}
function FechaActual(oText)
{var d,s;if(oText.value.length==0)
{d=new Date();s=d.getDate()+"/"+(d.getMonth()+1)+"/"+d.getFullYear();oText.value=Transformar_Data(s);if(oText){var oCampoFecha=oText.id;updateInputDate(oText.value,oCampoFecha);ActualizarFechaHora(oCampoFecha.substr(0,9))}}}
function FechaHoraActual(oText)
{var d,s;if(oText.value.length==0)
{d=new Date();s=d.getDate()+"/"+(d.getMonth()+1)+"/"+d.getFullYear()+' '+d.getHours()+':'+d.getMinutes()+':'+d.getSeconds();oText.value=Transformar_Data(s);}}
function ActualizarFechaHora(sNomCampo)
{var oFechaHora,oFecha,oHora,sNew;oFechaHora=document.getElementById(sNomCampo);oFecha=document.getElementById(sNomCampo+'0');oHora=document.getElementById(sNomCampo+'1');sNew="";if(oFechaHora&&oFecha&&oHora)
{if(oFecha.value.length==0&&oHora.value.length==0)
sNew="";else if(oFecha.value.length==0&&oHora.value.length!=0)
sNew='01/01/1900 '+oHora.value+':00';else if(oFecha.value.length!=0&&oHora.value.length==0)
sNew=oFecha.value+'00:00:00';else
sNew=oFecha.value+' '+oHora.value+':00';if(sNew!=oFechaHora.value)
oFechaHora.value=sNew;}
return sNew;}
function ActualizarFechaAndHora(sNomCampo)
{var oFechaHora,oFecha,oHora;oFechaHora=document.getElementById(sNomCampo);oFecha=document.getElementById(sNomCampo+'0');oHora=document.getElementById(sNomCampo+'1');if(oFechaHora&&oFecha&&oHora)
{var sFechaHora,sHora;sFechaHora=oFechaHora.value.split(' ');if(Validar_Data(sFechaHora[0])&&(oFecha.value!=sFechaHora[0]))
oFecha.value=sFechaHora[0];if(sFechaHora.length==2)
{sHora=sFechaHora[1].split(":");if(sHora.length>=2)
{sHora=sHora[0]+':'+sHora[1];if(Validar_Hora(sHora)&&(oHora.value!=sHora))
oHora.value=sHora;}}}}
function HoraActual(oText)
{var d,s;if(oText.value.length==0)
{d=new Date();s=d.getHours()+':'+d.getMinutes();oText.value=Transformar_Hora(s);}}
function ObtenerTeclaPulsada(oEvent){var iTeclaPulsada;if(NavegadorNetscape()){if(oEvent.charCode!=0){iTeclaPulsada=oEvent.charCode;}else{iTeclaPulsada=oEvent.keyCode;if(iTeclaPulsada==46)iTeclaPulsada=127;}}else{iTeclaPulsada=oEvent.keyCode;if(iTeclaPulsada==46&&NavegadorOpera())iTeclaPulsada=127;}
return iTeclaPulsada;}
function Mascara_Numero(oEvent,oText,intMaxDecimals,blnNegatiu){var intNumero,strNumero,intPosicionDecimal,bCancel;strNumero=oText.value;intNumero=ObtenerTeclaPulsada(oEvent);bCancel=false;if(intNumero!=0)
{if((intNumero<44)||(intNumero>57)||intNumero==47)
{if(!TeclaFuncional(intNumero)||intNumero==47)bCancel=true;}
else{intPosicioDecimal=strNumero.search(/[,]|[.]/);if(intNumero==45){if((!(blnNegatiu))||strNumero.length>0)
bCancel=true;}
else if((intNumero==44)||(intNumero==46)){if(intMaxDecimals>0){if(intPosicioDecimal>=0)bCancel=true;}
else bCancel=true;}
else{if((intPosicioDecimal>=0)&&(intMaxDecimals>0)){if(strNumero.length-intPosicioDecimal-1-intMaxDecimals>=0)
bCancel=true;}}}}
if(bCancel)
{if(NavegadorIE())oEvent.returnValue=0;else oEvent.preventDefault();}}
function Validar_Numero(sNumero,lNumDecimales)
{var iPosNeg,iPosDec,bOk;iPosNeg=sNumero.indexOf("-");bOk=(iPosNeg<=0);if(bOk)
{iPosDec=sNumero.indexOf(".");if(iPosDec==-1)iPosDec=sNumero.indexOf(",");if(iPosDec==-1)bOk=(sNumero.length<=(19-lNumDecimales));else bOk=(iPosDec<=(19-lNumDecimales));}
return(bOk);}
function LlenarListas(oSelect,oElemXML,sLista,sCodElem,bSoloListasPagina,oSelected)
{var oListas,oElemento,oListaElementos,oOption,sXPath,oLista,xmlHttpReq,bListaCargada,sBase,bBlanco,oBlanco,sOSelectName;bBlanco=false;if(oSelect.options.length>=1)
{oSelected=oSelect.value;if(oSelect.options[0].value=="")
{bBlanco=true;oBlanco=oSelect.options[0].text;}}
EliminarElementosSubLista(oSelect);bListaCargada=false;oListas=oElemXML;if(oListas!=null)
{sXPath="e[@i='"+sCodElem+"']";oElemento=SelectSingleNode(oListas,sXPath);if(oElemento!=null)
{if(oElemento.getAttribute("s")!=null)
{if(('INF_'==oSelect.name.substr(0,4))||('FIL_'==oSelect.name.substr(0,4)))
{sOSelectName=oSelect.name.substr(4,oSelect.name.length);}
else
{sOSelectName=oSelect.name;}
sBase=sOSelectName.concat("B");document.getElementById(sBase).value=oElemento.getAttribute("s");sXPath="f[@i='"+oElemento.getAttribute("s")+"']";if(SelectSingleNode(oListas,sXPath)==null)
{if(!bSoloListasPagina)
{oLista=peticionListaAsincrona(oElemento.getAttribute("s"));oListaElementos=oLista.getElementsByTagName("e");}}
else
{sXPath=sXPath.concat("/e");oListaElementos=oListas.selectNodes(sXPath);}
if(oListaElementos!=null)
{bListaCargada=true;EliminarElementosSubLista(oSelect);for(i=0;i<oListaElementos.length;i++)
{oElemento=oListaElementos.item(i);oOption=document.createElement("OPTION");if(NavegadorIE())oOption.text=oElemento.nodeTypedValue;else oOption.text=oElemento.firstChild.nodeValue;if(oSelect.id.substr(0,4)=="FIL_")
{oOption.value=oElemento.getAttribute("i");}
else
{if(NavegadorIE())oOption.value=oElemento.getAttribute("i")+"-"+oElemento.nodeTypedValue;else oOption.value=oElemento.getAttribute("i")+"-"+oElemento.firstChild.nodeValue;}
oSelect.options.add(oOption);if(oOption.value==oSelected)
{oOption.selected=true;oSelect.value=oOption.value;}}}}}}
return(bListaCargada);}
function peticionListaAsincrona(id)
{var xmlHttpReq,oLista,oListaElementos;if(NavegadorIE())
{xmlHttpReq=new ActiveXObject("MSXML2.XMLHTTP");xmlHttpReq.open("GET","../Comun/Listas.asp?id="+id,false);xmlHttpReq.send("");if(xmlHttpReq.responseXML!=null)
{oLista=xmlHttpReq.responseXML.documentElement;}}
else
{xmlHttpReq=new XMLHttpRequest();xmlHttpReq.open("GET","../Comun/Listas.asp?id="+id,false);xmlHttpReq.send("");if(xmlHttpReq.responseXML!=null)
{oLista=xmlHttpReq.responseXML.documentElement;}}
return oLista;}
function SelectSingleNode(xmlDoc,elementPath)
{if(NavegadorIE())
{return xmlDoc.selectSingleNode(elementPath);}
else
{var xpe=new XPathEvaluator();var nsResolver=xpe.createNSResolver(xmlDoc.ownerDocument==null?xmlDoc.documentElement:xmlDoc.ownerDocument.documentElement);var results=xpe.evaluate(elementPath,xmlDoc,nsResolver,XPathResult.FIRST_ORDERED_NODE_TYPE,null);return results.singleNodeValue;}}
function EliminarElementosSubLista(oSelect)
{if(oSelect.options)
{while(oSelect.options.length>1)oSelect.removeChild(oSelect.options[1]);if(oSelect.options.length==1)
if(oSelect.options[0].value!='')
oSelect.removeChild(oSelect.options[0]);}}
function EliminarElementosSubListaMenosBlanco(oSelect)
{while(oSelect.options.length>1)oSelect.removeChild(oSelect.options[1]);if(oSelect.options.length==1)
{if(oSelect.options[0].value!="")
oSelect.removeChild(oSelect.options[0]);}
if(oSelect.options.length==0)
{oOption=document.createElement("OPTION");oOption.text='';oOption.value='';if(NavegadorIE())oSelect.add(oOption);else oSelect.appendChild(oOption);}}
function LlenarListaAsociadaOnFocus(oSelect,sLista,sElemento,bSoloListasPagina,bOrigenListaAsociada,oSelected)
{if(!NavegadorIE())
{LlenarListaAsociada(oSelect,sLista,sElemento,bSoloListasPagina,bOrigenListaAsociada,oSelected);}}
function LlenarListaAsociadaOnMouseOver(oSelect,sLista,sElemento,bSoloListasPagina,bOrigenListaAsociada,oSelected)
{try
{if(NavegadorIE())
{LlenarListaAsociada(oSelect,sLista,sElemento,bSoloListasPagina,bOrigenListaAsociada,oSelected);}}
catch(err)
{}}
function LlenarListaAsociada(oSelect,sLista,sElemento,bSoloListasPagina,bOrigenListaAsociada,oSelected)
{var i,oElemXML,bCargar,bListaCargada,sValor,xmlHttpReq;if(typeof sElemento.value!="undefined")
{sElemento=sElemento.value;if(oSelect[0].tagName!="OPTION")oSelect=oSelect[0];}
else
{sElemento=sElemento[0].value;if(oSelect[0].tagName!="OPTION")oSelect=oSelect[0];}
bListaCargada=false;sValor=oSelect.value;sCodElem="";for(i=0;i<sElemento.length;i++)
{if('-'==sElemento.substr(i,1))break;else sCodElem=sCodElem.concat(sElemento.substr(i,1));}
oElemXML=peticionListaAsincrona(sLista);if(oElemXML!=null)
{bListaCargada=LlenarListas(oSelect,oElemXML,sLista,sCodElem,bSoloListasPagina,oSelected);}
if(bListaCargada)
{oSelect.setAttribute("bPrimeraVez","N");if(bSoloListasPagina)oSelect.value=sValor;}
if(document.createEvent)
{try
{var ev=document.createEvent("HTMLEvents");ev.initEvent('change',true,true);oSelect.dispatchEvent(ev);}
catch(err)
{alert(err);}}
else if(document.createEventObject)
{oSelect.fireEvent("onchange");}}
function Longitud(sLista)
{try
{return peticionListaAsincrona(sLista).childNodes.length;}
catch(e)
{return 0;}}
function CargarListaMouseOver(oSelect,sLista)
{if(NavegadorIE())
CargarLista(oSelect,sLista);}
function CargarListaHijosEDC(sCombo,sValor)
{var sLista;var oComboColec;sLista=sListas.split('|');for(var j=0;j<sLista.length;j++)
{if(typeof aDinList[sLista[j]]!="undefined")
{oComboColec=aDinList[sLista[j]]['campos'].split("|")
for(var i=0;i<oComboColec.length;i++)
{if(oComboColec[i]==sCombo)
{CargarAndLlenarComboDinamicaEDC(document.getElementById(sCombo),sLista[j],sValor);return;}}}}}
function CargarListasEDC()
{var sLista;var oComboColec;var sValor;if(typeof(sListas)!="undefined")
{sLista=sListas.split('|')
for(var j=0;j<sLista.length;j++)
{if(typeof aDinList[sLista[j]]!="undefined")
{oComboColec=aDinList[sLista[j]]['campos'].split("|")
for(var i=0;i<oComboColec.length;i++)
{if(aDinCmp[oComboColec[i]]['lst']=='EDC')
{if(aDinCmp[oComboColec[i]]['fil']=='')
CargarAndLlenarComboDinamicaEDC(document.getElementById(oComboColec[i]),sLista[j],-1);else
{sValor=document.getElementById(aDinCmp[oComboColec[i]]['fil']).value;if(sValor!='')
CargarAndLlenarComboDinamicaEDC(document.getElementById(oComboColec[i]),sLista[j],sValor.split('-')[0]);}}}}}}}
function CargarSubListaEDC(oSelect)
{var sValor;var oHijo;if(typeof aListaPadres!="undefined")
{if(typeof aListaPadres[oSelect.id]!="undefined")
{sValor=oSelect.value.split("-");oHijo=document.getElementById(aListaPadres[oSelect.id]);EliminarElementosSubListaMenosBlanco(oHijo);if(typeof sValor[0]!="undefined")
{CargarListaHijosEDC(aListaPadres[oSelect.id],sValor[0]);}
else
{CargarListaHijosEDC(aListaPadres[oSelect.id],sValor);}}}}
function CargarAndLlenarComboDinamicaEDC(oSelect,sListaEDC,sValor)
{if(oSelect&&aDinCmp)
{if(oSelect.value=='')
{var sLista=sListaEDC;if((!aDinList[sLista]['cargada'])||(typeof aDinCmp[oSelect.id]['fbd']!="undefined"))
{EliminarElementosSubLista(oSelect);if(aDinCmp[oSelect.id]['fil']!='')
{var urlASP='../../forms_base/ListasEDC.asp?codigoWeb='+aDinCmp[oSelect.id]['web']+'&codigoConsulta='+aDinCmp[oSelect.id]['met']+'&tipo='+aDinCmp[oSelect.id]['tpc']+'&filtro='+aDinCmp[oSelect.id]['fbd']+'|$|'+sValor+'|$|varchar|$|1'+'&cod='+aDinCmp[oSelect.id]['cod']+'&des='+aDinCmp[oSelect.id]['des'];}
else
{var urlASP='../../forms_base/ListasEDC.asp?codigoWeb='+aDinCmp[oSelect.id]['web']+'&codigoConsulta='+aDinCmp[oSelect.id]['met']+'&tipo='+aDinCmp[oSelect.id]['tpc']+'&filtro='+'&cod='+aDinCmp[oSelect.id]['cod']+'&des='+aDinCmp[oSelect.id]['des'];}
var sNomCampo=oSelect.id;var aCampos=new Array(sNomCampo);var idtargetDIV='targetLst_'+sNomCampo;new Ajax.Listcompleter(sNomCampo,idtargetDIV,urlASP,new Array(),sLista,true,true,false).getValues();}
else
{LlenarComboDinamica(oSelect,true);}}
else
{LlenarComboDinamica(oSelect,true);}}}
function CargarLista(oSelect,sLista)
{var j,oElemXML,oElemento,oOption,bSelected,sIdSelected,bCargar,bBlanco,oBlanco;bSelected=true;bCargar=false;bBlanco=false;var oFormAlta=document.getElementById('frmAltaUsuario');if(oFormAlta&&!oSelect.options)
{var oListaCampos=oFormAlta.getElementsByTagName("select")
for(var i=0;i<oListaCampos.length;i++)
{if(oListaCampos[i].id==oSelect.id)
oSelect=oListaCampos[i];}}
sIdSelected=oSelect.value.split('-')[0];var count=1;for(var i=0;i<oSelect.options.length;i++){if(oSelect.options[i].value=="")
count++;}
if(oSelect.options.length-(count-1)<Longitud(sLista))
{bCargar=true;if((oSelect.options[0]!=null)&&(oSelect.options[0].value==""))
{bBlanco=true;oBlanco=oSelect.options[0].innerHTML;}}
if(bCargar)
{EliminarElementosSubListaMenosBlanco(oSelect);oElemXML=peticionListaAsincrona(sLista);if(oElemXML!=null)
{for(j=0;j<oElemXML.childNodes.length;j++)
{oElemento=oElemXML.childNodes[j];if(oElemento.nodeType!=3)
{oOption=document.createElement("OPTION");if(NavegadorIE()){oOption.text=oElemento.text;if(oSelect.id.substr(0,4)=="FIL_"){oOption.value=oElemento.getAttribute("i");}else{oOption.value=oElemento.getAttribute("i")+"-"+oElemento.text;}
if(bSelected&&oOption.value.split('-')[0]==sIdSelected)
{oOption.selected=true;}
oSelect.add(oOption);if(bSelected&&oOption.value.split('-')[0]==sIdSelected)
{oSelect.value=oOption.value;}}
else{oOption.text=oElemento.textContent;if(oSelect.id.substr(0,4)=="FIL_"){oOption.value=oElemento.getAttribute("i");}else{oOption.value=oElemento.getAttribute("i")+"-"+oElemento.textContent;}
oSelect.appendChild(oOption);if(bSelected&&oOption.value.split('-')[0]==sIdSelected)
{oOption.selected=true;oSelect.value=oOption.value;}}}}}
if(document.createEvent)
{var ev=document.createEvent("HTMLEvents");ev.initEvent("change",true,true);oSelect.dispatchEvent(ev);}
else if(document.createEventObject)
oSelect.fireEvent("onchange");}}
function CargarListaAsociada(oSelect,sLista,sElemento,bSoloListasPagina,bOrigenListaAsociada)
{CargarLista(oSelect,sLista);LlenarListaAsociada(oSelect,sLista,sElemento,bSoloListasPagina,bOrigenListaAsociada);}
function CargarListaSub(oSelect,oSelectPrev)
{var sLista;sLista=(oSelectPrev[0].value.split("-"))[0];if(oSelect[0].options.length<=2)
CargarLista(oSelect[0],sLista);}
function ActualizarListas()
{var i,aElementos,aElemAux,aListas,sName;aElementos=document.getElementsByTagName("SELECT");for(i=0;i<aElementos.length;i++)
{sName=aElementos.item(i).name;sName=sName.substr(0,sName.length-1)+'1';if(sName!=aElementos.item(i).name)
{if(window.location.search.indexOf('procedencia=Confirmacion')>=0){(aElementos.item(i))[1].selected=true;}
aListas=document.getElementsByName(sName);if(aListas.length>=12)
{aElemAux=document.getElementsByName(aElementos.item(i).name);LlenarListaAsociada(aListas.item(0),aElemAux.item(aElemAux.length-1).value,aElementos.item(i).value,true,false);}}}
aElementos=document.getElementsByTagName("INPUT");for(i=0;i<aElementos.length;i++)
{if(aElementos.item(i).type=="radio")
{if(aElementos.item(i).checked)
{sName=aElementos.item(i).name;sName=sName.substr(0,sName.length-1)+'1';if(sName!=aElementos.item(i).name)
{aListas=document.getElementsByName(sName);if(aListas.length>=12)
{aElemAux=document.getElementsByName(aElementos.item(i).name);LlenarListaAsociada(aListas.item(0),aElemAux.item(aElemAux.length-1).value,aElementos.item(i).value,true,false);}}}}}}
function InicializarFormulario()
{try
{InicializarCampos();var oDatosRepre=document.getElementById('datosRepresentante');var oCheckRepre=document.getElementById('checkRepresentante');if(oDatosRepre&&oCheckRepre)
{if(oCheckRepre.checked)
clickHandlerCheck(null,'datosRepresentante','checkRepresentante');}}
catch(ex)
{}
ActualizarListas();}
function ValidarDigitoControlCueBan(sEntidad,sOficina,sDC,sCuenta)
{if((sEntidad.length>0)&&(sOficina.length>0)&&(sCuenta.length>0))
{sDC=FormatearCadena(sDC,2,'0');if(sDC!=CalcularDigitosControlCueBan(sEntidad,sOficina,sCuenta))
{alert(strDCCuentaBancaria);}}}
function CalcularDigitosControlCueBan(sEntidad,sOficina,sCuenta)
{var sDC,sCode,iFirstDigit,iSecondDigit;sEntidad=FormatearCadena(sEntidad,4,'0');sOficina=FormatearCadena(sOficina,4,'0');sCuenta=FormatearCadena(sCuenta,10,'0');sCode=FormatearCadena(sEntidad+sOficina,10,'0');iFirstDigit=CalcularDigitoControlCueBan(sCode);iSecondDigit=CalcularDigitoControlCueBan(sCuenta);sDC=iFirstDigit.toString()+iSecondDigit.toString();return(sDC);}
function CalcularDigitoControlCueBan(sCadena)
{var k,iTemp,iDigito;var aCoef=new Array(1,2,4,8,5,10,9,7,3,6);iTemp=0;for(k=0;k<10;k++)
iTemp=iTemp+(sCadena.substr(k,1)*aCoef[k]);iTemp=11-(iTemp%11);switch(iTemp)
{case 10:iDigito=1;break;case 11:iDigito=0;break;default:iDigito=iTemp;}
return(iDigito);}
function FormatearCadena(sCadena,iCaracteres,sCaracter)
{var i;sResultado=sCadena;if(sCadena.length<iCaracteres)
{for(i=0;i<(iCaracteres-sCadena.length);i++)
{sResultado=sCaracter+sResultado;}}
return(sResultado);}
function ComprobarLongitudTexto(oTexto,lMaximo)
{if(lMaximo-oTexto.value.length<0)
oTexto.value=oTexto.value.substring(0,lMaximo);}
function LimitarTexto(oEvent,oTexto,lMaximo)
{var iKeyCode;iKeyCode=ObtenerTeclaPulsada(oEvent);if((oTexto.value.length>=lMaximo)&&(!TeclaFuncional(iKeyCode)))
{if(NavegadorIE())
{oEvent.cancelBubble=true;oEvent.returnValue=false;}
else
{oEvent.stopPropagation();oEvent.preventDefault();}}}
function CampoObligatorio(valor){}
function ModificarDatos(oFormulario)
{if(oFormulario==null)
{oFormulario=document.getElementsByName("frmConfirmacion").item(0);}
var surl=window.document.referrer;var aUrl;aUrl=surl.split('?');if(aUrl.lenght>1)
surl=aUrl[0]+'?procedencia=Confirmacion&'+aUrl[1];else
surl=aUrl[0]+'?procedencia=Confirmacion';oFormulario.action=surl;oFormulario.submit();}
var aCmpNoIni;function TieneSelected(aCampos)
{var booleano=false;for(j=0;j<aCampos.options.length;j++)
{if(aCampos.options[j].selected)
{booleano=booleano||true}}
return booleano;}
function EstablecerValorCampo(theForm,nombreCampo,valorCampo,habilitado)
{var aCampos,oCampo;var sName,aElemAux,aListas,i,sOrden,z;var bValorCompuesto;var aListaAux,aCamposAux;var iLength;var formLogin;try
{iLength=document.forms.length;for(z=0;z<iLength;z++){formLogin=document.forms[z];if(formLogin.id.substr(formLogin.id.length-9)=="_TABLOGIN"){theForm=formLogin}}
aCampos=window.document.getElementsByName(nombreCampo);iLength=aCampos.length;for(z=0;z<iLength;z++){if(aCampos[z].form.id==theForm.id){oCampo=aCampos[z];break;}}
if(oCampo==null&&aCampos.length>0)
oCampo=aCampos[0];if(oCampo!=null)
{if(oCampo.type=='checkbox')
{if(valorCampo=='S'){oCampo.checked=true;if(oCampo.disabled)
{document.getElementsByName(oCampo.name)[1].value="S";}
if(oCampo.title==''){var oRep;oRep=document.getElementById('datosRepresentante');oRep.style.display='';}}
else{oCampo.checked=false;}}
else
{if((oCampo.type=='select-one')||(oCampo.type=='radio'))
{bValorCompuesto=(valorCampo.indexOf('-')>0);if(oCampo.type=='select-one')
{if(typeof aDinCmp!="undefined")
{if(aDinCmp[nombreCampo])
{if(typeof aDinList[aDinCmp[nombreCampo]['lst']]!="undefined")
{if(aDinList[aDinCmp[nombreCampo]['lst']]['cargada']==false||oCampo.options.length<=2)
{aDinCmp[nombreCampo]['val']=valorCampo;return;}}
aListaAux=sListas.split("|")
for(var i=0;i<aListaAux.length;i++)
{aCamposAux=aDinList[aListaAux[i]]['campos'].split("|")
for(var j=0;j<aCamposAux.length;j++)
{if(aCamposAux[j]==nombreCampo)
{if(aDinList[aListaAux[i]]['cargada']==false)
{aDinCmp[nombreCampo]['val']=valorCampo;return;}}}}}}
sOrden=nombreCampo.substr(nombreCampo.length-1,1);if(sOrden=='0'||((sOrden!='1')&&(sOrden!='2')&&(sOrden!='3')&&(sOrden!='4'))||(((sOrden=='1')||(sOrden=='2')||(sOrden=='3')||(sOrden=='4'))&&((aCampos.length==11&&aCampos[0].disabled)||(aCampos.length==10&&!aCampos[0].disabled))))
{CargarLista(oCampo,aCampos[aCampos.length-1].value);}
for(i=0;i<oCampo.options.length;i++)
{var aPartes=oCampo.options[i].value.split('-');if(!bValorCompuesto)
{if(aPartes[0]==valorCampo)
{oCampo.value=oCampo.options[i].value;break;}}
else
{var auxValorCampo=valorCampo.split('-')
if(aPartes[0]==auxValorCampo[0])
{oCampo.value=oCampo.options[i].value;break;}}}}
else
{for(i=0;i<aCampos.length-1;i++)
{if(bValorCompuesto)
{if(aCampos[i].value==valorCampo)
{aCampos[i].checked=true;break;}}
else
{var aPartes=aCampos[i].value.split('-');if(aPartes[0]==valorCampo)
{valorCampo=aCampos[i].value;aCampos[i].checked=true;break;}}}}
sName=nombreCampo;sOrden=nombreCampo.substr(nombreCampo.length-1,1);switch(sOrden)
{case'0':sName=sName.substr(0,sName.length-1)+'1';break
case'1':sName=sName.substr(0,sName.length-1)+'2';break
case'2':sName=sName.substr(0,sName.length-1)+'3';break
case'3':sName=sName.substr(0,sName.length-1)+'4';break}
if(sName!=nombreCampo)
{aListas=document.getElementsByName(sName);if((aListas.length>11&&aListas[0].disabled)||(aListas.length>=11&&!aListas[0].disabled))
{aElemAux=document.getElementsByName(nombreCampo);LlenarListaAsociada(aListas,aElemAux.item(aElemAux.length-1).value,aElemAux,false,false);}}}
else
{if(!(valorCampo==''&&oCampo.value.split('|$|').length==2))
{oCampo.value=valorCampo.replace(/&euro;/g,"€");}
if((!NavegadorIE())&&((oCampo.getAttribute('onpropertychange')+'').indexOf('ActualizarFechaAndHora')>=0))
ActualizarFechaAndHora(nombreCampo);}}
if(oCampo.disabled&&((oCampo.type=='select-one')||((oCampo.type=='radio')||(oCampo.type=='checkbox')||(oCampo.type=='textarea'))))
{if(oCampo.type=='radio')
{for(i=0;i<aCampos.length-1;i++)
{if(aCampos[i].type!='radio')
{break;}}
aCampos[i].value=valorCampo;}
else if(oCampo.type=='select-one')
{if(aCampos.length==13||aCampos.length==11||aCampos.length==12)aCampos[1].value=oCampo.value;}
else
{aCampos[1].value=oCampo.value;}}
if(habilitado=='N'){oCampo.readOnly=true;}
else if(habilitado=='S'){oCampo.readOnly=false;}}
else
{if(!aCmpNoIni)
aCmpNoIni=new Array();aCmpNoIni[nombreCampo]=valorCampo;}}
catch(ex)
{}}
function InicializarPaginaServicio()
{var i,j,aElemOri,aElemDes,oCampoDes;for(i=0;i<aRFSCamposDestino.length;i++)
{aElemDes=document.getElementsByName(aRFSCamposDestino[i]);if(aElemDes.length>0)
{oCampoDes=aElemDes.item(0);aElemOri=document.getElementsByName(aRFSCamposOrigen[i]);if(aElemOri.length>0)
{if(oCampoDes.type=='radio')
{for(j=0;j<aElemDes.length;j++)
{if(aElemDes[j].type!='radio')break;else
{aElemDes[j].checked=(aElemDes[j].value==aElemOri.item(0).value);}}
if(oCampoDes.disabled)aElemDes[j].value=aElemOri.item(0).value;}
else if(oCampoDes.type=='checkbox')
{if(aElemOri.length>7)oCampoDes.checked=(aElemOri.item(0).value='S');else oCampoDes.checked=false;if(oCampoDes.disabled)
{if(oCampoDes.checked)aElemDes[1].value='S';else aElemDes[1].value='N';}}
else if((oCampoDes.type=='select-one')&&(oCampoDes.disabled))
{oCampoDes.value=aElemOri.item(0).value;aElemDes[1].value=aElemOri.item(0).value;}
else
oCampoDes.value=aElemOri.item(0).value;}}}}
function ConvertToPDF()
{var sEntidad,sIdioma,sNumInt,sDlg,sParametros,URL;sIdTramite=document.getElementById("IdTramite").value;sIdioma=document.getElementById("WTGIDIOMA").value;sNumInt=document.getElementById("NumInt").value;sEntidad=document.getElementById("WTGCODENT").value;sDlg=document.getElementById("Dlg").value;sParametros="sIdTramite="+sIdTramite+"&sNumInt="+sNumInt+"&sDlg="+sDlg+"&sEntidad="+sEntidad+"&Idioma="+sIdioma;URL="../../forms_base/convertToPdf.asp?"+sParametros;window.open(URL,"mywindow");}
function getDocHeight()
{var D=document;return Math.max(Math.max(D.body.scrollHeight,D.documentElement.scrollHeight),Math.max(D.body.offsetHeight,D.documentElement.offsetHeight),Math.max(D.body.clientHeight,D.documentElement.clientHeight));}
function establirAlturaDoc()
{var am=getDocHeight();document.body.style.height=am+"px";}
function InvocarFormularioValidadorCertificados(oFormulario)
{var oCampoTipoLoginOrigen,oCampoTipoLogin;oCampoTipoLoginOrigen=oFormulario.elements.namedItem('TIPO_LOGIN');if(oCampoTipoLoginOrigen)
{oCampoTipoLogin=document.FormLoginCertificatDigital.elements.namedItem('tipoLogin');if(oCampoTipoLogin)
{oCampoTipoLogin.value=oCampoTipoLoginOrigen.value;}}
oCampoTipoLoginOrigen=oFormulario.elements.namedItem('CLASE_TIPO_LOGIN');if(oCampoTipoLoginOrigen)
{oCampoTipoLogin=document.FormLoginCertificatDigital.elements.namedItem('claseTipoLogin');if(oCampoTipoLogin)
{oCampoTipoLogin.value=oCampoTipoLoginOrigen.value;}}
var sUrlVal=document.FormLoginCertificatDigital.elements.namedItem('urlValidador').value;if(sUrlVal.toLowerCase().indexOf("dlg/cer/dlgvalidarcertificado.aspx")==-1)
{if(sUrlVal.substr(sUrlVal.length-2,1)!="/")
{sUrlVal=sUrlVal+"/"}
sUrlVal=sUrlVal+"DLG/CER/dlgValidarCertificado.aspx";}
var sParamsVal='?tipoDlg=2&atributo=NIF&atributo=Nombre&atributo=Apellido1&atributo=Apellido2&atributo=EMail&atributo=Emisor';sParamsVal=sParamsVal+'&urlRespuesta='+escape(document.getElementsByName("urliFrame")[0].value);sParamsVal=sParamsVal+'&idioma='+document.FormLoginCertificatDigital.elements.namedItem('idioma').value
abrirDlgCross(sUrlVal+sParamsVal,520,300,strTitAppletCert,2,'no','tratarSelecCert()');}
function tratarSelecCert()
{if(typeof(m_absResDlg)=='undefined'||m_absResDlg==null)return;if(typeof(m_absResDlg['NIF'])!='undefined')
{var oCampo;oCampo=document.createElement('INPUT');oCampo.type='hidden';oCampo.name='NIF';oCampo.value=m_absResDlg['NIF'];document.FormLoginCertificatDigital.appendChild(oCampo);if(typeof(m_absResDlg['Nombre'])!='undefined')
{oCampo=document.createElement('INPUT');oCampo.type='hidden';oCampo.name='Nombre';oCampo.value=m_absResDlg['Nombre'];document.FormLoginCertificatDigital.appendChild(oCampo);}
if(typeof(m_absResDlg['Apellido1'])!='undefined')
{oCampo=document.createElement('INPUT');oCampo.type='hidden';oCampo.name='Apellido1';oCampo.value=m_absResDlg['Apellido1'];document.FormLoginCertificatDigital.appendChild(oCampo);}
if(typeof(m_absResDlg['Apellido2'])!='undefined')
{oCampo=document.createElement('INPUT');oCampo.type='hidden';oCampo.name='Apellido2';oCampo.value=m_absResDlg['Apellido2'];document.FormLoginCertificatDigital.appendChild(oCampo);}
if(typeof(m_absResDlg['EMail'])!='undefined')
{oCampo=document.createElement('INPUT');oCampo.type='hidden';oCampo.name='EMail';oCampo.value=m_absResDlg['EMail'];document.FormLoginCertificatDigital.appendChild(oCampo);}
if(typeof(m_absResDlg['Emisor'])!='undefined')
{oCampo=document.createElement('INPUT');oCampo.type='hidden';oCampo.name='Emisor';oCampo.value=m_absResDlg['Emisor'];document.FormLoginCertificatDigital.appendChild(oCampo);}
document.FormLoginCertificatDigital.submit();}}
function SelecCertCallback(sNIF,sNombre,sApellido1,sApellido2,sEMail,sEmisor)
{if(typeof(sNIF)!='undefined'&&sNIF.length)
{var oCampo;oCampo=document.createElement('INPUT');oCampo.type='hidden';oCampo.name='NIF';oCampo.value=sNIF;document.FormLoginCertificatDigital.appendChild(oCampo);if(typeof(sNombre)!='undefined'&&sNombre.length)
{oCampo=document.createElement('INPUT');oCampo.type='hidden';oCampo.name='Nombre';oCampo.value=sNombre;document.FormLoginCertificatDigital.appendChild(oCampo);}
if(typeof(sApellido1)!='undefined'&&sApellido1.length)
{oCampo=document.createElement('INPUT');oCampo.type='hidden';oCampo.name='Apellido1';oCampo.value=sApellido1;document.FormLoginCertificatDigital.appendChild(oCampo);}
if(typeof(sApellido2)!='undefined'&&sApellido2.length)
{oCampo=document.createElement('INPUT');oCampo.type='hidden';oCampo.name='Apellido2';oCampo.value=sApellido2;document.FormLoginCertificatDigital.appendChild(oCampo);}
if(typeof(sEMail)!='undefined'&&sEMail.length)
{oCampo=document.createElement('INPUT');oCampo.type='hidden';oCampo.name='EMail';oCampo.value=sEMail;document.FormLoginCertificatDigital.appendChild(oCampo);}
if(typeof(sEmisor)!='undefined'&&sEmisor.length)
{oCampo=document.createElement('INPUT');oCampo.type='hidden';oCampo.name='Emisor';oCampo.value=sEmisor;document.FormLoginCertificatDigital.appendChild(oCampo);}
document.FormLoginCertificatDigital.submit();}}
function updateInputDate(strDate,idField){var fieldDate=$(idField);var valor_antiguo=document.getElementById(idField).value;strDate=Transformar_Data(strDate);fieldDate.value=strDate;fieldDate.focus();fieldDate.blur();fieldDate.focus();if(fieldDate.onchange!=null)
{if(valor_antiguo.length>0)
{if(valor_antiguo.toString()!=fieldDate.value.toString())
{fieldDate.onchange();}}
else
{fieldDate.onchange();}}
if(document.getElementById('cal_'+idField)){Element.remove('cal_'+idField);}}
function mostrarCalendario(id,idField){var dimensions=Element.getDimensions(idField);var html_calendario='<div id="cal_'+idField+'" class="cont_calendario" style="display:none;"></div>';if(!document.getElementById('cal_'+idField)){new Insertion.After(id,html_calendario);clone_position(idField,'cal_'+idField,{offsetTop:dimensions.height});new Draggable('cal_'+idField,{revert:true});var fecha=$F(idField);var aFecha=fecha.split(' ');fecha=aFecha[0];var cal_0=new Calendarios(fecha,'cal_'+idField,'',-1,'',idField,{});Element.show('cal_'+idField);}else{Element.remove('cal_'+idField);cal_0='';}}
function clone_position(source,target){var options=Object.extend({setLeft:true,setTop:true,setWidth:false,setHeight:false,offsetTop:0,offsetLeft:0},arguments[2]||{})
source=$(source);var p=Position.page(source);target=$(target);var delta=[0,0];var parent=null;if(Element.getStyle(target,'position')=='absolute'){parent=Position.offsetParent(target);delta=Position.page(parent);}
if(parent==document.body){delta[0]-=document.body.offsetLeft;delta[1]-=document.body.offsetTop;}
if(options.setLeft)target.style.left=(p[0]-delta[0]+
options.offsetLeft)+'px';if(options.setTop)target.style.top=(p[1]-delta[1]+
options.offsetTop)+'px';if(options.setWidth)target.style.width=source.offsetWidth+'px';if(options.setHeight)target.style.height=source.offsetHeight+'px';}
function CargarFechaActual(){var oForms=document.getElementsByName("frmTramite");for(j=0;j<oForms.length;j++)
{var elementList=oForms[j].getElementsByTagName("input");for(i=0;i<elementList.length;i++)
{if(elementList[i].type=='hidden'&&elementList[i].value=='date')
{var idCampo=elementList[i].name
if(document.getElementById(idCampo+'0')&&document.getElementById(idCampo+'1'))
{FechaActual($(idCampo+'0'));HoraActual($(idCampo+'1'));}
else
{FechaActual($(idCampo));}}}}}
function EDC_fechaAccionCalendario(idCampo,sCampo){var oCampoFiltroCal=document.getElementById(idCampo);oCampoFiltroCal.value=sCampo;}
function CargaListaDinamicaById(idElemento)
{var oSelect=document.getElementById(idElemento);var actual;var value;var padre;if(!oSelect)return true;padre=oSelect.parentNode;var hijos=padre.childNodes;for(var i=1;i<hijos.length;i++)
{actual=hijos[i];if(actual.id==idElemento)
{value=actual.value;break;}}
CargarListaDinamicaByValue(idElemento,value);}
var gNumListasPorCargar=0;var gPestanaCargada;function CargarListasDinamicas()
{}
function CargarCombosDinamicasDe(oElemPadre)
{if(oElemPadre)
{var aCombos=oElemPadre.getElementsByTagName('SELECT');for(var i=0;i<aCombos.length;i++)
{if(EsComboDinamicaMaestra(aCombos[i]))
{CargarAndLlenarComboDinamica(aCombos[i]);}}}}
function EsComboDinamicaMaestra(oSelect)
{if(typeof aDinCmp!="undefined")
{if(typeof aDinCmp[oSelect.id]!="undefined")
if(typeof aDinList[aDinCmp[oSelect.id]['lst']]!="undefined")
if(aDinList[aDinCmp[oSelect.id]['lst']]['load']==true)return true;if(aDinCmp[oSelect.id])
if(aDinCmp[oSelect.id]['val']!='')
return true;}
return false;}
function CargarAndLlenarComboDinamica(oSelect)
{if(oSelect&&aDinCmp)
{if(oSelect.value=='')
{var sLista=aDinCmp[oSelect.id]['lst'];if(!aDinList[sLista]['cargada'])
{EliminarElementosSubLista(oSelect);var urlASP='../../forms_base/ListaDinamica.asp?IdLista='+sLista;var sNomCampo=oSelect.id;var aCampos=new Array(sNomCampo);var idtargetDIV='targetLst_'+sNomCampo;new Ajax.Listcompleter(sNomCampo,idtargetDIV,urlASP,new Array(),sLista,true,true,false).getValues();}
else
{LlenarComboDinamica(oSelect,true);}}
else
{LlenarComboDinamica(oSelect,true);}}}
function LlenarComboDinamica(oSelect)
{LlenarComboDinamica(oSelect,true);}
function LlenarComboDinamica(oSelect,bMantenerEstado)
{var bLlenar=false;var bStatus=oSelect.disabled;var sValor;if(!oSelect.options)bLlenar=true;else if(oSelect.options.length==0)bLlenar=true;else if(oSelect.options.length<=2)
{if(oSelect.options[0].value=='')bLlenar=true;}
if(bLlenar&&aDinCmp)
if(aDinCmp[oSelect.id])bLlenar=true;if(bLlenar)
{EliminarElementosSubLista(oSelect);var oTarget=document.getElementById('targetLst_'+oSelect.id);if(oTarget)
{if(NavegadorIE())
{var oListaElems=oTarget.XMLDocument.selectNodes("//e");if(oSelect.disabled&&oListaElems.length!=0)oSelect.disabled=false;for(i=0;i<oListaElems.length;i++)
{oOption=document.createElement("OPTION");oOption.text=oListaElems(i).nodeTypedValue;var sNombreCombo=oSelect.id;if(sNombreCombo.match("FIL_")||sNombreCombo.match("INF_")){oOption.value=oListaElems(i).getAttribute("i");}else{oOption.value=oListaElems(i).getAttribute("i")+"-"+oListaElems(i).nodeTypedValue;}
oSelect.add(oOption);}}
else
{var oLista=oTarget.childNodes[1].getElementsByTagName('E');if(oSelect.disabled&&oLista.length!=0)oSelect.disabled=false;var sNombreCombo=oSelect.id;if(sNombreCombo.match("FIL_")||sNombreCombo.match("INF_")){for(i=0;i<oLista.length;i++)
{oSelect.options[oSelect.options.length]=new Option(oLista[i].innerHTML,oLista[i].getAttribute('i'));}}else{for(i=0;i<oLista.length;i++)
{oSelect.options[oSelect.options.length]=new Option(oLista[i].innerHTML,oLista[i].getAttribute('i')+'-'+oLista[i].innerHTML);}}}
if(bMantenerEstado)
{oSelect.disabled=bStatus;}
if(aDinCmp[oSelect.id]['val']!='')
{EstablecerValorCampo(window.document,oSelect.id,aDinCmp[oSelect.id]['val'],'=');aDinCmp[oSelect.id]['val']='';}
else
{if(oSelect.options)
{if(oSelect.options.length==1)oSelect.selectedIndex=0;else if(oSelect.options.length==2){if(oSelect.options[0].value=='')oSelect.selectedIndex=1;}}}}
if(typeof aListaPadres[oSelect.id]!="undefined")
{sValor=oSelect.value.split("-");if(typeof sValor[0]!="undefined")
{CargarListaHijosEDC(aListaPadres[oSelect.id],sValor[0]);}
else
{CargarListaHijosEDC(aListaPadres[oSelect.id],sValor);}}}}
function LlenarUnValorComboDinamica(oSelect,bMantenerEstado)
{var bLlenar=false;var bStatus=oSelect.disabled;if(!oSelect.options)bLlenar=true;else if(oSelect.options.length==0)bLlenar=true;else if(oSelect.options.length==1)
{if(oSelect.options[0].value=='')bLlenar=true;}
if(bLlenar&&aDinCmp)
if(aDinCmp[oSelect.id])bLlenar=true;if(bLlenar)
{var oTarget=document.getElementById('targetLst_'+oSelect.id);if(oTarget)
{if(NavegadorIE())
{var oListaElems=oTarget.XMLDocument.selectNodes("//e");oSelect.disabled=(oListaElems.length==0);for(i=0;i<oListaElems.length;i++)
{if(aDinCmp[oSelect.id]['val'].split('-')[0]==oListaElems(i).getAttribute("i"))
{oOption=document.createElement("OPTION");oOption.text=oListaElems(i).nodeTypedValue;oOption.value=oListaElems(i).getAttribute("i")+"-"+oListaElems(i).nodeTypedValue;oSelect.add(oOption);}}}
else
{var oLista=oTarget.childNodes[1].getElementsByTagName('E');oSelect.disabled=(oLista.length==0);for(i=0;i<oLista.length;i++)
{if(aDinCmp[oSelect.id]['val'].split('-')[0]==oLista[i].getAttribute("i"))
{oSelect.options[oSelect.options.length]=new Option(oLista[i].innerHTML,oLista[i].getAttribute('i')+'-'+oLista[i].innerHTML);}}}
if(bMantenerEstado)
{oSelect.disabled=bStatus;}
EstablecerValorCampo(window.document,oSelect.id,aDinCmp[oSelect.id]['val'],'=');}
if(typeof aListaPadres[oSelect.id]!="undefined")
{CargarListaHijosEDC(aListaPadres[oSelect.id],oSelect.value);}}}
function CargarSubComboDinamica(oSelectDest,sListaPadre,sValor,sSubLista)
{if(oSelectDest)EliminarElementosSubLista(oSelectDest);if(window.location.search.indexOf('procedencia=Confirmacion')>=0)
{if(aDinList)
{if(aDinList[sListaPadre])
{if(aDinCmp[aDinList[sListaPadre]['campos']])
{ValorAux=aDinCmp[aDinList[sListaPadre]['campos']]['val'];}}
if(ValorAux.length>0)
{sValor=ValorAux;}}}
var urlASP='../../forms_base/SubListaDinamica.asp?IdListaPadre='+sListaPadre+'&valor='+sValor.split('-')[0]+'&IdSubLista='+sSubLista;var sNomCampo=oSelectDest.id;oSelectDest.disabled=true;var aCampos=new Array(sNomCampo);var idtargetDIV='targetLst_'+oSelectDest.id;if(typeof(aDinList)=='undefined')return;aDinList[sSubLista]['cargada']=false;new Ajax.Listcompleter(sNomCampo,idtargetDIV,urlASP,aCampos,sSubLista,true,false,false).getValues();}
var enabletabpersistence=1;var tabcontentIDs=new Object();var pestanaActual="";var selectedTabs=new Array();var idsTabs=new Array();function GetPagina()
{var aTmp=window.location.pathname.split('/');var idPagina=aTmp[aTmp.length-1].substring(0,32);return idPagina;}
function RecuperandoDatos()
{var resultado=false;var aTmp=window.location.search;aTmp=aTmp.toLowerCase();resultado=aTmp=="?procedencia=consulta";return resultado;}
function InicializarPestana(pestana)
{CargarCombosPestanaVisible(pestana);var idPagina=GetPagina();if(RecuperandoDatos()&&GetCampoValidacion(pestana)=="S")
{RecuperacionDatosLogicaNegocioPestana(idPagina,pestana);return;}
if(GetCampoValidacion(pestana)=="S")return;InicializacionLogicaNegocioPestana(idPagina,pestana);}
function CargarCombosPestanaVisible(idPestana)
{for(var k=0;k<idsTabs.length;k++)
{if(selectedTabs[idsTabs[k]])
{if(selectedTabs[idsTabs[k]].substring(0,idPestana.length)==idPestana)
idPestana=selectedTabs[idsTabs[k]];}}
CargarCombosDinamicasDe(document.getElementById(idPestana));}
function initializetabcontent(){var primeroDeTodos=true;idsTabs=arguments;for(var i=0;i<arguments.length;i++)
{var primeroDeTab=true;if(enabletabpersistence==0&&getCookieTab(arguments[i])!="")setCookieTab(arguments[i],"");var clickedontab=getCookieTab(arguments[i]);var ulobj=document.getElementById(arguments[i]);var ulist=ulobj.getElementsByTagName("li");for(var x=0;x<ulist.length;x++)
{var ulistlink=ulist[x].getElementsByTagName("a")[0];if(ulistlink.getAttribute("rel"))
{ulistlink.onclick=function(){if(validaPestana(pestanaActual)){expandcontent(this);pestanaActual=this.getAttribute("rel");for(var k=0;k<idsTabs.length;k++)
{if(idsTabs[k]!=this.parentNode.parentNode.id)
if(selectedTabs[idsTabs[k]].substring(0,pestanaActual.length)==pestanaActual)
pestanaActual=selectedTabs[idsTabs[k]];else
selectedTabs[idsTabs[k]]=pestanaActual;}
InicializarPestana(pestanaActual);}
return false;}
savetabcontentids(arguments[i],ulistlink.getAttribute("rel"));if(ulist[x].className=="selected"&&clickedontab=="")
{if(primeroDeTodos)
{primeroDeTodos=false;pestanaActual=ulistlink.getAttribute("rel");}
if(primeroDeTab)
{primeroDeTab=false;idsTabs[i]=arguments[i];selectedTabs[arguments[i]]=ulistlink.getAttribute("rel");}
expandcontent(ulistlink);}}}
if(clickedontab!="")
{var culistlink=getullistlinkbyId(arguments[i],clickedontab);if(typeof culistlink!="undefined"){expandcontent(culistlink);}
else{expandcontent(ulist[0].getElementsByTagName("a")[0]);}
if(primeroDeTodos){pestanaActual=culistlink.getAttribute("rel");primeroDeTodos=false;}
if(primeroDeTab){primeroDeTab=false;idsTabs[i]=arguments[i];selectedTabs[arguments[i]]=culistlink.getAttribute("rel");}
for(var k=0;k<idsTabs.length;k++)
{if(idsTabs[k]!=culistlink.parentNode.parentNode.id)
if(selectedTabs[idsTabs[k]])
if(selectedTabs[idsTabs[k]].substring(0,pestanaActual.length)==pestanaActual)
pestanaActual=selectedTabs[idsTabs[k]];}}}}
function validaPestana(idPestana,bSubmit)
{var oCampo,sMensajeError;var bError=false;var pestana=document.getElementById(idPestana);var listaInputs=pestana.getElementsByTagName('input');for(var i=0;i<listaInputs.length;i++)
{if((listaInputs[i].getAttribute('type')!="hidden")&&(listaInputs[i].getAttribute('onblur')!=null))
{if((((listaInputs[i].getAttribute('onblur')+'').indexOf('CampoObligatorio')>=0)&&(listaInputs[i].value.length==0))||((listaInputs[i].style.color=='Red')||(listaInputs[i].style.color=='red')))
{bError=true;oCampo=listaInputs[i];sMensajeError=strCampoObligatorio+' '+listaInputs[i].getAttribute('title').toUpperCase();}}
if(bError){break;}}
var listaInputs=pestana.getElementsByTagName('select')
for(i=0;i<listaInputs.length;i++)
{if((listaInputs[i].getAttribute('type')!="hidden")&&(listaInputs[i].getAttribute('onblur')!=null))
{if(((listaInputs[i].getAttribute('onblur')+'').indexOf('CampoObligatorio')>=0)&&(!listaInputs[i].disabled)&&(listaInputs[i].value.length==0))
{bError=true;oCampo=listaInputs[i];sMensajeError=strCampoObligatorio+' '+listaInputs[i].getAttribute('title').toUpperCase();}}
if(bError){break;}}
if(bError)
{actualizaCampoValidacion(idPestana,"N");alert(sMensajeError);if(oCampo.type!='hidden'){try{oCampo.focus();}catch(ex){}}
return false;}
else
{var aTmp=window.location.pathname.split('/');var idPagina=aTmp[aTmp.length-1].substring(0,32);if(!ValidacionLogicaNegocioPestana(idPagina,idPestana,bSubmit))
{actualizaCampoValidacion(idPestana,"N");return false;}
else
{actualizaCampoValidacion(idPestana,"S");return true;}}}
function GetCampoValidacion(nombrePestana)
{var oCampoVal=document.getElementById(nombreCampoValidacion(nombrePestana));return oCampoVal.value;}
function nombreCampoValidacion(nombrePestana)
{var nombreCampo="WTXVAL";var letra="a";i=nombrePestana.length;if(isNaN(nombrePestana.substr(i-1,1))){letra=nombrePestana.substr(i-1,1);nombrePestana=nombrePestana.substr(0,i-1);}
i=nombrePestana.length;while(isNaN(nombrePestana.substr(0))){nombrePestana=nombrePestana.substr(nombrePestana.length-(i--));}
if(nombrePestana.length==1){nombrePestana='0'+nombrePestana;}
nombreCampo=nombreCampo+nombrePestana+letra;return nombreCampo;}
function actualizaCampoValidacion(nombrePestana,valor)
{var oCampoVal=document.getElementById(nombreCampoValidacion(nombrePestana));if(oCampoVal)oCampoVal.value=valor;}
function expandcontent(linkobj)
{var oLoad=document.getElementById('tcontent0');var bMensajeCarga=false;if(typeof oLoad!='undefined')
{if(oLoad.style.display!='none')bMensajeCarga=true;}
var ulid=linkobj.parentNode.parentNode.id;var ullist=document.getElementById(ulid).getElementsByTagName("li");for(var i=0;i<ullist.length;i++)
{ullist[i].className="";if(typeof tabcontentIDs[ulid][i]!="undefined"){document.getElementById(tabcontentIDs[ulid][i]).style.display="none";}}
if((pestanaActual!='')||(pestanaActual==linkobj.getAttribute("rel")))
{if(!bMensajeCarga||ulid!='maintab')
{linkobj.parentNode.className="selected";document.getElementById(linkobj.getAttribute("rel")).style.display="block";saveselectedtabcontentid(ulid,linkobj.getAttribute("rel"));}
else
{oLoad.style.display="block";document.getElementById(linkobj.getAttribute("rel")).style.display="none";gPestanaCargada=linkobj;}}
else
{if(pestanaActual==''&&typeof oLoad=='undefined')
{linkobj.parentNode.className="selected";document.getElementById(linkobj.getAttribute("rel")).style.display="block";}
else
{oLoad.style.display="block";document.getElementById(linkobj.getAttribute("rel")).style.display="none";}}
self.scroll(0,0);}
function expandtab(tabcontentid,tabnumber){var thetab=document.getElementById(tabcontentid).getElementsByTagName("a")[tabnumber];if(thetab.getAttribute("rel")){expandcontent(thetab);}}
function savetabcontentids(ulid,relattribute){if(typeof tabcontentIDs[ulid]=="undefined"){tabcontentIDs[ulid]=new Array();}tabcontentIDs[ulid][tabcontentIDs[ulid].length]=relattribute;}
function saveselectedtabcontentid(ulid,selectedtabid){if(enabletabpersistence==1)setCookieTab(ulid,selectedtabid);}
function getCookieTab(Name){return"";var re=new RegExp(Name+"=[^;]+","i");if(document.cookie.match(re)){return document.cookie.match(re)[0].split("=")[1];}return"";}
function setCookieTab(name,value){document.cookie=name+"="+value;}
function getullistlinkbyId(ulid,tabcontentid){var ullist=document.getElementById(ulid).getElementsByTagName("li");for(var i=0;i<ullist.length;i++)
{if(ullist[i].getElementsByTagName("a")[0].getAttribute("rel")==tabcontentid){return ullist[i].getElementsByTagName("a")[0];break;}}}
function showElementsTab(oEvent,theForm,idPestana){var oBtnAceptar,idPagina,oSelTab;if(NavegadorIE())oBtnAceptar=oEvent.srcElement;else oBtnAceptar=oEvent.target;if(oBtnAceptar!=null)oBtnAceptar.disabled=true;var aTmp=window.location.pathname.split('/');idPagina=aTmp[aTmp.length-1].substring(0,32);oSelTab=document.getElementById('WTXSELTAB');if(oSelTab)oSelTab.value=idPestana;if(!validaPestana(idPestana,true))
{if(oBtnAceptar!=null)oBtnAceptar.disabled=false;if(NavegadorIE())
{oEvent.cancelBubble=true;oEvent.returnValue=false;}
else
{oEvent.stopPropagation();oEvent.preventDefault();}}
else
{var oSend=document.getElementById('tcontent0b');if(oSend)
{document.getElementById(idPestana).style.display='none';oSend.style.display='block';self.scroll(0,0);}
if(winAttachEDF)
{if(!winAttachEDF.closed)winAttachEDF.close();}
if(hayElementoFirma(theForm))
{if(firmar(theForm,theForm.FIRMA_SOLICITUD,oEvent))
{theForm.submit();}}
else
{theForm.submit();}}}
function FinCargaListasDinamicas()
{var oLoad=document.getElementById('tcontent0');if((typeof oLoad!='undefined')&&(typeof gPestanaCargada!='undefined'))
{oLoad.style.display='none';expandcontent(gPestanaCargada);gPestanaCargada=undefined;}}
function pintaFondoCampo(oCampo){if(oCampo.value==""&&(oCampo.onblur+' ').indexOf('CampoObligatorio')>=0)
{oCampo.style.backgroundColor=colorAvisoCampoVacio;}else{oCampo.style.backgroundColor="white";}}
function getNewForm(){var submitForm=document.createElement("FORM");document.body.appendChild(submitForm);submitForm.method="POST";return submitForm;}
function createNewFormElement(inputForm,elementName,elementValue){var newElement=document.createElement("input");newElement.value=elementValue;newElement.name=elementName;newElement.type="hidden";inputForm.appendChild(newElement);return newElement;}
function crearCampoForm(tag,name)
{var oCampo;if(NavegadorIE())
{oCampo=document.createElement('<'+tag+' name="'+name+'">');}
else
{oCampo=document.createElement(tag);oCampo.setAttribute('name',name);}
return oCampo;}
function AbrirFormSeleccAdjuntos(sCampoImagen,link)
{var oFormLink,oAttachments,i,oCampoOri,oCampoDes,iLeft,iTop,iWidth,iHeight,sFeatures,sEnlace,sEstilo,iIni,iFin,iNumCampAtt,paramsGenerales;paramsGenerales="";oFormLink=document.getElementById('frmLink');while(oFormLink.childNodes.length>0)
oFormLink.removeChild(oFormLink.childNodes.item(0));oAttachments=document.getElementsByTagName('span');iNumCampAtt=0;for(j=0;j<oAttachments.length;j++)
{if(oAttachments.item(j).id.substring(0,15)=='spanAttachFiles')
{iNumCampAtt++;for(i=0;i<oAttachments.item(j).childNodes.length;i++)
{oCampoOri=oAttachments.item(j).childNodes.item(i);oCampoDes=document.createElement('INPUT');oCampoDes.type='hidden';oCampoDes.name=oCampoOri.name;oCampoDes.value=oCampoOri.value;if(oCampoOri.name!=undefined&&oCampoOri.name!=undefined)
oFormLink.appendChild(oCampoDes);}
var hiddens=link.getElementsByTagName("input");for(i=0;i<hiddens.length;i++)
{if(hiddens.item(i).name=="maxArchivos")
{paramsGenerales="&maxArchivos="+hiddens.item(i).value;}
if(hiddens.item(i).name=="extensionesAdmitidas")
{paramsGenerales+="&extensionesAdmitidas="+hiddens.item(i).value;}}}}
if(iNumCampAtt>0)
{iWidth=530;iHeight=350;iLeft=Math.round((window.screen.availWidth-iWidth)/2);if(iLeft<0)iLeft=0;iTop=Math.round((window.screen.availHeight-iHeight)/2);if(iTop<0)iTop=0;sFeatures="height="+iHeight+",width="+iWidth+",left="+iLeft+",top="+iTop+",scrollbars=1,directories=no,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,titlebar=no"
winAttachEDF=window.open('about:blank','winAttachFiles',sFeatures);sEnlace='../src/asp/selecFicheros/SelecFicheros.asp';if(sCSS.length>0)
sParamEstilo='?css='+sCSS;else
{if(document.styleSheets.length>0){var z=document.styleSheets.length-1;var strSearch;while(z>=0){if(document.styleSheets.item(z).media.mediaText){strSearch=new String(document.styleSheets.item(z).media.mediaText);}else{strSearch=new String(document.styleSheets.item(z).media);}
strHref=new String(document.styleSheets.item(z).href);if(strSearch.search(/print/i)==-1&&strHref.search(/tiny/i)==-1){sEstilo=document.styleSheets.item(z).href;break;}
z--;}}
if(sEstilo==null)
{sEstilo="";}
var i=2;var sParamEstilo="";while((sEstilo=="")&&(i<=document.styleSheets.length))
{sEstilo=document.styleSheets.item(document.styleSheets.length-i).href;i++;}
if(sEstilo!="")
{iIni=sEstilo.lastIndexOf('/');iFin=sEstilo.lastIndexOf('.');if((iIni>=0)&&(iFin>=0)&&(iIni<iFin))
sParamEstilo='?css='+sEstilo.substr(iIni+1,iFin-iIni-1);}}
if(sParamEstilo!="")
sEnlace=sEnlace+sParamEstilo+'&img='+sCampoImagen+paramsGenerales;else
sEnlace=sEnlace+'?img='+sCampoImagen+paramsGenerales;oFormLink.action=sEnlace;oFormLink.target='winAttachFiles';oFormLink.submit();if(winAttachEDF)winAttachEDF.focus();}}
function AnadirFicheroAdjuntoFormulario(sKey,sNombre,sTamano,sId,sCampoImagen,vaFirmado)
{var oSpanCampos,oSpanTexto,oCampo,sTexto;if(!(vaFirmado=='true'||vaFirmado==true))
{vaFirmado=false;}
oSpanCampos=document.getElementById('spanAttachFiles'+sCampoImagen);if(oSpanCampos)
{oCampo=crearCampoForm("INPUT",sKey);oCampo.type='hidden';oCampo.value=sNombre;oSpanCampos.appendChild(oCampo);oCampo=crearCampoForm("INPUT",sKey);oCampo.type='hidden';oCampo.value=sTamano;oSpanCampos.appendChild(oCampo);oCampo=crearCampoForm("INPUT",sKey);oCampo.type='hidden';oCampo.value=sId;oSpanCampos.appendChild(oCampo);if(sCampoImagen!='')
{oSpanCampos.appendChild(oCampo);oCampo=document.createElement('INPUT');oCampo.type='hidden';oCampo.name=sKey;oCampo.value=sCampoImagen;oSpanCampos.appendChild(oCampo);}
else
{oSpanCampos.appendChild(oCampo);oCampo=crearCampoForm("INPUT",sKey);oCampo.value=sCampoImagen;oCampo.type='hidden';oCampo.name=sKey;oSpanCampos.appendChild(oCampo);}
oSpanTexto=document.getElementById('spanAttachText'+sCampoImagen);if(oSpanTexto.getElementsByTagName("ul").length<1)
{oCampo=document.createElement('UL');oSpanTexto.appendChild(oCampo);}
oSpanTexto=oSpanTexto.getElementsByTagName("ul")[0];if(oSpanTexto)
{oCampo=crearCampoForm("LI",sKey.replace('fileAttach','fileAttachLi'));oCampo.id=sKey.replace('fileAttach','fileAttachLi');oCampo.innerHTML=sNombre+' ('+sTamano+' Mb)';if(vaFirmado=="true")
{oCampo.innerHTML+="<span><img alt='Firmado'  src='"+document.getElementsByName('imagenFirmados')[0].value+"'/><span>";}
oSpanTexto.appendChild(oCampo);}
if(!document.getElementById('spanAttachFirmas'))
{oCampo=document.createElement('SPAN');oCampo.name='spanAttachFirmas';oCampo.id='spanAttachFirmas';oSpanTexto=document.getElementById('spanAttachText'+sCampoImagen).parentNode.appendChild(oCampo)}
oCampo=crearCampoForm("INPUT",sKey.replace('fileAttach','fileAttachFirma'));oCampo.type="hidden";oCampo.value=vaFirmado;document.getElementById('spanAttachFirmas').appendChild(oCampo);}}
function Base64Encode(sTextoAConvertir)
{var sURL;sURL="../../forms_base/convertbase64.asp";sTextoAConvertir=escape(sTextoAConvertir);if(NavegadorIE())
{xmlHttpReq=new ActiveXObject("MSXML2.XMLHTTP");xmlHttpReq.open("POST",sURL,false);xmlHttpReq.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlHttpReq.send("entrada="+sTextoAConvertir);}
else
{xmlHttpReq=new XMLHttpRequest();xmlHttpReq.open("POST",sURL,false);xmlHttpReq.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlHttpReq.send("entrada="+sTextoAConvertir);}
return xmlHttpReq.responseText;}
function ObtenerContenidoFichero(sIdEntidad,sIdioma,sIdFichero,bBase64)
{var sURL;sURL="../Comun/Ficheros.asp?id="+sIdEntidad+"&idioma="+sIdioma+"&fichero="+sIdFichero+"&base64="+bBase64
if(NavegadorIE())
{xmlHttpReq=new ActiveXObject("MSXML2.XMLHTTP");xmlHttpReq.open("GET",sURL,false);xmlHttpReq.send("");}
else
{xmlHttpReq=new XMLHttpRequest();xmlHttpReq.open("GET",sURL,false);xmlHttpReq.send("");}
return xmlHttpReq.responseText;}
function VisualizarFicheroAdjunto(sIdEntidad,sNomTab,sTraGen,sOrden,sIdFichero,sOrigen,sIdioma)
{iWidth=600;iHeight=480;sIdioma=sIdioma.split("|$FIRMA$|")[0];iLeft=Math.round((window.screen.availWidth-iWidth)/2);if(iLeft<0)iLeft=0;iTop=Math.round((window.screen.availHeight-iHeight)/2);if(iTop<0)iTop=0;sFeatures="height="+iHeight+",width="+iWidth+",left="+iLeft+",top="+iTop+",directories=no,status=yes,toolbar=no,menubar=yes,location=no,resizable=yes,titlebar=no"
sEnlace='../src/asp/selecFicheros/DescargaFichero.asp';sEnlace=sEnlace+'?sIdEntidad='+sIdEntidad+'&sNomTab='+sNomTab+'&sTraGen='+sTraGen+'&sOrden='+sOrden+'&sIdFichero='+sIdFichero+'&sOrigen='+sOrigen+'&sIdioma='+sIdioma;if(sCSS.length>0)sEnlace=sEnlace+'&css='+sCSS;else
{sEstilo=document.styleSheets.item(document.styleSheets.length-1).href;iIni=sEstilo.lastIndexOf('/');iFin=sEstilo.lastIndexOf('.');if((iIni>=0)&&(iFin>=0)&&(iIni<iFin))
{sEnlace=sEnlace+'&css='+sEstilo.substr(iIni+1,iFin-iIni-1);}}
winAttachEDF=window.open(sEnlace,'_blank',sFeatures);winAttachEDF.focus();}
function DescargaFicheroServer(sFilePath)
{iWidth=600;iHeight=480;iLeft=Math.round((window.screen.availWidth-iWidth)/2);if(iLeft<0)iLeft=0;iTop=Math.round((window.screen.availHeight-iHeight)/2);if(iTop<0)iTop=0;sFeatures="height="+iHeight+",width="+iWidth+",left="+iLeft+",top="+iTop+",directories=no,status=yes,toolbar=no,menubar=yes,location=no,resizable=yes,titlebar=no"
sEnlace='../src/asp/selecFicheros/DescargaFicheroServer.asp';oFormLink=document.getElementById('frmLink');while(oFormLink.childNodes.length>0)
oFormLink.removeChild(oFormLink.childNodes.item(0));oCampoOculto=document.getElementById(sFilePath);oCampoOculto.name='path';oFormLink.appendChild(oCampoOculto);oCampo=document.getElementById('EDC_ID_VENTANA');if(oCampo!=null)sNombreVentana=oCampo.value;else sNombreVentana='EDC_link';oVentana=window.open('about:blank',sNombreVentana,sFeatures);oFormLink.target=sNombreVentana;oFormLink.action=sEnlace;oVentana.focus();oFormLink.submit();}
var winAttachEDF;function SeleccionarFicheros(e)
{var targ;if(!e)
{var e=window.event;}
if(e.target)
{targ=e.target;}
else if(e.srcElement)
{targ=e.srcElement;}
if(targ.nodeType==3)
{targ=targ.parentNode;}
targ=targ.parentNode.parentNode.parentNode;AbrirFormSeleccAdjuntos('',targ);}
function SeleccionarFicherosFirmar()
{if(document.getElementById("spanAttachText").getElementsByTagName("LI").length>0)
{AbrirFormSeleccAdjuntosFirmar('');}}
function SeleccionarImagen(sCampoImagen,e)
{var targ;if(!e)
{var e=window.event;}
if(e.target)
{targ=e.target;}
else if(e.srcElement)
{targ=e.srcElement;}
if(targ.nodeType==3)
{targ=targ.parentNode;}
targ=targ.parentNode.parentNode.parentNode;AbrirFormSeleccAdjuntos(sCampoImagen,targ);}
function AbrirFormSeleccAdjuntosFirmar(sCampoImagen)
{var oFormLink,oAttachments,i,oCampoOri,oCampoDes,iLeft,iTop,iWidth,iHeight
var sFeatures,sEnlace,sEstilo,iIni,iFin,iNumCampAtt,sNumero,sFirma,i2,sListaFicheros;oFormLink=document.getElementById('frmLink');while(oFormLink.childNodes.length>0)
oFormLink.removeChild(oFormLink.childNodes.item(0));if(!document.getElementById('spanAttachFirmas'))
{oCampoDes=document.createElement('SPAN');oCampoDes.name='spanAttachFirmas';oCampoDes.id='spanAttachFirmas';document.getElementById('spanAttachFiles').parentNode.insertBefore(oCampoDes,null);}
oAttachments=document.getElementsByTagName('span');iNumCampAtt=0;sListaFicheros="";for(j=0;j<oAttachments.length;j++)
{if(oAttachments.item(j).id.substring(0,15)=='spanAttachFiles')
{for(i=0;i<oAttachments.item(j).childNodes.length-1;i=i+4)
{i2=0;while(i2<4)
{oCampoOri=oAttachments.item(j).childNodes.item(i+i2);oCampoDes=crearCampoForm('INPUT',oCampoOri.name);oCampoDes.setAttribute('type','hidden');oCampoDes.setAttribute('value',oCampoOri.value);if(oCampoOri.name!=undefined)
oFormLink.appendChild(oCampoDes);i2++;}
sListaFicheros+=oCampoOri.name+"|";sNumero=oCampoDes.name.replace(/fileAttach/g,'');sFirma=document.getElementsByName("fileAttachFirma"+sNumero);oCampoDes=crearCampoForm("INPUT","fileAttachFirma"+sNumero);oCampoDes.setAttribute('type','hidden');if(sFirma.length==1)
{oCampoDes.setAttribute('value',sFirma[0].value);oFormLink.appendChild(oCampoDes);}
else
{oCampoDes.setAttribute('value','false');oFormLink.appendChild(oCampoDes);document.getElementById("spanAttachFirmas").appendChild(oCampoDes)}
iNumCampAtt++;}}}
oCampoDes=document.createElement('INPUT');oCampoDes.type='hidden';oCampoDes.name='ListaFicheros';oCampoDes.value=sListaFicheros;oFormLink.appendChild(oCampoDes);if(iNumCampAtt>0)
{iWidth=450;iHeight=350;iLeft=Math.round((window.screen.availWidth-iWidth)/2);if(iLeft<0)iLeft=0;iTop=Math.round((window.screen.availHeight-iHeight)/2);if(iTop<0)iTop=0;sFeatures="height="+iHeight+",width="+iWidth+",left="+iLeft+",top="+iTop+",directories=no,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,titlebar=no,scrollbars=yes"
winAttachEDF=window.open('about:blank','winAttachSign',sFeatures);sEnlace='../src/asp/selecFicheros/firmarFicheros.asp';if(sCSS.length>0)
sParamEstilo='?css='+sCSS;else
{if(document.styleSheets.length>0)
{sEstilo=document.styleSheets.item(document.styleSheets.length-1).href;}
if(sEstilo==null)
{sEstilo="";}
var i=2;var sParamEstilo="";while((sEstilo=="")&&(i<=document.styleSheets.length))
{sEstilo=document.styleSheets.item(document.styleSheets.length-i).href;i++;}
if(sEstilo!="")
{iIni=sEstilo.lastIndexOf('/');iFin=sEstilo.lastIndexOf('.');if((iIni>=0)&&(iFin>=0)&&(iIni<iFin))
sParamEstilo='?css='+sEstilo.substr(iIni+1,iFin-iIni-1);}}
if(sParamEstilo!="")
sEnlace=sEnlace+sParamEstilo+'&img='+sCampoImagen;else
sEnlace=sEnlace+'?img='+sCampoImagen;oFormLink.action=sEnlace;oFormLink.target='winAttachSign';oFormLink.method='POST';oFormLink.submit();if(winAttachEDF)winAttachEDF.focus();}}
var gNumAdjuntos=0;function EstablecerValorCampoImagen(theForm,nombreCampo,valorCampo)
{var oHiddenImg,oTextoSpan,oFilesSpan;var sName,aElemAux,aListas,i;var bValorCompuesto;var aFirma,sFirma,oSpanFirmas
try
{oHiddenImg=theForm.getElementById(nombreCampo);if(oHiddenImg)
oHiddenImg.value=valorCampo;aFirma=valorCampo.split('|$|');if(aFirma.lenght>0)
{sFirma=aFirma[1]}
sFirma=false;valorCampo=aFirma[0]
aListas=aFirma;var oSpanCampos,oSpanTexto,oCampo,sTexto;oSpanCampos=document.getElementById('spanAttachFiles'+nombreCampo);oSpanFirmas=document.getElementById('spanAttachFirmas');if(oSpanCampos)
{oCampo=crearCampoForm('INPUT','fileAttach'+gNumAdjuntos);oCampo.setAttribute('type','hidden');oCampo.setAttribute('value',aListas[5]);oSpanCampos.appendChild(oCampo);oCampo=crearCampoForm('INPUT','fileAttach'+gNumAdjuntos);oCampo.setAttribute('type','hidden');oCampo.setAttribute('value',0);oSpanCampos.appendChild(oCampo);oCampo=crearCampoForm('INPUT','fileAttach'+gNumAdjuntos);oCampo.setAttribute('type','hidden');oCampo.setAttribute('value',aListas[4]);oSpanCampos.appendChild(oCampo);oCampo=crearCampoForm('INPUT','fileAttach'+gNumAdjuntos);oCampo.setAttribute('type','hidden');oCampo.setAttribute('value',nombreCampo);oSpanCampos.appendChild(oCampo);oSpanTexto=document.getElementById('spanAttachText'+nombreCampo);if(oSpanTexto)
{if(oSpanTexto.getElementsByTagName("ul").length<1)
{oCampo=document.createElement('UL');oSpanTexto.appendChild(oCampo);}
oSpanTexto=oSpanTexto.getElementsByTagName("ul")[0];oCampo=crearCampoForm('LI','fileAttachLi'+gNumAdjuntos);oCampo.id='fileAttachLi'+gNumAdjuntos;oCampo.innerHTML=aListas[5];if(sFirma)
oSpanTexto.innerHTML+="<span><img alt='Firmado'  src='"+document.getElementsByName('imagenFirmados')[0].value+"'/><span>";oSpanTexto.appendChild(oCampo);}
gNumAdjuntos++;if(!document.getElementById('spanAttachFirmas'))
{oCampo=document.createElement('SPAN');oCampo.name='spanAttachFirmas';oCampo.id='spanAttachFirmas';document.getElementById('spanAttachFiles').parentNode.insertBefore(oCampoDes,null);}}}
catch(ex)
{}}
function EstablecerValorListaAdjuntos(theForm,listaAdjuntos)
{var aFiles=listaAdjuntos.split('|$$|');var arrayFirmas;var vaFirmado=false;var aData;for(var i=0;i<aFiles.length;i++)
{if(aFiles[i]!='')
{arrayFirmas=aFiles[i].split('|$FIRMA$|');if(arrayFirmas.length==1)
{vaFirmado=false;}
else
{vaFirmado=arrayFirmas[1];}
aFiles[i]=arrayFirmas[0];aData=aFiles[i].split('|$|');descargarAdjuntoPasados(aData[0],aData[1],aData[2],aData[3],aData[4],aData[5],aData[aData.length-1])
AnadirFicheroAdjuntoFormulario('fileAttach'+gNumAdjuntos,aData[5],0,aData[4],'',vaFirmado);gNumAdjuntos++;}}}
function descargarAdjuntoPasados(sIdEntidad,sNomTab,sTraGen,sOrden,sIdFichero,sOrigen,sIdioma)
{var sURL;var sParams;sParams="sIdEntidad="+sIdEntidad+"&sNomTab="+sNomTab+"&sTraGen="+sTraGen+"&sOrden="+sOrden+"&sIdFichero="+sIdFichero+"&sOrigen=TraGen&sIdioma="+sIdioma;sURL="../src/asp/selecFicheros/DescargaFicheros.asp?"+sParams
makePOSTRequest("../src/asp/selecFicheros/DescargaFicheros.asp",sParams);}
function makePOSTRequest(url,parameters){http_request=false;if(window.XMLHttpRequest){http_request=new XMLHttpRequest();if(http_request.overrideMimeType){http_request.overrideMimeType('text/html');}}else if(window.ActiveXObject){try{http_request=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{http_request=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}}}
if(!http_request){alert('Cannot create XMLHTTP instance');return false;}
http_request.open('POST',url,false);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.setRequestHeader("Content-length",parameters.length);http_request.setRequestHeader("Connection","close");http_request.send(parameters);return http_request.responseText;}
var oFirma;function objetoFirma()
{var respuesta;this.sXmlDoc;this.signature;this.theForm;this.absArchivo='N';this.proveedor='';this.avisar='N';this.ejecutar='N';this.estilo='GRIS';this.timestamp='N';if(window.location.href.lastIndexOf("?")>0||window.location.href.lastIndexOf("#")>0)
{respuesta=window.location.href;if(respuesta.lastIndexOf("?")>0)
{respuesta=respuesta.substring(0,window.location.href.lastIndexOf("?"))}
if(respuesta.lastIndexOf("#")>0)
{respuesta=respuesta.substring(0,window.location.href.lastIndexOf("#"))}}
else
{respuesta=window.location.href;}
this.urlRespuesta=respuesta+'/../../../forms_base/FirmaRespuesta.asp';this.targetRespuesta='frmRespuestaFirma';this.identificadores=''
this.firmas=''
this.NIF=''
if(document.getElementsByName("WTXNIFUSU").length>0)
{this.NIF=document.getElementsByName("WTXNIFUSU")[0].value}
if(this.NIF==''&&document.getElementsByName("WTXDNIFIR").length>0)
{if(document.getElementsByName("WTXDNIFIR")[0].value.length>0)
{this.NIF=document.getElementsByName("WTXDNIFIR")[0].value}
var NIFUSU=crearCampoForm("input","WTXNIFUSU");NIFUSU.setAttribute("type","hidden");NIFUSU.value=this.NIF;document.getElementsByName("WTXDNIFIR")[0].parentNode.insertBefore(NIFUSU,document.getElementsByName("WTXDNIFIR")[0]);}
this.vaFirmado=false
this.ventana
this.realizada=false;}
function hayElementoFirma(theForm)
{return(firmarElTramite(theForm)||hayAdjuntosAFirmar(theForm));}
function firmarElTramite(theForm)
{return(theForm.elements.namedItem('FIRMA_SOLICITUD')!=null);}
function hayAdjuntosAFirmar(theForm)
{var input;var i=0;var hayadjuntos=false;if(theForm.name!="")
{input=document.getElementsByName(theForm.name)[0].getElementsByTagName("input");while(i<input.length&&!hayadjuntos)
{if(input[i].type=="hidden"&&(input[i].id.substring(0,15)=="fileAttachFirma"||input[i].name.substring(0,15)=="fileAttachFirma"))
{if(input[i].value=="true")
hayadjuntos=true;}
i++;}
if(hayadjuntos)
{if(document.getElementsByName("frmRespuestaFirma").length==0)
{hayadjuntos=false;}}}
return hayadjuntos;}
function hayElementoIdCertificado(theForm)
{return(theForm.elements.namedItem('ID_CERTIFICADO').value!="#|#");}
function firmar(theForm,oEvent)
{var name,value;var sXmlCampo,sTextoAFirmarTemp,sFirma;var bTipoLista,bTipoSubLista
var numElems,z;var aCod;var oBtnAceptar,oBtnAtras;var sIdEntidad,sIdioma;var bOk,bJaDecimal;var iNumDecimales,sXmlDocTemp,oFormLink;var parentFormLink,bQuitadoFormLink;PonerCortinaEspera(strFirmando);oFormLink=document.getElementById('frmLink');if(oFormLink!=null)
{if(oFormLink.length>0)
{parentFormLink=oFormLink.parentNode;parentFormLink.removeChild(oFormLink);bQuitadoFormLink=true;}}
oFirma=new objetoFirma();oFirma.theForm=theForm;oFirma.signature=oFirma.theForm.FIRMA_SOLICITUD;oFirma.vaFirmado=firmarElTramite(theForm);buscarIdentificadoresFirma();bOk=true;sTextoAFirmarTemp="";sXmlDocTemp="<datosFirma><campos>";if(theForm.elements.namedItem('WTGCODENT'))
{sIdEntidad=theForm.elements.namedItem('WTGCODENT').value;}
if(theForm.elements.namedItem('WTGIDIOMA'))
{sIdioma=theForm.elements.namedItem('WTGIDIOMA').value;}
value=theForm.elements[0].value;for(i=0;i<theForm.length;i++)
{bTipoLista=false;bTipoSubLista=false;bJaDecimal=false;oCampo=theForm.elements[i];name=theForm.elements[i].name;value=Trim(theForm.elements[i].value);if(name)
{if((name.substr(0,4)!="RFS_")&&((name.substr(0,3)!="WTS")))
{numElems=document.getElementsByName(name).length;if(!numElems){numElems=1;}
var bIncluirEnFirma=true;if(numElems>=9&&document.getElementsByName(name)[8].value=='false')
{bIncluirEnFirma=false;}
if(numElems>=8&&document.getElementsByName(name)[0].value=='boolean'&&document.getElementsByName(name)[7].value=='false')
{bIncluirEnFirma=false;}
if(bIncluirEnFirma)
{z=-1;if((numElems>=9)&&(document.getElementsByName(name)[1].value=='decimal')&&(value!=""))
{sXmlCampo="<campo dec='"+document.getElementsByName(name)[2].value+"'>"+name+"</campo>"
bJaDecimal=true;}
if(numElems==3||numElems==4)
{value="";}
else
{if(!bJaDecimal)
{sXmlCampo="<campo dec='0'>"+name+"</campo>";}}
if(numElems==8)
{z=1;value='N';}
if(numElems>=9)
{z=2;if((document.getElementsByName(name)[1].value=='decimal')&&(value!=""))
{iNumDecimales=document.getElementsByName(name)[2].value;value=FormatearDecimal(value,iNumDecimales);}
if(document.getElementsByName(name)[0].getAttribute("type")=="checkbox")
{if(document.getElementsByName(name)[0].getAttribute("checked")!="")
{if((document.getElementsByName(name)[1].value=='boolean'))
{if(document.getElementsByName(name)[0].checked=='checked'||document.getElementsByName(name)[0].checked==true)
value="S";else
value="N";}}}
else if(!bJaDecimal)
{value=document.getElementsByName(name)[0].value;}
if(theForm.elements[i+1].name=='btn_'+name)
{i++;}}
if(z>0)
{if(numElems>=z+8)
{if(value!="")
{aCod=value.split('-');value=aCod[0];}}}
i=i+numElems-1;if(numElems!=1)
{if(value!="")
{if(document.getElementsByName(name)[1].value=="date"&&document.getElementsByName(name+"1").length==0)
{value+=" 00:00:00"}
sXmlDocTemp+=sXmlCampo;sTextoAFirmarTemp+=Trim(value);}}}
else
{i=i+numElems-1;}}}}
oFirma.sTextoAFirmar=sTextoAFirmarTemp.replace(/€/g,"&euro;");oFirma.sXmlDoc=sXmlDocTemp;var sName,oVentana,sUrl,submitForm,params,sIdentificadoresArray,i;submitForm=getNewForm();if(oFirma.vaFirmado)
{oFirma.sTextoAFirmar=Base64Encode(oFirma.sTextoAFirmar);createNewFormElement(submitForm,"doc",oFirma.sTextoAFirmar);}
sIdentificadoresArray=oFirma.identificadores.split("|");i=0;while(i<sIdentificadoresArray.length-1)
{if(sIdentificadoresArray[i].length>0)
{name=document.getElementsByName(sIdentificadoresArray[i])[2].value;value=ObtenerContenidoFichero(sIdEntidad,sIdioma,name,"S");createNewFormElement(submitForm,"doc",value);}
i++;}
params="?";params+="absArchivo="+oFirma.absArchivo;params+="&avisar="+oFirma.avisar;params+="&ejecutar="+oFirma.ejecutar;params+="&idioma="+sIdioma;params+="&estilo="+oFirma.estilo;params+="&timestamp="+oFirma.timestamp;params+="&urlRespuesta="+escape(oFirma.urlRespuesta);if(oFirma.NIF!=null&&oFirma.NIF.length>0)
{params+="&nif="+oFirma.NIF;}
if(bQuitadoFormLink)
{parentFormLink.appendChild(oFormLink);}
sUrl=document.getElementsByName("CampoURLValidador")
if(sUrl.length<1)
{sUrl="/ABSIS/IDI/CCO/IDICCOFIRMWEB/DLG/FIR/dlgFirmar.aspx"+params;}
else
{sUrl=sUrl.item(0).value
if(sUrl.toLowerCase().indexOf("dlg/cer/dlgvalidarcertificado.aspx")>-1)
{sUrl=sUrl.toLowerCase().replace("dlg/cer/dlgvalidarcertificado.aspx","dlg/fir/dlgFirmar.aspx");}
else if(sUrl.toLowerCase().indexOf("dlg/fir/dlgfirmar.aspx")==-1)
{if(sUrl.substr(sUrl.length-2,1)!="/")
{sUrl=sUrl+"/"}
sUrl=sUrl+"dlg/fir/dlgFirmar.aspx"}
sUrl=sUrl+params;}
submitForm.action=sUrl;sName='PopUpFirmar';submitForm.target=sName;oVentana=firma_AbrirVentana('about:blank',590,145,'yes',sName,true);submitForm.submit();if(oVentana)oVentana.focus();oFirma.ventana=oVentana;validarVentanaAbierta();return true;}
function buscarIdentificadoresFirma()
{var inputs,i,j;var arrayIdentificadores=new Array();j=0;inputs=document.getElementsByTagName('input');if(inputs.length>0)
{for(i=0;i<inputs.length;i++)
{if(inputs[i].type=='hidden'&&inputs[i].name.indexOf('fileAttachFirma')>=0)
{if(inputs[i].value=='true')
{oFirma.identificadores+=inputs[i].name.replace('Firma','')+"|";}
arrayIdentificadores[j]=inputs[i].name;j++;}}}}
function borrarIdentificadoresFirma()
{var inputs,i,j;var inputABorrar;var arrayIdentificadores=new Array();j=0;inputs=document.getElementsByTagName('input');if(inputs.length>0)
{for(i=0;i<inputs.length;i++)
{if(inputs[i].type=='hidden'&&inputs[i].name.indexOf('fileAttachFirma')>=0)
{arrayIdentificadores[j]=inputs[i].name;j++;}}}
i=0;while(i<arrayIdentificadores.length)
{inputABorrar=document.getElementsByName(arrayIdentificadores[i])[0];arrayIdentificadores[i]='elim';inputABorrar.parentNode.removeChild(inputABorrar);i++;}}
function firma_AbrirVentana(sUrl,lWidth,lHeight,sResizable,sName,bSimple)
{var sFeatures,oVentana,lLeft,lTop;lLeft=0;lTop=0;if(lWidth!=0)lLeft=(screen.availWidth-lWidth)/2;else lWidth=screen.availWidth;if(lHeight!=0)lTop=(screen.availHeight-lHeight)/2;else lHeight=screen.availHeight;if(!bSimple)
{if(lTop>100)lTop=lTop-100;else lTop=0;}
sFeatures='top='+lTop+',left='+lLeft+',width='+lWidth+',height='+lHeight+',resizable='+sResizable;if(bSimple)sFeatures=sFeatures+',directories=no,menubar=no,status=no,toolbar=no';else sFeatures=sFeatures+',directories=yes,menubar=yes,status=yes,toolbar=yes';oVentana=window.open(sUrl,sName,sFeatures);return oVentana;}
function validarVentanaAbierta()
{var dialog=oFirma.ventana;var realizada=oFirma.realizada;if(!realizada)
{if(dialog!=null)
{if(dialog.closed)
{CambiarTextoCortina(strEsperando);}
else
{setTimeout("validarVentanaAbierta()",1500);}}}}
function firmarArchivos(inputs,popUp)
{var idArxiu;var cadena="";var submitForm;var algunCheck=false;var fileAttachFirmas;var li,span;for(var i=0;i<inputs.length;i++)
{if(inputs[i].getAttribute('type')=='checkbox')
{if(inputs[i]["checked"])
{algunCheck=true;ponerCandado(inputs[i].name.replace('fileAttach',''));}}}
popUp.close();return true;}
function ponerCandado(Id)
{var li,hidden,span;if(document.getElementsByName("fileAttachFirma"+Id))
{hidden=document.getElementsByName("fileAttachFirma"+Id)[0];hidden.value=true;}
if(document.getElementById("fileAttachLi"+Id))
{li=document.getElementById("fileAttachLi"+Id);if(document.getElementsByName("imagenFirmados"))
{if(li.getElementsByTagName("span").length==0&&document.getElementsByName("imagenFirmados")[0].value.length>0)
{span=document.createElement("span")
span.innerHTML='<img alt="Firmado" src="'+document.getElementsByName("imagenFirmados")[0].value+'" border="0"/>';li.appendChild(span);}}}
return true;}
function borrarCandado(Id)
{var hidden,span,li;if(document.getElementsByName("fileAttachFirma"+Id).length>0)
{hidden=document.getElementsByName("fileAttachFirma"+Id)[0];hidden.parentNode.removeChild(hidden);}
if(document.getElementById("fileAttachLi"+Id))
{li=document.getElementById("fileAttachLi"+Id);if(li.getElementsByTagName("span").length>0)
{span=li.getElementsByTagName("span")[0];span.parentNode.removeChild(span);}}}
function CallBackFirmar(result)
{oFirma.realizada=true;oFirma.ventana=null;if((result=="")||(result==";"))
{oBtnAceptar=document.getElementById('btnAceptar');if(oBtnAceptar!=null)
{oBtnAceptar.disabled=false;}
CambiarTextoCortina("Error al firmar");setTimeout("QuitarCortinaEspera()",3000);}
else if(result.indexOf("undefined")>-1)
{oBtnAceptar=document.getElementById('btnAceptar');if(oBtnAceptar!=null)
{oBtnAceptar.disabled=false;}
CambiarTextoCortina("Firma Erronea");setTimeout("QuitarCortinaEspera()",3000);}
else
{CambiarTextoCortina(strEnviando);CallBack_Firmar(result);}}
function CallBack_Firmar(sFirma)
{var bOk=true;var tipoFirma;var sFirmaArray;var i,sIdentificadoresArray,idCampoFirma,hiddenFirma,hiddenTipoFirma;var vaFirmado;remplazoEuros(oFirma.theForm);var oFormLink=document.getElementById('frmLink');if(oFormLink!=null)
{if(oFormLink.length>0)
{oFormLink.parentNode.removeChild(oFormLink);}}
borrarIdentificadoresFirma();sFirmaArray=sFirma.split(";");tipoFirma=sFirmaArray[0];if(oFirma.vaFirmado)
{sFirmaArray=sFirmaArray[1].split(",");sFirma=sFirmaArray[0];vaFirmado=1;}
else
{sFirmaArray=sFirmaArray[1].split(",");vaFirmado=0;}
sIdentificadoresArray=oFirma.identificadores.split("|");i=0;while(i<sIdentificadoresArray.length-1)
{if(sIdentificadoresArray[i].length>0)
{hiddenFirma=crearCampoForm('INPUT',sIdentificadoresArray[i].replace("fileAttach","fileAttachFirma"));hiddenFirma.setAttribute('type','hidden');hiddenFirma.setAttribute('value',sFirmaArray[i+vaFirmado])
document.getElementsByName(sIdentificadoresArray[i])[0].parentNode.appendChild(hiddenFirma);}
i++;}
hiddenTipoFirma=crearCampoForm('INPUT','tipoFirma');hiddenTipoFirma.setAttribute('type','hidden');hiddenTipoFirma.setAttribute('value',tipoFirma)
var formulario=obtenerFormularioPadre();formulario.appendChild(hiddenTipoFirma);if(bOk)
{if(!sFirma.length)
{bOk=false;CambiarTextoCortina("Error al firmar");setTimeout("QuitarCortinaEspera()",2000);}
if(sFirma.substr(0,5)=="error")
{bOk=false;if(!(bFiltrado&&sFirma=='error:internalError'))
{if(sFirma=='error:noMatchingCert'&&strNoHayCertificados)
{alert(strNoHayCertificados);}
else if(sFirma!='error:userCancel')
{alert(sFirma);}}}}
if(!bOk)
{oBtnAceptar=document.getElementById('btnAceptar');oBtnAtras=document.getElementById('btnAtras');if(oBtnAceptar!=null)oBtnAceptar.disabled=false;if(oBtnAtras!=null)oBtnAtras.disabled=false;}
else
{if(oFirma.vaFirmado)
{oFirma.sXmlDoc+="</campos><tipoFirma>"+tipoFirma+"</tipoFirma><firma>"+sFirma+"</firma></datosFirma>";oFirma.signature.value=oFirma.sXmlDoc;}
oFirma.theForm.submit();}
return(bOk);}
function Trim(s)
{s=s.replace(/^\s+|\s+$/g,"");return s;}
function obtenerFormularioPadre()
{try
{var encontrado=false;var actual=document.getElementById("spanAttachFiles");while(!encontrado)
{if(actual.tagName=="FORM"&&(actual.name=="frmConfirmacion"||actual.name=="frmTramite"))
{encontrado=true;}
else
{actual=actual.parentNode;}}}
catch(err)
{if(document.getElementsByName('frmConfirmacion').length>0)
{actual=document.getElementsByName('frmConfirmacion')[0];}
else
{actual=document.getElementsByName('frmTramite')[0];}}
return actual;}
function PonerRelojEspera()
{document.getElementById("pagina").style["cursor"]="wait";}
function QuitarRelojEspera()
{document.getElementById("pagina").style["cursor"]="default";}
function PonerCortinaEspera(sMensaje)
{var IE6=false;var IE7=false;window.scrollTo(0,0)
document.documentElement.style.overflow="hidden";cortina=document.getElementById("panelCortina");dialogoNot=document.getElementById("dialogoNot");if(cortina==null||cortina=='undefined')
{var cortina=document.createElement('div');cortina.className="panelCortina";cortina.id="panelCortina";var cuerpo=document.body;cuerpo.insertBefore(cortina,null);}
if(dialogoNot==null||dialogoNot=='undefined')
{var dialogoNot=document.createElement('div');dialogoNot.className="dialogoNotSinGif";dialogoNot.id="dialogoNot";cuerpo.insertBefore(dialogoNot,null);}
if(document.all&&!IE7)
{cortina.style["filter"]="alpha(opacity=50)";cortina.style["backgroundColor"]="#666666";cortina.style["backgroundImage"]="none";cortina.style["height"]="10000px";}
cortina.style["display"]="block";cortina.style["cursor"]="wait";dialogoNot.style["display"]="block";dialogoNot.style["cursor"]="wait"
dialogoNot.innerHTML="<center>"+sMensaje+"</center>";}
function CambiarTextoCortina(sMensaje)
{try
{var dialogoNot=document.getElementById("dialogoNot");dialogoNot.style["display"]="block";dialogoNot.innerHTML="<center>"+sMensaje+"</center>";dialogoNot.className="dialogoNotSinGif";}
catch(err)
{}}
function QuitarCortinaEspera()
{var cortina=document.getElementById("panelCortina");cortina.style["display"]="none";cortina.style["cursor"]="default";var dialogoNot=document.getElementById("dialogoNot");dialogoNot.style["display"]="none";dialogoNot.style["cursor"]="default";document.documentElement.style.overflow="auto";QuitarRelojEspera();}
function AñadirItemMultiLista(strNamePatron,strMaxCajasTxt)
{var oElemDivDatos,oElemDivTmp,oElemCampo;var strNombreCampo,strNombreLen,strNombreRaiz,strDivDatos,strDivTemp;var strHiddenCampo;var i,strSpan,sufijoId,sOrden;var intNum,NumMax;strNombreLen=strNamePatron.length-parseInt(strMaxCajasTxt.substring(0,1));strNombreRaiz=strNamePatron.substring(0,strNombreLen);switch(strMaxCajasTxt.substring(0,1))
{case"1":strDivDatos="div_"+strNombreRaiz+"0_datos";strDivTemp="div_"+strNombreRaiz+"0_TMP";sufijoId=strNamePatron.substring(3,8);intNum="0";NumMax=9;break;case"2":strDivDatos="div_"+strNombreRaiz+"00_datos";strDivTemp="div_"+strNombreRaiz+"00_TMP";sufijoId=strNamePatron.substring(3,7);intNum="00";NumMax=99;break;case"3":strDivDatos="div_"+strNombreRaiz+"000_datos";strDivTemp="div_"+strNombreRaiz+"000_TMP";sufijoId=strNamePatron.substring(3,6);intNum="000";NumMax=999;break;}
oElemDivDatos=document.getElementById(strDivDatos);oElemDivTmp=document.getElementById(strDivTemp);sOrden=(oElemDivTmp.children.length)+1;if(sOrden<=NumMax)
{sOrden+=''
switch(strMaxCajasTxt.substring(0,1))
{case"1":strNombreCampo=strNombreRaiz+""+sOrden;sLinea=strNombreCampo.substring(8,9);break;case"2":if(sOrden.length==1)
{strNombreCampo=strNombreRaiz+"0"+sOrden;}
else
{strNombreCampo=strNombreRaiz+""+sOrden;}
sLinea=strNombreCampo.substring(7,9);break;case"3":if(sOrden.length==1)
{strNombreCampo=strNombreRaiz+"00"+sOrden;}
if(sOrden.length==2)
{strNombreCampo=strNombreRaiz+"0"+sOrden;}
if(sOrden.length==3)
{strNombreCampo=strNombreRaiz+""+sOrden;}
sLinea=strNombreCampo.substring(6,9);break;}
strHiddenCampo=oElemDivDatos.innerHTML;strSpan="<span id='span_"+strNombreCampo+"'  class = '' >"+document.getElementById("txt_"+strNamePatron+"_TMP").value+"<img class = '' src='../img/formularios/EditDelete2.gif' alt='Eliminar elemento' id='img_"+strNombreCampo+"' onclick=\"javascript:EliminarMultiCampo('"+strNombreCampo+"', '"+sufijoId+"' , '"+intNum+"')\"/> <BR>";if(oElemDivTmp.innerHTML!=undefined)
{oElemDivTmp.innerHTML=oElemDivTmp.innerHTML+""+strSpan+""+strHiddenCampo+"</span>";}
else
{oElemDivTmp.innerHTML=strSpan+""+strHiddenCampo+"</span>";}
oElemSpan=document.getElementById("span_"+strNombreCampo);oElemSpan.innerHTML=TextoMultiEntrada_ActualizarIdentificadoresHTML(oElemSpan.innerHTML,sufijoId,sLinea,intNum);oElemCampo=document.getElementById(strNombreCampo);oElemCampo.value=document.getElementById("txt_"+strNamePatron+"_TMP").value;document.getElementById("txt_"+strNamePatron+"_TMP").value="";}
else
{alert("El número de TextosMultiEntrada es superior al intervalo especificado inicialmente.");}}
function TextoMultiEntrada_ActualizarIdentificadoresHTML(txt,sufijoId,sLinea,intNum)
{var reg=new RegExp("(WTX"+sufijoId+")"+intNum,"g");var txt2=txt.replace(reg,"$1"+sLinea);return txt2;}
function EliminarMultiCampo(strCampo,sufijoId,intNum)
{var oElemDiv;var oElemRemove=document.getElementById("span_"+strCampo);var padre=oElemRemove.parentNode;padre.removeChild(oElemRemove);OrdenarElementosMultiLista(strCampo,sufijoId,intNum);}
function OrdenarElementosMultiLista(strCampo,sufijoId,intNum)
{var sOrden=1;var sOrden2=0;var NumSel;strNombreDiv="div_WTX"+sufijoId+""+intNum+"_TMP";var oElemDiv=document.getElementById(strNombreDiv);for(sOrden=1;sOrden<oElemDiv.childNodes.length+1;sOrden++)
{switch(intNum.length)
{case 1:sOrden2=sOrden+"";NumElement=sOrden;NumSel=oElemDiv.childNodes(sOrden-1).id.split("span_WTX"+sufijoId)[1];oElemDiv.children(sOrden-1).outerHTML=TextoMultiEntrada_ActualizarIdentificadoresHTML(oElemDiv.children(sOrden-1).outerHTML,sufijoId,NumElement,NumSel);break;case 2:sOrden2=sOrden+"";if(sOrden2.length==1)
{NumElement="0"+sOrden;}
if(sOrden.length==2)
{NumElement=sOrden;}
NumSel=oElemDiv.childNodes(sOrden-1).id.split("span_WTX"+sufijoId)[1];oElemDiv.children(sOrden-1).outerHTML=TextoMultiEntrada_ActualizarIdentificadoresHTML(oElemDiv.children(sOrden-1).outerHTML,sufijoId,NumElement,NumSel);break;case 3:sOrden2=sOrden+"";if(sOrden2.length==1)
{NumElement="00"+sOrden;}
if(sOrden.length==2)
{NumElement="0"+sOrden;}
if(sOrden.length==2)
{NumElement=sOrden;}
NumSel=oElemDiv.childNodes(sOrden-1).id.split("span_WTX"+sufijoId)[1];oElemDiv.children(sOrden-1).outerHTML=TextoMultiEntrada_ActualizarIdentificadoresHTML(oElemDiv.children(sOrden-1).outerHTML,sufijoId,NumElement,NumSel);break;}}}
function InsertAutoComplete()
{var iCampo,jSubCampo,NumSubCampos;var NombresSubCampos="";var NomSubCamp="";var sNombreSubCampo="";var NomSubCampBD="";var VisibleAutoComplet="";var TipoDatoSubCampo="";for(iCampo=0;iCampo<=aCampoAjax.length-1;iCampo++)
{sNombreCampo=aCampoAjax[iCampo];NomSubCamp="NombreSubCampo0="+sNombreCampo;NomSubCampBD="NombreCampoBD0="+aDetalleAjax[sNombreCampo]['campoBD'][0];VisibleAutoComplet="visibleCompletador0="+aDetalleAjax[sNombreCampo]['visibleComplet'][0];TipoDatoSubCampo="tipoDatos="+aDetalleAjax[sNombreCampo]['tipoDato'][0];NumSubCampos=aDetalleAjax[sNombreCampo]['campoForm'].length
for(jSubCampo=1;jSubCampo<=NumSubCampos-1;jSubCampo++)
{NomSubCamp=NomSubCamp+"&NombreSubCampo"+jSubCampo+"="+aDetalleAjax[sNombreCampo]['campoForm'][jSubCampo];NomSubCampBD=NomSubCampBD+"&NombreCampoBD"+jSubCampo+"="+aDetalleAjax[sNombreCampo]['campoBD'][jSubCampo];VisibleAutoComplet=VisibleAutoComplet+"&visibleCompletador"+jSubCampo+"="+aDetalleAjax[sNombreCampo]['visibleComplet'][jSubCampo];TipoDatoSubCampo=TipoDatoSubCampo+"&tipoDatos"+jSubCampo+"="+aDetalleAjax[sNombreCampo]['tipoDato'][jSubCampo];}
var urlASP="../../forms_base/ConsultaAJAX.asp?codigoWeb="+aDetalleAjax[sNombreCampo]['web']+"&codigoConsulta="+aDetalleAjax[sNombreCampo]['met']+"&tipo="+aDetalleAjax[sNombreCampo]['tpc']+"&WebService="+aDetalleAjax[sNombreCampo]['ws']+"&NumSubCampos="+NumSubCampos+"&"+NomSubCamp+"&"+NomSubCampBD+"&"+VisibleAutoComplet+"&"+TipoDatoSubCampo+"";var idtargetDIV='targetLst_'+sNombreCampo;var htmltargetDiv='<div id="'+idtargetDIV+'" class="auto_complete" ></div>';var getItemUpdate=function(resp){var oNode=resp
var NumSubCampos=oNode.parentNode.getAttribute("NumSubCampos")
var sLista=oNode.parentNode.getAttribute("listaCampos")
var aLista=sLista.split('|');var i,CampoSeleccion;for(i=0;i<=NumSubCampos-1;i++)
{CampoSeleccion=document.getElementById(aLista[i]);CampoSeleccion.value=oNode.getAttribute(aLista[i])}}
new Insertion.After(sNombreCampo,htmltargetDiv);new Ajax.Autocompleter(sNombreCampo,idtargetDIV,urlASP,{updateElement:getItemUpdate});}}
function InsertSeccionBusqueda()
{var sNombreCampo="";var iCampoBusq,jSubCampo,NumSubCampos
var sBusqSubForm="";var sBusqSubCons="";var sBusqueda="";var sNombreMaestro="";var oFormLink;for(iCampoBusq=0;iCampoBusq<=aCampoBusq.length-1;iCampoBusq++)
{sNombreCampo=aCampoBusq[iCampoBusq];sNombreMaestro=aDetalleBusq[sNombreCampo]['CampoMaestro'];sTipoBusq=aDetalleBusq[sNombreCampo]['TipoBusq'];sOperadorBusq=aDetalleBusq[sNombreCampo]['OperadorBusq'];sBusqueda=document.getElementById(sNombreCampo).value;NumSubCampos=aDetalleBusq[sNombreCampo]['CampoBusqForm'].length;oFormLink=document.getElementById('frmLink');while(oFormLink.childNodes.length>0)
{oFormLink.removeChild(oFormLink.childNodes.item(0));}
oCampoOculto=document.createElement('INPUT');oCampoOculto.type='hidden';oCampoOculto.name='codigoWeb';oCampoOculto.value=aDetalleBusq[sNombreCampo]['web'];oCampoOculto.id='codigoWeb';oFormLink.appendChild(oCampoOculto);oCampoOculto=document.createElement('INPUT');oCampoOculto.type='hidden';oCampoOculto.name='codigoConsulta';oCampoOculto.value=aDetalleBusq[sNombreCampo]['met'];oCampoOculto.id='codigoConsulta';oFormLink.appendChild(oCampoOculto);oCampoOculto=document.createElement('INPUT');oCampoOculto.type='hidden';oCampoOculto.name='tipo';oCampoOculto.value=aDetalleBusq[sNombreCampo]['tpc'];oCampoOculto.id='tipo';oFormLink.appendChild(oCampoOculto);oCampoOculto=document.createElement('INPUT');oCampoOculto.type='hidden';oCampoOculto.name='WebService';oCampoOculto.value=aDetalleBusq[sNombreCampo]['ws'];oCampoOculto.id='WebService';oFormLink.appendChild(oCampoOculto);oCampoOculto=document.createElement('INPUT');oCampoOculto.type='hidden';oCampoOculto.name='NumSubCampos';oCampoOculto.value=NumSubCampos;oCampoOculto.id='NumSubCampos';oFormLink.appendChild(oCampoOculto);oCampoOculto=document.createElement('INPUT');oCampoOculto.type='hidden';oCampoOculto.name='TipoCampo';oCampoOculto.value='SeccionBusqueda';oCampoOculto.id='TipoCampo';oFormLink.appendChild(oCampoOculto);oCampoOculto=document.createElement('INPUT');oCampoOculto.type='hidden';oCampoOculto.name='NombreCampoMaestro';oCampoOculto.value=sNombreMaestro;oCampoOculto.id='NombreCampoMaestro';oFormLink.appendChild(oCampoOculto);oCampoOculto=document.createElement('INPUT');oCampoOculto.type='hidden';oCampoOculto.name='TipoBusq';oCampoOculto.value=sTipoBusq;oCampoOculto.id='TipoBusq';oFormLink.appendChild(oCampoOculto);oCampoOculto=document.createElement('INPUT');oCampoOculto.type='hidden';oCampoOculto.name='OperadorBusq';oCampoOculto.value=sOperadorBusq;oCampoOculto.id='OperadorBusq';oFormLink.appendChild(oCampoOculto);for(jSubCampo=0;jSubCampo<=NumSubCampos-1;jSubCampo++)
{oCampoOculto=document.createElement('INPUT');oCampoOculto.type='hidden';oCampoOculto.name='BusqSubForm'+jSubCampo;oCampoOculto.value=aDetalleBusq[sNombreCampo]['CampoBusqForm'][jSubCampo];oCampoOculto.id='BusqSubForm'+jSubCampo;oFormLink.appendChild(oCampoOculto);oCampoOculto=document.createElement('INPUT');oCampoOculto.type='hidden';oCampoOculto.name='BusqSubCons'+jSubCampo;oCampoOculto.value=aDetalleBusq[sNombreCampo]['CampoBusqCons'][jSubCampo];oCampoOculto.id='BusqSubCons'+jSubCampo;oFormLink.appendChild(oCampoOculto);}
oCampoOculto=document.createElement('INPUT');oCampoOculto.type='hidden';oCampoOculto.name='OperadorBusq';oCampoOculto.value=sOperadorBusq+""+sBusqSubForm+""+sBusqSubCons;oCampoOculto.id='OperadorBusq';oFormLink.appendChild(oCampoOculto);oCampoOculto=document.createElement('INPUT');oCampoOculto.type='hidden';oCampoOculto.name='sBusqueda';oCampoOculto.value=sBusqueda;oCampoOculto.id='sBusqueda';oFormLink.appendChild(oCampoOculto);oCampoOculto=document.createElement('INPUT');oCampoOculto.type='hidden';oCampoOculto.name='NombreCampo';oCampoOculto.value=sNombreCampo;oCampoOculto.id='NombreCampo';oFormLink.appendChild(oCampoOculto);var urlASP="../../forms_base/ConsultaAJAX.asp";var getItemUpdate=function(resp)
{var oElement;if(200==resp.status)
{var NumSubCampos,CampoEdicion,jSubCampo,CampoSubForm,iXml;var oNode=resp;if(NavegadorIE())
{oElement=oNode.responseXML.selectSingleNode('//SeccionBusq');CampoEdicion=oElement.getAttribute("NombreCampo");}
else
{oElement=oNode.responseXML.getElementsByTagName('SeccionBusq')[0];CampoEdicion=oElement.getAttribute("NombreCampo");}
NumSubCampos=aDetalleBusq[sNombreCampo]['CampoBusqForm'].length;for(jSubCampo=0;jSubCampo<=NumSubCampos-1;jSubCampo++)
{sBusqSubForm=aDetalleBusq[CampoEdicion]['CampoBusqForm'][jSubCampo];sBusqSubCons=aDetalleBusq[CampoEdicion]['CampoBusqCons'][jSubCampo];if(NavegadorIE()){if(oElement.selectSingleNode(sBusqSubCons))
if(sBusqSubCons.match("DNINIF")){EstablecerValorCampo(window.document,sBusqSubForm,CalculaNIFeAtiende(oElement.selectSingleNode(sBusqSubCons).text,sBusqSubForm),'=');}else{EstablecerValorCampo(window.document,sBusqSubForm,oElement.selectSingleNode(sBusqSubCons).text,'=');}}
else{if(sBusqSubCons.match("DNINIF")){EstablecerValorCampo(window.document,sBusqSubForm,CalculaNIFeAtiende(oElement.getElementsByTagName(sBusqSubCons)[0].textContent,sBusqSubForm),'=');}else{EstablecerValorCampo(window.document,sBusqSubForm,oElement.getElementsByTagName(sBusqSubCons)[0].textContent,'=');}}}}}
new Ajax.Request(urlASP,{method:'post',parameters:Form.serialize('frmLink'),onComplete:getItemUpdate,onFailure:function(){alert(strNoRegistros)}});}}
function SingleSignOn(sUrlWS)
{var sHostUrl,sHostWS;sHostUrl=window.location.href.substr(0,window.location.href.indexOf('/',8));sHostWS=sUrlWS.substr(0,sUrlWS.indexOf('/',8));if(document.getElementsByName("WTGCODENT").length>0&&document.getElementsByName("WUSCODUSU").length>0&&document.getElementsByName("WUSPINUSU").length&&sHostUrl.toLowerCase()==sHostWS.toLowerCase())
{var reg=/login=.*LOGINEATI/i
if(reg.test(window.location.search))
sUrlWS=sUrlWS+'/SrvLDAP.asmx/LoginLDAPeConstruye';else
sUrlWS=sUrlWS+'/SrvLDAP.asmx/LoginLDAP';sParam="sEntidad="+document.getElementsByName("WTGCODENT")[0].value;if(NavegadorIE())xmlHttpReq=new ActiveXObject("MSXML2.XMLHTTP");else xmlHttpReq=new XMLHttpRequest();xmlHttpReq.open("POST",sUrlWS,false);xmlHttpReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');xmlHttpReq.send(sParam);if(xmlHttpReq.responseXML!=null)
{var sUser,sPwd;sUser='';sPwd='';if(xmlHttpReq.responseXML.xml!='')
{if(NavegadorIE())
{var sUser=xmlHttpReq.responseXML.selectSingleNode("//user").text
document.getElementById("WUSCODUSU").value=sUser
var sPwd=xmlHttpReq.responseXML.selectSingleNode("//pwd").text
document.getElementById("WUSPINUSU").value=sPwd}
else
{var sUser=xmlHttpReq.responseXML.documentElement.getElementsByTagName("user")[0].textContent
document.getElementById("WUSCODUSU").value=sUser
var sPwd=xmlHttpReq.responseXML.documentElement.getElementsByTagName("pwd")[0].textContent
document.getElementById("WUSPINUSU").value=sPwd}}
if((sUser!="")&&(sPwd!=""))
{if(document.getElementById("btnAceptar")!=null)
{if(window.location.search.indexOf("salir=1")<0)
{if(document.createEvent)
{var evObj=document.createEvent('MouseEvents');evObj.initMouseEvent("click",true,false,window,0,0,0,0,0,false,false,false,false,0,null);document.getElementById("btnAceptar").dispatchEvent(evObj);}
else if(document.createEventObject)
document.getElementById("btnAceptar").fireEvent('onclick');}}}}}}
function BorrarCamposTramiteAdministracion(oForm){var aTipos=new Array("input","textarea","select");var intALength=aTipos.length;for(var x=0;x<intALength;x++)
{var cItems=oForm.getElementsByTagName(aTipos[x]);var intCItemsLength=cItems.length;for(var i=0;i<intCItemsLength;i++)
{if(!cItems.item(i).id==""&&cItems.item(i).type!="hidden"&&!cItems.item(i).readOnly&&cItems.item(i).type!="submit"){EstablecerValorCampo(window.document,cItems.item(i).id,'','=');if(document.getElementById(cItems.item(i).id).selectedIndex)
document.getElementById(cItems.item(i).id).selectedIndex="-1";if(document.getElementById(cItems.item(i).id+"_parent"))
tinyMCE.activeEditor.setContent("");}}}}
function CalculaNIFeAtiende(sDNINIF,sNomCampo)
{var dni;var lletra;var lletra_correcta;var bOk;var ocampo;ocampo=document.getElementById(sNomCampo)
if(ocampo){nif=sDNINIF;nif=nif.toUpperCase();bOk=true;if(nif!=''){if(isNaN(nif))
{if((nif.length>2)&&(nif.length<10))
{dni=nif.substring(0,nif.length-1);if(!isNumber(dni)){ocampo.style.color='Red';bOk=false;}
lletra=nif.substring(nif.length-1,nif.length);if(isNaN(dni)){ocampo.style.color='Red';bOk=false;}else{lletra_correcta=quina_lletra(dni);if(lletra!=lletra_correcta)
{nif=nif.substring(0,nif.length-1)+lletra_correcta;}}}else
{bOk=false}}
else
{if((nif.length>2)&&(nif.length<10))
{if(nif.length<9){nif=nif.concat(quina_lletra(nif));}else{bOk=false;}}
else
{bOk=false;}}}}
return nif;}