var which={selectDrivenEnable:function(a,c,b){if($("#"+a).val()===c){$("#"+b).removeAttr("disabled")
}else{$("#"+b).attr("disabled","disabled")
}$("#"+a).change(function(){if($("#"+a).val()===c){$("#"+b).removeAttr("disabled")
}else{$("#"+b).attr("disabled","disabled");
$("p.error[htmlfor="+b+"]").remove()
}})
},showForJS:function(){$("#page .show-for-js").show()
},printPage:function(){if(!document.getElementsByTagName){return
}$("#content h1").attr("id","print-page-positioner").before('<p id="print-page-js"><a href="#">Print this page</a></p>');
$("#print-page-js a").click(function(){window.print();
return false
})
},enlargeImage:function(a){$(a+" a").click(function(){$("#enlarged-image").remove();
$(this).parent().before('<div id="enlarged-image"><img src="/assets/images/icons/close.png" alt="Close" class="close" /><img src="'+this.href+'" height="400" width="400" alt="" /></div>');
$("#enlarged-image").click(function(){$(this).remove()
});
return false
})
},socialBookmarks:function(b){var a=(b?b:"#socialbookmarks");
$(a).append('<div class="addthis_toolbox addthis_default_style"><a class="addthis_button_email"></a><a class="addthis_button_twitter"></a><a class="addthis_button_favorites"></a><a class="addthis_button_facebook"></a><a class="addthis_button_google_plusone" g:plusone:count="false"></a><a class="addthis_button_compact"><img src="http://www.which.co.uk/assets/images/icons/more-bookmarks.jpg" width="76" height="16" border="0"/></a></div>');
if(a==="#socialbookmarks"){$(a).prepend("<h3>Share, bookmark or subscribe</h3>");
$.getScript("http://s7.addthis.com/js/250/addthis_widget.js#username=which")
}},socialBookmarksInNews:function(){var b=document.getElementById("breadcrumbs"),a;
if(!b){return
}b=b.getElementsByTagName("li");
a=$("#content").find("img:first").parent();
if(b&&b[2]&&b[2].innerHTML.toLowerCase().indexOf("/news/")>0&&b.length>4&&a.length>0){a.wrap('<div class="share-this-news"></div>');
which.socialBookmarks("div.share-this-news")
}},categoryToggle:function(){var a;
a=$("#report-listing.slider");
a.find("div").each(function(){$subCategory=$(this);
$subCategoryHeader=$(this).find("h3");
$subCategoryList=$(this).find("ul");
if($(this).index()===1){$subCategoryHeader.addClass("open")
}else{$subCategoryList.toggle();
$subCategoryHeader.addClass("closed")
}$subCategoryHeader.click(function(){$currentHeader=$(this);
$currentHeader.parent().find("ul").slideToggle(1000,function(){if($(this).index()===1){$currentHeader.toggleClass("open");
$currentHeader.toggleClass("closed")
}});
return false
})
})
},tabController:function(d,e){e=d+" "+e;
var a="",b=$(e).eq(0).text(),c;
$(d).eq(0).before('<ul id="inpage-nav"><li class="on"><a href="#"><span>'+b+"</span></a></li></ul>");
$(e).eq(0).addClass("removed");
if($(d).length>1){for(c=1;
c<=$(d).length-1;
c+=1){$(d).eq(c).hide();
a=$(e).eq(c).text();
$(e).eq(c).addClass("removed");
$("#inpage-nav").append('<li><a href="#"><span>'+a+"</span></a></li>")
}}$("#inpage-nav li").click(function(){$(d).hide();
$("#inpage-nav li.on").removeClass("on");
$(this).addClass("on");
var f=$("#inpage-nav li").index(this);
$(d).eq(f).show();
return false
})
},navigationHoverEnhancer:function(){if(!$.browser.opera){$("#tabs li").mouseover(function(){$("#tabs ul").removeClass("js-hover")
});
$("#tabs ul").bind("mouseleave",function(){$(this).addClass("js-hover")
})
}},ajaxLogReporter:function(c,d){var b="service/util/log",a='{"logMessage":{"message": "'+c+'", "ajaxRequestURL":"'+d+'"}}';
$.ajax({type:"POST",url:b,data:a,dataType:"json",contentType:"application/json; charset=utf-8"})
},createCookie:function(c,d,e){var b,a="";
if(e){b=new Date();
b.setTime(b.getTime()+(e*24*60*60*1000));
a="; expires="+b.toGMTString()
}document.cookie=c+"="+d+a+"; path=/"
},readCookie:function(b){var f,a,d,e;
a=document.cookie.split(";");
e=b+"=";
for(d=0;
d<a.length;
d+=1){f=a[d];
while(f.charAt(0)===" "){f=f.substring(1,f.length)
}if(f.indexOf(e)===0){return f.substring(e.length,f.length)
}}return null
},deleteCookie:function(a){which.createCookie(a,"",-1)
},resetCookies:function(){var h,d,l,k,j,i;
h=document.cookie.split("; ");
j=0;
i="Thu, 01 Jan 1970 00:00:00 GMT";
for(k=0;
k<h.length&&h[k];
k+=1){j+=1;
for(d="."+location.host;
d;
d=d.replace(/^(?:\.|[^\.]+)/,"")){for(l=location.pathname;
l;
l=l.replace(/.$/,"")){document.cookie=(h[k]+"; domain="+d+"; path="+l+"; expires="+i)
}}document.cookie=h[k]+"; expires="+i
}window.location.reload()
},omnitureSwitchCharityIDs:function(){var b,a="?cid="+$("#charity-switch-form").attr("class");
if(a.length>0){$("#tabs a, #sidebar a").each(function(){b=$(this).attr("href")+a;
$(this).attr("href",b)
});
b=$("#charity-switch-form").attr("action")+a;
$("#charity-switch-form").attr("action",b)
}},pageReferrer:function(){if(!document.getElementsByTagName){return("")
}var b,c=document.getElementsByTagName("meta"),a;
for(b=0;
b<c.length;
b+=1){if(c[b].name==="referrerUrl"){a=c[b].content;
return(a)
}}return("")
}};
var pageInfo={url:location.href,urlContains:function(a){return(pageInfo.url.indexOf(a)>-1)?true:false
}};
function externalLinks(){$("a[rel*=external]").live("click",function(){window.open(this.href);
return false
})
}function printThisPage(){window.print();
return false
}function printPageLinks(){if(!document.getElementsByTagName){return
}var b,c,a=document.getElementsByTagName("span");
for(b=0;
b<a.length;
b+=1){c=a[b];
if($(c).attr("class")==="js-print"){$(c).wrap('<a href="#"></a>');
$(c).parent("a").click(printThisPage())
}}}function hideForJS(){$(".js-hide").css({position:"absolute",left:"-99999px"})
}var numCounter=0,numMaxAscensions=4,strErrorContainerClass="er",strErrorElement="body";
function findErrorDiv(b){while(numCounter<numMaxAscensions){numCounter+=1;
var a=b.hasClass(strErrorContainerClass);
if(a){numCounter=0;
return b
}else{b=b.parent()
}}return $(strErrorElement)
}if(jQuery.validator){jQuery.validator.addMethod("money",function(b,a){return this.optional(a)||/^£?((\d{1,}(\.\d{1,2})?$)|((\d{1,3}(\,\d{3})*)((\.\d{2})?)$))/.test(b)
},"Please enter a money value (e.g. 100,000.00 or 100000)");
jQuery.validator.addMethod("moneywhole",function(b,a){return this.optional(a)||/^£?((\d{1,}$)|((\d{1,3}(\,\d{3})*)$))/.test(b)
},"Please enter a whole money value (e.g. 100,000 or 100000)");
jQuery.validator.addMethod("alphanumeric",function(b,a){return this.optional(a)||/^\w+$/i.test(b)
},"Please enter an alphanumeric value")
}function radioButtonControl(a){$("input[name="+a+"]").each(function(){if($(this).is(":checked")){$("#"+$(this).attr("id")+"-extra").css({position:"static",left:"auto"})
}else{$("#"+$(this).attr("id")+"-extra").css({position:"absolute",left:"-99999px"})
}})
}function radioClickEvent(a){radioButtonControl(a);
$("input[name="+a+"]").click(function(){radioButtonControl(a)
})
}var inPageNav={defaultAdtechPanel:"",init:function(){var a,b;
$("#in-page-nav div.category-taster").find("h3.title").remove().end().hide();
a=$("#in-page-nav .current a").attr("href");
b=$(a).html();
$("#category-taster-holder").prepend(b);
$("#in-page-nav a.tab-label").click(function(){inPageNav.flip($(this).parent(),$(this).attr("href"));
return false
})
},flip:function(b,a){var c=$(a).html();
if($("#category-taster-holder #adtech-technology-verticaltop-np div").length>0){inPageNav.defaultAdtechPanel=$("#adtech-technology-verticaltop-np").wrap("<div>").parent().html()
}if($(a).find(".adtech-promo").html()===""){c+=inPageNav.defaultAdtechPanel
}$("#category-taster-holder").html(c);
$("#in-page-nav li.current").removeClass("current");
b.addClass("current")
},initHorizontal:function(){var a,b;
$("#in-page-nav div.category-taster").find("h3.title").remove().end().hide();
a=$("#in-page-nav .current a").attr("href");
b=$(a).html();
$(a).find(".adtech-promo").attr("id","");
$("#category-taster-holder").prepend(b);
$("#in-page-nav a.tab-label").click(function(){inPageNav.flipHorizontal($(this).parent(),$(this).attr("href"));
return false
})
},flipHorizontal:function(b,a){if($("#category-taster-holder .adtech-promo div").length>0){inPageNav.defaultAdtechPanel=$("#category-taster-holder .adtech-promo").html()
}if($(a).find(".adtech-promo").html()===""){$(a).find(".adtech-promo").html(inPageNav.defaultAdtechPanel)
}var c=$(a).html();
$("#category-taster-holder").html(c);
$("#in-page-nav li.current").removeClass("current");
b.addClass("current")
}};
var moneyTables={init:function(){var c,a,b;
$('#recommended-providers > div:not(".current-table")').hide();
$("#recommended-providers h3.tab-title").each(function(e){var d=$(this);
a=d.parent().attr("id");
b=d.text();
if(e===0){c='<li class="current">';
c+='<a href="#'+a+'"><span>'+b+"</span></a></li>"
}else{if(d.parent().find("table").length===0){c+='<li class="disabled">';
c+="<span><span>"+b+"</span></span></li>"
}else{c+="<li>";
c+='<a href="#'+a+'"><span>'+b+"</span></a></li>"
}}});
$("#relationship-with-providers").hide().addClass("money-popup");
$("#relationship-with-providers").append('<a id="relationship-with-providers-close-link">Close</a>');
$("#relationship-with-providers").wrapInner('<div class="money-popup-inner" />');
$("#recommended-providers h2").after('<a id="link-relationship-with-providers" href="#relationship-with-providers">How Which? makes money from its tables</a><ul id="money-nav">'+c+"</ul>");
$("#recommended-providers h3.tab-title").remove();
$('#recommended-providers #money-nav li:not(".disabled") a').click(function(){moneyTables.flip($(this));
return false
});
$("#relationship-with-providers-close-link").click(function(){$("#relationship-with-providers").hide();
return false
});
$("#link-relationship-with-providers").click(function(){$("#relationship-with-providers").show();
return false
})
},flip:function(a){$("#recommended-providers li.current").first().removeClass("current");
$("#recommended-providers div.current-table").first().removeClass("current-table").hide();
a.parent().addClass("current");
a.blur();
a=$("#"+a.attr("href").split("#")[1]);
a.addClass("current-table").fadeIn("slow")
}};
var homepage={counter:1,carousel:function(){var b=$("#home-intro"),c=$("#intro-tabs li a"),d=b.find("div:first div").attr("class"),a=(typeof(carouselProps)!=="undefined")?carouselProps:{};
homepage.props=a;
homepage.props.enabled=a.enabled||"on";
homepage.props.opacityType=a.opacityType||"toggle";
homepage.props.speedOut=a.speedOut||1000;
homepage.props.speedIn=a.speedIn||1000;
homepage.props.timeout=a.timeout||6000;
b.addClass("js-enabled").tabs({fx:[{opacity:homepage.props.opacityType,duration:homepage.props.speedOut},{opacity:homepage.props.opacityType,duration:homepage.props.speedIn}]});
c.first().addClass(d);
if(homepage.props.enabled==="on"){b.tabs("rotate",homepage.props.timeout)
}}};
var MT={hideHelp:function(){if($("#contextual-help").length>0){$("#contextual-help").remove();
$("div.help-wrapper").css("z-index","10")
}},showHelp:function(d){var c,a=d.find("a.column-help").attr("href"),b;
if(a.indexOf("#")>0){c=a.split("#");
a="#"+c[1]
}b=$(a).html();
d.find("div.help-wrapper").append('<div id="contextual-help">'+b+"</div>");
$("#contextual-help").append('<span id="close-contextual-help">X</span>').bind("click",function(){MT.hideHelp();
return false
});
d.find("div.help-wrapper").css("z-index","20")
},setupHelp:function(){var c,d=$("table.money-table").find("thead"),b,a;
d.find("a.column-help").each(function(){b=$(this);
c=b.parent();
b.css({position:"absolute",top:"-15px",right:"-5px"});
a=c.html();
c.bind("click",function(){MT.hideHelp();
MT.showHelp($(this));
return false
});
c.html('<div class="help-wrapper">'+a+"</div>")
})
},ieVersion:function(){var c,a=3,d=document.createElement("div"),b=d.getElementsByTagName("i");
while(d.innerHTML="<!--[if gt IE "+(++a)+"]><i></i><![endif]-->",b[0]){}return a>4?a:c
},isIE:function(){if(MT.ieVersion()<9){var a=document.createElement("script");
a.async="true";
a.src="/assets/13/scripts/ie-css-fix.js";
document.getElementsByTagName("head")[0].appendChild(a)
}},init:function(){$("#contextual-help-text").hide();
MT.isIE();
MT.setupHelp()
}};
which.VIDEO={initPortalPlayer:function(){var a=document.createElement("script");
a.src="http://admin.brightcove.com/js/BrightcoveExperiences_all.js";
if(a.addEventListener){a.addEventListener("load",function(){brightcove.createExperiences()
},false)
}else{a.onreadystatechange=function(){if(this.readyState==="complete"||this.readyState==="loaded"){brightcove.createExperiences()
}}
}document.getElementsByTagName("head")[0].appendChild(a)
},playVideo:function(d){var c=$("object.BrightcoveExperience").attr("id"),a=brightcove.getExperience(c),b=a.getModule(APIModules.VIDEO_PLAYER);
b.loadVideo(d)
},enableHighlightVideos:function(){$(document).ready(function(){$("#featured-videos").bind("click",function(b){var a=$(b.target).closest("div").attr("data-video-id");
if(a){which.VIDEO.playVideo(a)
}})
})
}};
$(document).ready(function(){if($("#in-page-nav.horizontal").size()>0){inPageNav.initHorizontal()
}else{if(document.getElementById("in-page-nav")){inPageNav.init()
}}if(document.getElementById("recommended-providers")){moneyTables.init()
}if(document.getElementById("home-intro")){homepage.carousel()
}if(document.getElementById("products-a-z")){which.productsHoverInit()
}if($("#tabs").find("ul").length>0){which.navigationHoverEnhancer()
}if($("object.BrightcoveExperience").length>0){which.VIDEO.initPortalPlayer();
which.VIDEO.enableHighlightVideos()
}if(document.getElementById("video-gallery")){$("#video-gallery").tabs()
}if(document.getElementById("socialbookmarks")){which.socialBookmarks();
which.socialBookmarksInNews()
}if(document.getElementById("money")&&$("table.money-table").length>0){MT.init()
}if(document.getElementById("charity-switch-form")){which.omnitureSwitchCharityIDs()
}if($("span.js-print").length>0){printPageLinks()
}which.categoryToggle();
externalLinks();
which.showForJS();
hideForJS()
});
