if(typeof shell==="undefined"){shell={}}if(typeof shell.mobile==="undefined"){shell.mobile={}}shell.mobile.resizeTimeout=null;shell.mobile.cookie=null;shell.mobile.ie=(function(){var undef,v=3,div=document.createElement("div"),all=div.getElementsByTagName("i");while(div.innerHTML="<!--[if gt IE "+(++v)+"]><i></i><![endif]-->",all[0]){}return v>4?v:undef}());shell.mobile.shellForModule={isFlexibleHomepage:false,checkIfFlexibleHomepage:function(){if(this.isFlexibleHomepage===false){if($("#side_panel_wrapper .shell_for").length!==0){this.isFlexibleHomepage=true}}return this.isFlexibleHomepage},enable:function(){if(this.checkIfFlexibleHomepage()===false){return}$("#side_panel_wrapper .shell_for").appendTo("#content div:eq(0)")},disable:function(){if(this.checkIfFlexibleHomepage()===false){return}$(".shell_for").appendTo("#side_panel_wrapper")}};shell.mobile.newsModule={enable:function(){var items=$(".module.rss_wrapper");if(items.length===0){return}items.each(function(){var c=$(this).find("> ul");c.after('<div class="pager"></div>');c.cycle({fx:"scrollHorz",speed:500,timeout:0,pause:0,pager:$(this).find(".pager"),pagerAnchorBuilder:function(idx,element){return'<a href="#"><span>'+(idx+1)+"</span></a> |"}});if(typeof $.fn.touchwipe!=="undefined"){c.touchwipe({wipeLeft:function(){c.cycle("next")},wipeRight:function(){c.cycle("prev")},preventDefaultEvents:false})}})},disable:function(){var items=$(".module.rss_wrapper");if(items.length===0){return}items.find("> ul").cycle("destroy");items.find(".pager").remove();items.find("ul:first").attr("style","");items.find("ul:first > li").attr("style","")},resize:function(){$(".module.rss_wrapper > ul").each(function(){var height=0;$(this).children().each(function(){var h=$(this).height();height=h>height?h:height;$(this).get(0).cycleW=null});$(this).height(height)})}};shell.mobile.m6Module={enable:function(){var items=$(".m6"),that=this;if(items.length===0){return}items.find(".promo_keyline").remove();items.each(function(){var height,pager,item=$(this);item.children().each(function(){var h=$(this).height();height=h>height?h:height});item.after('<div class="pager"></div>');pager=item.next();item.cycle({speed:500,fx:"scrollHorz",timeout:0,pause:0,pager:pager,pagerAnchorBuilder:function(idx,element){return'<a href="#"><span>'+(idx+1)+"</span></a> |"}});if(typeof $.fn.touchwipe!=="undefined"){item.touchwipe({wipeLeft:function(){item.cycle("next")},wipeRight:function(){item.cycle("prev")},preventDefaultEvents:false})}});items.find("img").load(function(){that.resize()})},disable:function(){var items=$(".m6");if(items.length===0){return}items.cycle("destroy");items.next().remove();items.attr("style","");items.children().attr("style","");items.find("img").attr("style","");items.find("img").unbind("load")},resize:function(){var height=0,items=$(".m6");items.children().each(function(){var h=$(this).height();height=h>height?h:height;$(this).get(0).cycleW=null});items.height(height)},reload:function(obj){this.disable(obj);this.enable(obj)}};shell.mobile.navigationModule={enable:function(){var toggleButton,active,inactive,levelTwo,obj,searchStyle;obj=$(".module.navigation");if($(".homepage").length!==0){return}if($(".module.navigation > ul ul").size()===0){$(".shell .module.navigation > ul > li").attr("style","width: 50%; text-align: center");$(".shell .module.navigation > ul > li:even").attr("style","width: 50%; text-align: center; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box; border-right: 1px solid white;");return}toggleButton='<a href="#" class="fold_button folded"><span>+</span></a>';obj.find("li.active > h4 > a").after(toggleButton);toggleButton=obj.find(".fold_button");inactive=obj.find("> ul > li:not(.active)").hide();inactive=inactive.clone().attr("class","inactive");obj.find("> ul > li.active").after(inactive);levelTwo=obj.find("> ul > li.active > ul").hide();toggleButton.click(function(){if($(this).hasClass("folded")){inactive.show();levelTwo.show();$(this).attr("class","fold_button unfolded")}else{inactive.hide();levelTwo.hide();$(this).attr("class","fold_button folded")}})},disable:function(){var obj=$(".module.navigation");obj.find("> ul > li:not(.active)").attr("style","");obj.find("> ul > li.active > ul").attr("style","");obj.find(".fold_button").remove();obj.find(".inactive").remove()}};shell.mobile.breadcrumbsModule={enable:function(){var crumbs,html,text;text=$(".breadcrumb > ul > li:last").text();html='<div id="crumb_end">... > <span>'+text+"</span></div>";$(".breadcrumb > span").after(html);$(".breadcrumb > span").attr("class","hidden");$(".breadcrumb > ul").hide();$(".breadcrumb > span").click(function(){var c=$(this).attr("class");c?$(this).removeAttr("class"):$(this).attr("class","hidden");$(".breadcrumb > ul").toggle()})},disable:function(){$("#crumb_end").remove();$(".breadcrumb > span").unbind("click");$(".breadcrumb > ul").attr("style","")}};shell.mobile.searchModule={enable:function(){var search,searchLink,searchText,footerForm,hiddenFields,searchForm,copyrightText,date,title;date=new Date();copyrightText="&copy; "+date.getFullYear()+" Shell";search="";search+='<div id="search">';search+="    <form>";search+='        <div class="search_wrapper">';search+='             <input type="text" id="search_field" name="Search"/>';search+="         </div>";search+='        <input type="submit" value=""/>';search+="    </form>";search+="</div>";search+='<div id="copyright">'+copyrightText+"</div>";$("#footer").after(search);search=$("#search");searchText=$("#footer legend").text();searchLink="";searchLink+='<a href="#search" class="search_link">';searchLink+="    <span>"+searchText+"</span>";searchLink+="</a>";$(".module.shell_logo > :last").after(searchLink);$("#side_panel .search_link").click(function(){$("#search_field").focus();return true});searchForm=search.find("> form");footerForm=$("#footer form");searchForm.attr("method",footerForm.attr("method"));searchForm.attr("action",footerForm.attr("action"));hiddenFields=footerForm.find("input[type=hidden]").clone();searchForm.find("input[type=submit]").after(hiddenFields)},disable:function(){$(".search_link").remove();$("#search").remove();$("#copyright").remove()}};shell.mobile.titleModule={enable:function(){var title;if(shell.isSearch){title=$("title").text()}else{title=$("meta[name=title]").attr("content");title=title.substr(title.lastIndexOf("-")+2)}$("#side_panel > .shell_logo > a:first").after("<h1>"+title+"</h1>")},disable:function(){$("#side_panel > .shell_logo > h1").remove()}};shell.mobile.switchModule={enable:function(){var link="";link+='<li ><a id="mode_switch" href="#">';link+=shell.mobile.translations.fullSite;link+="</a></li>";$("#footer > ul:first > li:first > ul:first > li:first").before(link);$("#footer > ul:first > li:first > ul:first > li").hide();$("#footer > ul:first > li:first > ul:first > li:eq(0)").show();$("#footer > ul:first > li:first > ul:first > li:eq(1)").show();$("#footer > ul:first > li:first > ul:first > li:eq(5)").show();$("#footer > ul:first > li:first > ul:first > li:eq(6)").show();$("#mode_switch").click(function(){if(confirm(shell.mobile.translations.fullSiteInfo)===true){shell.mobile.switchModule.setCookie();shell.mobile.switchModule.disableMobile();return true}return false})},disable:function(){$("#mode_switch").parent().remove();$("#footer > ul:first > li:first > ul:first > li").attr("style","")},enableMobile:function(){shell.mobile.switchModule.enableMobileCSS();shell.mobile.switchModule.removeBackToLink();shell.mobile.enableMobileLogic()},disableMobile:function(){shell.mobile.switchModule.disableMobileCSS();shell.mobile.switchModule.addBackToLink();shell.mobile.disableMobileLogic()},disableMobileCSS:function(){var href=$("link[media~=screen]").attr("href");href=href.replace("global_mobile.css","global.css");$("link[media~=screen]").attr("href",href)},enableMobileCSS:function(){var href=$("link[media~=screen]").attr("href");href=href.replace("global.css","global_mobile.css");$("link[media~=screen]").attr("href",href)},addBackToLink:function(){var link="";link+='<a id="back_to_link" href="#">';link+=shell.mobile.translations.switchToMobile;link+="</a>";$("body > :first").before(link);$("#back_to_link").click(function(){shell.mobile.switchModule.deleteCookie();shell.mobile.switchModule.removeBackToLink();shell.mobile.switchModule.enableMobile()})},removeBackToLink:function(){$("#back_to_link").remove()},setCookie:function(){$.cookie("mobile_full_site","true",{expires:7})},getCookie:function(){return($.cookie("mobile_full_site")==="true")},deleteCookie:function(){$.cookie("mobile_full_site",null)}};shell.mobile.iframeModule={enable:function(){var height=window.innerHeight/2,msg="";msg+='<div id="not_optimised_message">';msg+=shell.mobile.translations.notOptimized;msg+="</div>";if($("iframe.not_optimised_for_mobile").length!==0){$("#wrapper > :first").before(msg)}if($("frameset").length!==0){$("head").after(msg)}},disable:function(){$(".app_link").remove();$("#not_optimised_message").remove()}};shell.mobile.videoPlayerModule={enable:function(){$(".jp-video").each(function(){var height=$(this).width()*0.75;$(this).height(height)})},disable:function(){$(".jp-video").attr("style","")},reload:function(){shell.mobile.videoPlayerModule.disable();shell.mobile.videoPlayerModule.enable()}};shell.mobile.getWidth=function(){var viewportwidth,viewportheight;if(typeof window.innerWidth!="undefined"){viewportwidth=window.innerWidth,viewportheight=window.innerHeight}else{if(typeof document.documentElement!="undefined"&&typeof document.documentElement.clientWidth!="undefined"&&document.documentElement.clientWidth!=0){viewportwidth=document.documentElement.clientWidth,viewportheight=document.documentElement.clientHeight}else{viewportwidth=document.getElementsByTagName("body")[0].clientWidth,viewportheight=document.getElementsByTagName("body")[0].clientHeight}}return viewportwidth};shell.mobile.checkIfSearch=function(){if(document.location.host.indexOf("search.shell.com")!==-1){return true}return false};shell.mobile.checkIfMobile=function(){var obj,from,to,size,width;width=(function(){var viewportwidth,viewportheight;if(typeof window.innerWidth!="undefined"){viewportwidth=window.innerWidth,viewportheight=window.innerHeight}else{if(typeof document.documentElement!="undefined"&&typeof document.documentElement.clientWidth!="undefined"&&document.documentElement.clientWidth!=0){viewportwidth=document.documentElement.clientWidth,viewportheight=document.documentElement.clientHeight}else{viewportwidth=document.getElementsByTagName("body")[0].clientWidth,viewportheight=document.getElementsByTagName("body")[0].clientHeight}}return viewportwidth})();if(typeof shell.mobileWidth==="undefined"){obj=$("link[media~=screen]");if(obj.length===0){return false}from=obj.attr("media").indexOf(": ")+2;to=obj.attr("media").indexOf("px");shell.mobileWidth=parseInt(obj.attr("media").substring(from,to))}if(width<=shell.mobileWidth){return true}return false};shell.mobile.checkIfDesktopMode=function(){return shell.mobile.switchModule.getCookie()};shell.mobile.enableMobileLogic=function(){shell.tabsModule.disable();shell.newsModule.disable();shell.mobile.newsModule.enable();shell.mobile.m6Module.enable();shell.mobile.navigationModule.enable();shell.mobile.searchModule.enable();shell.mobile.breadcrumbsModule.enable();shell.mobile.titleModule.enable();shell.mobile.switchModule.enable();shell.mobile.iframeModule.enable();shell.mobile.videoPlayerModule.enable();shell.mobile.shellForModule.enable()};shell.mobile.disableMobileLogic=function(){shell.mobile.newsModule.disable();shell.mobile.m6Module.disable();shell.mobile.navigationModule.disable();shell.mobile.searchModule.disable();shell.mobile.breadcrumbsModule.disable();shell.mobile.titleModule.disable();shell.mobile.switchModule.disable();shell.mobile.iframeModule.disable();shell.mobile.videoPlayerModule.disable();shell.mobile.shellForModule.disable();shell.tabsModule.enable();shell.newsModule.enable()};shell.mobile.doneResizing=function(){var wasMobile=shell.isMobile,isMobile=shell.mobile.checkIfMobile(),isDesktopMode=shell.mobile.checkIfDesktopMode();if(wasMobile===true&&isMobile===true){if(isDesktopMode===true){return}shell.mobile.newsModule.resize();shell.mobile.m6Module.resize();shell.mobile.videoPlayerModule.reload()}if(isMobile===true&&wasMobile===false){shell.isMobile=true;if(isDesktopMode===true){shell.mobile.switchModule.addBackToLink();return}shell.mobile.enableMobileLogic()}if(isMobile===false&&wasMobile===true){shell.isMobile=false;if(isDesktopMode===true){shell.mobile.switchModule.removeBackToLink();return}shell.mobile.disableMobileLogic()}};shell.mobile.iphoneViewportFix=function(){var metas=$("meta[name=viewport]");if(!navigator.userAgent.match(/iPhone/i)){return}metas.attr("content","width=device-width, initial-scale=1.0, maximum-scale=1.0");$("body").bind("orientationchange",function(event){metas.attr("content","width=device-width, initial-scale=1.0, maximum-scale=1.0")});$("body").bind("gesturestart",function(event){metas.attr("content","width=device-width, initial-scale=1.0, maximum-scale=3.0")})};shell.mobile.setSearchId=function(){if(shell.isSearch){$("body").attr("id","search_results_page")}};shell.mobile.checkMediaQuerriesSupport=function(){if(shell.mobile.ie<9){return false}return true};$(document).ready(function(){shell.isMobile=shell.mobile.checkIfMobile();shell.isDesktopMode=shell.mobile.checkIfDesktopMode();shell.isSearch=shell.mobile.checkIfSearch();shell.supportsMediaQueries=shell.mobile.checkMediaQuerriesSupport();if(shell.supportsMediaQueries===false){return}shell.mobile.setSearchId();shell.mobile.iphoneViewportFix();if(shell.isMobile===false){return}if(shell.isDesktopMode===true){shell.mobile.switchModule.disableMobileCSS();shell.mobile.switchModule.addBackToLink();return}shell.mobile.enableMobileLogic()});$(window).resize(function(e){if(shell.mobile.supportsMediaQueries===false){return}clearTimeout(shell.mobile.resizeTimeout);shell.mobile.resizeTimeout=setTimeout(shell.mobile.doneResizing,10)});
