AUI().ready(function(){removeOtherPermanentLinkDialogs=function(lastDialogOpened){AUI().use("node",function(A){A.all(".permalink-preview").each(function(crtPermanentLinkDialog){if(crtPermanentLinkDialog!==lastDialogOpened)crtPermanentLinkDialog.remove()})})};AUI().use("node",function(A){A.all(".authorSuccessorLink").on("click",function(e){e.preventDefault();var crtSuccessorElement=A.one(e.currentTarget);crtSuccessorElement.removeClass("successorLinkActive");crtSuccessorElement.all(".authorSuccessor").each(function(){this.removeClass("hidden")});
crtSuccessorElement.all(".show-more").each(function(){this.addClass("hidden")})});A.all(".show-hit-data-link").on("click",function(e){e.preventDefault();var crtHitLink=A.one(e.currentTarget);var crtHitLinkIcon=crtHitLink.one("i");if(crtHitLink.hasClass("show-hit-data-link-open")){crtHitLink.removeClass("show-hit-data-link-open");crtHitLinkIcon.addClass("icon-chevron-down");crtHitLinkIcon.removeClass("icon-chevron-up");crtHitLink.ancestor().ancestor().all(".search-hit-hidden-content").each(function(){this.addClass("hidden")})}else{crtHitLink.addClass("show-hit-data-link-open");
crtHitLinkIcon.removeClass("icon-chevron-down");crtHitLinkIcon.addClass("icon-chevron-up");crtHitLink.ancestor().ancestor().all(".search-hit-hidden-content").each(function(){this.removeClass("hidden")})}})})});
AUI().use("node","io-base",function(Y){Y.all(".facets-lists-container .facetSearchResultSelect").each(function(element){element.on("click",function(e){var currentTarget=e.currentTarget;var moreValuesContainer=currentTarget.ancestor().one("div");if(!moreValuesContainer||moreValuesContainer.html().trim().length>0)return;var currentId=currentTarget.getAttribute("id");if(!currentId)return;var currentFacet=currentId.replace("-facetSearchResultSelect","");var completeValueUrl=window.facetRequestURL+currentFacet;
var timeStamp=(new Date).getTime();moreValuesContainer.setHTML('\x3cdiv class\x3d"ajax-loader"\x3e\x3c/div\x3e');Y.io(completeValueUrl,{method:"GET",data:t=timeStamp,on:{success:function(id,result){var facets=Y.JSON.parse(result.responseText);if(facets.length==0)return;var currentFacet=facets[0];var moreValuesNode=Y.one('[id\x3d"'+currentFacet.facet.code+"-facetSearchResultMoreList"+'"]');if(!moreValuesNode||!currentFacet||!currentFacet.values||currentFacet.values.length<=0)return;moreValuesNode.setHTML("");
if(!moreValuesNode.hasClass("facet-child-values"))moreValuesNode.addClass("facet-child-values");var alreadyDisplayedCodes=updateAlreadyDisplayedValues(moreValuesNode,currentFacet);var existingItemsCount=moreValuesNode.ancestor().ancestor().ancestor().all("\x3e li").size()-1;for(var j=0;j<currentFacet.values.length;j++){if(alreadyDisplayedCodes.indexOf(currentFacet.values[j].code)>=0)continue;(function(){var facetValue=currentFacet.values[j];if(!facetValue)return;var isFacetChecked=false;var currentFacetCondition;
var hasFacets=false;var hasFacetCode=false;var isFacetCode=false;var hasFacetValues=false;for(var k=0;k<window.searchMetadata.facetValues.length&&!isFacetChecked;k++){currentFacetCondition=window.searchMetadata.facetValues[k];hasFacets=currentFacetCondition&&currentFacetCondition.facet;hasFacetCode=hasFacets&&currentFacetCondition.facet.code;isFacetCode=hasFacetCode&&currentFacetCondition.facet.code==currentFacet.facet.code;hasFacetValues=isFacetCode&&currentFacetCondition.values&&currentFacetCondition.values.length>
0;if(hasFacetValues)for(var l=0;l<currentFacetCondition.values.length&&!isFacetChecked;l++)if(currentFacetCondition.values[l].code&&currentFacetCondition.values[l].code==facetValue.code)isFacetChecked=true}var listItem=Y.Node.create("\x3cdiv\x3e");listItem.addClass("list-item");if(j==0)listItem.addClass("first");var label=Y.Node.create("\x3clabel\x3e");label.setHTML("\x3cinput onclick\x3d\"addFilterParameter('"+currentFacet.facet.code+"','"+facetValue.code+"',"+isFacetChecked+',this)" type\x3d"checkbox" '+
(isFacetChecked?'checked\x3d"true" checkbox-state\x3d"t"':"")+"/\x3e "+facetValue.label+" ("+facetValue.countNumber+")");var childValues=facetValue.childValues;var facetChild="";var facetChildNode="";var facetChildNodes=[];var facetChildNodeButton="";var isChildFacetChecked=false;var facetChildLabel="";if(childValues.length>0){facetChildNode=getFacetChildNode(facetChildNode,facetValue.code);facetChildNodeButton=builtFacetControlButton(facetChildNodeButton,facetValue.code)}if(j===0&&facetChildNode!==
"")facetChildNode.addClass("first");for(var c=0;c<childValues.length;c++){facetChild=childValues[c];isChildFacetChecked=facetChild.checked==="true"||facetChild.checked===true?true:false;isChildFacetChecked=checkSelectedFacet(facetChild,currentFacet,isChildFacetChecked);facetChildLabel=createNodeFacet(facetChildLabel,facetChild,isChildFacetChecked,currentFacet);facetChildNodes.push(facetChildLabel)}listItem.appendChild(label);if(facetChildNode!==""){listItem.appendChild(facetChildNodeButton);for(var x=
0;x<facetChildNodes.length;x++)facetChildNode.appendChild(facetChildNodes[x]);listItem.appendChild(facetChildNode)}moreValuesNode.appendChild(listItem)})()}},failure:function(id,result){}}})});function updateAlreadyDisplayedValues(moreValuesNode,currentFacet){var alreadyDisplayedCodes=[];var existingItems=moreValuesNode.ancestor().ancestor().ancestor().all("\x3e li");for(var existingItemIndex=0;existingItemIndex<existingItems.size();existingItemIndex++){var valueNode=existingItems.item(existingItemIndex);
var existingFacetCode=valueNode.getAttribute("facetValue");alreadyDisplayedCodes.push(existingFacetCode);var facetValue="";for(var valueIndex=0;valueIndex<currentFacet.values.length;valueIndex++)if(currentFacet.values[valueIndex].code===existingFacetCode){facetValue=currentFacet.values[valueIndex];break}if(facetValue==="")continue;var childValues=facetValue.childValues;if(childValues&&childValues.length>0){var childBtn=valueNode.one(".facet-childs-btn");var facetChildrenNode="";var startIndex=0;if(childBtn){startIndex=
valueNode.all(".child-facet").size();facetChildrenNode=valueNode.one(".facet-child-values")}else{var facetChildNodeButton="";facetChildNodeButton=builtFacetControlButton(facetChildNodeButton,facetValue.code);valueNode.appendChild(facetChildNodeButton);facetChildrenNode=getFacetChildNode(facetChildrenNode,facetValue.code);valueNode.appendChild(facetChildrenNode)}for(var c=startIndex;c<childValues.length;c++){var facetChild=childValues[c];var isChildFacetChecked=facetChild.checked==="true"||facetChild.checked===
true?true:false;isChildFacetChecked=checkSelectedFacet(facetChild,currentFacet,isChildFacetChecked);var facetChildLabel=createNodeFacet(facetChildLabel,facetChild,isChildFacetChecked,currentFacet);facetChildrenNode.appendChild(facetChildLabel)}}}return alreadyDisplayedCodes}function checkSelectedFacet(facetChild,currentFacet,isChildFacetChecked){var currentFacetConditionChild;var hasFacetsChild=false;var hasFacetCodeChild=false;var isFacetCodeChild=false;var hasFacetValuesChild=false;for(var k=0;k<
window.searchMetadata.facetValues.length&&!isChildFacetChecked;k++){currentFacetConditionChild=window.searchMetadata.facetValues[k];hasFacetsChild=currentFacetConditionChild&&currentFacetConditionChild.facet;hasFacetCodeChild=hasFacetsChild&&currentFacetConditionChild.facet.code;isFacetCodeChild=hasFacetCodeChild&&currentFacetConditionChild.facet.code==currentFacet.facet.code;hasFacetValuesChild=isFacetCodeChild&&currentFacetConditionChild.values&&currentFacetConditionChild.values.length>0;if(hasFacetValuesChild)for(var l=
0;l<currentFacetConditionChild.values.length&&!isChildFacetChecked;l++)if(currentFacetConditionChild.values[l].code&&currentFacetConditionChild.values[l].code==facetChild.code)isChildFacetChecked=true}return isChildFacetChecked}function createNodeFacet(facetChildLabel,facetChild,isChildFacetChecked,currentFacet){facetChildLabel=Y.Node.create("\x3cdiv\x3e");var childLabel=Y.Node.create("\x3clabel\x3e");childLabel.setHTML('\x3cinput type\x3d"checkbox" '+(isChildFacetChecked?'checked\x3d"true" checkbox-state\x3d"t"':
"")+"/\x3e"+facetChild.label+" ("+facetChild.countNumber+")");childLabel.on("click",function(){addFilterParameter(currentFacet.facet.code,facetChild.code,isChildFacetChecked,this)});facetChildLabel.addClass("list-item");facetChildLabel.appendChild(childLabel);return facetChildLabel}function builtFacetControlButton(facetChildNodeButton,code){var childSpanMinus=Y.Node.create("\x3cspan\x3e");childSpanMinus.addClass("glyphicon glyphicon-plus");var childSpanPlus=Y.Node.create("\x3cspan\x3e");childSpanPlus.addClass("glyphicon glyphicon-minus");
facetChildNodeButton=Y.Node.create("\x3cbutton\x3e");facetChildNodeButton.addClass("btn facet-childs-btn collapsed");facetChildNodeButton.setAttribute("data-target","#"+code+"_facet_child_collapse");facetChildNodeButton.setAttribute("type","button");facetChildNodeButton.setAttribute("data-toggle","collapse");facetChildNodeButton.appendChild(childSpanPlus);facetChildNodeButton.appendChild(childSpanMinus);return facetChildNodeButton}function getFacetChildNode(facetChildNode,code){facetChildNode=Y.Node.create("\x3cdiv\x3e");
facetChildNode.addClass("collapse facet-child-values-level-2");facetChildNode.setAttribute("id",code+"_facet_child_collapse");return facetChildNode}})});
function getFacetSearchURL(code,value,checked){var facetSearchURL="\x3c%\x3dfacetSearchURL%\x3e";if(!checked){facetSearchURL=facetSearchURL.replace("code_placeholder",code);facetSearchURL=facetSearchURL.replace("value_placeholder",value)}else{facetSearchURL=facetSearchURL.replace("\x26code_placeholder\x3dvalue_placeholder,","");if(facetSearchURL.indexOf(code)!=-1){var regex=new RegExp("(?:"+code+"\x3d)([^\x26]*)");var match=regex.exec(facetSearchURL);if(match&&match.length>0){var foundedGroup=match[1].split(",");
for(var i=foundedGroup.length-1;i>=0;i--)if(foundedGroup[i]==value)foundedGroup.splice(i,1);facetSearchURL=facetSearchURL.replace(match[1],foundedGroup.join(","))}}}return facetSearchURL}
var addFilterParameter=function(facetType,facetCode,facetValue,object){var crtObj=AUI().one(object);var facetExists=false;var checkbox_state=crtObj.getAttribute("checkbox-state");if(checkbox_state==="t")checkbox_state="f";else checkbox_state="t";for(var i=0;i<filterSearchParam.length;i++)if(filterSearchParam[i].facet===facetType&&filterSearchParam[i].code===facetCode){if(filterSearchParam[i].value){filterSearchParam[i].value=false;crtObj.setAttribute("checkbox-state",checkbox_state)}else{filterSearchParam[i].value=
true;crtObj.setAttribute("checkbox-state",checkbox_state)}facetExists=true;break}if(!facetExists){crtObj.setAttribute("checkbox-state",checkbox_state);filterSearchParam.push({"facet":facetType,"code":facetCode,"value":facetValue})}};
var applyFilterParameter=function(){YUI().use("node","aui-io-request","json-parse",function(Y){if(filterSearchParam.length>0){var timeStamp=(new Date).getTime();Y.io.request(FILTER_REQUEST_PATH,{method:"POST",data:{filterList:JSON.stringify(filterSearchParam),clickMethod:window.CLICK_METHOD,newActionUrl:window.ACTION_URL,t:timeStamp},on:{success:function(){var responseData=this.get("responseData");if(responseData!=null&&responseData!=undefined){responseData=responseData.replace("\\u0027","'");responseData=
responseData.replace("\\u0027","'")}if(responseData!=null&&responseData!=undefined)try{eval(responseData)}catch(err){responseData=document.createTextNode(responseData)}else location.reload()}}})}})};
AUI().ready(function(){var response;sendSortBy=function(portletNamespace){AUI().use("node",function(setSortBy){var sortByParam=setSortBy.one("#"+portletNamespace+"sortBy").get("value");if(sortByParam!="select")getSortByParam(sortByParam,portletNamespace)})};getSortByParam=function(sortByParam,portletNamespace){AUI().use("aui-io-request",function(A){A.io.request("/o/search-order-by/getSortByParam.jsp",{method:"POST",data:{sortBy:sortByParam},on:{success:function(){response=this.get("responseData");
AUI().use("node",function(setSortByParameter){var form=setSortByParameter.one("#"+portletNamespace+"doOrderBy"),action=form.getAttribute("action"),action=action.concat("sortBy\x3d"+response);form.setAttribute("action",action);form.submit()})},failure:function(){}}})})};if(typeof orderBy_loadJavascript==="undefined")return;submitOrderBy=function(portletNamespace){AUI().use("node","opportal-tools",function(A){var value=A.one(portletNamespace).get("value");var url=orderBy_fullURL+value;A.opportalTools.addCookie("PORTAL2012_SEARCH",
"sortBy",value,function(){window.location.href=url})})}});

