
(function(p){var q="string",w="head",H="body",Y="script",t="readyState",j="preloaddone",x="loadtrigger",I="srcuri",C="preload",Z="complete",y="done",z="which",J="preserve",D="onreadystatechange",ba="onload",K="hasOwnProperty",bb="script/cache",L="[object ",bv=L+"Function]",bw=L+"Array]",e=null,h=true,i=false,n=p.document,bx=p.location,bc=p.ActiveXObject,A=p.setTimeout,bd=p.clearTimeout,M=function(a){return n.getElementsByTagName(a)},N=Object.prototype.toString,O=function(){},r={},P={},be=/^[^?#]*\//.exec(bx.href)[0],bf=/^\w+\:\/\/\/?[^\/]+/.exec(be)[0],by=M(Y),bg=p.opera&&N.call(p.opera)==L+"Opera]",bh=("MozAppearance"in n.documentElement.style),u={cache:!(bh||bg),order:bh||bg,xhr:h,dupe:h,base:"",which:w};u[J]=i;u[C]=h;r[w]=n.head||M(w);r[H]=M(H);function Q(a){return N.call(a)===bv}function R(a,b){var c=/^\w+\:\/\//,d;if(typeof a!=q)a="";if(typeof b!=q)b="";d=(c.test(a)?"":b)+a;return((c.test(d)?"":(d.charAt(0)==="/"?bf:be))+d)}function bz(a){return(R(a).indexOf(bf)===0)}function bA(a){var b,c=-1;while(b=by[++c]){if(typeof b.src==q&&a===R(b.src)&&b.type!==bb)return h}return i}function E(v,k){v=!(!v);if(k==e)k=u;var bi=i,B=v&&k[C],bj=B&&k.cache,F=B&&k.order,bk=B&&k.xhr,bB=k[J],bC=k.which,bD=k.base,bl=O,S=i,G,s=h,l={},T=[],U=e;B=bj||bk||F;function bm(a,b){if((a[t]&&a[t]!==Z&&a[t]!=="loaded")||b[y]){return i}a[ba]=a[D]=e;return h}function V(a,b,c){c=!(!c);if(!c&&!(bm(a,b)))return;b[y]=h;for(var d in l){if(l[K](d)&&!(l[d][y]))return}bi=h;bl()}function bn(a){if(Q(a[x])){a[x]();a[x]=e}}function bE(a,b){if(!bm(a,b))return;b[j]=h;A(function(){r[b[z]].removeChild(a);bn(b)},0)}function bF(a,b){if(a[t]===4){a[D]=O;b[j]=h;A(function(){bn(b)},0)}}function W(b,c,d,g,f,m){var o=b[z];A(function(){if("item"in r[o]){if(!r[o][0]){A(arguments.callee,25);return}r[o]=r[o][0]}var a=n.createElement(Y);if(typeof d==q)a.type=d;if(typeof g==q)a.charset=g;if(Q(f)){a[ba]=a[D]=function(){f(a,b)};a.src=c}r[o].insertBefore(a,(o===w?r[o].firstChild:e));if(typeof m==q){a.text=m;V(a,b,h)}},0)}function bo(a,b,c,d){P[a[I]]=h;W(a,b,c,d,V)}function bp(a,b,c,d){var g=arguments;if(s&&a[j]==e){a[j]=i;W(a,b,bb,d,bE)}else if(!s&&a[j]!=e&&!a[j]){a[x]=function(){bp.apply(e,g)}}else if(!s){bo.apply(e,g)}}function bq(a,b,c,d){var g=arguments,f;if(s&&a[j]==e){a[j]=i;f=a.xhr=(bc?new bc("Microsoft.XMLHTTP"):new p.XMLHttpRequest());f[D]=function(){bF(f,a)};f.open("GET",b);f.send("")}else if(!s&&a[j]!=e&&!a[j]){a[x]=function(){bq.apply(e,g)}}else if(!s){P[a[I]]=h;W(a,b,c,d,e,a.xhr.responseText);a.xhr=e}}function br(a){if(a.allowDup==e)a.allowDup=k.dupe;var b=a.src,c=a.type,d=a.charset,g=a.allowDup,f=R(b,bD),m,o=bz(f);if(typeof d!=q)d=e;g=!(!g);if(!g&&((P[f]!=e)||(s&&l[f])||bA(f))){if(l[f]!=e&&l[f][j]&&!l[f][y]&&o){V(e,l[f],h)}return}if(l[f]==e)l[f]={};m=l[f];if(m[z]==e)m[z]=bC;m[y]=i;m[I]=f;S=h;if(!F&&bk&&o)bq(m,f,c,d);else if(!F&&bj)bp(m,f,c,d);else bo(m,f,c,d)}function bs(a){T.push(a)}function X(a){if(v&&!F)bs(a);if(!v||B)a()}function bt(a){var b=[],c;for(c=-1;++c<a.length;){if(N.call(a[c])===bw)b=b.concat(bt(a[c]));else b[b.length]=a[c]}return b}G={script:function(){bd(U);var a=bt(arguments),b=G,c;if(bB){for(c=-1;++c<a.length;){if(c===0){X(function(){br((typeof a[0]==q)?{src:a[0]}:a[0])})}else b=b.script(a[c]);b=b.wait()}}else{X(function(){for(c=-1;++c<a.length;){br((typeof a[c]==q)?{src:a[c]}:a[c])}})}U=A(function(){s=i},5);return b},wait:function(a){bd(U);s=i;if(!Q(a))a=O;var b=E(h,k),c=b.trigger,d=function(){try{a()}catch(err){}c()};delete b.trigger;var g=function(){if(S&&!bi)bl=d;else d()};if(v&&!S)bs(g);else X(g);return b}};if(v){G.trigger=function(){var a,b=-1;while(a=T[++b])a();T=[]}}return G}function bu(a){var b,c={},d={"UseCachePreload":"cache","UseLocalXHR":"xhr","UsePreloading":C,"AlwaysPreserveOrder":J,"AllowDuplicates":"dupe"},g={"AppendTo":z,"BasePath":"base"};for(b in d)g[b]=d[b];c.order=!(!u.order);for(b in g){if(g[K](b)&&u[g[b]]!=e)c[g[b]]=(a[b]!=e)?a[b]:u[g[b]]}for(b in d){if(d[K](b))c[d[b]]=!(!c[d[b]])}if(!c[C])c.cache=c.order=c.xhr=i;c.which=(c.which===w||c.which===H)?c.which:w;return c}p.$LAB={setGlobalDefaults:function(a){u=bu(a)},setOptions:function(a){return E(i,bu(a))},script:function(){return E().script.apply(e,arguments)},wait:function(){return E().wait.apply(e,arguments)}};(function(a,b,c){if(n[t]==e&&n[a]){n[t]="loading";n[a](b,c=function(){n.removeEventListener(b,c,i);n[t]=Z},i)}})("addEventListener","DOMContentLoaded")})(window);

try
{document.execCommand("BackgroundImageCache",true,true);}catch(err)
{}
$(document).ready(function()
{$('a[rel="external"],a[rel="external nofollow"]').unbind('click.externalLink').bind('click.externalLink',function(){window.open($(this).attr('href'));return false;});populateContext();$('#itv-Search-Container input.itv-button').click(function()
{location.href="http://www.itv.com/Search/default.html?q="+$('input#q1 ').val()+"&searchContext="+$('#searchContext').val();});$('#itv-Search-Container input#q1').attr('title','Search ITV.com').keyup(function(e)
{if(e.keyCode==13||e.charCode==13){location.href="http://www.itv.com/Search/default.html?q="+$('input#q1 ').val()+"&searchContext="+$('#searchContext').val();}});$('#glob-links-search input.itv-button').click(function()
{location.href="http://www.itv.com/Search/default.html?q="+$('input#q1 ').val()+"&searchContext="+$('#searchContext').val();});$('#glob-links-search input#q1').attr('title','Search ITV').keyup(function(e)
{if(e.keyCode==13||e.charCode==13){location.href="http://www.itv.com/Search/default.html?q="+$('input#q1 ').val()+"&searchContext="+$('#searchContext').val();}});checkLogin(loginSelectors,registerSelectors);NeighbourNavModification();});var loginSelectors='#itv-signIn li.itv-first a';var registerSelectors='#itv-signIn li.itv-last a';function checkLogin(loginControlID,registerControlID)
{if(checkCookie('.CommunityServer'))
{$(loginControlID).attr("href","javascript:logout();").attr("title","Sign out").text("Sign out");$(registerControlID).attr("title","Account").text("Account");}
else
{$(loginControlID).attr("href","https://sso.itv.com/register/signin.html").attr("title","Sign in").text("Sign in");$(registerControlID).attr("title","Register").text("Register");}}
function logout()
{flushLogin(loginSelectors,registerSelectors);}
function flushLogin(loginSelectors,registerSelectors)
{if(document.cookie!="")
{var path="/";var domain=getCookie("ITVCookieDomain");deleteCookie(".CommunityServer",path,domain);deleteCookie('.CSRoles',path,domain);deleteCookie('SSOMail',path,domain);deleteCookie('at',path,domain);deleteCookie('hd',path,domain);}
checkLogin(loginSelectors,registerSelectors);window.location=window.location.href;}
function getCookie(name)
{var start=document.cookie.indexOf(name+"=");var len=start+name.length+1;if((!start)&&(name!=document.cookie.substring(0,name.length))){return null;}
if(start==-1){return null;}
var end=document.cookie.indexOf(";",len);if(end==-1){end=document.cookie.length;}
return unescape(document.cookie.substring(len,end));}
function checkCookie(name)
{var arg=name+"=";var alen=arg.length;var clen=document.cookie.length;var i=0;while(i<clen)
{var j=i+alen;if(document.cookie.substring(i,j)==arg){return true;}
i=document.cookie.indexOf(" ",i)+1;if(i==0){break;}}
return false;}
function deleteCookie(name,path,domain)
{if(getCookie(name)){document.cookie=name+"=DELETED"+
((path)?";path="+path:"")+
((domain)?";domain="+domain:"")+";expires=Thu, 01-Jan-1990 00:00:01 GMT";}}
function NeighbourNavModification()
{var objCookieVals,strRegionUrl="http://www.itv.com/local/",strRegionText="Local";var strCookieRegion=getCookie("ITV-NBR-MENU");var strQueryString='#intcmp=NAV_LOCAL';if(strCookieRegion&&document.getElementById("Local")!=null)
{objCookieVals=strCookieRegion.split("~",2);strRegionText=unescape(objCookieVals[0].replace(/%7E/,"~"));strRegionUrl=unescape(objCookieVals[1].replace(/%7E/,"~"));localLink=document.getElementById("Local").firstChild;localLink.href=strRegionUrl+strQueryString;localLink.innerHTML=strRegionText;}}
function populateContext()
{pathArr=window.location.pathname.split('/');$("#searchContext").val(pathArr[1].toUpperCase());}

jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options=$.extend({},options);options.expires=-1;}
var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}
expires='; expires='+date.toUTCString();}
var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}
return cookieValue;}};
;(function($){var ie6=$.browser.msie&&parseInt($.browser.version)==6&&typeof window['XMLHttpRequest']!="object",ieQuirks=null,w=[];$.modal=function(data,options){return $.modal.impl.init(data,options);};$.modal.close=function(){$.modal.impl.close();};$.fn.modal=function(options){return $.modal.impl.init(this,options);};$.modal.defaults={appendTo:'body',focus:true,opacity:50,overlayId:'simplemodal-overlay',overlayCss:{},containerId:'simplemodal-container',containerCss:{},dataId:'simplemodal-data',dataCss:{},minHeight:200,minWidth:300,maxHeight:null,maxWidth:null,autoResize:false,autoPosition:true,zIndex:1000,close:true,closeHTML:'<a class="modalCloseImg" title="Close"></a>',closeClass:'simplemodal-close',escClose:true,overlayClose:false,position:null,persist:false,onOpen:null,onShow:null,onClose:null};$.modal.impl={o:null,d:{},init:function(data,options){var s=this;if(s.d.data){return false;}ieQuirks=$.browser.msie&&!$.boxModel;s.o=$.extend({},$.modal.defaults,options);s.zIndex=s.o.zIndex;s.occb=false;if(typeof data=='object'){data=data instanceof jQuery?data:$(data);if(data.parent().parent().size()>0){s.d.parentNode=data.parent();if(!s.o.persist){s.d.orig=data.clone(true);}}}else if(typeof data=='string'||typeof data=='number'){data=$('<div></div>').html(data);}else{alert('SimpleModal Error: Unsupported data type: '+typeof data);return s;}s.create(data);data=null;s.open();if($.isFunction(s.o.onShow)){s.o.onShow.apply(s,[s.d]);}return s;},create:function(data){var s=this;w=s.getDimensions();if(ie6){s.d.iframe=$('<iframe src="javascript:false;"></iframe>').css($.extend(s.o.iframeCss,{display:'none',opacity:0,position:'fixed',height:w[0],width:w[1],zIndex:s.o.zIndex,top:0,left:0})).appendTo(s.o.appendTo);}s.d.overlay=$('<div></div>').attr('id',s.o.overlayId).addClass('simplemodal-overlay').css($.extend(s.o.overlayCss,{display:'none',opacity:s.o.opacity/100,height:w[0],width:w[1],position:'fixed',left:0,top:0,zIndex:s.o.zIndex+1})).appendTo(s.o.appendTo);s.d.container=$('<div></div>').attr('id',s.o.containerId).addClass('simplemodal-container').css($.extend(s.o.containerCss,{display:'none',position:'fixed',zIndex:s.o.zIndex+2})).append(s.o.close&&s.o.closeHTML?$(s.o.closeHTML).addClass(s.o.closeClass):'').appendTo(s.o.appendTo);s.d.wrap=$('<div></div>').attr('tabIndex',-1).addClass('simplemodal-wrap').css({height:'100%',outline:0,width:'100%'}).appendTo(s.d.container);s.d.data=data.attr('id',data.attr('id')||s.o.dataId).addClass('simplemodal-data').css($.extend(s.o.dataCss,{display:'none'})).appendTo('body');data=null;s.setContainerDimensions();s.d.data.appendTo(s.d.wrap);if(ie6||ieQuirks){s.fixIE();}},bindEvents:function(){var s=this;$('.'+s.o.closeClass).bind('click.simplemodal',function(e){e.preventDefault();s.close();});if(s.o.close&&s.o.overlayClose){s.d.overlay.bind('click.simplemodal',function(e){e.preventDefault();s.close();});}$(document).bind('keydown.simplemodal',function(e){if(s.o.focus&&e.keyCode==9){s.watchTab(e);}else if((s.o.close&&s.o.escClose)&&e.keyCode==27){e.preventDefault();s.close();}});$(window).bind('resize.simplemodal',function(){w=s.getDimensions();s.setContainerDimensions(true);if(ie6||ieQuirks){s.fixIE();}else{s.d.iframe&&s.d.iframe.css({height:w[0],width:w[1]});s.d.overlay.css({height:w[0],width:w[1]});}});},unbindEvents:function(){$('.'+this.o.closeClass).unbind('click.simplemodal');$(document).unbind('keydown.simplemodal');$(window).unbind('resize.simplemodal');this.d.overlay.unbind('click.simplemodal');},fixIE:function(){var s=this,p=s.o.position;$.each([s.d.iframe||null,s.d.overlay,s.d.container],function(i,el){if(el){var bch='document.body.clientHeight',bcw='document.body.clientWidth',bsh='document.body.scrollHeight',bsl='document.body.scrollLeft',bst='document.body.scrollTop',bsw='document.body.scrollWidth',ch='document.documentElement.clientHeight',cw='document.documentElement.clientWidth',sl='document.documentElement.scrollLeft',st='document.documentElement.scrollTop',s=el[0].style;s.position='absolute';if(i<2){s.removeExpression('height');s.removeExpression('width');s.setExpression('height',''+bsh+' > '+bch+' ? '+bsh+' : '+bch+' + "px"');s.setExpression('width',''+bsw+' > '+bcw+' ? '+bsw+' : '+bcw+' + "px"');}else{var te,le;if(p&&p.constructor==Array){var top=p[0]?typeof p[0]=='number'?p[0].toString():p[0].replace(/px/,''):el.css('top').replace(/px/,'');te=top.indexOf('%')==-1?top+' + (t = '+st+' ? '+st+' : '+bst+') + "px"':parseInt(top.replace(/%/,''))+' * (('+ch+' || '+bch+') / 100) + (t = '+st+' ? '+st+' : '+bst+') + "px"';if(p[1]){var left=typeof p[1]=='number'?p[1].toString():p[1].replace(/px/,'');le=left.indexOf('%')==-1?left+' + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"':parseInt(left.replace(/%/,''))+' * (('+cw+' || '+bcw+') / 100) + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"';}}else{te='('+ch+' || '+bch+') / 2 - (this.offsetHeight / 2) + (t = '+st+' ? '+st+' : '+bst+') + "px"';le='('+cw+' || '+bcw+') / 2 - (this.offsetWidth / 2) + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"';}s.removeExpression('top');s.removeExpression('left');s.setExpression('top',te);s.setExpression('left',le);}}});},focus:function(pos){var s=this,p=pos||'first';var input=$(':input:enabled:visible:'+p,s.d.wrap);input.length>0?input.focus():s.d.wrap.focus();},getDimensions:function(){var el=$(window);var h=$.browser.opera&&$.browser.version>'9.5'&&$.fn.jquery<='1.2.6'?document.documentElement['clientHeight']:$.browser.opera&&$.browser.version<'9.5'&&$.fn.jquery>'1.2.6'?window.innerHeight:el.height();return[h,el.width()];},getVal:function(v){return v=='auto'?0:v.indexOf('%')>0?v:parseInt(v.replace(/px/,''));},setContainerDimensions:function(resize){var s=this;if(!resize||(resize&&s.o.autoResize)){var ch=s.getVal(s.d.container.css('height')),cw=s.getVal(s.d.container.css('width')),dh=s.d.data.outerHeight(true),dw=s.d.data.outerWidth(true);var mh=s.o.maxHeight&&s.o.maxHeight<w[0]?s.o.maxHeight:w[0],mw=s.o.maxWidth&&s.o.maxWidth<w[1]?s.o.maxWidth:w[1];if(!ch){if(!dh){ch=s.o.minHeight;}else{if(dh>mh){ch=mh;}else if(dh<s.o.minHeight){ch=s.o.minHeight;}else{ch=dh;}}}else{ch=ch>mh?mh:ch;}if(!cw){if(!dw){cw=s.o.minWidth;}else{if(dw>mw){cw=mw;}else if(dw<s.o.minWidth){cw=s.o.minWidth;}else{cw=dw;}}}else{cw=cw>mw?mw:cw;}s.d.container.css({height:ch,width:cw});if(dh>ch||dw>cw){s.d.wrap.css({overflow:'auto'});}}if(s.o.autoPosition){s.setPosition();}},setPosition:function(){var s=this,top,left,hc=(w[0]/2)-(s.d.container.outerHeight(true)/2),vc=(w[1]/2)-(s.d.container.outerWidth(true)/2);if(s.o.position&&Object.prototype.toString.call(s.o.position)==="[object Array]"){top=s.o.position[0]||hc;left=s.o.position[1]||vc;}else{top=hc;left=vc;}s.d.container.css({left:left,top:top});},watchTab:function(e){var s=this;if($(e.target).parents('.simplemodal-container').length>0){s.inputs=$(':input:enabled:visible:first, :input:enabled:visible:last',s.d.data[0]);if((!e.shiftKey&&e.target==s.inputs[s.inputs.length-1])||(e.shiftKey&&e.target==s.inputs[0])||s.inputs.length==0){e.preventDefault();var pos=e.shiftKey?'last':'first';setTimeout(function(){s.focus(pos);},10);}}else{e.preventDefault();setTimeout(function(){s.focus();},10);}},open:function(){var s=this;s.d.iframe&&s.d.iframe.show();if($.isFunction(s.o.onOpen)){s.o.onOpen.apply(s,[s.d]);}else{s.d.overlay.show();s.d.container.show();s.d.data.show();}s.focus();s.bindEvents();},close:function(){var s=this;if(!s.d.data){return false;}s.unbindEvents();if($.isFunction(s.o.onClose)&&!s.occb){s.occb=true;s.o.onClose.apply(s,[s.d]);}else{if(s.d.parentNode){if(s.o.persist){s.d.data.hide().appendTo(s.d.parentNode);}else{s.d.data.hide().remove();s.d.orig.appendTo(s.d.parentNode);}}else{s.d.data.hide().remove();}s.d.container.hide().remove();s.d.overlay.hide().remove();s.d.iframe&&s.d.iframe.hide().remove();s.d={};}}};})(jQuery);

