$(document).foundation({reveal:{multiple_opened:true}});if(!window.location.origin){window.location.origin=window.location.protocol+'//'+ window.location.hostname+(window.location.port?':'+ window.location.port:'');}
if(!String.prototype.startsWith){String.prototype.startsWith=function(searchString,position){position=position||0;return this.substr(position,searchString.length)===searchString;};}
var AOP=AOP||{};AOP.initAltMetric=function(){$('.altmetric-badge').not('.processed').each(function(){var $altEl=$(this);var doi=$altEl.data('doi');var badgeSize=$altEl.data('badge-size')||'small';var container=$altEl.data('altmetric-badge-container');if(container){$(container).hide();}
if(doi&&doi.length){$.ajax({type:'GET',dataType:'json',url:AOP.baseUrl+'/services/aop-cambridge-core/altmetric',data:{doi:doi},success:function(resp,status,xhr){if(xhr.status===200&&resp){var imageUrl=resp.images[badgeSize];var detailsUrl=resp.detailsUrl;var score=resp.score;if(imageUrl&&detailsUrl&&score){var altLink=$('<a>').attr('href',detailsUrl).attr('target','_blank');var altDonut=$('<img/>',{'src':imageUrl,'att':'Altmetric score: '});altLink.append(altDonut);$altEl.prepend(altLink);}
if(container){$(container).show();}
$altEl.addClass('processed');}else{$altEl.remove();}},error:function(err){console.log(err);}});}else{$altEl.remove();}});};AOP.loadQtip=function(){$('.download-types li a, .social li a').each(function(i,e){var $e=$(e);if(!$e.data('loadedQtip')){$e.data('loadedQtip',true);$e.qtip({style:{tip:{width:20,height:10}},content:{attr:'data-hasqtip'},position:{viewport:$(window),my:'bottom center',at:'top center',target:'event'}});}});$('.content-switch li a').qtip({style:{tip:{width:20,height:10}},content:{attr:'data-hasqtip'},position:{my:'center left',at:'center right',target:'event'}});$('.hasTooltipCustom').each(function(){$(this).qtip({style:{tip:{width:20,height:10},classes:'custom-tooltip'},content:{text:function(api){var content=$(this).find('.custom-tooltip');return content.length!==0?content.html():content.html();}},position:{viewport:$(window),adjust:{mouse:true,method:'flip'},my:'top center',at:'bottom center',target:'event'},hide:{fixed:true,delay:300}});});$('.access > li > a.hasTooltipCustom--bottom').each(function(){$(this).qtip({style:{tip:{width:20,height:10},classes:'custom-tooltip'},content:{text:function(api){var content=$(this).find('.custom-tooltip');return content.length!==0?content.html():content.html();}},position:{viewport:$(window),adjust:{mouse:true,method:'flip'},my:'top center',at:'bottom center',target:'event'},hide:{fixed:true,delay:300}});});$('a.hasTooltipCustom-top').each(function(){var eventType=$(this).data('qtipEvent');var qTipOpts={style:{tip:{width:20,height:10},classes:'custom-tooltip--buttons'},content:{text:function(api){var content=$(this).next('.custom-tooltip');return content.length?content.html():'';}},position:{viewport:$(window),adjust:{mouse:true,method:'flip'},my:'bottom center',at:'top center',target:'event'},hide:{fixed:true,delay:300}};if(eventType){qTipOpts.show={event:eventType};}
$(this).qtip(qTipOpts).on('click',function(e){return false;});});$('a.hasTooltipCustom-top-format').each(function(){$(this).qtip({style:{tip:{width:20,height:10},classes:'custom-tooltip--formats'},content:{text:function(api){var content=$(this).next('.custom-tooltip');return content.length!==0?content.html():content.html();}},position:{viewport:$(window),adjust:{mouse:true,method:'flip'},my:'bottom center',at:'top center',target:'event'},hide:{fixed:true,delay:300}});});$('.hasTooltipCustom-top-price').each(function(){$(this).qtip({style:{tip:{width:20,height:10},classes:'custom-tooltip--formats'},content:{text:function(api){var content=$(this).parent().parent().find('.custom-tooltip');return content.length!==0?content.html():content.html();}},position:{viewport:$(window),adjust:{mouse:true,method:'flip'},my:'bottom center',at:'top center',target:'event'},hide:{fixed:true,delay:300}});});$('.dashboard-blocks .info').each(function(){$(this).qtip({style:{tip:{width:20,height:10}},content:{attr:'data-hasqtip'},position:{my:'center left',at:'center right',target:'event'}});});$('.hasTooltipCustom-mathjax-listing').each(function(){$(this).qtip({style:{tip:{width:20,height:10},classes:'custom-tooltip--mathjax-listing'},content:{text:function(api){var content=$(this).next('.custom-tooltip');return content.length!==0?content.html():content.html();}},position:{viewport:$(window),adjust:{mouse:true,method:'flip'},my:'bottom center',at:'top center',target:'event'},show:'click',hide:{fixed:true,event:'click'}}).bind('click',function(e){return false;});});};AOP.stringTrim=function(untrimmed){if(untrimmed){return untrimmed.toString().replace(/^\s+|\s+$/gm,'');}
return'';};AOP.infiniteScroll=function(endpoint,opts){opts=opts||{};var _noMoreOutput=opts.noMoreOutput||'<center>No more posts to show.</center>';var _outputContainer=opts.outputContainer||'.reading-width';var _startingPage=opts.startingPage||2;var getQueryParams=function(){var query=window.location.search.substring(1);var vars=query.split('&');var vals=[];for(var i=0;i<vars.length;i++){var pair=vars[i].split('=');if(pair.length===2&&pair[0]&&pair[1]){vals.push({name:decodeURIComponent(pair[0]),value:decodeURIComponent(pair[1])});}}
return vals;};var loadingInfinitePage=false;};AOP.styleInputElements=function(container){var selector;if(container){selector=$('input[type=checkbox], input[type=radio]',container).not('.styled');}else{selector=$('input[type=checkbox], input[type=radio]').not('.styled');}
selector.each(function(i,el){$(this).addClass('styled');el=$(el)[0];var doneAlready=(el&&el.nextElementSibling&&el.nextElementSibling.outerHTML==='<span></span>');if(!doneAlready){$(this).after($('<span></span>'));}});};AOP.sentenceCase=function(sentence){if(typeof sentence!=='string'){return false;}
sentence=sentence.toLowerCase();return sentence.substr(0,1).toUpperCase()+ sentence.substr(1);};AOP.accordionTextSwitch=function(container){var $accordionTextSwitch;if(container){$accordionTextSwitch=$(container).find($('.accordion-navigation > a:not(.init)'));}else{$accordionTextSwitch=$('body').find($('.accordion-navigation > a:not(.init)'));}
$accordionTextSwitch.on('click',function(){$(this).find('.toggle-cord').toggleClass('close open-drawer');$(this).parent().find('.accordion').find('a[aria-expanded=\'true\']').each(function(){$(this).find('.close').toggleClass('close open-drawer');$(this).attr('aria-expanded','false');$(this).parent().find('>.content').removeClass('active');});var text=$(this).find('.toggle-text').text();$(this).find('.toggle-text').text(text==='View'?'Hide':'View');}).addClass('init');};AOP.clearForLogin=function(){$.post(AOP.baseUrl+'/services/aop-cambridge-core/session/clear-for-login');};AOP.isReaderPage=function(){var re=new RegExp('core-reader');return re.test(window.location.pathname);};AOP.loadGlobalNav=function(){if(!AOP.isReaderPage()){try{globalNav('//www.cambridge.org/tools/packages/cambridge_themes/global_navigation/v1.2',{},function(resp){jQuery('#global-nav').html(resp);responsiveNavOnloadCallback();},'html',5000);}catch(e){}}};AOP.validateOrcidId=function(orcidId,customErrorElSelector,callback){if(!orcidId){return callback(true);}
var customErrorEl=$(customErrorElSelector);var output=false;$.ajax({url:'//pub.orcid.org/v1.1/search/orcid-bio/?q=orcid:'+ orcidId,headers:{'Accept':'application/json'},async:true}).success(function(data){var results=data['orcid-search-results']['num-found'];if(results===0){customErrorEl.show();customErrorEl.parent().parent().addClass('error');}else{customErrorEl.hide();customErrorEl.parent().parent().removeClass('error');output=true;}
return callback(output);}).error(function(){customErrorEl.show();return callback(false);});};(function($){AOP.styleInputElements();AOP.accordionTextSwitch();AOP.initAltMetric();AOP.loadGlobalNav();function putEmptyValuesInSelects(){if($('select')){$('select option').each(function(){if(!$(this).attr('value')){$(this).attr('value','');}});}}
function formatStringInTitleCase(str){if(typeof str!=='string'){throw new TypeError('formatStringInTitleCase() :: argument:str :: expected:string :: actual:'+ typeof str);}
return str.charAt(0).toUpperCase()+ str.substr(1).toLowerCase();}
function escapeHTML(str){if(typeof str!=='string'){throw new TypeError('escapeHTML() :: argument:str :: expected:string :: actual:'+ typeof str);}
return $('<div/>').html(str).text();}
function getOuterHTML($target){return $target[0].outerHTML||$('<div>').append($target.clone()).html();}
$(document).on('DOMNodeInserted',function(e){var hasInputs=!!$('input[type=checkbox], input[type=radio]',e.target).length;if(hasInputs){AOP.styleInputElements(e.target);}});$(document).ready(function(){putEmptyValuesInSelects();$('.closeModal').on('click',function(){$('.reveal-modal').foundation('reveal','close');});});AOP.loadQtip();var $body=$('body'),$window=$('window'),$wrapper=$('.wrapper'),$mainContent=$wrapper.find($('.wrapper > .main-column')),$sideNav=$wrapper.find($('.wrapper > .narrow-column')),$pageOperativesDesktop=$wrapper.find('> .page-operatives'),$actions=$body.find($('.actions')),$tabsContent=$('.tabs-content'),$footer=$body.find($('footer')),$secondaryMenu=$body.find($('.secondary')),$subHeader=$body.find($('.sub-header')),$pageTabs=$body.find($('.page-tabs')),$corePageTabs=$body.find($('.core-page-tabs')),$bannerOverspill=$body.find($('.banner-overspill')),$optionSwitch=$wrapper.find($('.icon.switch')),$sideNavToggleDesktop=$wrapper.find('> .page-operatives .icon.toggle'),$sideNavToggleMobile=$wrapper.find('> .panel .page-operatives .icon.toggle'),$openMediumIcon=$tabsContent.find($('.icon.medium.open-drawer')),$openTabletIcon=$bannerOverspill.find($('.icon.tablet.open-drawer')),$secondaryMenuIcons=$body.find($('.menu-icon')),$searchExpand=$secondaryMenu.find($('.search-small')),$accordionExpanderFooter=$footer.find($('.accordion-expander')),$actionShowAllExplore=$actions.find($('.explore-all')),$addKeyword=$actions.find($('#addKeyword')),$pageTabsMobileExpand=$pageTabs.find($('.blue-square')),$corePageTabsMobileExpand=$corePageTabs.find($('.blue-square')),$currentMobileTabName=$('.current-mobile > a'),$panelSticky=$('.panel-sticky'),$panelStickyTopSpacing=50,$searchForms=$body.find($('.search-form'));if($panelSticky.attr('data-sticky-offset')!==undefined){$panelStickyTopSpacing=Number($panelSticky.attr('data-sticky-offset'));}
if($(window).width()>1025){$panelSticky.sticky({topSpacing:$panelStickyTopSpacing});$('.tab-title').on('click',function(){$panelSticky.unstick();$panelSticky.sticky({topSpacing:$panelStickyTopSpacing});});}else{$panelSticky.unstick();}
$(window).on('resize',function(){var width=this.innerWidth;var isSticky=$('.sticky-wrapper').length>0;if(width>1025){if(!isSticky){$panelSticky.sticky({topSpacing:$panelStickyTopSpacing});}
$('.tab-title').on('click',function(){$panelSticky.unstick();$panelSticky.sticky({topSpacing:$panelStickyTopSpacing});});}else{if(isSticky){$panelSticky.unstick();}}});$('.carousel-facts .spinner').on('init afterChange',function(event,slick,currentSlide){if(isNaN(parseFloat(currentSlide))){$('.carousel-facts').find('.current').text((1)+' of '+ slick.slideCount);}else{$('.carousel-facts').find('.current').text((currentSlide+ 1)+' of '+ slick.slideCount);}});$('.carousel-facts .spinner').slick({infinite:true,arrows:true});$('.autocomplete-suggest').each(function(){var autocompleteForm=$(this).closest('form');var moreMatchesText='More matches available, keep typing to refine';var productTypeFilter=$(this).data('productTypes');$(this).devbridgeAutocomplete({lookup:function(query,callback){var payload={input:query};if(productTypeFilter){payload.productType=productTypeFilter;}
$.get(AOP.baseUrl+'/services/aop-cambridge-core/search/suggest',payload,function(res){var suggestions={suggestions:[]};var categories=['JOURNAL','BOOK'];if(productTypeFilter){for(var i in categories){var category=categories[i];var categoryLabelForSelectGroup=formatStringInTitleCase(category)+' title matches';if(!res.hasOwnProperty(category)){continue;}
var numInCat=0;for(var suggestion in res[category]){numInCat++;if(numInCat>5&&category==='BOOK'){suggestions.suggestions.push({value:moreMatchesText,override:suggestions.suggestions[4].value,data:{category:categoryLabelForSelectGroup},isMoreResultHint:true});break;}else if(numInCat<=5){var data=res[category][suggestion]||{};var title=res[category][suggestion].value;if(category==='BOOK'){var biblio=[];if(typeof data['bookSubtitle']!=='undefined'&&AOP.stringTrim(data.bookSubtitle).length){biblio.push(data.bookSubtitle);}
if(typeof data['bookVolumeNumber']!=='undefined'&&data.bookVolumeNumber.length&&data.bookVolumeNumber.toString()!=='1'){biblio.push('Vol '+ data.bookVolumeNumber);}
if(typeof data['bookEditionNumber']!=='undefined'&&data.bookEditionNumber.length&&data.bookEditionNumber.toString()!=='1'){biblio.push('Edition '+ data.bookEditionNumber);}
if(biblio.length){title+=': '+ biblio.join(', ');}}
suggestions.suggestions.push({value:title.toString(),data:{data:res[category][suggestion].data,text:res[category][suggestion].value,category:categoryLabelForSelectGroup}});}}}}
callback(suggestions);});},beforeRender:function(container){$(container).find('.autocomplete-more-results').parent().removeClass('autocomplete-suggestion').addClass('autocomplete-group');return container;},minChars:3,maxHeight:600,open:function(){var $autocompleteOptions=$(document).find('.autocomplete-suggestions');var autocompleteOptionsWidth=$autocompleteOptions.width();$autocompleteOptions.width(autocompleteOptionsWidth+ 4);},showNoSuggestionNotice:false,noSuggestionNotice:'Sorry, no matching titles',groupBy:'category',triggerSelectOnValidInput:false,onSelect:function(suggestion){var eventPayload=$(autocompleteForm).data('autocompleteCupEventPayload');var eventPayloadForAutoComplete=$.extend({},eventPayload,{searchString:suggestion.value,usedIdentities:[]});$.cupEvent.dispatchEvent(eventPayloadForAutoComplete,function(err){if(suggestion.data.data){var eventPayloadForProduct=$.extend({},eventPayload,{searchString:suggestion.value,usedIdentities:[],eventCode:'SE-RC',productId:suggestion.data.data});$.cupEvent.dispatchEvent(eventPayloadForProduct,function(err){window.location.href=AOP.baseUrl+'/product/'+ suggestion.data.data;});}else{if(suggestion.value===moreMatchesText&&suggestion.override){$(this).val(suggestion.override);}}});},formatResult:function(suggestion,currentValue){var suggestionTitle=escapeHTML(suggestion.value);var template=$('<div/>').attr('title',suggestionTitle).html(suggestionTitle);if(suggestion.isMoreResultHint===true){template.wrapInner('<em/>').addClass('autocomplete-more-results');}
return getOuterHTML(template);}});});$('img').error(function(){$(this).css('border','none');});var excludedActions='.book-page, .article, .chapter-page';$sideNavToggleDesktop.on('click',function(){var animationTime=250;$(this).toggleClass('open-drawer close');if($(this).hasClass('close')){if($('.sticky-wrapper').length===0){$panelSticky.sticky({topSpacing:$panelStickyTopSpacing});}
$sideNav.add($mainContent).add($pageOperativesDesktop).removeClass('closed-view');$actions.not(excludedActions).show();$sideNav.hide().delay(animationTime).fadeIn(animationTime);$sideNavToggleMobile.addClass('close');}else{$actions.not(excludedActions).fadeOut(animationTime).promise().done(function(){$sideNav.add($mainContent).add($pageOperativesDesktop).addClass('closed-view');$sideNavToggleMobile.removeClass('close');$panelSticky.unstick();});}});$sideNavToggleMobile.on('click',function(){$(this).toggleClass('close');if($(this).hasClass('close')){$sideNav.add($mainContent).removeClass('closed-view');$actions.not(excludedActions).show();$sideNavToggleDesktop.removeClass('open-drawer').addClass('close');}else{$actions.not(excludedActions).hide().promise().done(function(){$sideNav.add($mainContent).addClass('closed-view');$sideNavToggleDesktop.removeClass('close').addClass('open-drawer');});}});$subHeader.find('input[type=submit]').on('click',function(e){if($subHeader.find('input[name=q]').val().length===0){e.preventDefault();}});$($searchForms).each(function(){var self=this;if($(this).hasClass('prevent-empty-search')){$(this).find('input[type=submit]').on('click',function(e){if($.trim($(self).find('input[name=q]').val()).length===0){e.preventDefault();}});}
$(this).submit(function(e,evented){var self=this;var eventPayload=$(this).data('cupEventPayload');if(eventPayload){$.extend(eventPayload,{searchString:$(self).find('input[name="q"]').val(),usedIdentities:[]});if(!evented){e.preventDefault();$.cupEvent.dispatchEvent(eventPayload,function(){$(self).trigger('submit',true);});}}});});$secondaryMenuIcons.each(function(i,e){$(this).on('click',function(e){var $anyDropdown=$body.find('.dropdown-menu-mobile'),$nearestDropdown=$(this).parent().parent().next(),$backdrop='<div class="backdrop"></div>';if(!$anyDropdown.hasClass('open-drawer')){$nearestDropdown.toggleClass('open-drawer').parent().append($backdrop);if($(this).hasClass('identities')){$nearestDropdown.removeClass('personal').addClass('identities');}
if($(this).hasClass('personal')){$nearestDropdown.removeClass('identities active').addClass('personal');}
if(!$(this).hasClass('identities')){$(this).addClass('active');}}else{$anyDropdown.removeClass('open-drawer').parent().find('.backdrop').remove();$(this).removeClass('active');}});});$('.js-toggle-show').on('click',function(){var $button=$(this);if($('.accordion').data('showing')===true){$('.accordion').find('.content').removeClass('active');$button.text('Expand full list');$('.accordion').data('showing',false);}else{$('.accordion').find('.content').addClass('active');$button.text('Hide full list');$('.accordion').data('showing',true);}});$optionSwitch.on('click',function(){$(this).toggleClass('off on');});$('.js-outglow').on('focus',function(){$(this).closest('.js-outglow-parent').toggleClass('glow');});$('.js-outglow').on('blur',function(){$(this).closest('.js-outglow-parent').toggleClass('glow');});$openMediumIcon.on('click',function(){$(this).toggleClass('open-drawer close');});$openTabletIcon.on('click',function(){$(this).toggleClass('open-drawer close');});$('.toggle-cord').on('click',function(){$(this).toggleClass('open-drawer close');$(this).toggleClass('open-drawer close');});$accordionExpanderFooter.on('click',function(){$(this).find('.icon').toggleClass('close open-drawer');});$('.js-expand').on('click',function(e){e.preventDefault();var expandButtons=$('.js-expand');var expandButtonsText=expandButtons.find('span');var buttonText;var ariaExpandText=$(this).data('ariaExpandText');var ariaCollapseText=$(this).data('ariaCollapseText');if(!$(this).data('expanded')){$('.nested-accordion .content').removeClass('active').addClass('active');$('.nested-accordion [aria-expanded="false"]').attr('aria-expanded','true');$('.nested-accordion .toggle-cord').removeClass('open-drawer').addClass('close');buttonText='Collapse list';$(this).data('expanded',true);expandButtonsText.text(buttonText);expandButtons.attr('aria-label',ariaCollapseText);expandButtons.data('expanded',true);}else{$('.nested-accordion .content').removeClass('active');$('.nested-accordion [aria-expanded="true"]').attr('aria-expanded','false');$('.nested-accordion .toggle-cord').removeClass('close').addClass('open-drawer');buttonText='Expand full list';$(this).data('expanded',false);expandButtonsText.text(buttonText);expandButtons.attr('aria-label',ariaExpandText);expandButtons.data('expanded',false);}
return false;});$searchExpand.on('click',function(){if($subHeader.hasClass('slide-up')){$subHeader.removeClass('slide-up').addClass('slide-down');$(this).addClass('active');$(this).children('span').addClass('active');}else{$subHeader.removeClass('slide-down').addClass('slide-up');$(this).removeClass('active');$(this).children('span').removeClass('active');}});$('.tab-title.current-mobile a').on('click',function(){$corePageTabsMobileExpand.find('a.icon').toggleClass('open');});$pageTabs.on('click','.tab-title a',function(e){e.preventDefault();if($(window).width()<1024){if($('.sticky-wrapper').length>0){$panelSticky.unstick();}}
$pageTabs.find('.tabs').toggleClass('open-drawer');if(!$(this).hasClass('icon')){$currentMobileTabName.text($(this).text());if($(window).width()<1024){$pageTabsMobileExpand.find('a').toggleClass('open');$('.icon.toggle.close').click();}}else{$(this).toggleClass('open');}});var loaded=false;$actionShowAllExplore.each(function(){$(this).on('click',function(e){var limit=5;if($(this).data('limit')){limit=$(this).data('limit');}
var $showAll=$(this);var $buttonTextAction=$(this).find('.toggle-text');var $buttonTextAmount=$(this).find('.excerpt-type');var $buttonIcon=$(this).find('.icon');e.preventDefault();var $thisActionsList=$showAll.closest($actions).find('ul');if(loaded){if($thisActionsList.find('li:eq('+(limit)+')').is(':hidden')){$thisActionsList.find('li:gt('+(limit- 1)+')').fadeIn(300,function(){$buttonTextAction.text('Show');$buttonTextAmount.text('fewer');$buttonIcon.addClass('close');});}else{$thisActionsList.find('li:gt('+(limit- 1)+')').fadeOut(300,function(){$buttonTextAction.text('Show');$buttonTextAmount.text('all');$buttonIcon.removeClass('close');});}}else{$($thisActionsList).find('li:gt('+(limit- 1)+')').fadeIn(300,function(){$buttonTextAction.text('Show');$buttonTextAmount.text('fewer');$buttonIcon.addClass('close');});loaded=true;}});});$actions.on('submit',$addKeyword,function(e){e.preventDefault();var keyword=$addKeyword.val();if(keyword&&keyword.length){var addedKeywordListItem='<li><a href="#"><span class="icon delete"></span>'+ keyword+'</a></li>';$('.keywords').append(addedKeywordListItem);}});$('.keywords').on('click','li a',function(e){e.preventDefault();$(this).parent().remove();});$('ul#text-resizer-controls').each(function(){$(this).children().textresizer({target:'.large-12 .wrapper',type:'cssClass',sizes:['standard-text','large-text'],selectedIndex:1});});$('.dashboard-blocks .info').one('click mouseenter',function(e){$(this).removeClass('unread');});$('.blurred-cover').foggy({blurRadius:8,opacity:0.8,cssFilterSupport:true});$('.abstract').on('click','a',function(e){e.preventDefault();var toggleText=$(this).find('.toggle-text');var icon=$(this).find('>span');icon.toggleClass('close');$(this).next().toggle();});$('#institutions-dropdown img, .show-for-small.institutions img').on({click:function(){var link=$(this).parent().parent().find('a');if(link.attr('data-no-link')===undefined){window.open(link.attr('href'),'_blank');}},mouseenter:function(){var link=$(this).parent().parent().find('a');if(link.attr('data-no-link')===undefined){$(this).css({cursor:'pointer'});}else{$(this).css({cursor:'default'});}}});var orgLogoCheck=function(){var deviceLogo=$('a.account-loggedin.identities');if(window.orientation===0&&$(window).width()<=320){deviceLogo.addClass('no-logo');}else{deviceLogo.removeClass('no-logo');}};var tabName;var tabIdx=0;var $collection=$pageTabs.length!==0?$pageTabs:$corePageTabs;$.each($collection,function(){tabName=$(this).find('.tab-title.active').text();$($currentMobileTabName.get(tabIdx)).text(tabName);tabIdx++;});var institutions=$('.institution-name ul li.institution'),primaryLogo=$('.institution-primary-logo'),deviceLogo=$('a.account-loggedin.identities'),link,image,institutionName,imageFound=false;if(institutions.length>0){$.each(institutions,function(){link=$(this).find('a');image=$(this).find('img');institutionName=link.text();if(!!image.attr('src')){primaryLogo.find('a').append('<img src="'+ image.attr('src')+'" alt="'+ institutionName+'">');deviceLogo.find('img').attr('src',image.attr('src')).attr('alt',institutionName);orgLogoCheck();if(!link.attr('data-no-link')&&!!link.attr('href')){primaryLogo.find('a').attr('href',link.attr('href')).attr('target','_blank');}else{primaryLogo.find('a').attr('data-no-link',true);}
primaryLogo.show();imageFound=true;return false;}});}
if(!imageFound){primaryLogo.remove();}
if(window.addEventListener){window.addEventListener('orientationchange',function(){orgLogoCheck();},false);}
$('.aop-toggle-text').each(function(){var $event=$(this);var $buttonText=$event.find('.button-text');var textOn=$event.data('toggleOn')||$buttonText.html();var textOff=$event.data('toggleOff');var ariaEntityName=$event.data('ariaEntityName');var setAriaLabel=function(el,labelText,entityName){if(typeof labelText==='string'&&el){el.attr('aria-label',labelText.trim()+(entityName?' '+ entityName:''));}};setAriaLabel($event,textOn,ariaEntityName);if(!textOn||!textOff){console.warn('Specify data attributes for toggling text',$event);}else{$event.click(function(e){e.preventDefault();if($buttonText.html()===textOn){$buttonText.html(textOff);setAriaLabel($event,textOff,ariaEntityName);}else{$buttonText.html(textOn);setAriaLabel($event,textOn,ariaEntityName);}});}});$('.aop-toggle-class').each(function(){var $event=$(this);var cssOn=$event.data('toggleClassOn');var cssOff=$event.data('toggleClassOff');if(!cssOn||!cssOff){console.warn('Specify data attributes for toggling css',$event);}else{$event.click(function(e){e.preventDefault();$event.hasClass(cssOn)?$event.removeClass(cssOn).addClass(cssOff):$event.removeClass(cssOff).addClass(cssOn);});}});$('.aop-toggle-show').each(function(){var $event=$(this);var $target=$($event.data('toggleTarget'));if($target.length>0){$event.click(function(e){e.preventDefault();$target.toggleClass('hide');});}});$('.aop-toggle-replace').each(function(){var $event=$(this);var targets=$event.data('replaceTarget').split(',');if(!targets.length){return false;}
var $initial=$(targets[0]);var $target=$(targets[1]);if($target.length&&$initial.length){$event.click(function(e){e.preventDefault();$target.toggleClass('hide');$initial.toggleClass('hide');});}});$('.aop-toggle-action').each(function(){var $event=$(this);var action=$event.data('toggleAction');var $target=$($event.data('toggleTarget'));if(!action){console.warn('Specify toggle action',$event);}else{$event.click(function(e){e.preventDefault();switch(action){case'showHide':$target.toggleClass('hide');break;}});}});var initSecondaryMenuDropdowns=function(elementId,opts){if(!elementId||typeof elementId!=='string'){return;}
var $button={noTouch:$('.no-touch #'+ elementId).parent(),touch:$('.touch #'+ elementId).parent()};var dropdown={$el:$('#'+ elementId).next(),top:opts.top||0,left:opts.left||0,isHidden:function(){return this.$el.attr('aria-hidden')==='true';},hide:function(){this.$el.css({left:-9999,top:this.top}).attr('aria-hidden','true');},show:function(){this.$el.css({left:$('#'+ elementId).position().left+ this.left,top:this.top}).attr('aria-hidden','false');},toggle:function(){if(this.isHidden()){this.show();return;}
this.hide();}};$button.noTouch.bind('mouseenter mouseleave click',function(e){switch(e.type){case'click':dropdown.toggle();break;case'mouseenter':dropdown.show();break;case'mouseleave':dropdown.hide();break;default:break;}});$button.touch.on('touchend',function(e){e.preventDefault();var href=$(e.target).attr('href');if(!href){dropdown.toggle();}else{window.location.href=href;}});$('.touch body').on('touchend',function(e){var $target=$(e.target);if($target.attr('id')!==elementId){dropdown.hide();}});};initSecondaryMenuDropdowns('r-user-dropdown-icon',{top:40,left:-12});initSecondaryMenuDropdowns('institution-current',{top:31});$(document).on('close.fndtn.reveal','#login-modal[data-reveal]',function(){AOP.clearForLogin();});})(jQuery);$(window).on('load',function(){var images=$('[data-enable-cup-replacement="true"]');for(var i=0;i<images.length;i++){var img=$(images)[i];if(!img.complete||typeof img.naturalWidth==='undefined'||img.naturalWidth===0){$(img).attr('src',AOP.baseUrl+'/cambridge-core/public/images/jacket_blank_300x448.jpg');$(img).css('width',180);}}});window.addEventListener('hashchange',function(event){var element=document.getElementById(location.hash.substring(1));if(element){if(!/^(?:a|select|input|button|textarea)$/i.test(element.tagName)){element.tabIndex=-1;}
element.focus();}},false);