AUI().ready(function(){var POP_UP_CONTENT_ID="popup-content";var dialogCloseButton="\x3cbutton onclick\x3d'closeDialog();'\x3eOK\x3c/button\x3e";var ACTION_SAVE_QUERY="saveQuery";var ACTION_CREATE_RSS="createRss";var ACTION_ALERT_ME="alertMe";var CONTAINER_SAVE_QUERY="saveQuery-number";var CONTAINER_CREATE_RSS="createRss-number";var CONTAINER_ALERT_ME="alertMe-number";showPopUp=function(renderUrl,title,dialogHeight){AUI().use("node","opportal-dialog",function(A){A.opportalDialog.show(renderUrl,title,
"auto");var el=A.one(".myportalwrapper ul.worpmenu");if(el!=null&&el!=undefined)el.addClass("colapsed")})};asyncSubmitSearchActionsForm=function(portletNamespace,actionName,actionURL){var checkMail=false;AUI().use("node",function(myAui){var emailInput=myAui.one(".form_user_email input[type\x3d'text']");if(emailInput!=null&&emailInput!="null")if(emailInput.get("value")==""){checkMail=false;myAui.one(".form_user_email .control-group").addClass("error");emailInput.focus()}else{checkMail=true;myAui.one(".form_user_email .control-group").removeClass("error")}else checkMail=
true});AUI().use("aui-io-request","opportal-dialog",function(A){if(checkMail)A.io.request(actionURL,{method:"POST",data:{actionName:actionName},form:{id:portletNamespace+"sa_fm"},on:{success:function(){var responseData=this.get("responseData");if(A.opportalDialog.getDialog()!=undefined){A.opportalDialog.getDialog().set("bodyContent","\x3cbr/\x3e\x3cp\x3e"+responseData+"\x3c/p\x3e\x3cp\x3e"+dialogCloseButton+"\x3c/p\x3e");refreshMyPortalNumbers(actionName)}}}})})};showPopUp=function(renderUrl,title,
dialogHeight,actionName){window.location.hash=actionName;AUI().use("node","opportal-dialog",function(A){A.opportalDialog.show(renderUrl,title,"auto");var el=A.one(".myportalwrapper ul.worpmenu");if(el!=null&&el!=undefined)el.addClass("colapsed")})};refreshMyPortalNumbers=function(actionName){if(actionName==="")return;var containerId="";if(ACTION_SAVE_QUERY===actionName)containerId=CONTAINER_SAVE_QUERY;else if(ACTION_ALERT_ME===actionName)containerId=CONTAINER_ALERT_ME;else if(ACTION_CREATE_RSS===
actionName)containerId=CONTAINER_CREATE_RSS;if(containerId==="")return;var container=document.getElementById(containerId);if(container!=undefined&&container.firstChild!=undefined){var value=container.innerHTML;try{var number=parseInt(value);number=number+1;container.replaceChild(container.firstChild,document.createTextNode(number+""))}catch(exception){}}};closeDialog=function(){AUI().use("node","opportal-dialog",function(A){if(A.opportalDialog.getDialog()!=undefined)A.opportalDialog.getDialog().hide()})};
checkFrequencyType=function(element){if(element.value=="WEEKLY")document.getElementById("dayOfWeek_Selector").style.display="block";else document.getElementById("dayOfWeek_Selector").style.display="none"}});
AUI().ready(function(){if(typeof searchParametersDetails_loadJavascript==="undefined")return;AUI().use("node",function(A){A.all(searchParametersDetails_portletNamespace+"show-more-button").on("click",function(e){e.preventDefault();var _this=A.one(e.target);var parentNode=_this.get("parentNode");_this.remove();parentNode.one(searchParametersDetails_portletNamespace+"more-options").show();return false})});showHideContinuation=function(){AUI().use("node",function(aui){var cont=aui.one("#search-term-continuation");
var href=aui.one("#search-term-href");var style=cont.getAttribute("style");if(style.indexOf("none")>0){cont.setAttribute("style","display:inline;");href.setAttribute("style","display:none;")}else cont.setAttribute("style","display:none;")})}});

