var ImageDetailDataManager;(function(n){function wt(){typeof IIConfig!="undefined"&&IIConfig&&IIConfig.ie&&(s=IIConfig.ie);b=[].slice.call(t.gebc(lt,_d));k=[].slice.call(t.gebc(ft,_d));sj_evt.bind(DetailPageUtils.DetailPageEvent.Navigation,ht);s&&sj_evt.bind(DetailPageUtils.DetailPageEvent.ActiveItemChange,ct);sj_be(_w,"unload",a);sj_evt.bind("ajax.unload",a);var n=parseInt(pMMUtils.qsv("selectedIndex",!0));u=isNaN(n)?0:n}function a(){sj_evt.unbind(DetailPageUtils.DetailPageEvent.Navigation,ht);s&&sj_evt.unbind(DetailPageUtils.DetailPageEvent.ActiveItemChange,ct);sj_ue(_w,"unload",a);sj_evt.unbind("ajax.unload",a)}function h(n,t,i){var r=i?gt(n):c(n),u,f,e;return r&&t&&(u=g(r),u&&(r[at]=u),f=ni(r),e="brq",f&&typeof r[e]=="undefined"&&(r.brq=f[e])),r}function d(n){return n?f&&f.insights||(f=h(u,!0)):f||(f=h(u)),f}function bt(n){var t=h(n),i=t?t.cidx:null;return typeof i=="number"?i:n}function kt(n,t){var i=c(n);i&&!i[ot]&&(i[ot]=t)}function dt(n){var e,f,o,h;if(typeof n=="undefined"&&(n=!1),e=_ge("ivd"),f=e?t.ga(e,"json-data"):null,f&&f.length>0){f=decodeURIComponent(f.replace(/\+/g,"%20"));try{o=JSON.parse(f)}catch(c){}o&&o[ut]&&(ti(o[ut],n),ii(o[pt]),sj_evt.fire(DetailPageUtils.DetailPageEvent.MoreResultsLoaded,i,r));t.r(e.parentNode,e)}s&&(h=u,it(h,function(n,t){v(n);y(h,t)},function(n){y(h,n)}))}function v(n){var c=sj_ce("div"),r,u,i,f,e,s,h;if(c.innerHTML=n,r=t.gebc(ft,c),r)for(u=0;u<r.length;u++)(i=t.ga(r[u],vt),f=t.ga(r[u],w),i&&f)&&(o[i]||(o[i]={}),e=o[i],e[f]||(e[f]=r[u].innerHTML),s=t.ga(r[u],yt),s&&(l[i]||(l[i]={}),h=l[i],h[f]||(h[f]=s)))}function c(n){if(n>=i)while(n<=r){var t=e[n];if(t)return t;n++}return null}function gt(n){if(n<=r)while(n>=i){var t=e[n];if(t)return t;n--}return null}function g(n){return st(o,n)}function ni(n){return st(l,n)}function st(n,t){var i=t[et];return i?n[i]:null}function ht(t){var e=t[1],i,r,c,l,o,h;(i=typeof e.newIndex=="number"?e.newIndex:e.direction==DetailPageUtils.NavigationDirection.Next?u+1:u-1,r=n.getFullData(i,!1,i<u),r)&&(i=r.idx,c={newIndex:i,oldIndex:u,triggerType:e.eventType,component:e.source},u=i,f=r,nt(r),sj_evt.fire(DetailPageUtils.DetailPageEvent.ActiveIndexChange,c),s)&&(l=g(r),l?(tt(i),o=r[p]+rt-1,h=n.getFullData(o,!0),h&&!h.insights&&it(o,function(n){v(n)})):it(i,function(n,t){v(n);y(i,t)},function(n){y(i,n)}))}function nt(n){for(var r,u,f,e,i=0;i<b.length;i++)r=b[i],u=t.ga(r,w),u&&(f="",n[u]&&(f=n[u]),r.innerHTML=f,e=t.gpc(r,"A","webAnswerContainer"),e&&(f==""?t.ac(e,"disable"):t.rc(e,"disable")))}function y(n,t){var i=d();i&&i.mid&&t.indexOf(i.mid)>=0&&tt(n)}function tt(n){var t=h(n,!0),i={index:n,resultData:t};sj_evt.fire(DetailPageUtils.DetailPageEvent.ActiveItemChange,i)}function ct(n){var i=n[1],s,f,r,e,o,h,c,l;if(i!=null&&i.resultData!=null&&i.resultData.insights!=null&&i.index==u){for(nt(i.resultData),s=i.resultData.insights,f=0;f<k.length;f++)r=k[f],e=t.ga(r,w),e&&(o="",s[e]&&(o=s[e]),h=r.firstChild,h&&r.removeChild(h),o&&(c=sj_ce("div"),c.innerHTML=o,l=c.firstChild,l&&r.appendChild(l)));sj_evt.fire(DetailPageUtils.DetailPageEvent.InsightsUpdated)}}function it(n,t,i){for(var u=[],s=[],h=0,f=n,r,e,l,a;h<rt&&f!=null;)r=c(f),f=null,r&&(g(r)||(e=r[et],e&&(u.push(e),o[e]={},l=r.ccid?r.ccid:"",s.push(l))),f=typeof r[p]!="undefined"?parseInt(r[p])+1:null),h++;u.length>0?(a={mid:u.join(","),cid:s.join(",")},InsightsFetcher.fetch(a,InsightsFetcher.ImageRequestMode.Batch,function(n){t(n,u)},function(){i&&i(u)})):tt(n)}function ti(n,u){var o=[],l,s,p,h,a,f,v,w,y;for(l in n)n.hasOwnProperty(l)&&o.push(n[l]);for(u&&(o=o.reverse()),p=i==null||r==null,i!=null&&r!=null&&(s=u?c(i).cidx:c(r).cidx),h=0;h<o.length;h++)a=o[h],f=a.idx,e[f]||(e[f]=a,i==null||r==null?s=e[f].cidx=i=r=f:(e[f].cidx=u?--s:++s,i=i>f?f:i,r=r<f?f:r));v=t.qsv("iss",!0);w=v&&/^VS(I|P)$/i.test(v);p&&w&&(y=d(),y&&nt(y))}function ii(t){t&&(n.favData=t)}function ri(n){var u={},i,f,r;return n.insights&&n.insights&&n.insights.caption&&(i=sj_ce("div"),i.innerHTML=n.insights.caption,f=i?t.gebc("cap_items",i):[],f.length>0&&(u.content=f[0].textContent,r=i?t.gebc("cap_link",i):[],r&&r.length>0&&(u.source=r[0].textContent))),u}var o={},e={},l={},t=pMMUtils,i,r,rt=5,s=!1,ut="web",lt="webAns",ft="insightsAns",et="mid",p="idx",ot="mainImg",at="insights",w="data-type",vt="data-id",yt="data-metadata",pt="ext",b,k,u,f;n.init=wt;n.getFullData=h;n.getCurrentMetaData=d;n.getContinuousIndex=bt;n.insertMainImage=kt;n.loadData=dt;n.loadInsightsData=v;n.getCaptionInfo=ri})(ImageDetailDataManager||(ImageDetailDataManager={}));ImageDetailDataManager.init()