try{var hostString=window.location.host;var portNumberIndex=hostString.indexOf(':');if(portNumberIndex>-1){hostString=hostString.substring(0,portNumberIndex);}
var domainPieces=hostString.split('.');if(domainPieces.length>1){document.domain=domainPieces[domainPieces.length-2]+'.'+domainPieces[domainPieces.length-1];}}
catch(ex){}
ItvJs.Social={HasComments:false,HasAPI:false,DeferedActions:[],Defer:function(fAction)
{if(ItvJs.Social.HasAPI===false)
{ItvJs.Social.DeferedActions.push(fAction);}
else
{fAction();}},Initialise:function()
{if(window.location.host.toLowerCase()==='www.itv.com'){ItvJs.Social.Views.AuthenticationDialog.SsoServer="https://sso.itv.com";}
if(window.location.host.toLowerCase()==='rc3.itv.com'){ItvJs.Social.Views.AuthenticationDialog.SsoServer="https://sso.rc3.itv.com";}
if(window.location.host.toLowerCase()==='g22ms17.itvbb.ads:8083'){ItvJs.Social.Views.AuthenticationDialog.SsoServer="https://g22ms17.itvbb.ads";}
if(window.location.host.toLowerCase()==='g22msrc217.itvbbrc2.ads:8083'){ItvJs.Social.Views.AuthenticationDialog.SsoServer="https://g22msrc217.itvbbrc2.ads";}
this.Authentication.LoggedInUser=this.Authentication.GetLoggedInUser();checkLogin(loginSelectors,registerSelectors);},WriteScript:function()
{if(window.ItvJs.Social&&ItvJs.Social.HasComments===true||ItvJs.Social.HasLinks===true)
{document.write('<scri'+'pt type="text/javascript" src="http://'+ItvJs.PluckServer+'/ver1.0/Direct/DirectProxy"></scr'+'ipt>');document.write('<scri'+'pt type="text/javascript" src="http://'+ItvJs.PluckServer+'/ver1.0/Direct/SocialProxy?sid='+ItvJs.PluckServer+'"></scr'+'ipt>');document.write('<scri'+'pt type="text/javascript" src="http://'+ItvJs.PluckServer+'/ver1.0/Content/ua/scripts/pluckApps.js"></scr'+'ipt>');ItvJs.Social.HasAPI=true;}},PluckReplacementCallback:function(tagNode,tagName,paramData,retryCount)
{try
{$(tagNode).remove();this.callApp(tagName,paramData,function(data)
{if(paramData.itvtarget!==undefined)
{$("#"+paramData.itvtarget).html(data);}
else
{$(tagNode).html(data);}
ItvJs.Social.Commenting.OnDisplayed();},true);}
catch(e)
{if(!retryCount)
{retryCount=1;}
else
{retryCount++;}
if(retryCount>4)
{return;}
var plck=this;setTimeout(function()
{plck.fetchTagData(tagNode,tagName,paramData,retryCount);},100);}},Commenting:{Settings:{CommentingOnModuleId:null,IsDay:true,Container:null,CommentsPerPage:10,PluckWidget:"pluck_comments",SortedBy:"TimeStampDescending"},CommentingOnModuleId:null,RenderModule:function(contentType,commentOn,targetDivId,pageSize,isDay)
{this.Settings.CommentingOnModuleId=commentOn;this.Settings.Container=$("#"+targetDivId);this.Settings.IsDay=isDay;this.Settings.CommentsPerPage=pageSize;ItvJs.Social.HasComments=true;document.write('<pas:'+this.Settings.PluckWidget+' plckcommentonkeytype="'+contentType+'" plckcommentonkey="'+commentOn+'" itvtarget="'+targetDivId+'" plckitemsperpage="'+pageSize+'" isday="'+isDay+'" plcksort="'+this.Settings.SortedBy+'" />');},RefreshModule:function()
{var params={clientUrl:document.location.href,isday:this.Settings.IsDay,plckcommentonkey:this.Settings.CommentingOnModuleId,plckcommentonkeytype:"article",plckitemsperpage:this.Settings.CommentsPerPage,plcksort:this.Settings.SortedBy};pluckAppProxy.callApp(this.Settings.PluckWidget,params,function(data)
{ItvJs.Social.Commenting.Settings.Container.html(data);ItvJs.Social.Commenting.OnDisplayed();});},OnDisplayed:function()
{this.DisplayCommentCountsElsewhere();this.DisplayUserName();ItvJs.Social.Commenting.InitialiseBCM();},DisplayUserName:function()
{if(ItvJs.Social.Authentication.LoggedInUser!=null){$(".itv-Authentication-Details #profileLink").text(ItvJs.Social.Authentication.LoggedInUser.Name);}},DisplayCommentCountOnPostCommentsBox:function(commentCount)
{$(".pluck-comm-commentcount").text("Comments "+commentCount);},DisplayCommentCountOnCommentingOnModule:function(commentCount)
{var commentCountMessage;var aggregateBox=$("[ihavecommentsfrom='"+this.Settings.CommentingOnModuleId+"']");if(commentCount<1){commentCountMessage="Comment";}
else{commentCountMessage="Comments "+commentCount;}
$(".itv-CommentCount",aggregateBox).text(commentCountMessage);$(".itv-HideCommentCountIfNoCommentsModule",aggregateBox).show("normal",function(){$(this).css("display","inline");});},DisplayCommentCountsElsewhere:function()
{var commentCount=$("#TotalCommentCount").val();if(commentCount===undefined){commentCount=0;}
this.DisplayCommentCountOnPostCommentsBox(commentCount);this.DisplayCommentCountOnCommentingOnModule(commentCount);},InitialiseBCM:function(){var commentButtons=$("a.pluck-comm-submit");for(var iCommentCount=0;iCommentCount<commentButtons.length;iCommentCount++){ItvJs.Social.Commenting.RemoveExistingBCMClickEvent(commentButtons[iCommentCount]);}
var recommendButtons=$("ul.itv-SocialAggregates").find("a:contains('Like')");for(var iRecommendCount=0;iRecommendCount<recommendButtons.length;iRecommendCount++){ItvJs.Social.Commenting.RemoveExistingBCMClickEvent(recommendButtons[iRecommendCount]);}
var voteUpButtons=$("a.pluck-thumb-up-link");for(var iUpCount=0;iUpCount<voteUpButtons.length;iUpCount++){ItvJs.Social.Commenting.RemoveExistingBCMClickEvent(voteUpButtons[iUpCount]);}
var voteDownButtons=$("a.pluck-thumb-down-link");for(var iDownCount=0;iDownCount<voteDownButtons.length;iDownCount++){ItvJs.Social.Commenting.RemoveExistingBCMClickEvent(voteDownButtons[iDownCount]);}
commentButtons.unbind("click",this.CallBCMForCommentAction);recommendButtons.unbind("click",this.CallBCMForRecommendAction);voteUpButtons.unbind("click",this.CallBCMForCommentVoteUpAction);voteDownButtons.unbind("click",this.CallBCMForCommentVoteDownAction);commentButtons.bind("click",this.CallBCMForCommentAction);recommendButtons.bind("click",this.CallBCMForRecommendAction);voteUpButtons.bind("click",this.CallBCMForCommentVoteUpAction);voteDownButtons.bind("click",this.CallBCMForCommentVoteDownAction);},RemoveExistingBCMClickEvent:function(obj){if(obj.addEventListener){obj.removeEventListener('click',BCM,false);}
else if(obj.attachEvent){for(var p in obj){if(p.indexOf('BCM')>-1){obj[p]=null;}}}},CallBCMForAction:function(strAction,strValue){var fullUrl=BCMUrl+''+strAction+'&value='+strValue;$.getScript(fullUrl);},CallBCMForCommentAction:function(){if(BCMRunning){var strUrl=window.location.protocol+'//'+window.location.host+window.location.pathname;var commentingOnModule=ItvJs.Social.Commenting.Settings.CommentingOnModuleId;ItvJs.Social.Commenting.CallBCMForAction("Comment",strUrl+'|'+commentingOnModule);}},CallBCMForRecommendAction:function(){if(BCMRunning){var strUrl=window.location.protocol+'//'+window.location.host+window.location.pathname;var strValue=$(this).parents("ul.itv-SocialAggregates").attr("ihavecommentsfrom");ItvJs.Social.Commenting.CallBCMForAction("Recommend",strUrl+'|'+strValue);}},CallBCMForCommentVoteUpAction:function(){if(BCMRunning){var strUrl=window.location.protocol+'//'+window.location.host+window.location.pathname;var strCommentKey=$(this).attr("scoreontargetkey");var commentKeyIndex=strCommentKey.indexOf('CommentKey:');var strValue=strCommentKey.substring(commentKeyIndex+11);ItvJs.Social.Commenting.CallBCMForAction("CommentVote",strUrl+'|up|'+strValue);}},CallBCMForCommentVoteDownAction:function(){if(BCMRunning){var strUrl=window.location.protocol+'//'+window.location.host+window.location.pathname;var strCommentKey=$(this).attr("scoreontargetkey");var commentKeyIndex=strCommentKey.indexOf('CommentKey:');var strValue=strCommentKey.substring(commentKeyIndex+11);ItvJs.Social.Commenting.CallBCMForAction("CommentVote",strUrl+'|down|'+strValue);}}},Aggregation:function(socialService)
{this.socialService=socialService;this.AddTotalsToPage=function()
{articleIdsThatNeedTotals=this.CollectArticleIdsRequiringTotals();this.socialService.FetchTotals(articleIdsThatNeedTotals);};this.CollectArticleIdsRequiringTotals=function()
{var articleIdsThatNeedTotals=[];$("[ihavecommentsfrom]").each(function()
{articleIdsThatNeedTotals.push($(this).attr("ihavecommentsfrom"));});return articleIdsThatNeedTotals;};this.DisplayTotalsOnPage=function(totals)
{for(i=0;i<totals.length;i++)
{var aggregateBox=$("[ihavecommentsfrom='"+totals[i].ArticleId+"']");this.DisplayCommentCount(aggregateBox,totals[i].CommentCount);this.DisplayRecommendationCount(aggregateBox,totals[i].RecommendationCount);this.EnableRecommending(aggregateBox,totals[i].RecommendationCount,totals[i].ArticleId,totals[i].CurrentUserHasRecommended);aggregateBox.fadeIn("def");}};this.DisplayCommentCount=function(aggregateBox,commentCount)
{var commentCountMessage;if(commentCount<1){commentCountMessage="Comment";}
else{commentCountMessage="Comments "+commentCount;}
$(".itv-CommentCount",aggregateBox).text(commentCountMessage);};this.DisplayRecommendationCount=function(aggregateBox,RecommendationCount)
{$(".itv-RecommendationCount",aggregateBox).text(RecommendationCount);};this.EnableRecommending=function(aggregateBox,RecommendationCount,moduleToRecommendId,CurrentUserHasRecommended)
{if(CurrentUserHasRecommended=="False")
{$(".itv-RecommendationCount.itv-CanRecommend",aggregateBox).html("<a href='#'>Like</a> ("+RecommendationCount+")").click(function()
{ItvJs.Social.Aggregator.Recommend(moduleToRecommendId,RecommendationCount,this);return false;});}
else
{$(".itv-RecommendationCount",aggregateBox).html(RecommendationCount);}};this.Recommend=function(moduleToRecommendId,originalCount,buttonClickOn)
{this.socialService.Recommend(moduleToRecommendId);try
{originalCount=parseInt(originalCount,10);}
catch(ex){}
buttonClickOnAsJQuery=$(buttonClickOn);buttonClickOnAsJQuery.fadeOut("slow",function()
{buttonClickOnAsJQuery.html(originalCount+1);buttonClickOnAsJQuery.removeClass("itv-CanRecommend");buttonClickOnAsJQuery.unbind();buttonClickOnAsJQuery.fadeIn("slow");});};},Services:{Pluck:function(serverName)
{this.apiUri="http://"+serverName+"/ver1.0/Direct/Process";this.Recommend=function(moduleToRecommendId)
{try
{var requestBatch=new RequestBatch();var pluckArticleThatRepresentsTheModuleToBeRecommended=new ArticleKey(moduleToRecommendId);var recommendAction=new RecommendAction(pluckArticleThatRepresentsTheModuleToBeRecommended);requestBatch.AddToRequest(recommendAction);requestBatch.BeginRequest(this.apiUri,this.recommendCallback);}
catch(ex){}};this.FetchTotals=function(articleIds)
{for(batch=0;batch<articleIds.length;batch=(batch+20))
{this.FetchBatchedTotals(articleIds.slice(batch,((batch+1)*20)));}};this.FetchBatchedTotals=function(batchedArticleIdsOf20)
{try
{var requestBatch=new RequestBatch();for(i=0;i<batchedArticleIdsOf20.length;i++)
{var article=new ArticleKey(batchedArticleIdsOf20[i]);if(article.ArticleKey.Key!=="")
{requestBatch.AddToRequest(article);}}
requestBatch.BeginRequest(this.apiUri,this.fetchTotalsCallback);}
catch(ex){}};this.fetchTotalsCallback=function(response)
{var articleCounts=Array();for(i=0;i<response.Responses.length;i++)
{articleCounts.push({ArticleId:response.Responses[i].Article.ArticleKey.Key,CommentCount:response.Responses[i].Article.Comments.NumberOfComments,RecommendationCount:response.Responses[i].Article.Recommendations.NumberOfRecommendations,CurrentUserHasRecommended:response.Responses[i].Article.Recommendations.CurrentUserHasRecommended});}
ItvJs.Social.Aggregator.DisplayTotalsOnPage(articleCounts);};this.recommendCallback=function(response)
{};}},Authentication:{LoggedInUser:null,FlushCookies:function()
{var path="/";var domain=getCookie("ITVCookieDomain");deleteCookie('at',path,domain);deleteCookie('hd',path,domain);if(typeof window.logout=='function'){logout();}},ClearTextCookieUser:function(hdCookie)
{this.Name=hdCookie.split("|")[1];},VerifiedCookieUser:function(atCookie)
{var regEx=new RegExp("&a=(.*?)&");var matches=regEx.exec(atCookie);this.Name=matches[1];},GetLoggedInUser:function()
{if($.cookie('hd')===null)
{if($.cookie('at')===null){return null;}
else{return new this.VerifiedCookieUser($.cookie('at'));}}
else
{return new this.ClearTextCookieUser($.cookie('hd'));}}},Views:{ModalDialog:{Open:function(elementId,height)
{try
{eval('document.Mercury_VideoPlayer'+ItvJs.Video.Mercury.defaultVideoPlayerId+'.pauseVideo()');}
catch(ex){}
$("#"+elementId).modal({onOpen:function(dialog)
{dialog.overlay.fadeIn('slow',function()
{$('#'+elementId+' #contentBox').hide();dialog.container.fadeIn('slow',function()
{dialog.data.animate({height:height},function()
{$('#contentBox').fadeIn('slow');});});});},onClose:function(dialog)
{$('#'+elementId+' #contentBox').fadeOut('slow',function()
{dialog.data.animate({height:60},function()
{dialog.container.fadeOut('slow',function()
{dialog.overlay.fadeOut('slow',function()
{$.modal.close();});});});});}});}},AuthenticationDialog:{SsoServer:'',OpenLogin:function()
{this.Open({Height:220,Uri:this.SsoServer+'/_app/dynamic/commentingmodals/Login.aspx'});return false;},OpenRegister:function()
{this.Open({Height:700,Uri:this.SsoServer+'/_app/dynamic/commentingmodals/Registration.aspx'});return false;},OpenPasswordReminder:function()
{this.Open({Height:220,Uri:this.SsoServer+'/_app/dynamic/commentingmodals/resetpassword.aspx'});return false;},OpenTools:function()
{this.Open({Height:280,Uri:this.SsoServer+'/_app/dynamic/commentingmodals/Tools.html'});return false;},Open:function(windowToOpen)
{if(this.IsOpen)
{this.SwitchWindow(windowToOpen);}
else
{this.ConfigureFrame(windowToOpen);ItvJs.Social.Views.ModalDialog.Open('authenticationDialog',windowToOpen.Height+30);this.IsOpen=true;}},CloseAndRefresh:function()
{this.Close();ItvJs.Social.Authentication.LoggedInUser=ItvJs.Social.Authentication.GetLoggedInUser();ItvJs.Social.Commenting.RefreshModule();checkLogin(loginSelectors,registerSelectors);},Close:function()
{$.modal.close();this.IsOpen=false;},SwitchWindow:function(windowToOpen)
{$('#authenticationDialog #contentBox').fadeOut('slow',function()
{$('#authenticationDialog').animate({height:60},function()
{ItvJs.Social.Views.AuthenticationDialog.ConfigureFrame(windowToOpen);$('#authenticationDialog').animate({height:windowToOpen.Height+30},function()
{$('#contentBox').fadeIn('slow');});});});},ConfigureFrame:function(openingWindow)
{$("#authenticationDialog #authenticationFrame").attr('height',openingWindow.Height);$("#authenticationDialog #authenticationFrame").attr('src',openingWindow.Uri);},IsOpen:false}}};try
{ItvJs.Social.Initialise();}
catch(e){}
$(document).ready(function()
{if(window.ItvJs.Social&&window.pluckAppProxy&&(ItvJs.Social.HasComments===true||ItvJs.Social.HasLinks===true))
{pluckAppProxy.fetchTagData=ItvJs.Social.PluckReplacementCallback;for(i=0;i<ItvJs.Social.DeferedActions.length;i++)
{ItvJs.Social.DeferedActions[i]();}
ItvJs.Social.PluckServer=ItvJs.PluckServer;if(typeof(RequestBatch)!=='undefined')
{var service=new ItvJs.Social.Services.Pluck(ItvJs.Social.PluckServer);ItvJs.Social.Aggregator=new ItvJs.Social.Aggregation(service);ItvJs.Social.Aggregator.AddTotalsToPage();}}});