AUI().ready(function(){var response;sendPerPage=function(){AUI().use("node",function(page){var perPageParam=page.one("#rezultsPerPage").get("value");getPerPageParam(perPageParam)})};getPerPageParam=function(perPageParam){AUI().use("aui-io-request",function(A){A.io.request("/o/eu.europa.publications.portlet.search_result_summary/getPerPageParam.jsp",{method:"POST",data:{resultsPerPage:perPageParam},on:{success:function(){response=this.get("responseData");AUI().use("node",function(setPerPageParameter){var form=
setPerPageParameter.one("#perpage"),action=form.getAttribute("action"),action=action.concat("resultsPerPage\x3d"+response);form.setAttribute("action",action);submitForm(document.perpage)})},failure:function(){}}})})};if(typeof searchResultSummary_loadJavascript==="undefined")return;submitResultsPerPage=function(searchResultSummary_this){AUI().use("node","opportal-tools",function(A){var value=A.one(searchResultSummary_this).get("value");var url=searchResultSummary_fullURL+value;A.opportalTools.addCookie("PORTAL2012_SEARCH",
"perPage",value,function(){window.location.href=url})})}});
AUI().ready(function(){var DOMAIN_URL="";var SUBDOMAIN_URL="";var SUBJECT_URL="";var PAGE_RENDERED=false;var PORTLET_NAMESPACE_PARAM="_portletNamespace";var PORTLET_ID_PARAM="_portlet_id";var LANGUAGE_PARAM="_language";var SUBJECT_SELECTED_ACTION_URL_PARAM="selectedSubjectActionURL";var SELECTED_CODES_PARAM="selectedCodes";var SELECTED_SUBJECT_LABEL_PARAM="selectedSubjectLabel";var SELECTED_SUBJECT_ID_PARAM="selectedSubjectId";var USER_LOCALE_PARAM="userLocale";var SEARCH_TYPE_PARAM="SEARCH_TYPE";
var ELEMENT_TYPE_PARAM="elementType";var EUROVOC_DOMAIN_FACET="facet.eurovoc.domain";var EUROVOC_SUBDOMAIN_FACET="facet.eurovoc.subdomain";var EUROVOC_SUBJECT_FACET="facet.eurovoc.subject";var DOMAINS_CONTAINER="document-domain";var SUB_DOMAINS_CONTAINER="document-sub-domain";var SUBJECTS_CONTAINER="document-subject";var MOBILE_SELECTED_SUBJECT_CONTAINER="mobile-selected-subject";var DOMAINS_LISTBOX="domainsListBox";var SUB_DOMAINS_LISTBOX="subDomainsListBox";var SUBJECTS_LISTBOX="subjectsListBox";
var DOMAINS_LABEL="domainsLabel";var SUBDOMAINS_LABEL="subDomainsLabel";var SUBJECTS_LABEL="subjectsLabel";var SEARCH_BUTTON="executeBBSSearch";var SEARCH_LINK="executeBBSearchLink";var domainsListBox;var subDomainsListBox;var subjectsListBox;var language;var subjectSelectedActionURL;var DOMAINS_LISTBOX_INTERNAL=undefined;var SUB_DOMAINS_LISTBOX_INTERNAL=undefined;var SUBJECTS_LISTBOX_INTERNAL=undefined;var SUBJECT_QUERY_HANDLER_PATH="/o/eu.europa.publications.portlet.subject_filter/subjectQueryHandler.jsp";
var ACTION_ALL="ALL";var PORTLET_ID="";var DOMAINS_CACHE=[];var SELECTED_CODES=[];var SELECTED_ELEMENT_ID="";var SELECTED_ELEMENT_LABEL="";var IDENTIFIER="identifier";var CODE="code";var LABEL="label";var ELEMENT_TYPE="elementType";var CHILDREN_COUNT="childrenCount";var NESTED_TEMPLATE_ICON='\x3cspan class\x3d"icon-container icon-op-bullet-small-light-gray"\x3e\x26nbsp;\x3c/span\x3e';var NESTED_TEMPLATE_OPTION_ICON='\x3cspan class\x3d"icon-container icon-round-bullet-small-light-gray"\x3e\x26nbsp;\x3c/span\x3e';
var CHILDREN_COUNT_REPLACE="_childrenCount_";var NESTED_TEMPLATE_CHILDREN_COUNT='\x3cspan class\x3d"childrenCount"\x3e\x26nbsp;('+CHILDREN_COUNT_REPLACE+")\x3c/span\x3e";var TABINDEX=1;var TABINDEX_REPLACE="_tabindex_";var CODE_REPLACE="_code_";var PORTLET_ID_REPLACE="_portletId_";var LANGUAGE_REPLACE="_language_";var ELEMENT_TYPE_REPLACE="_elementType_";var LABEL_REPLACE="_label_";var DOMAIN_REPLACE="_domain_";var SUBDOMAIN_REPLACE="_subdomain_";var SUBJECT_REPLACE="_subjectid_";var EVENT_REPLACE=
"_event_";var NESTED_TEMPLATE_ANCHOR='\x3ca rel\x3d"nofollow" href\x3d"./browse-by-subject?'+"p_p_id\x3d"+PORTLET_ID_REPLACE+"\x26"+"p_p_lifecycle\x3d1\x26"+"p_p_state\x3dnormal\x26"+"p_p_mode\x3dview\x26"+"p_p_col_id\x3dmaintop\x26"+"p_p_col_count\x3d1\x26"+"_"+PORTLET_ID_REPLACE+"_javax.portlet.action\x3dsubject\x26"+"userLocale\x3d"+LANGUAGE_REPLACE+"\x26"+"elementType\x3d"+ELEMENT_TYPE_REPLACE+"\x26"+"SEARCH_TYPE\x3d"+"BROWSE_BY_SUBJECT"+"\x26"+"selectedSubjectId\x3d"+CODE_REPLACE+DOMAIN_REPLACE+
SUBDOMAIN_REPLACE+SUBJECT_REPLACE+'" '+EVENT_REPLACE+"\x3e"+LABEL_REPLACE+"\x3c/a\x3e";var ON_CLICK_ANCHOR="./browse-by-subject?"+"p_p_id\x3d"+PORTLET_ID_REPLACE+"\x26"+"p_p_lifecycle\x3d1\x26"+"p_p_state\x3dnormal\x26"+"p_p_mode\x3dview\x26"+"p_p_col_id\x3dmaintop\x26"+"p_p_col_count\x3d1\x26"+"_"+PORTLET_ID_REPLACE+"_javax.portlet.action\x3dsubject\x26"+"userLocale\x3d"+LANGUAGE_REPLACE+"\x26"+"elementType\x3d"+ELEMENT_TYPE_REPLACE+"\x26"+"SEARCH_TYPE\x3d"+"BROWSE_BY_SUBJECT"+"\x26"+"selectedSubjectId\x3d"+
CODE_REPLACE+DOMAIN_REPLACE+SUBDOMAIN_REPLACE+SUBJECT_REPLACE;var NESTED_TEMPLATE_LABEL=""+LABEL_REPLACE+"";isMobile=function(Y){if(Y==undefined||Y==null)return false;return Y.one("body").get("winWidth")<=992};isSubjectSelectedAfterMobileQuery=function(Y){return isMobile(Y)&&(SELECTED_ELEMENT_LABEL!=undefined&&SELECTED_ELEMENT_LABEL!=null&&SELECTED_ELEMENT_LABEL!="")};YUI().use("node","widget","widget-parent","widget-child","node-focusmanager","json-parse","aui-io-request","node-event-simulate",function(Y){Y.ListBox=
Y.Base.create("listbox",Y.Widget,[Y.WidgetParent,Y.WidgetChild],{BOUNDING_TEMPLATE:'\x3cli class\x3d"yui3-listbox-option list-item"\x3e\x3c/li\x3e',CONTENT_TEMPLATE:'\x3cul class\x3d"div-block-mob item-list vertical hidden"\x3e\x3c/ul\x3e',bindUI:function(){if(this.isRoot())this.get("contentBox").plug(Y.Plugin.NodeFocusManager,{descendants:".yui3-option",keys:{next:"down:40",previous:"up:38"},circular:true});this.on("option:keydown",function(event){var item=event.target,domEvent=event.domEvent,keyCode=
domEvent.keyCode,direction=keyCode==40;if(this.get("multiple")){if(keyCode==40||keyCode==38)if(domEvent.shiftKey)this._selectNextSibling(item,direction);else{this.deselectAll();this._selectNextSibling(item,direction)}}else if(keyCode==13||keyCode==32){domEvent.preventDefault();item.set("selected",1)}});this.on("option:mousedown",function(event){event.stopPropagation();event.target.set("frommousedown","1");event.target.frommousedown="1";this._selectOnMouseDown(this,event.target,event.domEvent)})},
_selectNextSibling:function(item,direction){var parent=item.get("parent"),method=direction?"next":"previous",circular=parent===this,sibling=item[method](circular);if(sibling)if(sibling instanceof Y.ListBox||sibling instanceof Y.RootListBox)sibling.selectChild(direction?0:sibling.size()-1);else sibling.set("selected",1);else parent[method](true).set("selected",1)},_selectOnMouseDown:function(root,item,domEvent){if(root.get("multiple"))if(domEvent.metaKey)item.set("selected",1);else{root.deselectAll();
item.set("selected",1)}else try{root.deselectAll();item.set("selected",1)}catch(exception){}},NESTED_TEMPLATE:"\x3cli\x3e\x3c/li\x3e",renderUI:function(){var content=getIconAndLabel(this);if(content!=undefined){var boundingBox=this.get("boundingBox");boundingBox.addClass("level"+this.get("depth"));var contentBox=this.get("contentBox");var contentWrapper=Y.Node.create('\x3cdiv class\x3d"listbox-content-wrapper"\x3e\x3c/div\x3e');contentWrapper.setContent(content);boundingBox.insertBefore(contentWrapper,
contentBox);var t=this;contentWrapper.on("mousedown",function(event){t.set("frommousedown","1");return subjectSelectionChange(event,t,true)});this.after("render",function(event){PAGE_RENDERED=true;afterListElementRender(this)})}}},{ATTRS:{defaultChildType:{value:"Option"},identifier:{},code:{validator:Y.Lang.isString},label:{validator:Y.Lang.isString},elementType:{},childrenCount:{},frommousedown:{}}});Y.RootListBox=Y.Base.create("rootlistbox",Y.ListBox,[Y.WidgetParent,Y.WidgetChild],{BOUNDING_TEMPLATE:"\x3cdiv\x3e\x3c/div\x3e",
CONTENT_TEMPLATE:'\x3cul class\x3d"div-block-mob item-list vertical"\x3e\x3c/ul\x3e'},{});Y.Option=Y.Base.create("option",Y.Widget,[Y.WidgetChild],{BOUNDING_TEMPLATE:"\x3cli class\x3d'list-item'\x3e\x3c/li\x3e",renderUI:function(){var contentBox=this.get("contentBox");contentBox.setContent(getIconAndLabel(this));this.after("render",function(event){afterListElementRender(this)})}},{ATTRS:{identifier:{},code:{validator:Y.Lang.isString},label:{validator:Y.Lang.isString},elementType:{},childrenCount:{},
tabIndex:{value:-1},frommousedown:{}}});afterListElementRender=function(element){try{if(!SELECTED_CODES)return;var code=element.get(CODE);var elementType=element.get(ELEMENT_TYPE);if(SELECTED_CODES.length>=elementType+1&&SELECTED_CODES[elementType]==code){if(element instanceof Y.ListBox){var d=document.getElementById(element.get("id")).children[0];d.className=d.className+" yui3-option-selected";d.setAttribute("aria-selected","true");toggleChildrenContentBox(element);toggleParentsContentBox(element)}else setTimeout(function(){element.set("selected",
1)},50);if(elementType==0)setTimeout(function(){autoScrollIntoView(DOMAINS_LISTBOX,element.get("id"),element.get("code"),true)},200);else if(elementType==1)setTimeout(function(){autoScrollIntoView(SUB_DOMAINS_LISTBOX,element.get("id"),element.get("code"),true)},150);else setTimeout(function(){autoScrollIntoView(SUBJECTS_LISTBOX,element.get("id"),element.get("code"),true)},150);return}}catch(exception){}};setSearchButtonAction=function(Y,widget){try{var code=widget.get(CODE);if(code==undefined)return undefined;
var isOption=widget.name=="option";var label=widget.get(LABEL);var elementType=widget.get(ELEMENT_TYPE);var childrenCount=widget.get(CHILDREN_COUNT);var newLocation="";newLocation=ON_CLICK_ANCHOR.replace(CODE_REPLACE,code).replace(LABEL_REPLACE,label).replace(ELEMENT_TYPE_REPLACE,elementType).replace(PORTLET_ID_REPLACE,PORTLET_ID).replace(PORTLET_ID_REPLACE,PORTLET_ID).replace(LANGUAGE_REPLACE,language);var domainstring=elementType>0?"\x26"+EUROVOC_DOMAIN_FACET+"\x3d"+SELECTED_CODES[0]:elementType==
0?"\x26"+EUROVOC_DOMAIN_FACET+"\x3d"+code:"";var subdomainstring=elementType>1?"\x26"+EUROVOC_SUBDOMAIN_FACET+"\x3d"+SELECTED_CODES[1]:elementType==1?"\x26"+EUROVOC_SUBDOMAIN_FACET+"\x3d"+code:"";var subjectstring=elementType==2?"\x26"+EUROVOC_SUBJECT_FACET+"\x3d"+code:"";if(PAGE_RENDERED==true)if(elementType==0)SELECTED_CODES=[code];else if(elementType==1)SELECTED_CODES=[SELECTED_CODES[0],code];else if(elementType==2)SELECTED_CODES=[SELECTED_CODES[0],SELECTED_CODES[1],code];newLocation=newLocation.replace(DOMAIN_REPLACE,
domainstring).replace(SUBDOMAIN_REPLACE,subdomainstring).replace(SUBJECT_REPLACE,subjectstring);Y.one("#"+SEARCH_LINK).set("href",newLocation)}catch(exception){}};getIconAndLabel=function(widget){var code=widget.get(CODE);if(code==undefined)return undefined;var isOption=widget.name=="option";var label=widget.get(LABEL);var elementType=widget.get(ELEMENT_TYPE);var childrenCount=widget.get(CHILDREN_COUNT);if(elementType!=2||elementType==2&&childrenCount!=undefined&&childrenCount>0)label=NESTED_TEMPLATE_LABEL.replace(CODE_REPLACE,
code).replace(LABEL_REPLACE,label).replace(ELEMENT_TYPE_REPLACE,elementType).replace(PORTLET_ID_REPLACE,PORTLET_ID).replace(PORTLET_ID_REPLACE,PORTLET_ID).replace(LANGUAGE_REPLACE,language);else label=NESTED_TEMPLATE_ANCHOR.replace(CODE_REPLACE,code).replace(LABEL_REPLACE,label).replace(ELEMENT_TYPE_REPLACE,elementType).replace(PORTLET_ID_REPLACE,PORTLET_ID).replace(PORTLET_ID_REPLACE,PORTLET_ID).replace(LANGUAGE_REPLACE,language);var domainstring=elementType>0?"\x26"+EUROVOC_DOMAIN_FACET+"\x3d"+
SELECTED_CODES[0]:elementType==0?"\x26"+EUROVOC_DOMAIN_FACET+"\x3d"+code:"";var subdomainstring=elementType>1?"\x26"+EUROVOC_SUBDOMAIN_FACET+"\x3d"+SELECTED_CODES[1]:elementType==1?"\x26"+EUROVOC_SUBDOMAIN_FACET+"\x3d"+code:"";var subjectstring=elementType==2?"\x26"+EUROVOC_SUBJECT_FACET+"\x3d"+code:"";label=label.replace(DOMAIN_REPLACE,domainstring).replace(SUBDOMAIN_REPLACE,subdomainstring).replace(SUBJECT_REPLACE,subjectstring);if(isMobile(Y)){var onclick=elementType!=2||elementType==2&&childrenCount!=
undefined&&childrenCount>0?'onclick\x3d"event.preventDefault();"':"";label=label.replace(EVENT_REPLACE,onclick)}var icon=isOption!=undefined&&isOption?NESTED_TEMPLATE_OPTION_ICON:NESTED_TEMPLATE_ICON;var childrenCountDisplay=childrenCount==undefined||childrenCount==0?"":NESTED_TEMPLATE_CHILDREN_COUNT.replace(CHILDREN_COUNT_REPLACE,childrenCount);return icon+label+childrenCountDisplay};getSubDomains=function(domainId){for(var i=0;i<DOMAINS_CACHE.length;i++){var domain=DOMAINS_CACHE[i];if(domain.id==
domainId)return domain.subDomains}return[]};getSubjects=function(domainId,subDomainId){var subDomains=getSubDomains(domainId);for(var i=0;i<subDomains.length;i++){var subDomain=subDomains[i];if(subDomain.id==subDomainId)return subDomain.subjects}return[]};getOptionElements=function(list){var optionElements=[];for(var i=0;i<list.length;i++){var element=list[i];var childrenCount=getChildrenCount(element);var optionElement=getOptionElement(element.id,element.code,element.label,element.elementType,element.children,
childrenCount);optionElements.push(optionElement)}return optionElements};getChildrenCount=function(element){if(element==undefined||element==null)return 0;var children=element.children;if(children!=undefined&&children!=null)return children.length;else{var subDomains=element.subDomains;var subjects=element.subjects;if(subDomains!=undefined&&subDomains!=null)return subDomains.length;else if(subjects!=undefined&&subjects!=null)return subjects.length}return 0};getOptionElement=function(id,code,label,elementType,
children,childrenCount){if(children==undefined||children==null||children.length==0)return{type:"Option",identifier:id,code:code,label:label,elementType:elementType,childrenCount:childrenCount};else return{type:"ListBox",identifier:id,code:code,label:label,elementType:elementType,childrenCount:childrenCount,children:getOptionElements(children)}};getSelection=function(object){if(object==undefined||object==null)return object;var selection=object.get("selection");if(selection==undefined||selection==null)return object;
if(selection instanceof Y.ListBox)selection=getSelection(selection);return selection};storeSubjects=function(data){if(data!=undefined&&data!=null)try{DOMAINS_CACHE=Y.JSON.parse(data)}catch(e){}else;};fillBoxesWithDataFromCache=function(domainsListBox){try{var optionElements=getOptionElements(DOMAINS_CACHE);for(var i=0;i<optionElements.length;i++)domainsListBox.add(optionElements[i])}catch(e){}setTimeout(function(){YUI().use("node","widget",function(Y){Y.one("#browse-by-subject-loader").hide();Y.all(".document-domain").removeClass("hide")})},
150)};autoScrollIntoView=function(containerId,childId,childCode,useRealdirtyhack){try{var target=document.getElementById(childId);var container=document.getElementById(containerId);var targetOffsetTop=useRealdirtyhack!=undefined&&useRealdirtyhack?target.offsetTop<150?0:target.offsetTop-150:target.offsetTop;targetOffsetTop=useRealdirtyhack!=undefined&&useRealdirtyhack&&parseInt(childCode)<100&&parseInt(childCode)>40?200:targetOffsetTop;container.scrollTop=targetOffsetTop}catch(exception){}};handleQuery=
function(Y,event,language,subjectSelectedActionURL,elementType,selection){var code=selection.get(CODE);if(code==undefined)return false;var identifier=selection.get(IDENTIFIER);var isAlreadySelectedCode=SELECTED_CODES&&SELECTED_CODES[elementType]==code;if(isMobile(Y)&&isAlreadySelectedCode)return false;var hasChildren=selection.name=="listbox";if(isMobile(Y)&&(elementType!=2||hasChildren))return false;if(elementType!=2||hasChildren)return false;var frommousedown=selection.get("frommousedown")=="1"||
selection.frommousedown=="1";var allowReselectionOfHigherElementInDesktopVersion=frommousedown;if(!isMobile(Y)&&!allowReselectionOfHigherElementInDesktopVersion)return false;if(identifier&&code&&SELECTED_ELEMENT_ID!=code)return true;return false};subjectSelectionChange=function(event,target,isListBox){var selection=isListBox?target:getSelection(target);setSearchButtonAction(Y,selection);selection.set("frommousedown",target.get("frommousedown"));Y.one("#"+SUB_DOMAINS_CONTAINER).removeClass("active");
if(selection){var executed=handleQuery(Y,event,language,subjectSelectedActionURL,2,selection);if(executed||selection.get(CODE)==undefined)return true;toggleChildrenContentBox(selection);toggleParentsContentBox(selection)}return true};mobileHideSubjectsAfterQuery=function(Y){if(isSubjectSelectedAfterMobileQuery(Y)){Y.one("#"+MOBILE_SELECTED_SUBJECT_CONTAINER).addClass("active");Y.one("#"+MOBILE_SELECTED_SUBJECT_CONTAINER+" .back-button").setHTML(SELECTED_ELEMENT_LABEL);Y.one("#"+MOBILE_SELECTED_SUBJECT_CONTAINER+
" .back-button").on("click",function(ev){ev.preventDefault();SELECTED_ELEMENT_LABEL="";SELECTED_CODES=[];Y.one("#"+MOBILE_SELECTED_SUBJECT_CONTAINER).removeClass("active");Y.one("#"+SUBJECTS_CONTAINER).addClass("active");subjectsListBox.set("selection","")})}};toggleChildrenContentBox=function(target){var contentBox=target.get("contentBox");if(contentBox==undefined)return;if(contentBox.hasClass("hidden")){contentBox.removeClass("hidden");contentBox.addClass("visible")}else if(contentBox.hasClass("visible")){contentBox.removeClass("visible");
contentBox.addClass("hidden")}var boundingBox=target.get("boundingBox");if(boundingBox==undefined)return;var wrapper=boundingBox.one(".listbox-content-wrapper");if(wrapper==undefined||wrapper==null)return;if(!wrapper.hasClass("expanded"))wrapper.addClass("expanded");else wrapper.removeClass("expanded")};toggleParentsContentBox=function(target){if(target==undefined)return target;var parent=target.get("parent");if(parent==undefined||parent.name!="listbox")return target;else{var contentBox=parent.get("contentBox");
if(contentBox==undefined)return;if(contentBox.hasClass("hidden")){contentBox.removeClass("hidden");contentBox.addClass("visible")}var boundingBox=parent.get("boundingBox");if(boundingBox==undefined)return;var wrapper=boundingBox.one(".listbox-content-wrapper");if(wrapper==undefined||wrapper==null)return;if(!wrapper.hasClass("expanded"))wrapper.addClass("expanded")}return toggleParentsContentBox(parent)};renderListbox=function(){var portletNamespaceElement=Y.one("#"+PORTLET_NAMESPACE_PARAM);if(portletNamespaceElement==
null)return;var portletNamespace=Y.one("#"+PORTLET_NAMESPACE_PARAM).get("value");PORTLET_ID=Y.one("#"+PORTLET_ID_PARAM).get("value");language=Y.one("#"+LANGUAGE_PARAM).get("value");subjectSelectedActionURL=Y.one("#"+SUBJECT_SELECTED_ACTION_URL_PARAM).get("value");var selectedCodes=Y.one("#"+SELECTED_CODES_PARAM).get("value");if(selectedCodes&&selectedCodes.length>0)SELECTED_CODES=selectedCodes.split(",");SELECTED_ELEMENT_LABEL=Y.one("#"+SELECTED_SUBJECT_LABEL_PARAM).get("value");SELECTED_ELEMENT_ID=
Y.one("#"+SELECTED_SUBJECT_ID_PARAM).get("value");domainsListBox=new Y.RootListBox({id:DOMAINS_LISTBOX});subDomainsListBox=new Y.RootListBox({id:SUB_DOMAINS_LISTBOX});subjectsListBox=new Y.RootListBox({id:SUBJECTS_LISTBOX});domainsListBox.after("selectionChange",function(e){var selection=getSelection(this);if(selection){setSearchButtonAction(Y,selection);if(SELECTED_CODES.length==0)SELECTED_CODES.push(selection.get("code"));var executed=handleQuery(Y,e,language,subjectSelectedActionURL,0,selection);
if(executed||selection.get(CODE)==undefined)return;subjectsListBox.removeAll();SUBJECTS_LISTBOX_INTERNAL.get("childNodes").remove();subDomainsListBox.removeAll();SUB_DOMAINS_LISTBOX_INTERNAL.get("childNodes").remove();var optionElements=getOptionElements(getSubDomains(selection.get(IDENTIFIER)));for(var i=0;i<optionElements.length;i++)subDomainsListBox.add(optionElements[i]);Y.one("#"+SUBJECTS_CONTAINER).removeClass("active");Y.one("#"+DOMAINS_CONTAINER).removeClass("active");if(!isSubjectSelectedAfterMobileQuery(Y))Y.one("#"+
SUB_DOMAINS_CONTAINER).addClass("active");Y.one("#"+SUB_DOMAINS_CONTAINER+" .back-button").setHTML(getIconAndLabel(selection));Y.one("#"+SUB_DOMAINS_CONTAINER+" .back-button").on("click",function(ev){ev.preventDefault();Y.one("#"+SUB_DOMAINS_CONTAINER).removeClass("active");Y.one("#"+DOMAINS_CONTAINER).addClass("active");domainsListBox.set("selection","")})}});subDomainsListBox.after("selectionChange",function(e){var selectedDomain=getSelection(domainsListBox);var selection=getSelection(this);if(selection){setSearchButtonAction(Y,
selection);if(SELECTED_CODES.length==1)SELECTED_CODES.push(selection.get("code"));var executed=handleQuery(Y,e,language,subjectSelectedActionURL,1,selection);if(executed||selection.get(CODE)==undefined)return;subjectsListBox.removeAll();SUBJECTS_LISTBOX_INTERNAL.get("childNodes").remove();var optionElements=getOptionElements(getSubjects(selectedDomain.get(IDENTIFIER),selection.get(IDENTIFIER)));for(var i=0;i<optionElements.length;i++)subjectsListBox.add(optionElements[i]);Y.one("#"+SUB_DOMAINS_CONTAINER).removeClass("active");
if(!isSubjectSelectedAfterMobileQuery(Y))Y.one("#"+SUBJECTS_CONTAINER).addClass("active");Y.one("#"+SUBJECTS_CONTAINER+" .back-button").setHTML(getIconAndLabel(selection));Y.one("#"+SUBJECTS_CONTAINER+" .back-button").on("click",function(ev){ev.preventDefault();Y.one("#"+SUBJECTS_CONTAINER).removeClass("active");Y.one("#"+SUB_DOMAINS_CONTAINER).addClass("active");subDomainsListBox.set("selection","")})}});subjectsListBox.after("selectionChange",function(e){return subjectSelectionChange(e,this,false)});
domainsListBox.after("render",function(e){domainsListBox.get("boundingBox").addClass("subject-browser")});subDomainsListBox.after("render",function(e){subDomainsListBox.get("boundingBox").addClass("subject-browser")});subjectsListBox.after("render",function(e){subjectsListBox.get("boundingBox").addClass("subject-browser")});var domainsLabel=Y.one("#"+DOMAINS_LABEL).get("value");var subDomainsLabel=Y.one("#"+SUBDOMAINS_LABEL).get("value");var subjectsLabel=Y.one("#"+SUBJECTS_LABEL).get("value");Y.one("#"+
DOMAINS_CONTAINER).one("h3").setContent(domainsLabel);Y.one("#"+SUB_DOMAINS_CONTAINER).one("h3").setContent(subDomainsLabel);Y.one("#"+SUBJECTS_CONTAINER).one("h3").setContent(subjectsLabel);Y.one("#"+SEARCH_BUTTON).on("click",function(){window.location.href=document.getElementById(SEARCH_LINK).href;return false});domainsListBox.render("#"+DOMAINS_CONTAINER);subDomainsListBox.render("#"+SUB_DOMAINS_CONTAINER);subjectsListBox.render("#"+SUBJECTS_CONTAINER);DOMAINS_LISTBOX_INTERNAL=Y.one("#"+DOMAINS_LISTBOX).one("ul");
SUB_DOMAINS_LISTBOX_INTERNAL=Y.one("#"+SUB_DOMAINS_LISTBOX).one("ul");SUBJECTS_LISTBOX_INTERNAL=Y.one("#"+SUBJECTS_LISTBOX).one("ul");if(DOMAINS_CACHE.length>0);else Y.io.request(SUBJECT_QUERY_HANDLER_PATH,{method:"POST",data:{userLocale:language,action:ACTION_ALL},on:{success:function(){var responseData=this.get("responseData");storeSubjects(responseData);if(!isSubjectSelectedAfterMobileQuery(Y))Y.one("#"+DOMAINS_CONTAINER).addClass("active");mobileHideSubjectsAfterQuery(Y);fillBoxesWithDataFromCache(domainsListBox)}}})};
renderListbox()})});
