var Spry;if(!Spry){Spry={}}if(!Spry.Utils){Spry.Utils={}}Spry.Utils.submitForm=function(C,E,B){if(!C){return true}if(typeof C=="string"){C=document.getElementById(C)||document.forms[C]}var D={};D.method=C.method;D.url=C.action||document.location.href;D.enctype=C.enctype;Spry.Utils.setOptions(D,B);var A=Spry.Utils.extractParamsFromForm(C,D.elements);if(D.additionalData){A+="&"+D.additionalData}if(D.enctype.toLowerCase()!="multipart/form-data"){D.method=(D.method.toLowerCase()=="post")?"POST":"GET";if(D.method=="GET"){if(D.url.indexOf("?")==-1){D.url+="?"}else{D.url+="&"}D.url+=A}else{if(!D.headers){D.headers={}}if(!D.headers["Content-Type"]||D.headers["Content-Type"].indexOf("application/x-www-form-urlencoded")==-1){D.headers["Content-Type"]="application/x-www-form-urlencoded"}D.postData=A}Spry.Utils.loadURL(D.method,D.url,true,E,D);return false}return true};Spry.Utils.extractParamsFromForm=function(B,A){if(!B){return""}if(typeof B=="string"){B=document.getElementById(B)||document.forms[B]}var E;if(A){E=","+A.join(",")+","}var I=new Array();var D;for(var G=0;G<B.elements.length;G++){D=B.elements[G];if(D.disabled||!D.name){continue}if(!D.type){continue}if(E&&E.indexOf(","+D.name+",")==-1){continue}switch(D.type.toLowerCase()){case"text":case"password":case"textarea":case"hidden":case"submit":I.push(encodeURIComponent(D.name)+"="+encodeURIComponent(D.value));break;case"select-one":var H="";var C;if(D.selectedIndex>=0){C=D.options[D.selectedIndex];H=C.value||C.text}I.push(encodeURIComponent(D.name)+"="+encodeURIComponent(H));break;case"select-multiple":for(var F=0;F<D.length;F++){if(D.options[F].selected){H=D.options[F].value||D.options[F].text;I.push(encodeURIComponent(D.name)+"="+encodeURIComponent(H))}}break;case"checkbox":case"radio":if(D.checked){I.push(encodeURIComponent(D.name)+"="+encodeURIComponent(D.value))}break;default:break}}return I.join("&")};var Spry;if(!Spry){Spry={}}if(!Spry.Widget){Spry.Widget={}}Spry.Widget.ValidationRadio=function(A,B){this.init(A);Spry.Widget.Utils.setOptions(this,B);var C=["submit"].concat(this.validateOn||[]);C=C.join(",");this.validateOn=0|(C.indexOf("submit")!=-1?Spry.Widget.ValidationRadio.ONSUBMIT:0);this.validateOn=this.validateOn|(C.indexOf("blur")!=-1?Spry.Widget.ValidationRadio.ONBLUR:0);this.validateOn=this.validateOn|(C.indexOf("change")!=-1?Spry.Widget.ValidationRadio.ONCHANGE:0);if(this.additionalError){this.additionalError=this.getElement(this.additionalError)}if(Spry.Widget.ValidationRadio.onloadDidFire){this.attachBehaviors()}else{Spry.Widget.ValidationRadio.loadQueue.push(this)}};Spry.Widget.ValidationRadio.ONCHANGE=1;Spry.Widget.ValidationRadio.ONBLUR=2;Spry.Widget.ValidationRadio.ONSUBMIT=4;Spry.Widget.ValidationRadio.prototype.init=function(A){this.element=this.getElement(A);this.additionalError=false;this.radioElements=null;this.form=null;this.event_handlers=[];this.requiredClass="radioRequiredState";this.focusClass="radioFocusState";this.invalidClass="radioInvalidState";this.validClass="radioValidState";this.emptyValue="";this.invalidValue=null;this.isRequired=true;this.validateOn=["submit"]};Spry.Widget.ValidationRadio.onloadDidFire=false;Spry.Widget.ValidationRadio.loadQueue=[];Spry.Widget.ValidationRadio.prototype.getElement=function(A){if(A&&typeof A=="string"){return document.getElementById(A)}return A};Spry.Widget.ValidationRadio.processLoadQueue=function(C){Spry.Widget.ValidationRadio.onloadDidFire=true;var D=Spry.Widget.ValidationRadio.loadQueue;var A=D.length;for(var B=0;B<A;B++){D[B].attachBehaviors()}};Spry.Widget.ValidationRadio.addLoadListener=function(A){if(typeof window.addEventListener!="undefined"){window.addEventListener("load",A,false)}else{if(typeof document.addEventListener!="undefined"){document.addEventListener("load",A,false)}else{if(typeof window.attachEvent!="undefined"){window.attachEvent("onload",A)}}}};Spry.Widget.ValidationRadio.addLoadListener(Spry.Widget.ValidationRadio.processLoadQueue);Spry.Widget.ValidationRadio.addLoadListener(function(){Spry.Widget.Utils.addEventListener(window,"unload",Spry.Widget.Form.destroyAll,false)});Spry.Widget.ValidationRadio.prototype.attachBehaviors=function(){if(!this.element){return }if(this.element.nodeName=="INPUT"){this.radioElements=[this.element]}else{this.radioElements=this.getRadios()}if(this.radioElements){var B=this;this.event_handlers=[];var A=this.radioElements.length;for(var C=0;C<A;C++){this.event_handlers.push([this.radioElements[C],"focus",function(D){return B.onFocus(D)}]);this.event_handlers.push([this.radioElements[C],"blur",function(D){return B.onBlur(D)}]);if(this.validateOn&Spry.Widget.ValidationRadio.ONCHANGE){this.event_handlers.push([this.radioElements[C],"click",function(D){return B.onClick(D)}])}}for(var C=0;C<this.event_handlers.length;C++){Spry.Widget.Utils.addEventListener(this.event_handlers[C][0],this.event_handlers[C][1],this.event_handlers[C][2],false)}this.form=Spry.Widget.Utils.getFirstParentWithNodeName(this.element,"FORM");if(this.form){if(!this.form.attachedSubmitHandler&&!this.form.onsubmit){this.form.onsubmit=function(D){D=D||event;return Spry.Widget.Form.onSubmit(D,D.srcElement||D.currentTarget)};this.form.attachedSubmitHandler=true}if(!this.form.attachedResetHandler){Spry.Widget.Utils.addEventListener(this.form,"reset",function(D){D=D||event;return Spry.Widget.Form.onReset(D,D.srcElement||D.currentTarget)},false);this.form.attachedResetHandler=true}Spry.Widget.Form.onSubmitWidgetQueue.push(this)}}};Spry.Widget.ValidationRadio.prototype.getRadios=function(){var B;var D=this.element.getElementsByTagName("INPUT");if(D.length){B=[];var A=D.length;for(var C=0;C<A;C++){if(D[C].getAttribute("type").toLowerCase()=="radio"){B.push(D[C])}}return B}return null};Spry.Widget.ValidationRadio.prototype.addClassName=function(B,A){if(!B||!A||(B.className&&B.className.search(new RegExp("\\b"+A+"\\b"))!=-1)){return }B.className+=(B.className?" ":"")+A};Spry.Widget.ValidationRadio.prototype.removeClassName=function(B,A){if(!B||!A||(B.className&&B.className.search(new RegExp("\\b"+A+"\\b"))==-1)){return }B.className=B.className.replace(new RegExp("\\s*\\b"+A+"\\b","g"),"")};Spry.Widget.ValidationRadio.prototype.onFocus=function(B){var A=(B.srcElement!=null)?B.srcElement:B.target;if(A.disabled){return }this.addClassName(this.element,this.focusClass);this.addClassName(this.additionalError,this.focusClass)};Spry.Widget.ValidationRadio.prototype.onBlur=function(C){var B=(C.srcElement!=null)?C.srcElement:C.target;if(B.disabled){return }var A=false;if(this.validateOn&Spry.Widget.ValidationRadio.ONBLUR){A=true}if(A){this.validate()}this.removeClassName(this.element,this.focusClass);this.removeClassName(this.additionalError,this.focusClass)};Spry.Widget.ValidationRadio.prototype.onClick=function(B){var A=(B.srcElement!=null)?B.srcElement:B.target;if(A.disabled){return }this.validate()};Spry.Widget.ValidationRadio.prototype.reset=function(){this.removeClassName(this.element,this.validClass);this.removeClassName(this.element,this.requiredClass);this.removeClassName(this.element,this.invalidClass);this.removeClassName(this.additionalError,this.validClass);this.removeClassName(this.additionalError,this.requiredClass);this.removeClassName(this.additionalError,this.invalidClass)};Spry.Widget.ValidationRadio.prototype.validate=function(){this.reset();var E=0;var C=0;var D=0;if(this.radioElements){var A=this.radioElements.length;for(var B=0;B<A;B++){if(!this.radioElements[B].disabled&&this.radioElements[B].checked){if(this.radioElements[B].value==this.emptyValue){D++}else{if(this.invalidValue&&this.radioElements[B].value==this.invalidValue){C++}else{E++}}}}}if(this.invalidValue&&C!=0){this.addClassName(this.element,this.invalidClass);this.addClassName(this.additionalError,this.invalidClass);return false}if(this.isRequired&&(E==0||D!=0)){this.addClassName(this.element,this.requiredClass);this.addClassName(this.additionalError,this.requiredClass);return false}this.addClassName(this.element,this.validClass);this.addClassName(this.additionalError,this.validClass);return true};Spry.Widget.ValidationRadio.prototype.isDisabled=function(){var B=true;if(this.radioElements){var A=this.radioElements.length;for(var C=0;C<A;C++){if(!this.radioElements[C].disabled){B=false;break}}}return B};Spry.Widget.ValidationRadio.prototype.destroy=function(){if(this.event_handlers){for(var B=0;B<this.event_handlers.length;B++){Spry.Widget.Utils.removeEventListener(this.event_handlers[B][0],this.event_handlers[B][1],this.event_handlers[B][2],false)}}try{delete this.element}catch(C){}if(this.radioElements){for(var B=0;B<this.radioElements.length;B++){try{delete this.radioElements[B]}catch(C){}}}try{delete this.radioElements}catch(C){}try{delete this.form}catch(C){}try{delete this.event_handlers}catch(C){}var D=Spry.Widget.Form.onSubmitWidgetQueue;var A=D.length;for(var B=0;B<A;B++){if(D[B]==this){D.splice(B,1);break}}};if(!Spry.Widget.Form){Spry.Widget.Form={}}if(!Spry.Widget.Form.onSubmitWidgetQueue){Spry.Widget.Form.onSubmitWidgetQueue=[]}if(!Spry.Widget.Form.validate){Spry.Widget.Form.validate=function(F){var E=true;var D=true;var C=Spry.Widget.Form.onSubmitWidgetQueue;var A=C.length;for(var B=0;B<A;B++){if(!C[B].isDisabled()&&C[B].form==F){D=C[B].validate();E=D&&E}}return E}}if(!Spry.Widget.Form.onSubmit){Spry.Widget.Form.onSubmit=function(B,A){if(Spry.Widget.Form.validate(A)==false){return false}return true}}if(!Spry.Widget.Form.onReset){Spry.Widget.Form.onReset=function(D,E){var C=Spry.Widget.Form.onSubmitWidgetQueue;var A=C.length;for(var B=0;B<A;B++){if(!C[B].isDisabled()&&C[B].form==E&&typeof (C[B].reset)=="function"){C[B].reset()}}return true}}if(!Spry.Widget.Form.destroy){Spry.Widget.Form.destroy=function(B){var C=Spry.Widget.Form.onSubmitWidgetQueue;for(var A=0;A<Spry.Widget.Form.onSubmitWidgetQueue.length;A++){if(C[A].form==B&&typeof (C[A].destroy)=="function"){C[A].destroy();A--}}}}if(!Spry.Widget.Form.destroyAll){Spry.Widget.Form.destroyAll=function(){var B=Spry.Widget.Form.onSubmitWidgetQueue;for(var A=0;A<Spry.Widget.Form.onSubmitWidgetQueue.length;A++){if(typeof (B[A].destroy)=="function"){B[A].destroy();A--}}}}if(!Spry.Widget.Utils){Spry.Widget.Utils={}}Spry.Widget.Utils.setOptions=function(D,C,A){if(!C){return }for(var B in C){if(A&&C[B]==undefined){continue}D[B]=C[B]}};Spry.Widget.Utils.getFirstParentWithNodeName=function(A,B){while(A.parentNode&&A.parentNode.nodeName.toLowerCase()!=B.toLowerCase()&&A.parentNode.nodeName!="BODY"){A=A.parentNode}if(A.parentNode&&A.parentNode.nodeName.toLowerCase()==B.toLowerCase()){return A.parentNode}else{return null}};Spry.Widget.Utils.destroyWidgets=function(A){if(typeof A=="string"){A=document.getElementById(A)}var C=Spry.Widget.Form.onSubmitWidgetQueue;for(var B=0;B<Spry.Widget.Form.onSubmitWidgetQueue.length;B++){if(typeof (C[B].destroy)=="function"&&Spry.Widget.Utils.contains(A,C[B].element)){C[B].destroy();B--}}};Spry.Widget.Utils.contains=function(B,C){if(typeof B.contains=="object"){return C&&B&&(B==C||B.contains(C))}else{var A=C;while(A){if(A==B){return true}A=A.parentNode}return false}};Spry.Widget.Utils.addEventListener=function(C,B,D,A){try{if(C.addEventListener){C.addEventListener(B,D,A)}else{if(C.attachEvent){C.attachEvent("on"+B,D,A)}}}catch(E){}};Spry.Widget.Utils.removeEventListener=function(C,B,D,A){try{if(C.removeEventListener){C.removeEventListener(B,D,A)}else{if(C.detachEvent){C.detachEvent("on"+B,D,A)}}}catch(E){}};function changeVideo(F,G,A,E,B,K,D,H,N,M,J){var L="";var I="";if(M!=""){duraSecs=Math.round(J/1000);I='soMini.addVariable("publicidad",\''+M+"/VIDEODURACION="+duraSecs+"');"}if(D=="directo"){L='<script type=\'text/javascript\'>var alto = 238;var ancho = 305;var soMini = new SWFObject(\'/swf/mediaplayer.swf?t=\' +new Date().getTime(),\'flashcontent\',ancho,alto,\'8\');soMini.addParam("allowfullscreen","true");soMini.addParam("allowScriptAccess","always");soMini.addParam("wmode","transparent");soMini.addVariable("autostart","true");soMini.addVariable("showdigits","false");soMini.addVariable("overstretch","true");soMini.addVariable("isExtern","true");soMini.addVariable("width", ancho);soMini.addVariable("folder","/swf/flvplayer/");soMini.addVariable("height", alto);soMini.addVariable("file",\''+H+'\');soMini.addVariable("playicon","/swf/flvplayer/playicon.swf");soMini.addVariable("live","true");soMini.addVariable("url",\''+N+"');soMini.write('"+A+"');<\/script>"}else{L='<script type=\'text/javascript\'>var alto = 238;var ancho = 305;var soMini = new SWFObject(\'/swf/mediaplayer.swf?t=\'+new Date().getTime(),\'flashcontent\',ancho,alto,\'8\');soMini.addParam("allowfullscreen","true");soMini.addParam("allowScriptAccess","always");soMini.addParam("wmode","transparent");soMini.addVariable("autostart","true");soMini.addVariable("showdigits","true");soMini.addVariable("overstretch","true");soMini.addVariable("isExtern","true");soMini.addVariable("width", ancho);soMini.addVariable("folder","/swf/flvplayer/");soMini.addVariable("height", alto);soMini.addVariable("file",\''+F+"');soMini.addVariable(\"duration\",'"+J+"');soMini.addVariable(\"image\",'"+G+'\');soMini.addVariable("playicon","/swf/flvplayer/playicon.swf");soMini.addVariable("url",\''+N+"');"+I+"soMini.write('"+A+"');<\/script>"}$("#"+A).html(L);var C="<p class='title'><a href='"+N+"'>"+E+"</a></p>";$("#"+K).html(C)}function changeVideo2(F,G,A,E,B,K,D,H,N,M,J){var L="";var C="";var I="";if(M!=""){duraSecs=Math.round(J/1000);I='soMini.addVariable("publicidad",\''+M+"/VIDEODURACION="+duraSecs+"');"}if(D=="directo"){L="<script type='text/javascript'>var alto = 238;var ancho = 305;var flashcontentId= 'player"+B+'\';var soMini = new SWFObject(\'/swf/mediaplayer.swf?t=\' +new Date().getTime(),flashcontentId,ancho,alto,\'8\');soMini.addParam("allowfullscreen","true");soMini.addParam("allowScriptAccess","always");soMini.addParam("wmode","transparent");soMini.addVariable("autostart","true");soMini.addVariable("showdigits","false");soMini.addVariable("overstretch","true");soMini.addVariable("isExtern","true");soMini.addVariable("width", ancho);soMini.addVariable("folder","/swf/flvplayer/");soMini.addVariable("javascriptid", flashcontentId);soMini.addVariable("height", alto);soMini.addVariable("file",\''+H+'\');soMini.addVariable("playicon","/swf/flvplayer/playicon.swf");soMini.addVariable("live","true");soMini.addVariable("url",\''+N+"');soMini.write('"+A+"');<\/script>";C="<h2><a href='"+N+"'><span>DIRECTO</span>"+E+"</a></h2>"}else{L="<script type='text/javascript'>var alto = 238;var ancho = 305;var flashcontentId= 'player"+B+'\';var soMini = new SWFObject(\'/swf/mediaplayer.swf?t=\'+new Date().getTime(),flashcontentId,ancho,alto,\'8\');soMini.addParam("allowfullscreen","true");soMini.addParam("allowScriptAccess","always");soMini.addParam("wmode","transparent");soMini.addVariable("autostart","true");soMini.addVariable("showdigits","true");soMini.addVariable("overstretch","true");soMini.addVariable("isExtern","true");soMini.addVariable("width", ancho);soMini.addVariable("folder","/swf/flvplayer/");soMini.addVariable("javascriptid", flashcontentId);soMini.addVariable("height", alto);soMini.addVariable("file",\''+F+"');soMini.addVariable(\"duration\",'"+J+"');soMini.addVariable(\"image\",'"+G+'\');soMini.addVariable("playicon","/swf/flvplayer/playicon.swf");soMini.addVariable("url",\''+N+"');"+I+"soMini.write('"+A+"');<\/script>";C="<h2><a href='"+N+"'>"+E+"</a></h2>"}$("#"+A).html(L);$("#"+K).html(C)}function mostrarSiProcedeUnEnlaceDePaginaDeDirectoDelCanal24Horas(B,D){var F="idiphone83746";$("#"+F).remove();var A=(/iphone/i).test(navigator.userAgent);if(A){var C=B==3341;if(C){var E='<a id="'+F+'" href="http://m.rtve.es/live24/" style="background:#900;width:297px;color:white;font-weight:bold;text-decoration:underline;float:left;padding:4px;font-size:1.3em">Para ver el Canal 24h en tu Iphone, pincha aqu&iacute;</a>';$("#"+D).after(E)}}}function changeVideoAS3(A,E,B,F,D,L,K,I){var H="";var C="";var J=(D=="directo")?"<span>DIRECTO</span>":"";var G=currentId.substring(13);document.getElementById("publi_"+G).style.display="none";document.getElementById("publi_"+B).style.display="block";thisMovie(currentId).setStop();H="<script type='text/javascript'>var alto = 238;var ancho = 305;var flashcontentId= 'minividplayer"+B+'\';currentId = flashcontentId;var soMini = new SWFObject(\'/swf/v2/RTVEPlayer.swf\',flashcontentId,ancho,alto,\'9\');soMini.addParam("allowfullscreen","true");soMini.addParam("allowScriptAccess","always");soMini.addParam("wmode","transparent");soMini.addVariable("assetID","'+B+"_"+I+'_videos");soMini.addVariable("location","'+K+'");';H=H+'soMini.write("'+A+'");<\/script>';C="<h2><a href='"+L+"'>"+J+E+"</a></h2>";$("#"+A).html(H);$("#"+F).html(C);setTimeout("thisMovie('minividplayer"+B+"').setPlay()",3000);mostrarSiProcedeUnEnlaceDePaginaDeDirectoDelCanal24Horas(B,A)}function thisMovie(A){if(navigator.appName.indexOf("Microsoft")!=-1){return window[A]}else{return document[A]}}function loadVideo(A,B){thisMovie(A).setAutostart(true);thisMovie(A).loadFile(B)}function changeVideoAS3New(R,L,K,J,M,I,D,T,P,G,B,Q){var E="";var S="";var C="";var F=(D=="directo")?T:R;var N=Math.round(B/1000);var O=(D=="directo")?"<span>DIRECTO</span>":"";var A=K.substring(7);var H="player"+A;alert(H);if(thisMovie(H)){alert("entra en no creado");loadVideo(H,{file:F,image:L,category:null});if(D=="directo"){updatePlugin(H,"controlbar",{live:"true"})}else{updatePlugin(H,"controlbar",{live:"false",scrub:"false"})}updatePlugin(H,"advertisement",{url:G,type:"antevenio",timeout:"10",videoduracion:N})}else{alert("entra en creado");E="<script type='text/javascript'>var alto = 238;var ancho = 305;var flashcontentId= 'player"+M+'\';var soMini = new SWFObject(\'/swf/FLVPlayer.swf\',flashcontentId,ancho,alto,\'9\');soMini.addParam("allowfullscreen","true");soMini.addParam("allowScriptAccess","always");soMini.addParam("wmode","transparent");soMini.addVariable("autostart","true");soMini.addVariable("width", ancho);soMini.addVariable("height", alto);soMini.addVariable("config","/swf/data/rtve_config_mini.xml");soMini.addVariable("javascriptid", flashcontentId);soMini.addVariable("duration",\''+N+"');soMini.addVariable(\"file\",'"+F+'\');soMini.addVariable("nielsen","assetID::'+M+",url::"+P+",rsCG::"+Q+'");soMini.addVariable("advertisement","url::'+G+",type::antevenio,timeout::10,videoduracion::"+N+'");';if(D=="directo"){E=E+'soMini.addVariable("controlbar","live::true,scrub::false,stopTimer::120,mute::true");'}else{E=E+'soMini.addVariable("controlbar","live::false,scrub::true");'}if(L=!""){E=E+'soMini.addVariable("image",\''+L+"');"}E=E+"soMini.write('"+K+"');<\/script>";$("#"+K).html(E)}S="<h2><a href='"+P+"'>"+O+J+"</a></h2>";$("#"+I).html(S)}var mini_volume=80;function enviarEvento(B,A){if($.browser.msie){playerW=window[B]}else{playerW=document[B]}switch(A){case"mute":if(mini_volume>0){playerW.setVolume(0);mini_volume=0}else{playerW.setVolume(80);mini_volume=80}break;case"pp":playerW.setPause();break;case"stop":playerW.setStop();break}}function updatePlugin(A,B,C){thisMovie(A).updatePlugin(B,C)}function loadFile(A,B){thisMovie(A).loadFile(B)}I18n.es.messages_servicio_no_disponible="El servicio no est? disponible temporalmente, int?ntelo en unos minutos.";I18n.es.messages_error_interno_servidor="Error interno en el servidor.";I18n.ca.messages_servicio_no_disponible="El servei no est? disponible temporalment, torneu-ho en uns minuts.";I18n.ca.messages_error_interno_servidor="Error intern del servidor";function printMessage(C,B){var A=Spry.$(C);if(A){Spry.Utils.setInnerHTML(C,B)}else{alert(B)}}function printError(E,D){var C=D.xhRequest.responseXML;if(!C||!C.firstChild){C=Spry.Utils.stringToXMLDoc(escape(D.xhRequest.responseText));if(!C||!C.firstChild){if(D.xhRequest.status==503||D.xhRequest.status==504){A="El servicio no est? disponible temporalmente, int?ntelo en unos minutos.";printMessage(E,A);return }else{var A=D.xhRequest.statusText;A=((A)&&(A!=""))?A:"Error interno en el servidor.";printMessage(E,A);return }}}var B=Spry.XML.documentToObject(C);if(B.exception){if(B.exception.cause){printMessage(E,B.exception.cause.message._value())}else{printMessage(E,B.exception.message._value())}}else{if(D.xhRequest.status==503||D.xhRequest.status==504){A="El servicio no est? disponible temporalmente, int?ntelo en unos minutos.";printMessage(E,A);return }else{var A=D.xhRequest.statusText;A=((A)&&(A!=""))?A:"Error interno en el servidor.";printMessage(E,A)}}}function printErrorI18n(E,D){var C=D.xhRequest.responseXML;if(!C||!C.firstChild){C=Spry.Utils.stringToXMLDoc(escape(D.xhRequest.responseText));if(!C||!C.firstChild){if(D.xhRequest.status==503||D.xhRequest.status==504){A=I18n[D.userData.locale].messages_servicio_no_disponible;printMessage(E,A);return }else{var A=D.xhRequest.statusText;A=((A)&&(A!=""))?A:I18n[D.userData.locale].messages_error_interno_servidor;printMessage(E,A);return }}}var B=Spry.XML.documentToObject(C);if(B.exception){if(B.exception.cause){printMessage(E,B.exception.cause.message._value())}else{printMessage(E,B.exception.message._value())}}else{if(D.xhRequest.status==503||D.xhRequest.status==504){A=I18n[D.userData.locale].messages_servicio_no_disponible;printMessage(E,A);return }else{var A=D.xhRequest.statusText;A=((A)&&(A!=""))?A:I18n[D.userData.locale].messages_error_interno_servidor;printMessage(E,A)}}}function cleanMessageArea(B){var A=Spry.$(B);if(A){printMessage(B,"")}}function showMessage(A,B){if(!B){B=2000}printMessage("toolsMessageArea",A);mostrar_toolbar("toolsMessageBox");setTimeout("ocultar_toolbar('toolsMessageBox')",B)}function showBox(B){var A=Spry.$(B);if(A){A.style.display="block"}}function closeBox(B){var A=Spry.$(B);if(A){A.style.display="none"}}I18n.es.poll_voto_ok="Tu voto se ha computado correctamente.";I18n.es.poll_seleccionar_opcion="Para votar, es obligatorio especificar una opci?n de la encuesta.";I18n.ca.poll_voto_ok="El teu vot s'ha computat correctament.";I18n.ca.poll_seleccionar_opcion="Per a votar, ?s obligatori especificar una opci?n de l'enquesta.";var POLL_FORM="pollForm";var pollLoaded=false;var dsPoll=new Spry.Data.XMLDataSet(null,"/com.ctv.web.vo.PollVO/content",{useCache:false});var dsPollResponses=new Spry.Data.NestedXMLDataSet(dsPoll,"contentRelations/entry[string='PL_RESPOST']/list/com.ctv.deliverty.common.vo.ContentRelationVO",{useCache:false,sortOnLoad:"order"});dsPollResponses.addObserver(PreProcessScoreData);function PreProcessScoreData(C,N,F){if(C=="onPreLoad"){pollLoaded=false}if(C!="onPostLoad"){return }pollLoaded=true;var B=dsPollResponses.getData();var I=B.length;if(I==0){return }var M=0;for(var G=0;G<I;G++){var L=B[G];L.votos=0;var K=Spry.XML.nodeToObject(L.ds_XMLNode);var J=K.attributes._getPropertyAsArray("entry");for(var E=0;E<J.length;E++){if(J[E].string[0]._value()=="PR_VOTES"){L.votos=parseInt(J[E].string[1]._value());M+=L.votos}}}for(var G=0;G<I;G++){var L=B[G];var D=0;var A=0;if(M>0){D=L.votos*100/M;A=L.votos*210/M}if(D.toFixed){D=D.toFixed(1)}var H=L.toContentId;pintadato("percent_"+H,String(D));pintadato("votos_"+H,String(L.votos));pintabarra("barra_"+H,A)}pintadato("total_votos",String(M))}function pintadato(A,B){var C=Spry.$(A);if(C){Spry.Utils.setInnerHTML(A,B)}}function pintabarra(A,B){var C=Spry.$(A);if(C){C.style.width=B+"px"}}function loadPoll(A){dsPoll.setURL("/su/services/getPoll?POLLID="+A);dsPoll.loadData()}function addPollVote(C,A){var B=Spry.$(POLL_FORM+"_"+C);if(Spry.Widget.Form.validate(B)==true){B.action="/su/services/addPollVote";Spry.Utils.submitForm(B,pollVoteResponse,{method:"post",errorCallback:pollVoteError,headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},userData:{pollid:C,Url:A}})}return false}function addPollVoteI18n(F,B,A){var E=Spry.$(POLL_FORM+"_"+F);var C=$("fieldset#vrespuestas p input");var D=false;for(i=0;i<C.length;i++){if(C[i].checked){D=true}}if(!D){printMessage("toolsMessageArea",I18n[A].poll_seleccionar_opcion);return false}if(Spry.Widget.Form.validate(E)==true){E.action="/su/services/addPollVote";Spry.Utils.submitForm(E,pollVoteResponseI18n,{method:"post",errorCallback:pollVoteErrorI18n,headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},userData:{pollid:F,Url:B,locale:A}})}return false}pollVoteError=function(A){printError("toolsMessageArea",A);window.location.href=A.userData.Url};pollVoteErrorI18n=function(A){printErrorI18n("toolsMessageArea",A);window.location.href=A.userData.Url};pollVoteResponse=function(A){printMessage("toolsMessageArea","Tu voto se ha computado correctamente.");showBox("toolsMessageBox");setTimeout("closeBox('toolsMessageBox');",3000);window.location.href=A.userData.Url};pollVoteResponseI18n=function(A){printMessage("toolsMessageArea",I18n[A.userData.locale].poll_voto_ok);showBox("toolsMessageBox");setTimeout("closeBox('toolsMessageBox');",3000);window.location.href=A.userData.Url};var REGEXP_UNICODE=function(){var B=[" ","\u0120",-1,"!","\u0120",-1,"\u0120","\u0120",0,"\u0121","\u0120",-1,"\u0121","\u0120|\u0121",0,"\u0122","\u0120|\u0121",-1,"\u0120","[\u0120]",0,"\u0121","[\u0120]",-1,"\u0121","[\u0120\u0121]",0,"\u0122","[\u0120\u0121]",-1,"\u0121","[\u0120-\u0121]",0,"\u0122","[\u0120-\u0121]",-1];for(var A=0;A<B.length;A+=3){if(B[A].search(new RegExp(B[A+1]))!=B[A+2]){return false}}return true}();var XML_S="[ \t\r\n]+";var XML_EQ="("+XML_S+")?=("+XML_S+")?";var XML_CHAR_REF="&#[0-9]+;|&#x[0-9a-fA-F]+;";var XML10_VERSION_INFO=XML_S+"version"+XML_EQ+"(\"1\\.0\"|'1\\.0')";var XML10_BASE_CHAR=(REGEXP_UNICODE)?"\u0041-\u005a\u0061-\u007a\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0100-\u0131\u0134-\u013e\u0141-\u0148\u014a-\u017e\u0180-\u01c3\u01cd-\u01f0\u01f4-\u01f5\u01fa-\u0217\u0250-\u02a8\u02bb-\u02c1\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03ce\u03d0-\u03d6\u03da\u03dc\u03de\u03e0\u03e2-\u03f3\u0401-\u040c\u040e-\u044f\u0451-\u045c\u045e-\u0481\u0490-\u04c4\u04c7-\u04c8\u04cb-\u04cc\u04d0-\u04eb\u04ee-\u04f5\u04f8-\u04f9\u0531-\u0556\u0559\u0561-\u0586\u05d0-\u05ea\u05f0-\u05f2\u0621-\u063a\u0641-\u064a\u0671-\u06b7\u06ba-\u06be\u06c0-\u06ce\u06d0-\u06d3\u06d5\u06e5-\u06e6\u0905-\u0939\u093d\u0958-\u0961\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09dc-\u09dd\u09df-\u09e1\u09f0-\u09f1\u0a05-\u0a0a\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36\u0a38-\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8b\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9\u0abd\u0ae0\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32-\u0b33\u0b36-\u0b39\u0b3d\u0b5c-\u0b5d\u0b5f-\u0b61\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4\u0ba8-\u0baa\u0bae-\u0bb5\u0bb7-\u0bb9\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c60-\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cde\u0ce0-\u0ce1\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d60-\u0d61\u0e01-\u0e2e\u0e30\u0e32-\u0e33\u0e40-\u0e45\u0e81-\u0e82\u0e84\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa-\u0eab\u0ead-\u0eae\u0eb0\u0eb2-\u0eb3\u0ebd\u0ec0-\u0ec4\u0f40-\u0f47\u0f49-\u0f69\u10a0-\u10c5\u10d0-\u10f6\u1100\u1102-\u1103\u1105-\u1107\u1109\u110b-\u110c\u110e-\u1112\u113c\u113e\u1140\u114c\u114e\u1150\u1154-\u1155\u1159\u115f-\u1161\u1163\u1165\u1167\u1169\u116d-\u116e\u1172-\u1173\u1175\u119e\u11a8\u11ab\u11ae-\u11af\u11b7-\u11b8\u11ba\u11bc-\u11c2\u11eb\u11f0\u11f9\u1e00-\u1e9b\u1ea0-\u1ef9\u1f00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2126\u212a-\u212b\u212e\u2180-\u2182\u3041-\u3094\u30a1-\u30fa\u3105-\u312c\uac00-\ud7a3":"A-Za-z";var XML10_IDEOGRAPHIC=(REGEXP_UNICODE)?"\u4e00-\u9fa5\u3007\u3021-\u3029":"";var XML10_COMBINING_CHAR=(REGEXP_UNICODE)?"\u0300-\u0345\u0360-\u0361\u0483-\u0486\u0591-\u05a1\u05a3-\u05b9\u05bb-\u05bd\u05bf\u05c1-\u05c2\u05c4\u064b-\u0652\u0670\u06d6-\u06dc\u06dd-\u06df\u06e0-\u06e4\u06e7-\u06e8\u06ea-\u06ed\u0901-\u0903\u093c\u093e-\u094c\u094d\u0951-\u0954\u0962-\u0963\u0981-\u0983\u09bc\u09be\u09bf\u09c0-\u09c4\u09c7-\u09c8\u09cb-\u09cd\u09d7\u09e2-\u09e3\u0a02\u0a3c\u0a3e\u0a3f\u0a40-\u0a42\u0a47-\u0a48\u0a4b-\u0a4d\u0a70-\u0a71\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0b01-\u0b03\u0b3c\u0b3e-\u0b43\u0b47-\u0b48\u0b4b-\u0b4d\u0b56-\u0b57\u0b82-\u0b83\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0c01-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55-\u0c56\u0c82-\u0c83\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5-\u0cd6\u0d02-\u0d03\u0d3e-\u0d43\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb-\u0ebc\u0ec8-\u0ecd\u0f18-\u0f19\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86-\u0f8b\u0f90-\u0f95\u0f97\u0f99-\u0fad\u0fb1-\u0fb7\u0fb9\u20d0-\u20dc\u20e1\u302a-\u302f\u3099\u309a":"";var XML10_DIGIT=(REGEXP_UNICODE)?"\u0030-\u0039\u0660-\u0669\u06f0-\u06f9\u0966-\u096f\u09e6-\u09ef\u0a66-\u0a6f\u0ae6-\u0aef\u0b66-\u0b6f\u0be7-\u0bef\u0c66-\u0c6f\u0ce6-\u0cef\u0d66-\u0d6f\u0e50-\u0e59\u0ed0-\u0ed9\u0f20-\u0f29":"0-9";var XML10_EXTENDER=(REGEXP_UNICODE)?"\u00b7\u02d0\u02d1\u0387\u0640\u0e46\u0ec6\u3005\u3031-\u3035\u309d-\u309e\u30fc-\u30fe":"";var XML10_LETTER=XML10_BASE_CHAR+XML10_IDEOGRAPHIC;var XML10_NAME_CHAR=XML10_LETTER+XML10_DIGIT+"\\._:"+XML10_COMBINING_CHAR+XML10_EXTENDER+"-";var XML10_NAME="["+XML10_LETTER+"_:]["+XML10_NAME_CHAR+"]*";var XML10_ENTITY_REF="&"+XML10_NAME+";";var XML10_REFERENCE=XML10_ENTITY_REF+"|"+XML_CHAR_REF;var XML10_ATT_VALUE='"(([^<&"]|'+XML10_REFERENCE+")*)\"|'(([^<&']|"+XML10_REFERENCE+")*)'";var XML10_ATTRIBUTE="("+XML10_NAME+")"+XML_EQ+"("+XML10_ATT_VALUE+")";var XML11_VERSION_INFO=XML_S+"version"+XML_EQ+"(\"1\\.1\"|'1\\.1')";var XML11_NAME_START_CHAR=(REGEXP_UNICODE)?":A-Z_a-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c-\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd":":A-Z_a-z";var XML11_NAME_CHAR=XML11_NAME_START_CHAR+((REGEXP_UNICODE)?"\\.0-9\u00b7\u0300-\u036f\u203f-\u2040-":"\\.0-9-");var XML11_NAME="["+XML11_NAME_START_CHAR+"]["+XML11_NAME_CHAR+"]*";var XML11_ENTITY_REF="&"+XML11_NAME+";";var XML11_REFERENCE=XML11_ENTITY_REF+"|"+XML_CHAR_REF;var XML11_ATT_VALUE='"(([^<&"]|'+XML11_REFERENCE+")*)\"|'(([^<&']|"+XML11_REFERENCE+")*)'";var XML11_ATTRIBUTE="("+XML11_NAME+")"+XML_EQ+"("+XML11_ATT_VALUE+")";var XML_NC_NAME_CHAR=XML10_LETTER+XML10_DIGIT+"\\._"+XML10_COMBINING_CHAR+XML10_EXTENDER+"-";var XML_NC_NAME="["+XML10_LETTER+"_]["+XML_NC_NAME_CHAR+"]*";var DOM_ELEMENT_NODE=1;var DOM_ATTRIBUTE_NODE=2;var DOM_TEXT_NODE=3;var DOM_CDATA_SECTION_NODE=4;var DOM_ENTITY_REFERENCE_NODE=5;var DOM_ENTITY_NODE=6;var DOM_PROCESSING_INSTRUCTION_NODE=7;var DOM_COMMENT_NODE=8;var DOM_DOCUMENT_NODE=9;var DOM_DOCUMENT_TYPE_NODE=10;var DOM_DOCUMENT_FRAGMENT_NODE=11;var DOM_NOTATION_NODE=12;function xpathLog(A){}function xsltLog(A){}function xsltLogXml(A){}function assert(A){if(!A){throw"Assertion failed"}}function stringSplit(C,E){var B=C.indexOf(E);if(B==-1){return[C]}var D=[];D.push(C.substr(0,B));while(B!=-1){var A=C.indexOf(E,B+1);if(A!=-1){D.push(C.substr(B+1,A-B-1))}else{D.push(C.substr(B+1))}B=A}return D}function mapExec(C,B){for(var A=0;A<C.length;++A){B.call(this,C[A],A)}}function mapExpr(D,C){var A=[];for(var B=0;B<D.length;++B){A.push(C(D[B]))}return A}function reverseInplace(D){for(var A=0;A<D.length/2;++A){var C=D[A];var B=D.length-A-1;D[A]=D[B];D[B]=C}}function removeFromArray(E,C,D){var A=0;for(var B=0;B<E.length;++B){if(E[B]===C||(D&&E[B]==C)){E.splice(B--,1);A++}}return A}function copyArray(C,B){for(var A=0;A<B.length;++A){C.push(B[A])}}function xmlValue(C){if(!C){return""}var A="";if(C.nodeType==DOM_TEXT_NODE||C.nodeType==DOM_CDATA_SECTION_NODE||C.nodeType==DOM_ATTRIBUTE_NODE){A+=C.nodeValue}else{if(C.nodeType==DOM_ELEMENT_NODE||C.nodeType==DOM_DOCUMENT_NODE||C.nodeType==DOM_DOCUMENT_FRAGMENT_NODE){for(var B=0;B<C.childNodes.length;++B){A+=arguments.callee(C.childNodes[B])}}}return A}function xpathParse(M){xpathLog("parse "+M);xpathParseInit();var A=xpathCacheLookup(M);if(A){xpathLog(" ... cached");return A}if(M.match(/^(\$|@)?\w+$/i)){var I=makeSimpleExpr(M);xpathParseCache[M]=I;xpathLog(" ... simple");return I}if(M.match(/^\w+(\/\w+)*$/i)){var I=makeSimpleExpr2(M);xpathParseCache[M]=I;xpathLog(" ... simple 2");return I}var J=M;var L=[];var B=null;var G=null;var C=false;var H=0;var F=0;var O=0;while(!C){H++;M=M.replace(/^\s*/,"");G=B;B=null;var K=null;var E="";for(var D=0;D<xpathTokenRules.length;++D){var N=xpathTokenRules[D].re.exec(M);F++;if(N&&N.length>0&&N[0].length>E.length){K=xpathTokenRules[D];E=N[0];break}}if(K&&(K==TOK_DIV||K==TOK_MOD||K==TOK_AND||K==TOK_OR)&&(!G||G.tag==TOK_AT||G.tag==TOK_DSLASH||G.tag==TOK_SLASH||G.tag==TOK_AXIS||G.tag==TOK_DOLLAR)){K=TOK_QNAME}if(K){M=M.substr(E.length);xpathLog("token: "+E+" -- "+K.label);B={tag:K,match:E,prec:K.prec?K.prec:0,expr:makeTokenExpr(E)}}else{xpathLog("DONE");C=true}while(xpathReduce(L,B)){O++;xpathLog("stack: "+stackToString(L))}}xpathLog("stack: "+stackToString(L));if(L.length!=1){throw"XPath parse error "+J+":\n"+stackToString(L)}var N=L[0].expr;xpathParseCache[J]=N;xpathLog("XPath parse: "+H+" / "+F+" / "+O);return N}var xpathParseCache={};function xpathCacheLookup(A){return xpathParseCache[A]}function xpathReduce(H,A){var E=null;if(H.length>0){var F=H[H.length-1];var I=xpathRules[F.tag.key];if(I){for(var B=0;B<I.length;++B){var G=I[B];var C=xpathMatchStack(H,G[1]);if(C.length){E={tag:G[0],rule:G,match:C};E.prec=xpathGrammarPrecedence(E);break}}}}var D;if(E&&(!A||E.prec>A.prec||(A.tag.left&&E.prec>=A.prec))){for(var B=0;B<E.match.matchlength;++B){H.pop()}xpathLog("reduce "+E.tag.label+" "+E.prec+" ahead "+(A?A.tag.label+" "+A.prec+(A.tag.left?" left":""):" none "));var J=mapExpr(E.match,function(K){return K.expr});E.expr=E.rule[3].apply(null,J);H.push(E);D=true}else{if(A){xpathLog("shift "+A.tag.label+" "+A.prec+(A.tag.left?" left":"")+" over "+(E?E.tag.label+" "+E.prec:" none"));H.push(A)}D=false}return D}function xpathMatchStack(H,G){var D=H.length;var F=G.length;var B,I;var E=[];E.matchlength=0;var C=0;for(B=F-1,I=D-1;B>=0&&I>=0;--B,I-=C){C=0;var A=[];if(G[B]==Q_MM){B-=1;E.push(A);while(I-C>=0&&H[I-C].tag==G[B]){A.push(H[I-C]);C+=1;E.matchlength+=1}}else{if(G[B]==Q_01){B-=1;E.push(A);while(I-C>=0&&C<2&&H[I-C].tag==G[B]){A.push(H[I-C]);C+=1;E.matchlength+=1}}else{if(G[B]==Q_1M){B-=1;E.push(A);if(H[I].tag==G[B]){while(I-C>=0&&H[I-C].tag==G[B]){A.push(H[I-C]);C+=1;E.matchlength+=1}}else{return[]}}else{if(H[I].tag==G[B]){E.push(H[I]);C+=1;E.matchlength+=1}else{return[]}}}}reverseInplace(A);A.expr=mapExpr(A,function(J){return J.expr})}reverseInplace(E);if(B==-1){return E}else{return[]}}function xpathTokenPrecedence(A){return A.prec||2}function xpathGrammarPrecedence(E){var B=0;if(E.rule){if(E.rule.length>=3&&E.rule[2]>=0){B=E.rule[2]}else{for(var C=0;C<E.rule[1].length;++C){var D=xpathTokenPrecedence(E.rule[1][C]);B=Math.max(B,D)}}}else{if(E.tag){B=xpathTokenPrecedence(E.tag)}else{if(E.length){for(var A=0;A<E.length;++A){var D=xpathGrammarPrecedence(E[A]);B=Math.max(B,D)}}}}return B}function stackToString(A){var B="";for(var C=0;C<A.length;++C){if(B){B+="\n"}B+=A[C].tag.label}return B}function ExprContext(C,A,D,B){this.node=C;this.position=A||0;this.nodelist=D||[C];this.variables={};this.parent=B||null;if(B){this.root=B.root}else{if(this.node.nodeType==DOM_DOCUMENT_NODE){this.root=C}else{this.root=C.ownerDocument}}}ExprContext.prototype.clone=function(C,A,B){return new ExprContext(C||this.node,typeof A!="undefined"?A:this.position,B||this.nodelist,this)};ExprContext.prototype.setVariable=function(A,B){this.variables[A]=B};ExprContext.prototype.getVariable=function(A){if(typeof this.variables[A]!="undefined"){return this.variables[A]}else{if(this.parent){return this.parent.getVariable(A)}else{return null}}};ExprContext.prototype.setNode=function(A){this.node=this.nodelist[A];this.position=A};ExprContext.prototype.contextSize=function(){return this.nodelist.length};function StringValue(A){this.value=A;this.type="string"}StringValue.prototype.stringValue=function(){return this.value};StringValue.prototype.booleanValue=function(){return this.value.length>0};StringValue.prototype.numberValue=function(){return this.value-0};StringValue.prototype.nodeSetValue=function(){throw this};function BooleanValue(A){this.value=A;this.type="boolean"}BooleanValue.prototype.stringValue=function(){return""+this.value};BooleanValue.prototype.booleanValue=function(){return this.value};BooleanValue.prototype.numberValue=function(){return this.value?1:0};BooleanValue.prototype.nodeSetValue=function(){throw this};function NumberValue(A){this.value=A;this.type="number"}NumberValue.prototype.stringValue=function(){return""+this.value};NumberValue.prototype.booleanValue=function(){return !!this.value};NumberValue.prototype.numberValue=function(){return this.value-0};NumberValue.prototype.nodeSetValue=function(){throw this};function NodeSetValue(A){this.value=A;this.type="node-set"}NodeSetValue.prototype.stringValue=function(){if(this.value.length==0){return""}else{return xmlValue(this.value[0])}};NodeSetValue.prototype.booleanValue=function(){return this.value.length>0};NodeSetValue.prototype.numberValue=function(){return this.stringValue()-0};NodeSetValue.prototype.nodeSetValue=function(){return this.value};function TokenExpr(A){this.value=A}TokenExpr.prototype.evaluate=function(){return new StringValue(this.value)};function LocationExpr(){this.absolute=false;this.steps=[]}LocationExpr.prototype.appendStep=function(A){this.steps.push(A)};LocationExpr.prototype.prependStep=function(C){var A=this.steps;this.steps=[C];for(var B=0;B<A.length;++B){this.steps.push(A[B])}};LocationExpr.prototype.evaluate=function(A){var C;if(this.absolute){C=A.root}else{C=A.node}var B=[];xPathStep(B,this.steps,0,C,A);return new NodeSetValue(B)};function xPathStep(A,E,B,F,H){var I=E[B];var D=H.clone(F);var G=I.evaluate(D).nodeSetValue();for(var C=0;C<G.length;++C){if(B==E.length-1){A.push(G[C])}else{xPathStep(A,E,B+1,G[C],H)}}}function StepExpr(B,C,A){this.axis=B;this.nodetest=C;this.predicate=A||[]}StepExpr.prototype.appendPredicate=function(A){this.predicate.push(A)};StepExpr.prototype.evaluate=function(A){var C=A.node;var F=[];if(this.axis==xpathAxis.ANCESTOR_OR_SELF){F.push(C);for(var H=C.parentNode;H;H=H.parentNode){F.push(H)}}else{if(this.axis==xpathAxis.ANCESTOR){for(var H=C.parentNode;H;H=H.parentNode){F.push(H)}}else{if(this.axis==xpathAxis.ATTRIBUTE){copyArray(F,C.attributes)}else{if(this.axis==xpathAxis.CHILD){copyArray(F,C.childNodes)}else{if(this.axis==xpathAxis.DESCENDANT_OR_SELF){F.push(C);xpathCollectDescendants(F,C)}else{if(this.axis==xpathAxis.DESCENDANT){xpathCollectDescendants(F,C)}else{if(this.axis==xpathAxis.FOLLOWING){for(var H=C;H;H=H.parentNode){for(var G=H.nextSibling;G;G=G.nextSibling){F.push(G);xpathCollectDescendants(F,G)}}}else{if(this.axis==xpathAxis.FOLLOWING_SIBLING){for(var H=C.nextSibling;H;H=H.nextSibling){F.push(H)}}else{if(this.axis==xpathAxis.NAMESPACE){alert("not implemented: axis namespace")}else{if(this.axis==xpathAxis.PARENT){if(C.parentNode){F.push(C.parentNode)}}else{if(this.axis==xpathAxis.PRECEDING){for(var H=C;H;H=H.parentNode){for(var G=H.previousSibling;G;G=G.previousSibling){F.push(G);xpathCollectDescendantsReverse(F,G)}}}else{if(this.axis==xpathAxis.PRECEDING_SIBLING){for(var H=C.previousSibling;H;H=H.previousSibling){F.push(H)}}else{if(this.axis==xpathAxis.SELF){F.push(C)}else{throw"ERROR -- NO SUCH AXIS: "+this.axis}}}}}}}}}}}}}var B=F;F=[];for(var D=0;D<B.length;++D){var H=B[D];if(this.nodetest.evaluate(A.clone(H,D,B)).booleanValue()){F.push(H)}}for(var D=0;D<this.predicate.length;++D){var B=F;F=[];for(var E=0;E<B.length;++E){var H=B[E];if(this.predicate[D].evaluate(A.clone(H,E,B)).booleanValue()){F.push(H)}}}return new NodeSetValue(F)};function NodeTestAny(){this.value=new BooleanValue(true)}NodeTestAny.prototype.evaluate=function(A){return this.value};function NodeTestElementOrAttribute(){}NodeTestElementOrAttribute.prototype.evaluate=function(A){return new BooleanValue(A.node.nodeType==DOM_ELEMENT_NODE||A.node.nodeType==DOM_ATTRIBUTE_NODE)};function NodeTestText(){}NodeTestText.prototype.evaluate=function(A){return new BooleanValue(A.node.nodeType==DOM_TEXT_NODE)};function NodeTestComment(){}NodeTestComment.prototype.evaluate=function(A){return new BooleanValue(A.node.nodeType==DOM_COMMENT_NODE)};function NodeTestPI(A){this.target=A}NodeTestPI.prototype.evaluate=function(A){return new BooleanValue(A.node.nodeType==DOM_PROCESSING_INSTRUCTION_NODE&&(!this.target||A.node.nodeName==this.target))};function NodeTestNC(A){this.regex=new RegExp("^"+A+":");this.nsprefix=A}NodeTestNC.prototype.evaluate=function(A){var B=A.node;return new BooleanValue(this.regex.match(B.nodeName))};function NodeTestName(A){this.name=A}NodeTestName.prototype.evaluate=function(A){var B=A.node;return new BooleanValue(B.nodeName==this.name)};function PredicateExpr(A){this.expr=A}PredicateExpr.prototype.evaluate=function(A){var B=this.expr.evaluate(A);if(B.type=="number"){return new BooleanValue(A.position==B.numberValue()-1)}else{return new BooleanValue(B.booleanValue())}};function FunctionCallExpr(A){this.name=A;this.args=[]}FunctionCallExpr.prototype.appendArg=function(A){this.args.push(A)};FunctionCallExpr.prototype.evaluate=function(A){var B=""+this.name.value;var C=this.xpathfunctions[B];if(C){return C.call(this,A)}else{xpathLog("XPath NO SUCH FUNCTION "+B);return new BooleanValue(false)}};FunctionCallExpr.prototype.xpathfunctions={last:function(A){assert(this.args.length==0);return new NumberValue(A.contextSize())},position:function(A){assert(this.args.length==0);return new NumberValue(A.position+1)},count:function(A){assert(this.args.length==1);var B=this.args[0].evaluate(A);return new NumberValue(B.nodeSetValue().length)},id:function(J){assert(this.args.length==1);var E=this.args[0].evaluate(J);var F=[];var A;if(E.type=="node-set"){A=[];var B=E.nodeSetValue();for(var D=0;D<B.length;++D){var H=xmlValue(B[D]).split(/\s+/);for(var I=0;I<H.length;++I){A.push(H[I])}}}else{A=E.stringValue().split(/\s+/)}var G=J.node.ownerDocument;for(var D=0;D<A.length;++D){var C=G.getElementById(A[D]);if(C){F.push(C)}}return new NodeSetValue(F)},"local-name":function(A){alert("not implmented yet: XPath function local-name()")},"namespace-uri":function(A){alert("not implmented yet: XPath function namespace-uri()")},name:function(A){assert(this.args.length==1||this.args.length==0);var B;if(this.args.length==0){B=[A.node]}else{B=this.args[0].evaluate(A).nodeSetValue()}if(B.length==0){return new StringValue("")}else{return new StringValue(B[0].nodeName)}},string:function(A){assert(this.args.length==1||this.args.length==0);if(this.args.length==0){return new StringValue(new NodeSetValue([A.node]).stringValue())}else{return new StringValue(this.args[0].evaluate(A).stringValue())}},concat:function(A){var B="";for(var C=0;C<this.args.length;++C){B+=this.args[C].evaluate(A).stringValue()}return new StringValue(B)},"starts-with":function(A){assert(this.args.length==2);var C=this.args[0].evaluate(A).stringValue();var B=this.args[1].evaluate(A).stringValue();return new BooleanValue(C.indexOf(B)==0)},contains:function(A){assert(this.args.length==2);var C=this.args[0].evaluate(A).stringValue();var B=this.args[1].evaluate(A).stringValue();return new BooleanValue(C.indexOf(B)!=-1)},"substring-before":function(A){assert(this.args.length==2);var E=this.args[0].evaluate(A).stringValue();var D=this.args[1].evaluate(A).stringValue();var C=E.indexOf(D);var B;if(C==-1){B=""}else{B=E.substr(0,C)}return new StringValue(B)},"substring-after":function(A){assert(this.args.length==2);var E=this.args[0].evaluate(A).stringValue();var D=this.args[1].evaluate(A).stringValue();var C=E.indexOf(D);var B;if(C==-1){B=""}else{B=E.substr(C+D.length)}return new StringValue(B)},substring:function(A){assert(this.args.length==2||this.args.length==3);var F=this.args[0].evaluate(A).stringValue();var D=this.args[1].evaluate(A).numberValue();var C;if(this.args.length==2){var G=Math.max(0,Math.round(D)-1);C=F.substr(G)}else{var B=this.args[2].evaluate(A).numberValue();var H=Math.round(D)-1;var G=Math.max(0,H);var E=Math.round(B)-Math.max(0,-H);C=F.substr(G,E)}return new StringValue(C)},"string-length":function(A){var B;if(this.args.length>0){B=this.args[0].evaluate(A).stringValue()}else{B=new NodeSetValue([A.node]).stringValue()}return new NumberValue(B.length)},"normalize-space":function(A){var B;if(this.args.length>0){B=this.args[0].evaluate(A).stringValue()}else{B=new NodeSetValue([A.node]).stringValue()}B=B.replace(/^\s*/,"").replace(/\s*$/,"").replace(/\s+/g," ");return new StringValue(B)},translate:function(A){assert(this.args.length==3);var E=this.args[0].evaluate(A).stringValue();var D=this.args[1].evaluate(A).stringValue();var B=this.args[2].evaluate(A).stringValue();for(var C=0;C<D.length;++C){E=E.replace(new RegExp(D.charAt(C),"g"),B.charAt(C))}return new StringValue(E)},"boolean":function(A){assert(this.args.length==1);return new BooleanValue(this.args[0].evaluate(A).booleanValue())},not:function(A){assert(this.args.length==1);var B=!this.args[0].evaluate(A).booleanValue();return new BooleanValue(B)},"true":function(A){assert(this.args.length==0);return new BooleanValue(true)},"false":function(A){assert(this.args.length==0);return new BooleanValue(false)},lang:function(A){assert(this.args.length==1);var C=this.args[0].evaluate(A).stringValue();var E;var D=A.node;while(D&&D!=D.parentNode){E=D.getAttribute("xml:lang");if(E){break}D=D.parentNode}if(!E){return new BooleanValue(false)}else{var B=new RegExp("^"+C+"$","i");return new BooleanValue(E.match(B)||E.replace(/_.*$/,"").match(B))}},number:function(A){assert(this.args.length==1||this.args.length==0);if(this.args.length==1){return new NumberValue(this.args[0].evaluate(A).numberValue())}else{return new NumberValue(new NodeSetValue([A.node]).numberValue())}},sum:function(A){assert(this.args.length==1);var D=this.args[0].evaluate(A).nodeSetValue();var C=0;for(var B=0;B<D.length;++B){C+=xmlValue(D[B])-0}return new NumberValue(C)},floor:function(A){assert(this.args.length==1);var B=this.args[0].evaluate(A).numberValue();return new NumberValue(Math.floor(B))},ceiling:function(A){assert(this.args.length==1);var B=this.args[0].evaluate(A).numberValue();return new NumberValue(Math.ceil(B))},round:function(A){assert(this.args.length==1);var B=this.args[0].evaluate(A).numberValue();return new NumberValue(Math.round(B))},"ext-join":function(A){assert(this.args.length==2);var B=this.args[0].evaluate(A).nodeSetValue();var E=this.args[1].evaluate(A).stringValue();var C="";for(var D=0;D<B.length;++D){if(C){C+=E}C+=xmlValue(B[D])}return new StringValue(C)},"ext-if":function(A){assert(this.args.length==3);if(this.args[0].evaluate(A).booleanValue()){return this.args[1].evaluate(A)}else{return this.args[2].evaluate(A)}},"ext-cardinal":function(A){assert(this.args.length>=1);var D=this.args[0].evaluate(A).numberValue();var B=[];for(var C=0;C<D;++C){B.push(A.node)}return new NodeSetValue(B)}};function UnionExpr(B,A){this.expr1=B;this.expr2=A}UnionExpr.prototype.evaluate=function(C){var B=this.expr1.evaluate(C).nodeSetValue();var A=this.expr2.evaluate(C).nodeSetValue();var F=B.length;for(var D=0;D<A.length;++D){var H=A[D];var G=false;for(var E=0;E<F;++E){if(B[E]==H){G=true;E=F}}if(!G){B.push(H)}}return new NodeSetValue(B)};function PathExpr(B,A){this.filter=B;this.rel=A}PathExpr.prototype.evaluate=function(B){var D=this.filter.evaluate(B).nodeSetValue();var A=[];for(var E=0;E<D.length;++E){var C=this.rel.evaluate(B.clone(D[E],E,D)).nodeSetValue();for(var F=0;F<C.length;++F){A.push(C[F])}}return new NodeSetValue(A)};function FilterExpr(B,A){this.expr=B;this.predicate=A}FilterExpr.prototype.evaluate=function(A){var C=this.expr.evaluate(A).nodeSetValue();for(var E=0;E<this.predicate.length;++E){var B=C;C=[];for(var D=0;D<B.length;++D){var F=B[D];if(this.predicate[E].evaluate(A.clone(F,D,B)).booleanValue()){C.push(F)}}}return new NodeSetValue(C)};function UnaryMinusExpr(A){this.expr=A}UnaryMinusExpr.prototype.evaluate=function(A){return new NumberValue(-this.expr.evaluate(A).numberValue())};function BinaryExpr(B,C,A){this.expr1=B;this.expr2=A;this.op=C}BinaryExpr.prototype.evaluate=function(A){var B;switch(this.op.value){case"or":B=new BooleanValue(this.expr1.evaluate(A).booleanValue()||this.expr2.evaluate(A).booleanValue());break;case"and":B=new BooleanValue(this.expr1.evaluate(A).booleanValue()&&this.expr2.evaluate(A).booleanValue());break;case"+":B=new NumberValue(this.expr1.evaluate(A).numberValue()+this.expr2.evaluate(A).numberValue());break;case"-":B=new NumberValue(this.expr1.evaluate(A).numberValue()-this.expr2.evaluate(A).numberValue());break;case"*":B=new NumberValue(this.expr1.evaluate(A).numberValue()*this.expr2.evaluate(A).numberValue());break;case"mod":B=new NumberValue(this.expr1.evaluate(A).numberValue()%this.expr2.evaluate(A).numberValue());break;case"div":B=new NumberValue(this.expr1.evaluate(A).numberValue()/this.expr2.evaluate(A).numberValue());break;case"=":B=this.compare(A,function(D,C){return D==C});break;case"!=":B=this.compare(A,function(D,C){return D!=C});break;case"<":B=this.compare(A,function(D,C){return D<C});break;case"<=":B=this.compare(A,function(D,C){return D<=C});break;case">":B=this.compare(A,function(D,C){return D>C});break;case">=":B=this.compare(A,function(D,C){return D>=C});break;default:alert("BinaryExpr.evaluate: "+this.op.value)}return B};BinaryExpr.prototype.compare=function(L,H){var J=this.expr1.evaluate(L);var I=this.expr2.evaluate(L);var G;if(J.type=="node-set"&&I.type=="node-set"){var F=J.nodeSetValue();var E=I.nodeSetValue();G=false;for(var C=0;C<F.length;++C){for(var B=0;B<E.length;++B){if(H(xmlValue(F[C]),xmlValue(E[B]))){G=true;B=E.length;C=F.length}}}}else{if(J.type=="node-set"||I.type=="node-set"){if(J.type=="number"){var M=J.numberValue();var A=I.nodeSetValue();G=false;for(var D=0;D<A.length;++D){var K=xmlValue(A[D])-0;if(H(M,K)){G=true;break}}}else{if(I.type=="number"){var A=J.nodeSetValue();var M=I.numberValue();G=false;for(var D=0;D<A.length;++D){var K=xmlValue(A[D])-0;if(H(K,M)){G=true;break}}}else{if(J.type=="string"){var M=J.stringValue();var A=I.nodeSetValue();G=false;for(var D=0;D<A.length;++D){var K=xmlValue(A[D]);if(H(M,K)){G=true;break}}}else{if(I.type=="string"){var A=J.nodeSetValue();var M=I.stringValue();G=false;for(var D=0;D<A.length;++D){var K=xmlValue(A[D]);if(H(K,M)){G=true;break}}}else{G=H(J.booleanValue(),I.booleanValue())}}}}}else{if(J.type=="boolean"||I.type=="boolean"){G=H(J.booleanValue(),I.booleanValue())}else{if(J.type=="number"||I.type=="number"){G=H(J.numberValue(),I.numberValue())}else{G=H(J.stringValue(),I.stringValue())}}}}return new BooleanValue(G)};function LiteralExpr(A){this.value=A}LiteralExpr.prototype.evaluate=function(A){return new StringValue(this.value)};function NumberExpr(A){this.value=A}NumberExpr.prototype.evaluate=function(A){return new NumberValue(this.value)};function VariableExpr(A){this.name=A}VariableExpr.prototype.evaluate=function(A){return A.getVariable(this.name)};function makeTokenExpr(A){return new TokenExpr(A)}function passExpr(A){return A}function makeLocationExpr1(B,A){A.absolute=true;return A}function makeLocationExpr2(B,A){A.absolute=true;A.prependStep(makeAbbrevStep(B.value));return A}function makeLocationExpr3(B){var A=new LocationExpr();A.appendStep(makeAbbrevStep("."));A.absolute=true;return A}function makeLocationExpr4(B){var A=new LocationExpr();A.absolute=true;A.appendStep(makeAbbrevStep(B.value));return A}function makeLocationExpr5(B){var A=new LocationExpr();A.appendStep(B);return A}function makeLocationExpr6(A,B,C){A.appendStep(C);return A}function makeLocationExpr7(A,B,C){A.appendStep(makeAbbrevStep(B.value));return A}function makeStepExpr1(A){return makeAbbrevStep(A.value)}function makeStepExpr2(A){return makeAbbrevStep(A.value)}function makeStepExpr3(A,B,C){return new StepExpr(A.value,C)}function makeStepExpr4(A,B){return new StepExpr("attribute",B)}function makeStepExpr5(A){return new StepExpr("child",A)}function makeStepExpr6(B,A){B.appendPredicate(A);return B}function makeAbbrevStep(A){switch(A){case"//":return new StepExpr("descendant-or-self",new NodeTestAny);case".":return new StepExpr("self",new NodeTestAny);case"..":return new StepExpr("parent",new NodeTestAny)}}function makeNodeTestExpr1(A){return new NodeTestElementOrAttribute}function makeNodeTestExpr2(A,B,C){return new NodeTestNC(A.value)}function makeNodeTestExpr3(A){return new NodeTestName(A.value)}function makeNodeTestExpr4(C,A){var B=C.value.replace(/\s*\($/,"");switch(B){case"node":return new NodeTestAny;case"text":return new NodeTestText;case"comment":return new NodeTestComment;case"processing-instruction":return new NodeTestPI("")}}function makeNodeTestExpr5(D,C,A){var B=D.replace(/\s*\($/,"");if(B!="processing-instruction"){throw B}return new NodeTestPI(C.value)}function makePredicateExpr(C,B,A){return new PredicateExpr(B)}function makePrimaryExpr(C,B,A){return B}function makeFunctionCallExpr1(B,C,A){return new FunctionCallExpr(B)}function makeFunctionCallExpr2(E,G,D,C,A){var B=new FunctionCallExpr(E);B.appendArg(D);for(var F=0;F<C.length;++F){B.appendArg(C[F])}return B}function makeArgumentExpr(A,B){return B}function makeUnionExpr(C,A,B){return new UnionExpr(C,B)}function makePathExpr1(C,B,A){return new PathExpr(C,A)}function makePathExpr2(C,B,A){A.prependStep(makeAbbrevStep(B.value));return new PathExpr(C,A)}function makeFilterExpr(B,A){if(A.length>0){return new FilterExpr(B,A)}else{return B}}function makeUnaryMinusExpr(A,B){return new UnaryMinusExpr(B)}function makeBinaryExpr(B,C,A){return new BinaryExpr(B,C,A)}function makeLiteralExpr(A){var B=A.value.substring(1,A.value.length-1);return new LiteralExpr(B)}function makeNumberExpr(A){return new NumberExpr(A.value)}function makeVariableReference(A,B){return new VariableExpr(B.value)}function makeSimpleExpr(C){if(C.charAt(0)=="$"){return new VariableExpr(C.substr(1))}else{if(C.charAt(0)=="@"){var B=new NodeTestName(C.substr(1));var A=new StepExpr("attribute",B);var D=new LocationExpr();D.appendStep(A);return D}else{if(C.match(/^[0-9]+$/)){return new NumberExpr(C)}else{var B=new NodeTestName(C);var A=new StepExpr("child",B);var D=new LocationExpr();D.appendStep(A);return D}}}}function makeSimpleExpr2(E){var C=stringSplit(E,"/");var F=new LocationExpr();for(var D=0;D<C.length;++D){var B=new NodeTestName(C[D]);var A=new StepExpr("child",B);F.appendStep(A)}return F}var xpathAxis={ANCESTOR_OR_SELF:"ancestor-or-self",ANCESTOR:"ancestor",ATTRIBUTE:"attribute",CHILD:"child",DESCENDANT_OR_SELF:"descendant-or-self",DESCENDANT:"descendant",FOLLOWING_SIBLING:"following-sibling",FOLLOWING:"following",NAMESPACE:"namespace",PARENT:"parent",PRECEDING_SIBLING:"preceding-sibling",PRECEDING:"preceding",SELF:"self"};var xpathAxesRe=[xpathAxis.ANCESTOR_OR_SELF,xpathAxis.ANCESTOR,xpathAxis.ATTRIBUTE,xpathAxis.CHILD,xpathAxis.DESCENDANT_OR_SELF,xpathAxis.DESCENDANT,xpathAxis.FOLLOWING_SIBLING,xpathAxis.FOLLOWING,xpathAxis.NAMESPACE,xpathAxis.PARENT,xpathAxis.PRECEDING_SIBLING,xpathAxis.PRECEDING,xpathAxis.SELF].join("|");var TOK_PIPE={label:"|",prec:17,re:new RegExp("^\\|")};var TOK_DSLASH={label:"//",prec:19,re:new RegExp("^//")};var TOK_SLASH={label:"/",prec:30,re:new RegExp("^/")};var TOK_AXIS={label:"::",prec:20,re:new RegExp("^::")};var TOK_COLON={label:":",prec:1000,re:new RegExp("^:")};var TOK_AXISNAME={label:"[axis]",re:new RegExp("^("+xpathAxesRe+")")};var TOK_PARENO={label:"(",prec:34,re:new RegExp("^\\(")};var TOK_PARENC={label:")",re:new RegExp("^\\)")};var TOK_DDOT={label:"..",prec:34,re:new RegExp("^\\.\\.")};var TOK_DOT={label:".",prec:34,re:new RegExp("^\\.")};var TOK_AT={label:"@",prec:34,re:new RegExp("^@")};var TOK_COMMA={label:",",re:new RegExp("^,")};var TOK_OR={label:"or",prec:10,re:new RegExp("^or\\b")};var TOK_AND={label:"and",prec:11,re:new RegExp("^and\\b")};var TOK_EQ={label:"=",prec:12,re:new RegExp("^=")};var TOK_NEQ={label:"!=",prec:12,re:new RegExp("^!=")};var TOK_GE={label:">=",prec:13,re:new RegExp("^>=")};var TOK_GT={label:">",prec:13,re:new RegExp("^>")};var TOK_LE={label:"<=",prec:13,re:new RegExp("^<=")};var TOK_LT={label:"<",prec:13,re:new RegExp("^<")};var TOK_PLUS={label:"+",prec:14,re:new RegExp("^\\+"),left:true};var TOK_MINUS={label:"-",prec:14,re:new RegExp("^\\-"),left:true};var TOK_DIV={label:"div",prec:15,re:new RegExp("^div\\b"),left:true};var TOK_MOD={label:"mod",prec:15,re:new RegExp("^mod\\b"),left:true};var TOK_BRACKO={label:"[",prec:32,re:new RegExp("^\\[")};var TOK_BRACKC={label:"]",re:new RegExp("^\\]")};var TOK_DOLLAR={label:"$",re:new RegExp("^\\$")};var TOK_NCNAME={label:"[ncname]",re:new RegExp("^"+XML_NC_NAME)};var TOK_ASTERISK={label:"*",prec:15,re:new RegExp("^\\*"),left:true};var TOK_LITERALQ={label:"[litq]",prec:20,re:new RegExp("^'[^\\']*'")};var TOK_LITERALQQ={label:"[litqq]",prec:20,re:new RegExp('^"[^\\"]*"')};var TOK_NUMBER={label:"[number]",prec:35,re:new RegExp("^\\d+(\\.\\d*)?")};var TOK_QNAME={label:"[qname]",re:new RegExp("^("+XML_NC_NAME+":)?"+XML_NC_NAME)};var TOK_NODEO={label:"[nodetest-start]",re:new RegExp("^(processing-instruction|comment|text|node)\\(")};var xpathTokenRules=[TOK_DSLASH,TOK_SLASH,TOK_DDOT,TOK_DOT,TOK_AXIS,TOK_COLON,TOK_AXISNAME,TOK_NODEO,TOK_PARENO,TOK_PARENC,TOK_BRACKO,TOK_BRACKC,TOK_AT,TOK_COMMA,TOK_OR,TOK_AND,TOK_NEQ,TOK_EQ,TOK_GE,TOK_GT,TOK_LE,TOK_LT,TOK_PLUS,TOK_MINUS,TOK_ASTERISK,TOK_PIPE,TOK_MOD,TOK_DIV,TOK_LITERALQ,TOK_LITERALQQ,TOK_NUMBER,TOK_QNAME,TOK_NCNAME,TOK_DOLLAR];var XPathLocationPath={label:"LocationPath"};var XPathRelativeLocationPath={label:"RelativeLocationPath"};var XPathAbsoluteLocationPath={label:"AbsoluteLocationPath"};var XPathStep={label:"Step"};var XPathNodeTest={label:"NodeTest"};var XPathPredicate={label:"Predicate"};var XPathLiteral={label:"Literal"};var XPathExpr={label:"Expr"};var XPathPrimaryExpr={label:"PrimaryExpr"};var XPathVariableReference={label:"Variablereference"};var XPathNumber={label:"Number"};var XPathFunctionCall={label:"FunctionCall"};var XPathArgumentRemainder={label:"ArgumentRemainder"};var XPathPathExpr={label:"PathExpr"};var XPathUnionExpr={label:"UnionExpr"};var XPathFilterExpr={label:"FilterExpr"};var XPathDigits={label:"Digits"};var xpathNonTerminals=[XPathLocationPath,XPathRelativeLocationPath,XPathAbsoluteLocationPath,XPathStep,XPathNodeTest,XPathPredicate,XPathLiteral,XPathExpr,XPathPrimaryExpr,XPathVariableReference,XPathNumber,XPathFunctionCall,XPathArgumentRemainder,XPathPathExpr,XPathUnionExpr,XPathFilterExpr,XPathDigits];var Q_01={label:"?"};var Q_MM={label:"*"};var Q_1M={label:"+"};var ASSOC_LEFT=true;var xpathGrammarRules=[[XPathLocationPath,[XPathRelativeLocationPath],18,passExpr],[XPathLocationPath,[XPathAbsoluteLocationPath],18,passExpr],[XPathAbsoluteLocationPath,[TOK_SLASH,XPathRelativeLocationPath],18,makeLocationExpr1],[XPathAbsoluteLocationPath,[TOK_DSLASH,XPathRelativeLocationPath],18,makeLocationExpr2],[XPathAbsoluteLocationPath,[TOK_SLASH],0,makeLocationExpr3],[XPathAbsoluteLocationPath,[TOK_DSLASH],0,makeLocationExpr4],[XPathRelativeLocationPath,[XPathStep],31,makeLocationExpr5],[XPathRelativeLocationPath,[XPathRelativeLocationPath,TOK_SLASH,XPathStep],31,makeLocationExpr6],[XPathRelativeLocationPath,[XPathRelativeLocationPath,TOK_DSLASH,XPathStep],31,makeLocationExpr7],[XPathStep,[TOK_DOT],33,makeStepExpr1],[XPathStep,[TOK_DDOT],33,makeStepExpr2],[XPathStep,[TOK_AXISNAME,TOK_AXIS,XPathNodeTest],33,makeStepExpr3],[XPathStep,[TOK_AT,XPathNodeTest],33,makeStepExpr4],[XPathStep,[XPathNodeTest],33,makeStepExpr5],[XPathStep,[XPathStep,XPathPredicate],33,makeStepExpr6],[XPathNodeTest,[TOK_ASTERISK],33,makeNodeTestExpr1],[XPathNodeTest,[TOK_NCNAME,TOK_COLON,TOK_ASTERISK],33,makeNodeTestExpr2],[XPathNodeTest,[TOK_QNAME],33,makeNodeTestExpr3],[XPathNodeTest,[TOK_NODEO,TOK_PARENC],33,makeNodeTestExpr4],[XPathNodeTest,[TOK_NODEO,XPathLiteral,TOK_PARENC],33,makeNodeTestExpr5],[XPathPredicate,[TOK_BRACKO,XPathExpr,TOK_BRACKC],33,makePredicateExpr],[XPathPrimaryExpr,[XPathVariableReference],33,passExpr],[XPathPrimaryExpr,[TOK_PARENO,XPathExpr,TOK_PARENC],33,makePrimaryExpr],[XPathPrimaryExpr,[XPathLiteral],30,passExpr],[XPathPrimaryExpr,[XPathNumber],30,passExpr],[XPathPrimaryExpr,[XPathFunctionCall],30,passExpr],[XPathFunctionCall,[TOK_QNAME,TOK_PARENO,TOK_PARENC],-1,makeFunctionCallExpr1],[XPathFunctionCall,[TOK_QNAME,TOK_PARENO,XPathExpr,XPathArgumentRemainder,Q_MM,TOK_PARENC],-1,makeFunctionCallExpr2],[XPathArgumentRemainder,[TOK_COMMA,XPathExpr],-1,makeArgumentExpr],[XPathUnionExpr,[XPathPathExpr],20,passExpr],[XPathUnionExpr,[XPathUnionExpr,TOK_PIPE,XPathPathExpr],20,makeUnionExpr],[XPathPathExpr,[XPathLocationPath],20,passExpr],[XPathPathExpr,[XPathFilterExpr],19,passExpr],[XPathPathExpr,[XPathFilterExpr,TOK_SLASH,XPathRelativeLocationPath],20,makePathExpr1],[XPathPathExpr,[XPathFilterExpr,TOK_DSLASH,XPathRelativeLocationPath],20,makePathExpr2],[XPathFilterExpr,[XPathPrimaryExpr,XPathPredicate,Q_MM],20,makeFilterExpr],[XPathExpr,[XPathPrimaryExpr],16,passExpr],[XPathExpr,[XPathUnionExpr],16,passExpr],[XPathExpr,[TOK_MINUS,XPathExpr],-1,makeUnaryMinusExpr],[XPathExpr,[XPathExpr,TOK_OR,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_AND,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_EQ,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_NEQ,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_LT,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_LE,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_GT,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_GE,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_PLUS,XPathExpr],-1,makeBinaryExpr,ASSOC_LEFT],[XPathExpr,[XPathExpr,TOK_MINUS,XPathExpr],-1,makeBinaryExpr,ASSOC_LEFT],[XPathExpr,[XPathExpr,TOK_ASTERISK,XPathExpr],-1,makeBinaryExpr,ASSOC_LEFT],[XPathExpr,[XPathExpr,TOK_DIV,XPathExpr],-1,makeBinaryExpr,ASSOC_LEFT],[XPathExpr,[XPathExpr,TOK_MOD,XPathExpr],-1,makeBinaryExpr,ASSOC_LEFT],[XPathLiteral,[TOK_LITERALQ],-1,makeLiteralExpr],[XPathLiteral,[TOK_LITERALQQ],-1,makeLiteralExpr],[XPathNumber,[TOK_NUMBER],-1,makeNumberExpr],[XPathVariableReference,[TOK_DOLLAR,TOK_QNAME],200,makeVariableReference]];var xpathRules=[];function xpathParseInit(){if(xpathRules.length){return }xpathGrammarRules.sort(function(I,H){var K=I[1].length;var J=H[1].length;if(K<J){return 1}else{if(K>J){return -1}else{return 0}}});var A=1;for(var C=0;C<xpathNonTerminals.length;++C){xpathNonTerminals[C].key=A++}for(C=0;C<xpathTokenRules.length;++C){xpathTokenRules[C].key=A++}xpathLog("XPath parse INIT: "+A+" rules");function E(J,H,I){if(!J[H]){J[H]=[]}J[H].push(I)}for(C=0;C<xpathGrammarRules.length;++C){var G=xpathGrammarRules[C];var F=G[1];for(var B=F.length-1;B>=0;--B){if(F[B]==Q_1M){E(xpathRules,F[B-1].key,G);break}else{if(F[B]==Q_MM||F[B]==Q_01){E(xpathRules,F[B-1].key,G);--B}else{E(xpathRules,F[B].key,G);break}}}}xpathLog("XPath parse INIT: "+xpathRules.length+" rule bins");var D=0;mapExec(xpathRules,function(H){if(H){D+=H.length}});xpathLog("XPath parse INIT: "+(D/xpathRules.length)+" average bin size")}function xpathCollectDescendants(B,A){for(var C=A.firstChild;C;C=C.nextSibling){B.push(C);arguments.callee(B,C)}}function xpathCollectDescendantsReverse(B,A){for(var C=A.lastChild;C;C=C.previousSibling){B.push(C);arguments.callee(B,C)}}function xpathDomEval(C,B){var D=xpathParse(C);var A=D.evaluate(new ExprContext(B));return A}function xpathSort(H,F){if(F.length==0){return }var L=[];for(var G=0;G<H.contextSize();++G){var C=H.nodelist[G];var D={node:C,key:[]};var B=H.clone(C,0,[C]);for(var E=0;E<F.length;++E){var K=F[E];var J=K.expr.evaluate(B);var I;if(K.type=="text"){I=J.stringValue()}else{if(K.type=="number"){I=J.numberValue()}}D.key.push({value:I,order:K.order})}D.key.push({value:G,order:"ascending"});L.push(D)}L.sort(xpathSortByKey);var A=[];for(var G=0;G<L.length;++G){A.push(L[G].node)}H.nodelist=A;H.setNode(0)}function xpathSortByKey(D,C){for(var A=0;A<D.key.length;++A){var B=D.key[A].order=="descending"?-1:1;if(D.key[A].value>C.key[A].value){return +1*B}else{if(D.key[A].value<C.key[A].value){return -1*B}}}return 0}function xpathEval(A,C){var D=xpathParse(A);var B=D.evaluate(C);return B};