if(typeof ItvJs==='undefined'){ItvJs={};}
ItvJs.Glob={MakeAdCall:function(iWidth,iHeight,iPos){var dimensions=iWidth+'x'+iHeight;switch(dimensions){case'1600x1200':dimensions='pagetakeover';break;case'1x1':dimensions='outofpage';break;case'1000x40':dimensions='pushdownad';break;case'300x50':dimensions='mobilebanner';break;case'150x113':dimensions='sponsorbutton';break;case'163x64':dimensions='footballsponsorbutton';break;default:break;}
if(Bloom.Adverts.AdvertServer.Current.AdHash[dimensions]===undefined){Bloom.Adverts.AdvertServer.Current.AdHash[dimensions]=1;}else{Bloom.Adverts.AdvertServer.Current.AdHash[dimensions]++;}
if(iPos){Bloom.Adverts.AdvertServer.Current.AdHash[dimensions]=iPos;}
var pageNum=Bloom.Adverts.AdvertServer.Current.ViewId;if(!pageNum){pageNum=Math.round(Math.random()*100000000);}
if(Bloom.Adverts.AdvertServer.Current.Off===false){var adRestriction='';if(Bloom.Adverts.AdvertServer.Current.Restriction.toLowerCase()==='preview'){adRestriction='';}
if(Bloom.Adverts.AdvertServer.Current.Restriction.toLowerCase()==='kids'){adRestriction='k';}
var sTarget='/position='+Bloom.Adverts.AdvertServer.Current.AdHash[dimensions];var rsString='';if(!Bloom.Adverts.AdvertServer.Current.RSI){var rsiSegments=[];var segmentBegin=document.cookie.indexOf('rsi_segs=');if(segmentBegin>=0){segmentBegin=document.cookie.indexOf('=',segmentBegin)+1;if(segmentBegin>0){var segmentEnd=document.cookie.indexOf(';',segmentBegin);if(segmentEnd==-1){segmentEnd=document.cookie.length;}
rsiSegments=document.cookie.substring(segmentBegin,segmentEnd).split('|');}}
for(var i=0;i<rsiSegments.length;i++){rsString+=(rsiSegments[i]+'.');}
rsString=rsString.replace(/_/g,"");}
else{rsString=Bloom.Adverts.AdvertServer.Current.RSI;}
var adlbros=0;var admpuros=0;var adlbls=0;var admpuls=0;var adlben=0;var admpuen=0;var adlbso=0;var admpuso=0;if(typeof wl10184camp!=='undefined'&&wl10184camp!==""){adlbros=wl10184camp;}
if(typeof wl10185camp!=='undefined'&&wl10185camp!==""){admpuros=wl10185camp;}
if(typeof wl10178camp!=='undefined'&&wl10178camp!==""){adlbls=wl10178camp;}
if(typeof wl10179camp!=='undefined'&&wl10179camp!==""){admpuls=wl10179camp;}
if(typeof wl10180camp!=='undefined'&&wl10180camp!==""){adlben=wl10180camp;}
if(typeof wl10181camp!=='undefined'&&wl10181camp!==""){admpuen=wl10181camp;}
if(typeof wl10182camp!=='undefined'&&wl10182camp!==""){adlbso=wl10182camp;}
if(typeof wl10183camp!=='undefined'&&wl10183camp!==""){admpuso=wl10183camp;}
window.document.write('<script type="text/javascript" src="'+Bloom.Adverts.AdvertServer.Current.Server+'/'+Bloom.Adverts.AdvertServer.Current.Client.toLowerCase()+'/jserver'+'/site='+Bloom.Adverts.AdvertServer.Current.Site.toLowerCase()+adRestriction+'/area='+Bloom.Adverts.AdvertServer.Current.Area.toLowerCase()+'/viewid='+pageNum+'/size='+dimensions+'/random='+(Math.round(Math.random()*10000000000))+sTarget+'/rs='+rsString.toLowerCase()+'/adlbros='+adlbros+'/admpuros='+admpuros+'/adlbls='+adlbls+'/admpuls='+admpuls+'/adlben='+adlben+'/admpuen='+admpuen+'/adlbso='+adlbso+'/admpuso='+admpuso+'/seg='+Bloom.Adverts.AdvertServer.Current.Area.toLowerCase()+'"><\/sc'+'ript>');}
else{if(dimensions!='pagetakeover'&&dimensions!='pushdownad'&&dimensions!='outofpage'){document.write('<div class="cms-AdvertOff" style="width:'+iWidth+'px;height:'+iHeight+'px">'+'<strong>Site</strong>='+Bloom.Adverts.AdvertServer.Current.Site+' <strong>Area</strong>='+Bloom.Adverts.AdvertServer.Current.Area+' <strong>Segment</strong>='+Bloom.Adverts.AdvertServer.Current.Area+' <strong>Position</strong>='+Bloom.Adverts.AdvertServer.Current.AdHash[dimensions]+' <strong>Size</strong>='+dimensions+'</div>');}}},AdRefresh:function(){Bloom.Adverts.AdvertServer.Current.RefreshAdverts();},TakeoverToFront:function(){$('#itv-adBackground').css('z-index','1000');},TakeoverToBack:function(){$('#itv-adBackground').css('z-index','0');},loadPlayer:function(vodcrid){return loadPlayer(ItvJs.Video.Mercury.defaultVideoPlayerContainerId,vodcrid.toString(),true,false,null,ItvJs.Video.Mercury.defaultVideoPlayerId,false,true,true);},IsReady:function(){return true;},TogglePushdown:function(pos){var ele=$("#itv-pushdown");pos=(typeof pos!=="undefined"?pos:(ele.height()==40));var sz=(pos?360:40);if(sz!=ele.height()){ele.animate({height:sz+"px"},1000);}}};var TogglePushdown=ItvJs.Glob.TogglePushdown;

