var C4=C4||{};
C4.Util=(function utilities($){function Tabs(module,options){if(module.hasClass("tabs-initialised")){return 
}module.addClass("tabs-initialised");
this.options=$.extend({},this.defaults,options);
this.tabs=[];
this.selected=-1;
var tabs=module.find(".tabs a"),contents=module.find(".tab-content"),selected=module.find(".tabs a"+this.options.selected)[0],self=this;
tabs.each(function(i){var tab=$(this),content=contents.eq(i);
if(this==selected){self.selected=i
}else{content.addClass(self.options.hiddenClass)
}tab.click(function(e){e.preventDefault();
self.tabSelect(i);
return false
});
self.tabs[i]={link:tab,content:content}
});
if(this.options.duration){contents.css("height",0)
}if(this.selected>-1){this.openContent(this.selected)
}if(this.options.closeClass){module.find("."+this.options.closeClass).live("click",function(){var content=$(this).parents(".tab-content");
self.closeContent(contents.index(content),false);
return false
})
}}Tabs.prototype={defaults:{selected:":first",callback:$.noop(),closeClass:"close",hiddenClass:"hidden",closeSelf:false,duration:0,openCallback:$.noop(),closeCallback:$.noop()},tabSelect:function(i){if(i==this.selected){if(this.options.closeSelf){this.closeContent(i,false)
}}else{if(this.selected>-1){var container=this.tabs[0].content.parent(),containerHeight=container.height();
container.height(containerHeight);
this.closeContent(this.selected,true);
this.openContent(i,true);
container.height("auto")
}else{this.openContent(i,false)
}}},openContent:function(i,instant){var content=this.tabs[i].content,tab=this.tabs[i].link,contentHeight=content[0].scrollHeight;
this.selected=i;
content.removeClass(this.options.hiddenClass);
if(this.options.duration>0){if(instant){content.height("auto")
}else{content.stop(true).animate({height:contentHeight},this.options.duration,function(){content.height("auto")
})
}}tab.addClass("selected").parent().addClass("selected");
if(this.options.openCallback&&typeof this.options.openCallback=="function"){this.options.openCallback()
}},closeContent:function(i,instant){if($("#my4odClearAll").html()!==null){C4.My4oD.View.removeClearAllMessage()
}var content=this.tabs[i].content,tab=this.tabs[i].link,self=this;
this.selected=-1;
if(this.options.duration>0){if(instant){content.height(0).addClass(self.options.hiddenClass)
}else{content.stop(true).animate({height:0},this.options.duration,function(){content.addClass(self.options.hiddenClass)
})
}}else{content.addClass(self.options.hiddenClass)
}tab.removeClass("selected").parent().removeClass("selected");
if(this.options.closeCallback&&typeof this.options.closeCallback=="function"){this.options.closeCallback()
}}};
function InfoMessage(options){this.options=$.extend({},this.defaults,options);
if(C4.MessageManager.messageShowing()){C4.MessageManager.queueMessage(this)
}else{this.showMessage()
}}InfoMessage.prototype={defaults:{duration:4000,message:"",messageClass:"",operationTitle:"",operationTitleClass:"",highlightSel:"",highlightCallback:$.noop,skipMsgQueue:false,options:{alwaysQueue:false}},showMessage:function(){this.bind();
var self=this;
var html=self.generateMarkup();
if(html){$(".content-wrapper").prepend('<div id="messagingWindow" />');
$("#messagingWindow").html(html).fadeIn(500,function(){self.createTimer();
self.showHighlight()
})
}},generateMarkup:function(){var html="";
html+='<div id="customMessage"';
if(this.options.messageClass){html+=' class="'+this.options.messageClass+'"'
}html+=">";
html+='<span id="messageText">'+this.options.message+"</span>";
if(this.options.operationTitle){html+='<span id="operationText"';
if(this.options.operationTitleClass){html+=' class="'+this.options.operationTitleClass+'"'
}html+=">";
html+=this.options.operationTitle;
html+="</span>"
}html+="</div>";
return html
},clearMessage:function(){this.removeTimer();
$("#messagingWindow").remove();
this.removeHighlight();
this.highlightCallback()
},hideMessage:function(){var self=this;
this.removeTimer();
$("#messagingWindow").fadeOut(200,function(){$("#messagingWindow").remove();
self.removeHighlight();
self.highlightCallback();
if(C4.MessageManager.queue.length>0){var newMessage;
newMessage=C4.MessageManager.queue.shift();
newMessage.showMessage()
}})
},createTimer:function(){var self=this;
var timeoutId=window.setTimeout(function(){self.clearTimeoutId();
self.hideMessage()
},self.options.duration);
self.setTimeoutId(timeoutId)
},removeTimer:function(){var timeoutId=this.getTimeoutId();
if(timeoutId){window.clearTimeout(timeoutId);
return true
}else{return false
}},setTimeoutId:function(timeoutId){$("#messagingWindow").data("timeoutId",timeoutId)
},getTimeoutId:function(){var timeoutId=$("#messagingWindow").data("timeoutId");
if(timeoutId){return timeoutId
}else{return false
}},clearTimeoutId:function(){$("#messagingWindow").removeData("timeoutId")
},showHighlight:function(){C4.HighlightShown=false;
if(this.options.highlightSel&&this.options.highlightSel.length>0){$(this.options.highlightSel).addClass("highlight-link").fadeIn(500)
}},removeHighlight:function(){if(this.options.highlightSel&&this.options.highlightSel.length>0){$(this.options.highlightSel).removeClass("highlight-link")
}else{$(".four-on-demand-nav li .heart").removeClass("highlight-link")
}},highlightCallback:function(){if(!C4.HighlightShown&&this.options.highlightSel&&this.options.highlightSel.length>0){this.options.highlightCallback();
C4.HighlightShown=true
}},isViewObscured:function(){var flash4odPresent=false,flashPosTop,flashHeight;
$("#catchUp #flashContainer").each(function(){flash4odPresent=true;
flashPosTop=$(this).offset().top;
flashHeight=$(this).height()
});
if(flash4odPresent){var windowPos=$(window).scrollTop();
var flashPosBottom=flashPosTop+flashHeight;
if(windowPos>=flashPosTop&&windowPos<=flashPosBottom){flashPosTop=flashPosTop-40;
return flashPosTop
}else{return false
}}else{return false
}},scrollViewAndDisplay:function(top,message,time){$("html").animate({scrollTop:top+"px"},1000,"linear",function(){this.showMessage(message)
})
},bind:function(){var self=this;
$("body").click(function(event){self.hideMessage();
$(this).unbind()
});
$("body").keyup(function(event){if(event.keyCode=="27"){self.hideMessage()
}})
}};
return{Tabbing:Tabs,InfoMessage:InfoMessage,updateSelectedLink:function updateSelectedLink($module,$link){$module.find("li, a").removeClass("selected");
$link.addClass("selected").parent().addClass("selected")
},embedSharedObjectSWF:function embedSharedObjectSWF(options){if($("object#soAPI").length===0){swfobject.embedSWF("/static/programmes/asset/flash/swf/soAPI.swf","soAPIPlaceholder","10","10","9.0.115",null,{onReadyFunc:options.funcStr},{bgcolor:"#000000",allowScriptAccess:"always",wmode:"transparent"},{id:"soAPI"},function callbackFn(e){if(!e.success){C4.My4oD.Controller.getHelper().noFlashFailover()
}})
}else{options.funcRef()
}},getReadableTimeDiff:function getReadableTimeDiff(currentDate,ms){var today=currentDate.getTime(),diff=today-ms;
var days=C4.Util.getDays(diff),hours=C4.Util.getHours(diff),minutes=C4.Util.getMinutes(diff),seconds=C4.Util.getSeconds(diff),weeks=C4.Util.getWeeks(diff);
if(weeks>4){var monthsVal=C4.Util.getMonthsDiff(currentDate,new Date(ms));
if(monthsVal>12){return"1 year"
}else{return monthsVal+" month"+(monthsVal>1?"s":"")
}}else{if(weeks>2){return weeks+" weeks"
}else{if(days>0){return days+" day"+(days>1?"s":"")
}else{if(hours>0){return hours+" hour"+(hours>1?"s":"")
}else{if(minutes>0){return minutes+" minute"+(minutes>1?"s":"")
}else{return null
}}}}}},getSeconds:function getSeconds(ms){return(ms===null||ms<0)?null:Math.floor(ms/1000)
},getMinutes:function getMinutes(ms){return(ms===null||ms<0)?null:Math.floor(ms/(1000*60))
},getHours:function getHours(ms){return(ms===null||ms<0)?null:Math.floor(ms/(1000*60*60))
},getDays:function getDays(ms){return(ms===null||ms<0)?null:Math.floor(ms/(1000*60*60*24))
},getWeeks:function getWeeks(ms){return(ms===null||ms<0)?null:Math.floor(ms/(1000*60*60*24*7))
},getMonthsDiff:function getMonthsDiff(currentDate,historyDate){if(currentDate===null||historyDate===null){return null
}else{var monthDiff=currentDate.getMonth()-historyDate.getMonth(),yearDiff=currentDate.getFullYear()-historyDate.getFullYear(),extraMonths=yearDiff*12;
monthDiff+=extraMonths;
return currentDate.getDate()<historyDate.getDate()?monthDiff-1:monthDiff
}},getTextWidth:function getTextWidth(s){var $span=$("<span>"+s+"</span>").appendTo("body").hide();
var width=$span.width();
$span.remove();
return width
},urlToAjaxUrl:function urlToAjaxUrl(url){C4.OO.insistTypeof([String],url);
return url+".json"
},hashFromUrl:function hashFromUrl(url,excludeHash){C4.OO.insistTypeof([String],url);
C4.OO.insistTypeof([Boolean,undefined],excludeHash);
if(excludeHash){return url.replace(/^#/,"")
}else{return url.substring(url.indexOf("#"),url.length)
}},colorToHex:function colorToHex(color){var _hex=String(color);
switch(_hex){case"maroon":_hex="#800000";
break;
case"red":_hex="#ff0000";
break;
case"orange":_hex="#ffA500";
break;
case"yellow":_hex="#ffff00";
break;
case"olive":_hex="#808000";
break;
case"purple":_hex="#800080";
break;
case"fuchsia":_hex="#ff00ff";
break;
case"white":_hex="#ffffff";
break;
case"lime":_hex="#00ff00";
break;
case"green":_hex="#008000";
break;
case"navy":_hex="#000080";
break;
case"blue":_hex="#0000ff";
break;
case"aqua":_hex="#00ffff";
break;
case"teal":_hex="#008080";
break;
case"black":_hex="#000000";
break;
case"silver":_hex="#c0c0c0";
break;
case"gray":_hex="#808080";
break;
default:if(_hex.substring(0,3)==="rgb"){var _arrRGB=_hex.substring(_hex.indexOf("(")+1,_hex.indexOf(")")).split(",");
_hex="#"+C4.Util.toHex(_arrRGB[0])+C4.Util.toHex(_arrRGB[1])+C4.Util.toHex(_arrRGB[2])
}}return _hex.toUpperCase()
},toHex:function toHex(_n){if(_n==null){return"00"
}_n=parseInt(_n);
if(_n==0||isNaN(_n)){return"00"
}_n=Math.max(0,_n);
_n=Math.min(_n,255);
_n=Math.round(_n);
return"0123456789ABCDEF".charAt((_n-_n%16)/16)+"0123456789ABCDEF".charAt(_n%16)
},isMac:function isMac(){var isMac=(navigator.platform==="MacIntel"||navigator.platform==="MacPPC");
this.isMac=function(){return isMac
};
return isMac
},isIE7:function isIE7(){var isIE7=($.browser.msie===true&&parseInt($.browser.version,10)===7);
this.isIE7=function(){return isIE7
};
return isIE7
},isIE8:function isIE8(){var isIE8=($.browser.msie===true&&parseInt($.browser.version,10)===8);
this.isIE8=function(){return isIE8
};
return isIE8
},isNumeric:function isNumeric(str){var strValidChars="0123456789.";
var strChar;
var blnResult=true;
if(str.length==0){return false
}for(var i=0;
i<str.length&&blnResult==true;
i++){strChar=str.charAt(i);
if(strValidChars.indexOf(strChar)==-1){blnResult=false
}}return blnResult
},getHashValue:function getHashValue(url){var hashIndex=url.indexOf("#");
return url.substring(hashIndex+1)
},insertParam:function insertParam(href,param){var hashIndex=href.indexOf("#"),qStrIndex=href.indexOf("?"),hashStr="",qStr="",params="";
if(qStrIndex>-1&&hashIndex>-1){path=href.substring(0,qStrIndex);
qStr=href.substring(qStrIndex,hashIndex);
hashStr="#"+C4.Util.getHashValue(href);
params=qStr.substring(1)+"&"+param
}else{if(qStrIndex>-1&&hashIndex<0){path=href.substring(0,qStrIndex);
qStr=href.substring(qStrIndex);
params=qStr.substring(1)+"&"+param
}else{if(qStrIndex<0&&hashIndex>-1){path=href.slice(0,hashIndex);
hashStr="#"+C4.Util.getHashValue(href);
params=param
}else{path=href;
params=param
}}}return path+"?"+params+hashStr
},ignoreCaseSort:function(a,b){var ret=0;
a=a.toLowerCase();
b=b.toLowerCase();
if(a>b){ret=1
}if(a<b){ret=-1
}return ret
},hasAssetID:function hasAssetID(hash){var paramIndex=hash.indexOf("?");
if(paramIndex!=-1){hash=hash.substring(0,paramIndex)
}return C4.Util.isNumeric(hash)
},setAdvertStyle:function setAdvertStyle($advertDiv){$(function(){var $advertImg=$advertDiv.find("img");
var divWidth=300;
var imgWidth=parseInt($advertImg.attr("width"),10);
if((divWidth>imgWidth)&&imgWidth>5){$advertDiv.addClass("narrowAdvert");
$advertImg.addClass("advertImage")
}else{if(imgWidth<5){$advertImg.remove()
}}})
},equaliseHeights:function equaliseHeights($itemSet,itemToEqualise){var maxHeight=0;
var matchingItems=[];
$itemSet.each(function(){$(this).find(itemToEqualise).each(function(){matchingItems.push($(this));
if($(this).height()>=maxHeight){maxHeight=$(this).height()
}})
});
$(matchingItems).each(function(){var currentBottomMargin=parseInt($(this).css("margin-bottom"),0);
var currentItemHeight=$(this).height();
if(currentItemHeight<maxHeight){var newHeight=currentBottomMargin+(maxHeight-currentItemHeight);
$(this).css("margin-bottom",newHeight)
}})
},equaliseAcrossRow:function equaliseAcrossRow($itemSet,itemsPerLine,itemToEqualise){var ind=0,itemsToEqualise=[];
var numberOfRows=($itemSet.length/itemsPerLine);
for(var i=0;
i<numberOfRows;
i++){for(var j=0;
j<itemsPerLine;
j++){var item=$itemSet[ind];
itemsToEqualise.push(item);
ind++
}C4.Util.equaliseHeights($(itemsToEqualise),itemToEqualise);
itemsToEqualise=[]
}},fourOdHeaderRollover:function fourOdHeaderRollover(){$(".four-od-header").hover(function(){$(this).next(".button").addClass("over")
},function(){$(this).next(".button").removeClass("over")
});
$(".button").hover(function(){$(this).prev(".four-od-header").addClass("over")
},function(){$(this).prev(".four-od-header").removeClass("over")
})
},Fixes:{addIELastItemClasses:function(){if($.browser.msie){if($.browser.version>7&&$.browser.version<9){$(".main-content .promo:nth-child(5n)").addClass("promo-clear");
$(".main-content .promo-large:nth-child(4n)").addClass("promo-clear");
$(".main-content #browseEverything .logo-wrap:nth-child(4n)").addClass("promo-clear");
$(".secondary-content .promo:odd").addClass("last-horizontal-item");
$(".secondary-content .promo:even").addClass("promo-clear");
$(".secondary-content .editorial-promo .promo:last-child").addClass("last-vertical-item");
$(".main-content .module:last-child").addClass("last-vertical-item");
$(".module-container .module:last-child").addClass("last");
$(".logo-bar .channel:last-child").addClass("last-logo")
}if($.browser.version<8){$(".main-content .promo:nth-child(4n)").addClass("last-horizontal-item");
$(".main-content .highlights-module .promo:nth-child(4n)").remove("last-horizontal-item");
$(".main-content .highlights-module .promo:nth-child(3n)").addClass("last-horizontal-item");
$(".main-content .promo .indicators li:first-child").addClass("first-indicator");
$(".logo-bar .channel:last-child").addClass("last-logo")
}}}},getStorageValue:function getStorageValue(key){if(window.localStorage){return window.localStorage.getItem(key)
}else{return null
}},setStorageValue:function setStorageValue(key,jsonStr){if(window.localStorage){window.localStorage.setItem(key,jsonStr)
}},removeStorageValue:function removeStorageValue(key){if(window.localStorage){window.localStorage.removeItem(key)
}},getCookieValue:function getCookieValue(name){function getVal(offset){var endstr=document.cookie.indexOf(";",offset);
if(endstr==-1){endstr=document.cookie.length
}return unescape(document.cookie.substring(offset,endstr))
}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 getVal(j)
}i=document.cookie.indexOf(" ",i)+1;
if(i==0){break
}}return null
},setCookieValue:function setCookieValue(cookieName,obj){var jsonStr=null;
try{jsonStr=$.toJSON(obj)
}catch(e){}$.cookie(cookieName,jsonStr)
},applyClearing:function applyClearing(moduleSel,shortRowCount,fullRowCount,fullRowRemainder){var nthItem,remainder=0;
$(moduleSel).each(function(i){if(i===0){$(this).find(".promo").not(".hidden").each(function(j){if(j<(shortRowCount*2)+1){nthItem=shortRowCount
}else{nthItem=fullRowCount;
remainder=fullRowRemainder
}if(j>0&&j%nthItem===remainder){$(this).addClass("promo-clear")
}})
}})
},removeClearing:function removeClearing(containerSel){$(containerSel).removeClass("promo-clear")
},getPromoHoverObj:function getPromoHoverObj($promoContainer){if(C4&&C4.promoHovers){var promoHovers=C4.promoHovers;
for(var i=0;
i<promoHovers.length;
i++){if($promoContainer[0]===promoHovers[i].domElement){return promoHovers[i]
}}}return null
},appendQueryParam:function appendQueryParam(opts){var url=opts.url,queryParam=opts.queryParam;
if(!url){url=null
}else{var urlAsArray=url.split("?");
if(urlAsArray.length>1){if(urlAsArray[1]===""){url=url+queryParam
}else{var params=urlAsArray[1].split("&");
params.push(queryParam);
params=params.join("&");
url=urlAsArray[0]+"?"+params
}}else{if(queryParam){url=url+"?"+queryParam
}}}return url
},parseQuery:function(queryString){var parameters={};
$.each(queryString.split("&"),function(i,parameter){var pair=parameter.split("=");
var name=unescape(pair[0]),value=unescape(pair[1]);
parameters[name]=value
});
return parameters
},openPanel:function openPanel(panelName){var $button=$("#my4od").find("a[href='#"+panelName+"']"),$panel=$("#"+panelName);
if($panel.hasClass("tab-content-invisible")){$button.click()
}},getUserMessageOpenHtml:function getUserMessageOpenHtml(){var userMessageOpenHtml='<div class="availability-message">'+((this.isIE7()||this.isIE8())?'<div class="transparent"></div>':"")+'<div class="unavailable-message">';
this.getUserMessageOpenHtml=function(){return userMessageOpenHtml
};
return userMessageOpenHtml
},getUserMessageCloseHtml:function getUserMessageCloseHtml(){return"</div></div>"
},getNoFlashHtml:function getNoFlashHtml(){return'<p class="cb">For an enhanced view of this page <a href="http://get.adobe.com/flashplayer/" title="Link to Adobe Flash player site - opens in a new window" target="_blank">click here to install or upgrade Flash</a></p>'
}}
})(jQuery);
C4.MessageManager=(function messageQueue($){var queue=[];
var Helper={queueMessage:function queueMessage(Message){queue=queue||[];
queue.push(Message)
},clearQueue:function clearQueue(){C4.MessageManager.queue=[]
},messageShowing:function messageShowing(){return $("#messagingWindow").is(":visible")
}};
return{queue:queue,queueMessage:Helper.queueMessage,clearQueue:Helper.clearQueue,messageShowing:Helper.messageShowing}
})(jQuery);
C4.Util.Carousel=(function($){var Carousel=function(carouselSelector,options){var Model={pageNumber:0,numPages:0,currentPage:1,$carousel:$("<div/>")};
var View={addNextPrev:function(){var $carousel=Model.$carousel;
$carousel.prepend('<a class="carousel-prev" href="#" style="visibility:hidden"><span class="accessibility">Previous page of items</span></a>').append('<a class="carousel-next" href="#" style="visibility:hidden"><span class="accessibility">Next page of items</span></a>');
Event.bindArrowClick("next");
Event.bindArrowClick("prev")
},hideOtherPages:function(){var $carousel=Model.$carousel,$item=$carousel.find(Model.itemSelector+":first"),itemWidth=$item.outerWidth(true),itemHeight=$item.outerHeight(true),$itemContainer=$carousel.find(Model.itemContainer),itemContainerHeightModifier=parseInt($itemContainer.css("padding-top"))+parseInt($itemContainer.css("padding-bottom"))+parseInt($itemContainer.css("margin-top"))+parseInt($itemContainer.css("margin-bottom")),isIe6=$.browser.msie&&$.browser.version<7,ie6WidthModifier=isIe6?4:0;
Model.maskWidth=(Model.itemsPerPage*itemWidth);
$itemContainer.wrap('<div class="carousel-contents" />');
$carousel.find(".carousel-contents").width(Model.maskWidth+ie6WidthModifier).height(itemHeight+itemContainerHeightModifier-Model.marginModifier);
$itemContainer.addClass("carousel-item-container").addClass("cf").height(itemHeight).css({left:Model.paddingModifier})
},updateCarouselPosition:function(newLeftPos){var $carousel=Model.$carousel,$itemContainer=$carousel.find(".carousel-item-container");
Event.unbindArrowClick("next");
Event.unbindArrowClick("prev");
$itemContainer.animate({left:newLeftPos},500,function(){Event.bindArrowClick("next");
Event.bindArrowClick("prev")
})
},showArrow:function(type){var $carousel=Model.$carousel,$arrow=$carousel.find(".carousel-"+type);
$arrow.css({visibility:"visible"})
},hideArrow:function(type){var $carousel=Model.$carousel,$arrow=$carousel.find(".carousel-"+type);
$arrow.css({visibility:"hidden"})
},updateArrows:function updateArrows(){if(Model.numPages===Model.currentPage){View.hideArrow("next")
}if(Model.currentPage===1){View.hideArrow("prev")
}},createPaging:function(numPages){var $paging=$('<ol class="carousel-paging cf"/>'),i;
for(i=1;
i<=numPages;
i++){$paging.append('<li><a class="carousel-page'+i+'" href="#"><span class="accessibility">Page '+i+"</span></a></li>")
}return $paging
},highlightSelectedPageIndicator:function(page){var $carousel=Model.$carousel;
$carousel.find(".carousel-paging a").removeClass("current");
$carousel.find(".carousel-page"+page).addClass("current")
}};
var Helper={initPagination:function(){var $carousel=Model.$carousel;
if(Model.numItems>Model.itemsPerPage){View.hideOtherPages();
View.showArrow("next");
Model.numPages=Math.ceil(Model.numItems/Model.itemsPerPage);
Helper.addPaging()
}},addPaging:function(){var $carousel=Model.$carousel;
$carousel.append(View.createPaging(Model.numPages));
View.highlightSelectedPageIndicator(Model.currentPage);
Event.bindPageClick()
},removePaging:function(){var $carousel=Model.$carousel;
$carousel.find(".carousel-paging").remove()
},resetPaging:function(itemCount,currentPage){var $carousel=Model.$carousel;
Helper.removePaging();
Model.numPages=Math.ceil(itemCount/Model.itemsPerPage);
Model.currentPage=currentPage;
if(Model.numPages>1){Helper.addPaging();
View.updateArrows()
}else{View.hideArrow("next");
View.hideArrow("prev")
}View.updateCarouselPosition(Helper.calculateNewLeftPos())
},updateCarouselPage:function(nextPrev){var $carousel=Model.$carousel;
View.showArrow("next");
View.showArrow("prev");
View.highlightSelectedPageIndicator(Model.currentPage);
var leftPos=Helper.calculateNewLeftPos(nextPrev);
View.updateArrows();
View.updateCarouselPosition(leftPos)
},calculateNewLeftPos:function(shiftType){var $carousel=Model.$carousel,$itemContainer=$carousel.find(".carousel-item-container"),leftPos=parseInt($itemContainer.css("left"));
if(shiftType){newLeftPos=(shiftType==="next")?leftPos-Model.maskWidth:leftPos+Model.maskWidth
}else{newLeftPos=(0-((Model.currentPage-1)*Model.maskWidth))+Model.paddingModifier
}return newLeftPos
},getCarouseljQuery:function(){return Model.$carousel
}};
var Event={bindArrowClick:function(type){var $carousel=Model.$carousel,$arrow=$carousel.find(".carousel-"+type);
$arrow.unbind("click");
$arrow.click(function(e){e.preventDefault();
type==="next"?Model.currentPage++:Model.currentPage--;
Helper.updateCarouselPage(type)
})
},unbindArrowClick:function(type){var $carousel=Model.$carousel,$arrow=$carousel.find(".carousel-"+type);
$arrow.unbind("click");
$arrow.click(function(e){e.preventDefault()
})
},bindPageClick:function(){var $carousel=Model.$carousel,$paging=$carousel.find(".carousel-paging a");
$paging.click(function(e){Event.pageClick(e)
})
},pageClick:function(e){e.preventDefault();
$.each($(e.target).attr("class").split(" "),function(i,className){if(className.indexOf("carousel-page")!==-1){Model.currentPage=parseInt(className.substring("carousel-page".length,className.length))
}});
Helper.updateCarouselPage()
}};
function init(carouselSelector,options){options=options||{};
Model.$carousel=$(carouselSelector);
Model.itemsPerPage=options.itemsPerPage||5;
Model.itemSelector=options.itemSelector||".promo";
Model.itemContainer=options.itemContainer||".promo-container";
Model.paddingModifier=options.paddingModifier||0;
Model.marginModifier=options.marginModifier||0;
Model.numItems=Model.$carousel.find(Model.itemSelector).length;
Model.currentPage=1;
View.addNextPrev();
Helper.initPagination()
}init(carouselSelector,options);
return{Model:Model,Helper:Helper,View:View,resetPaging:Helper.resetPaging,getCarouseljQuery:Helper.getCarouseljQuery}
};
return function(carouselSelector,options){var newCarousel=new Carousel(carouselSelector,options);
return newCarousel
}
})(jQuery);
C4.Util.HashManager=(function($){return{handlers:{},init:function(){var self=this;
$(window).hashchange(function(){var parameters=C4.Util.parseQuery(location.hash.substr(1));
$.each(parameters,function(handlerKey,argument){if(self.handlers[handlerKey]){self.handlers[handlerKey].call(this,argument)
}})
})
},removeHandler:function(handlerKey){this.handlers[handlerKey]=null
},addHandler:function(handlerKey,handlerFunction){this.handlers[handlerKey]=handlerFunction
}}
})(jQuery);
if(!C4.PinController){C4.PinController=(function($){var Events={triggerEventFromFlash:function(eventType,popUp){switch(eventType){case"SETUP_PIN":if(popUp){self.opener.location="/static/global/html/parentalContent.html"
}else{window.location="/static/global/html/parentalContent.html"
}break;
case"CHANGE_PIN":if(popUp){self.opener.location="/static/global/html/parentalContent.html"
}else{window.location="/static/global/html/parentalContent.html"
}break;
case"DECLINE_PIN":break;
case"FORGOTTEN_PIN":if(popUp){window.open("http://www.channel4.com/4viewers/contact-us")
}else{window.open("http://www.channel4.com/4viewers/contact-us")
}break;
case"TERMS_PIN":window.open("/terms_and_conditions.html");
break
}}};
var Helper={getPinCookie:function getPinCookie(){var cookieName="C4PinCookie";
var cookieValue=C4.Util.getCookieValue(cookieName);
if(cookieValue!==null){cookieValue="cookieValue = "+cookieValue;
eval(cookieValue)
}return cookieValue
}};
var View={updatePinStatus:function updatePinStatus(){var cookieExists=C4.PinController.Helper.getPinCookie();
if(cookieExists){$(".parental").addClass("pin-on")
}else{$(".parental").removeClass("pin-on")
}}};
return{Helper:Helper,View:View,getEvents:function getEvents(){return Events
}}
})(jQuery)
}(function($){$.dropdown=function($dropdowns,options){var dropdown=this;
dropdown.options=options;
dropdown.offsetLeft=0;
dropdown.offsetTop=0;
$dropdowns.each(function(){var $dropdown=$(this);
$dropdown.find(dropdown.options.openerSelector).bind("click keypress",function(e){var open=e.type==="click"?true:false;
if(e.type==="keypress"&&e.keyCode===13){open=true
}if(open){$dropdown.toggleClass("opened");
dropdown.openDropdown()
}});
$dropdown.focusout(function(e){setTimeout(function(){$dropdown.removeClass("opened")
},200);
dropdown.closeDropdown()
})
})
};
$.dropdown.prototype={openDropdown:function openDropdown(){},closeDropdown:function closeDropdown(){}};
$.fn.dropdown=function(options){options=options||{};
options.height=options.height||400;
options.openerSelector=options.openerSelector||".dropdown-opener";
options.dropdownSelector=options.dropdownSelector||".dropdown-content";
new $.dropdown(this,options);
return this
}
})(jQuery);
C4.AdManager=(function($){var Helper={insertAds:function insertAds(mapping){$(function(){for(var i=0;
i<mapping.length;
i++){$(mapping[i].advertSelector).find("script").remove();
if(mapping[i].insertBefore){$(mapping[i].advertSelector).insertBefore(mapping[i].targetSelector)
}else{$(mapping[i].advertSelector).appendTo(mapping[i].targetSelector)
}if(mapping[i].wrapper&&mapping[i].wrapper.length>0){$(mapping[i].advertSelector).wrap(mapping[i].wrapper)
}if(Helper.advertExists(mapping[i].advertSelector)===false){Helper.removeAd(mapping[i].advertSelector)
}if(typeof mapping[i].callbackFunc=="function"){mapping[i].callbackFunc(mapping[i].callbackParam)
}}})
},advertExists:function advertExists(advertSel){var $ad=advertSel.jquery?advertSel:$(advertSel);
var hasContent=$ad.children().length>0&&!($ad.children().length===1&&$ad.find("h2").length===1),emptyGifImage=$ad.find("img[src*='empty.gif']").length>0,emptyGifLink=$ad.find("a[href*='empty.gif']").length>0;
return hasContent&&!emptyGifImage&&!emptyGifLink
},removeAd:function removeAd(advertSelector){var $ad=$(advertSelector);
var $container=Helper.getTopContainer($ad);
$container.remove()
},clearEmptyAd:function clearEmptyAd(advertSel,callbackFunc,callbackFuncParam){$(function(){if(Helper.advertExists(advertSel)===false){Helper.removeAd(advertSel);
if(typeof callbackFunc=="function"){callbackFunc(callbackFuncParam)
}}})
},getTopContainer:function getTopContainer($container){while($container.parent().children().length===1){$container=$container.parent()
}return $container
}};
return{insertAds:Helper.insertAds,clearEmptyAd:Helper.clearEmptyAd,advertExists:Helper.advertExists}
})(jQuery);
(function($){function sameOrChild(n1,n2){return n1===n2||(typeof (n1.contains)!=="undefined"?n1.contains(n2):!!(n1.compareDocumentPosition(n2)&16))
}function focusHandler(event){event=$.event.fix(event||window.event),$this=$(this),isFocused=$this.data("focus.isFocused");
if(!isFocused){$this.data("focus.isFocused",true);
event.type="focusin";
return $.event.handle.apply(this,[event])
}}function blurHandler(event){var args=[].slice.call(arguments,1),$this=$(this);
event=$.event.fix(event||window.event);
window.setTimeout(function(){if(!sameOrChild($this.get(0),document.activeElement)){$this.data("focus.isFocused",false);
event.type="focusout";
return $.event.handle.apply($this.get(0),[event])
}},0)
}function setupEvents(elem){var $elem=$(elem),ref=$elem.data("focus.handlerReferences")||0;
if(ref==0){if(elem.addEventListener){elem.addEventListener("focus",focusHandler,true);
elem.addEventListener("blur",blurHandler,true)
}else{elem.onfocusin=focusHandler;
elem.onfocusout=blurHandler
}}$elem.data("focus.handlerReferences",ref+1);
$elem.data("focus.isFocused",sameOrChild(elem,document.activeElement))
}function teardownEvents(elem){var $elem=$(elem),ref=$elem.data("focus.handlerReferences")||0;
if(ref==1){if(elem.removeEventListener){elem.removeEventListener("focus",focusHandler,true);
elem.removeEventListener("blur",blurHandler,true)
}else{elem.onfocusin=null;
elem.onfocusout=null
}$elem.removeData("focus.handlerReferences");
$elem.removeData("focus.isFocused")
}else{$elem.data("focus.handlerReferences",ref-1)
}}$.each(["focusin","focusout"],function(i,x){$.event.special[x]={setup:function(){setupEvents(this)
},teardown:function(){teardownEvents(this)
}}
});
$.fn.extend({focusin:function(fn){return fn?this.bind("focusin",fn):this.trigger("focusin")
},focusout:function(fn){return fn?this.bind("focusout",fn):this.trigger("focusout")
}})
})(jQuery);
(function($,e,b){var c="hashchange",h=document,f,g=$.event.special,i=h.documentMode,d="on"+c in e&&(i===b||i>7);
function a(j){j=j||location.href;
return"#"+j.replace(/^[^#]*#?(.*)$/,"$1")
}$.fn[c]=function(j){return j?this.bind(c,j):this.trigger(c)
};
$.fn[c].delay=50;
g[c]=$.extend(g[c],{setup:function(){if(d){return false
}$(f.start)
},teardown:function(){if(d){return false
}$(f.stop)
}});
f=(function(){var j={},p,m=a(),k=function(q){return q
},l=k,o=k;
j.start=function(){p||n()
};
j.stop=function(){p&&clearTimeout(p);
p=b
};
function n(){var r=a(),q=o(m);
if(r!==m){l(m=r,q);
$(e).trigger(c)
}else{if(q!==m){location.href=location.href.replace(/#.*/,"")+q
}}p=setTimeout(n,$.fn[c].delay)
}$.browser.msie&&!d&&(function(){var q,r;
j.start=function(){if(!q){r=$.fn[c].src;
r=r&&r+a();
q=$('<iframe tabindex="-1" title="empty"/>').hide().one("load",function(){r||l(a());
n()
}).attr("src",r||"javascript:0").insertAfter("body")[0].contentWindow;
h.onpropertychange=function(){try{if(event.propertyName==="title"){q.document.title=h.title
}}catch(s){}}
}};
j.stop=k;
o=function(){return a(q.location.href)
};
l=function(v,s){var u=q.document,t=$.fn[c].domain;
if(v!==s){u.title=h.title;
u.open();
t&&u.write('<script>document.domain="'+t+'"<\/script>');
u.close();
q.location.hash=v
}}
})();
return j
})()
})(jQuery,this);
