
function EstablecerCampoFiltroConsulta(sCampo,sValor)
{var aElemDes,oCampoDes,i,iLength;aElemDes=document.getElementsByName(sCampo);iLength=aElemDes.length;if(iLength>0)
{for(i=0;i<iLength;i++){oCampoDes=aElemDes[i];if(oCampoDes.nodeName=='SELECT'){var status=oCampoDes.disabled;oCampoDes.disabled=false;if(document.createEvent)
{oCampoDes.focus();}
else if(document.createEventObject)
{oCampoDes.fireEvent("onfocus");}
oCampoDes.disabled=status;}
if(oCampoDes.type=='checkbox')oCampoDes.checked=(sValor=='S');else if(oCampoDes.type=='radio')
{for(i=0;i<aElemDes.length;i++)
{oCampoDes=aElemDes[i];if(oCampoDes.value==sValor)oCampoDes.checked=true;}}
else if(oCampoDes.disabled&&((oCampoDes.type=='select-one')||(oCampoDes.type=='textarea')))
{EstablecerValorCampo(oCampoDes.form,sCampo,sValor,'=');aElemDes[1].value=sValor;}
else EstablecerValorCampo(oCampoDes.form,sCampo,sValor,'=');}}
else if(sCampo.substring(0,4)=='FIL_')
{EstablecerCampoFiltroConsulta('INF_'+sCampo.substring(4),sValor);}}
function GestionarEnlaceAccion(sEnlace,sIdAccion,iVentana,iWidth,iHeight,iHTTPS)
{var aElementos,i,sIdFila;sIdFila='';aElementos=document.getElementsByName('WTGSELECC');for(i=0;i<aElementos.length;i++)
{if(aElementos[i].checked)
{sIdFila=aElementos[i].value;break;}}
if(sIdFila.length>0)
{GestionarEnlaceAccionFila(sEnlace,sIdAccion,sIdFila,iVentana,iWidth,iHeight,iHTTPS);}
else
{alert(strSeleccionarFila);}}
function GestionarEnlaceAccionFila(sEnlace,sIdAccion,sIdFila,iVentana,iWidth,iHeight,iHTTPS)
{var oCampo,aRelServicio,aParejaRel,sValor,oFormLink,oCampoOculto,i,oVentana,sNombreVentana,iTop,iLeft,sFeatures,aParams;oFormLink=document.getElementById('frmLink');while(oFormLink.childNodes.length>0)
oFormLink.removeChild(oFormLink.childNodes.item(0));oCampo=document.getElementById(sIdAccion);if((oCampo!=null)&&(oCampo.value.length>0))
{aRelServicio=oCampo.value.split('&');for(i=0;i<aRelServicio.length;i++)
{aParejaRel=aRelServicio[i].split('=');aParams=aParejaRel[1].split('|$|');if(aParams.length==1)
{oCampo=document.getElementById(sIdFila.concat('_').concat(aParejaRel[1]));if(oCampo!=null)sValor=oCampo.value;else sValor='';oCampoOculto=document.createElement('INPUT');oCampoOculto.type='hidden';oCampoOculto.name=aParejaRel[0];oCampoOculto.value=sValor;oFormLink.appendChild(oCampoOculto);}
else if(aParams.length==2)
{switch(aParams[0])
{case'CMP':oCampo=document.getElementById(aParams[1]);if(oCampo!=null)sValor=oCampo.value;else sValor='';break;case'VAL':sValor=URLDecode(aParams[1]);break;default:sValor='';break;}
oCampoOculto=document.createElement('INPUT');oCampoOculto.type='hidden';oCampoOculto.name=aParejaRel[0];oCampoOculto.value=sValor;oFormLink.appendChild(oCampoOculto);}}}
if((iVentana==0)||(iVentana==1))
{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;if(iVentana==1)sFeatures='scrollbars=yes,resizable=yes';else sFeatures='menubar=yes,toolbar=yes,scrollbars=yes,resizable=yes,location=yes';sFeatures=sFeatures.concat(',width='+iWidth+',height='+iHeight+',left='+iLeft+',top='+iTop);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;oVentana.focus();}
else oFormLink.target='_self';sEnlace=CalcularURLHTTPS(sEnlace,iHTTPS);oFormLink.action=sEnlace.concat('?procedencia=Consulta');oFormLink.submit();}
function InicializarConsulta()
{try{InicializarCampos();}
catch(ex){}
InicializarSeccionesConsulta();}
function InicializarSeccionesConsulta()
{if(typeof aSeccCons!='undefined')
{for(var i=0;i<iNumSeccCons;i++)
{if(aSeccCons[i]['tipoSeccion']=="busqueda")
{if(aSeccCons[i]['ejecutar']=="True")
{CargarSeccionBusqueda('c'+aSeccCons[i]['id'],document.getElementById(ObtenerIdFormSeccionConsulta(aSeccCons[i]['id'])));}}
else{if(aSeccCons[i]['ejecutar']=="True")
{CargarSeccionConsulta('c'+aSeccCons[i]['id'],document.getElementById(ObtenerIdFormSeccionConsulta(aSeccCons[i]['id'])));}}}}}
function CargarSeccionConsulta(sIdConsulta,oForm)
{if(!oForm)return;var oContainer=document.getElementById(sIdConsulta+'_data');if(document.getElementById(sIdConsulta+'_data_PageActual'))document.getElementById(sIdConsulta+'_data_PageActual').value=1;if(oContainer.tagName=='DIV')
oContainer.innerHTML='<p align="center"><img src="../../css/img/loading.gif" alt="loading..." /></p>';if(typeof consultaRealizada!="undefined")
{var getCallback=function()
{consultaRealizada(sIdConsulta,oForm);}
new Ajax.Updater(sIdConsulta+'_data','../src/asp/consulta/SeccionConsulta.asp',{asynchronous:true,parameters:Form.serialize(oForm.id),onComplete:getCallback});}
else
{new Ajax.Updater(sIdConsulta+'_data','../src/asp/consulta/SeccionConsulta.asp',{asynchronous:true,parameters:Form.serialize(oForm.id)});}}
function CargarSeccionBusqueda(sIdConsulta,oForm)
{var urlASP='../src/asp/consulta/SeccionBusqueda.asp';var getItemUpdate=function(resp)
{var oElement;if(200==resp.status)
{var NumSubCampos,jSubCampo,sBusqSubCampos,sSubCamp;var oNode=resp;if(NavegadorIE())
{oElement=oNode.responseXML.selectSingleNode('//SeccionBusq');}
else
{oElement=oNode.responseXML.getElementsByTagName('SeccionBusq')[0];}
if(oElement!=null)
{NumSubCampos=oForm.elements.namedItem('NUM_SUB_CAMPOS').value;sBusqSubCampos=oForm.elements.namedItem('RELACION_FORM_CONS').value;sSubCamp=sBusqSubCampos.split("|");for(jSubCampo=0;jSubCampo<=NumSubCampos-1;jSubCampo++)
{sBusqSubForm=sSubCamp[jSubCampo].split("-")[0];sBusqSubCons=sSubCamp[jSubCampo].split("-")[1];if(NavegadorIE())
{EstablecerValorCampo(oForm,sBusqSubForm,oElement.selectSingleNode(sBusqSubCons).text,"=")}
else
{EstablecerValorCampo(oForm,sBusqSubForm,oElement.getElementsByTagName(sBusqSubCons)[0].textContent,"=")}}
if(typeof consultaRealizada!="undefined")
{consultaRealizada(sIdConsulta,oForm)}}
else{alert(resp.responseText);}}
else{alert(strErrorSeccBusq);}}
new Ajax.Request(urlASP,{method:'post',onComplete:getItemUpdate,onFailure:function(){alert(strErrorBusq)},parameters:Form.serialize(oForm)});}
function CargarSeccionConsultaPag(sIdDiv,sIdForm,PageActual)
{var oContainer=document.getElementById(sIdDiv);var oForm=document.getElementById(sIdForm);if(sIdDiv.length>37&&sIdDiv.substr(0,1)=='c')
document.getElementById(sIdDiv.substr(1,37)+'_PageActual').value=PageActual;else
document.getElementById(sIdDiv+'_PageActual').value=PageActual;if(oContainer.tagName=='DIV')
oContainer.innerHTML='<p align="center"><img src="../../css/img/loading.gif" alt="loading..." /></p>';else
{while(oContainer.firstChild){oContainer.removeChild(oContainer.firstChild);};var oRow=Builder.node('tr');var oCell=Builder.node('td');oCell.colSpan=100;oRow.appendChild(oCell);oContainer.appendChild(oRow);oCell.innerHTML='<p align="center"><img src="../../css/img/loading.gif" alt="loading..." /></p>';}
new Ajax.Updater(sIdDiv,'../src/asp/consulta/SeccionConsulta.asp',{asynchronous:true,parameters:Form.serialize(oForm.id)});}
function mostrarOcultarSeccionConsulta(sIdConsulta)
{var oSeccCons=document.getElementById(sIdConsulta);if(oSeccCons.style.display=="none")
{var oDataCons=document.getElementById(sIdConsulta+'_data');if(oDataCons.innerHTML.indexOf('<')<0)
{CargarSeccionConsulta(sIdConsulta,oSeccCons.getElementsByTagName('FORM')[0]);}
oSeccCons.style.display="";}
else
{oSeccCons.style.display="none";}
cambiarEstilosSeccionesConsulta(oSeccCons);}
function mostrarOcultarElimDupl(sIdDiv)
{var sSeccDiv=document.getElementById(sIdDiv);if(sSeccDiv.style.display=="none")
{sSeccDiv.style.display="";}
else
{sSeccDiv.style.display="none";}}
function comprobarEstadoVisible(sAccion,sElemento)
{var sStyle=document.getElementById(sElemento).style.display;if(sStyle=='')sStyle='block';if(sStyle!=sAccion)
{return true;}
else
{return false;}}
function mostrarOcultarElimDuplCapas(sElementId)
{var sElements=document.getElementsByName(sElementId);var i,oCampoDiv;if(sElements.length>0)
{for(i=0;i<=sElements.length-1;i++)
{oCampoDiv=sElements[i];if(oCampoDiv.style.display=="none")
{oCampoDiv.style.display="";}
else
{oCampoDiv.style.display="none";}}}}
function cambiarEstilosSeccionesConsulta(oSeccion)
{var sContConsulta='cnt'+oSeccion.id.slice(1,33);var oContConsulta=document.getElementById(sContConsulta);var sContConsultaClassName=oContConsulta.className;if(oSeccion.style.display=="none"){sContConsultaClassName=sContConsultaClassName.replace(/ desplegado/," plegado");if(sContConsultaClassName.search("plegado")=="-1"){sContConsultaClassName=sContConsultaClassName+" plegado";}}else{sContConsultaClassName=sContConsultaClassName.replace(/ plegado/," desplegado");if(sContConsultaClassName.search("desplegado")=="-1"){sContConsultaClassName=sContConsultaClassName+" desplegado";}}
oContConsulta.className=sContConsultaClassName;}
function mostrarOcultarSeccionesConsulta(sAccion,aSeccionesNoMobibles)
{var aSeccCons,iSeccCons,oSeccion,iSeccionesNoMobibles,bMob,oSeccionNoMobibleTemp;aSeccCons=document.getElementsByClassName('seccCons');iSeccCons=aSeccCons.length;for(i=0;i<iSeccCons;i++){bMob=true;oSeccion=document.getElementById(aSeccCons[i].id);iSeccionesNoMobibles=aSeccionesNoMobibles.length;for(x=0;x<iSeccionesNoMobibles;x++){if(aSeccionesNoMobibles[x]==oSeccion.id){bMob=false;oSeccionNoMobibleTemp=aSeccionesNoMobibles.splice(x,1);}}
if(oSeccion&&bMob){if(oSeccion.style.display=="none"){var oDataCons=document.getElementById(oSeccion.id+'_data');if(oDataCons.innerHTML.indexOf('<')<0)
CargarSeccionConsulta(oSeccion.id,oSeccion.getElementsByTagName('FORM')[0]);}
oSeccion.style.display=sAccion;cambiarEstilosSeccionesConsulta(oSeccion)}}}
function mostrarOcultarResultadosConsulta(sAccion)
{var aSeccCons,iSeccCons,oSeccion;aSeccCons=document.getElementsByClassName('ResultadosOcultables');iSeccCons=aSeccCons.length;for(i=0;i<iSeccCons;i++){oSeccion=aSeccCons[i];oSeccion.style.display=sAccion;}}
function CargarMapaAbsVisor()
{var ref,claveMapa,idCapa,idEntorno,maxElems,urlVisor,urlRespuesta,targetRespuesta;var oFrmMapa=document.getElementById("frmLink");while(oFrmMapa.childNodes.length>0)
oFrmMapa.removeChild(oFrmMapa.childNodes.item(0));if(document.getElementById('INF_WTXREFCAT').value!='')
ref=document.getElementById('INF_WTXREFCAT').value.replace('-','').substr(0,14);else
ref=document.getElementById('INF_WTXREFPAR').value+document.getElementById('INF_WTXREFPLA').value;if(ref.length==0&&window.location.search.indexOf('procedencia')>=0)
{alert(sLitRefCatIncorrecta);return;}
claveMapa=document.getElementById('INF_WTXCLAVEM').value;idCapa=document.getElementById('INF_WTXIDCAPA').value;idEntorno=document.getElementById('INF_WTXENTORN').value;maxElems=document.getElementById('INF_WTXMAXELE').value;urlVisor=document.getElementById('INF_WTXURLVIS').value;urlRespuesta=window.location.href.substr(0,window.location.href.lastIndexOf('/'))+'/../src/asp/absVisor/RespuestaMapa.asp?css='+document.styleSheets[1].href;targetRespuesta='frmRespuesta';AnadirCampoFormulario('ida',ref,oFrmMapa);AnadirCampoFormulario('claveMapa',claveMapa,oFrmMapa);AnadirCampoFormulario('idCapa',idCapa,oFrmMapa);AnadirCampoFormulario('idEntorno',idEntorno,oFrmMapa);AnadirCampoFormulario('max_elems',maxElems,oFrmMapa);AnadirCampoFormulario('urlRespuesta',urlRespuesta,oFrmMapa);AnadirCampoFormulario('targetRespuesta',targetRespuesta,oFrmMapa);oFrmMapa.action=urlVisor;oFrmMapa.target='frmVisor';oFrmMapa.submit();while(oFrmMapa.childNodes.length>0)
oFrmMapa.removeChild(oFrmMapa.childNodes.item(0));AnadirCampoFormulario('ida',ref,oFrmMapa);oFrmMapa.action=urlRespuesta;oFrmMapa.target=targetRespuesta;oFrmMapa.submit();}
function AnadirCampoFormulario(sNombre,sValor,oForm)
{var oCampo=document.createElement('INPUT');oCampo.type='hidden';oCampo.name=sNombre;oCampo.value=sValor;oForm.appendChild(oCampo);}
function ObtenerIdFormSeccionConsulta(sIdConsulta)
{if(document.getElementById(sIdConsulta+'_IdForm'))
return document.getElementById(sIdConsulta+'_IdForm').value;else
return'';}
function marcarFila(oTd){var aMarcados,iMarcadoslength;if(oTd){aMarcados=document.getElementsByClassName("selected");if(aMarcados)
iMarcadoslength=aMarcados.length;for(i=0;i<iMarcadoslength;i++){if(aMarcados[i].nodeName=='TR')
aMarcados[i].className=aMarcados[i].className.replace(/ selected/,"");}
if(oTd&&oTd.parentNode&&oTd.parentNode.parentNode&&oTd.parentNode.parentNode.nodeName=='TR'){oTd.parentNode.parentNode.className=oTd.parentNode.parentNode.className+" selected";}}}