$('html').addClass('jsEnabled');

(function($){$.fn.globDropNav=function(options){var config={hideDelay:10000,preventOverflow:true,autoTopDropdown:true};if(options){options.hideDelay=(parseInt(options.hideDelay,10)?parseInt(options.hideDelay,10):config.hideDelay);$.extend(config,options);}
this.each(function(){var self=this;var moduleBody=$(self).addClass('itv-jsEnabled');var topLevelItems=moduleBody.find('.glob-navList').children('li.parent');var currentMenu=-1;var moduleWidth=moduleBody.outerWidth();var timeout=null;topLevelItems.each(function(n){$(this).children('li.parent a').attr('href','#');$(this).click(function(e){e.stopPropagation();});$(this).children('li.parent a').click(function(e){e.preventDefault();if(currentMenu==n){hideMenu(n,0);}else{showMenu(n);}});$(this).find('a:last').blur(function(){hideMenu(n,0);});});$(document).keydown(function(e){if(e.which=='27'){hideMenu(currentMenu,0);}});function showMenu(n){if(n!=currentMenu){hideMenu(currentMenu,0);topLevelItems.eq(n).mouseenter(function(){clearTimeout(timeout);});topLevelItems.eq(n).mouseleave(function(){hideMenu(n,config.hideDelay);});$(document).click(function(){hideMenu(currentMenu,0);});currentMenu=n;dropMenu=topLevelItems.eq(n).children('ul');topLevelItems.eq(n).children('a').addClass('itv-hover');dropMenu.show();if(config.preventOverflow&&dropMenu.closest('li').css('position')=='relative'){menuWidth=dropMenu.outerWidth();dropMenu.css('left','0px');menuWidth=dropMenu.outerWidth();leftOffset=dropMenu.closest('li').position().left;if(menuWidth+leftOffset>moduleWidth){newOffset=(-1)*(menuWidth+leftOffset-moduleWidth);dropMenu.css('left',newOffset+'px');}}
if(config.autoTopDropdown){dropMenu.css('top',topLevelItems.eq(n).children('a:first').innerHeight()+'px');}}}
function hideMenu(n,delay){if(n>=0){clearTimeout(timeout);if(delay>0){timeout=setTimeout(function(){closeMenuAction(n);},delay);}else{closeMenuAction(n);}}}
function closeMenuAction(n){topLevelItems.eq(n).unbind('mouseenter');topLevelItems.eq(n).unbind('mouseleave');$(document).unbind('click');dropMenu=topLevelItems.eq(n).children('ul');topLevelItems.eq(n).children('a').removeClass('itv-hover');dropMenu.hide();currentMenu=-1;}});};})(jQuery);
