if(typeof(Shadowbox)!="undefined"){Shadowbox.loadSkin('classic',cwsConfig.contextPath+'js/lib/shadowbox/skin/');Shadowbox.loadLanguage('en',cwsConfig.contextPath+'js/lib/shadowbox/lang/');Shadowbox.loadPlayer(['flv'],cwsConfig.contextPath+'js/lib/shadowbox/player/')}$.fn.extend({check:function(){return this.each(function(){this.checked=true})},uncheck:function(){return this.each(function(){this.checked=false})}});var AllUsers={comments:{maxLength:0},init:function(){if(typeof(Shadowbox)!="undefined"&&$("a[rel^=shadowbox]").size()>0){var d={flvPlayer:cwsConfig.contextPath+'multimedia/mediaplayer.swf',loadingImage:cwsConfig.contextPath+'icons/platform/loadingAnimation.gif',overlayBgImage:cwsConfig.contextPath+'icons/platform/overlay-85.png',autoplayMovies:true};Shadowbox.init(d);var e="div.videos a[href^=http], div.videos a[href^=/]";$(e).each(function(){var a=$(this).attr("href").split("/");var b=a.pop();var c=a.pop();if(b.indexOf(';')>0){b=b.split(";")[0]}$(this).attr("href",cwsConfig.videoBaseUrl+c+'/'+b)});$(e).click(function(){pageTracker._trackPageview("/video/"+this.href)});Shadowbox.setup($(e))}AllUsers.attachEvents();AllUsers.addDateWidgets();if($.browser.msie){AllUsers.restrictArticleElementWidth()}else{$(".articleElement img").load(AllUsers.restrictArticleElementWidth)}if($("#instituteLogin").size()>0){AllUsers.enhanceInstituteLogin()}$("#subjectNav h3").addClass('collapso');$(".showCharsRemaining").parent().find("label").append("&nbsp;<em></em>");$(".showCharsRemaining").each(function(){if($(this).is('.stealth')){$(this).parent().find('span').hide()}AllUsers.showCharsRemaining(this);$(this).keyup(function(){AllUsers.showCharsRemaining(this)})});$("h3.trigger").next().hide();$("a[href=#requestInfo]").attr("href","#TB_inline?height=600&width=500&inlineId=requestInfo");var f=cwsConfig.contextPath+'icons/platform/jquery-lightbox/';$('a[rel*=lightbox]').lightBox({imageLoading:f+'lightbox-ico-loading.gif',imageBtnPrev:f+'lightbox-btn-prev.gif',imageBtnNext:f+'lightbox-btn-next.gif',imageBtnClose:f+'lightbox-btn-close.gif',imageBlank:f+'lightbox-blank.gif'});if($.browser.msie){$("#buyersguide #categoryList li").append("|&nbsp;")}if($("form.validate").size()>0){$("form.validate").validate({errorElement:"em",success:function(a){a.parent().find("input").addClass("fieldOk")},highlight:function(a,b){$(a).addClass(b);$(a).removeClass("fieldOk")},unhighlight:function(a,b){$(a).removeClass(b);$(a).addClass("fieldOk")}})}$(".categoryExplorer > ul > li > a").click(function(){$(this).parent().toggleClass('expanded').find("ul").toggle();return false});$("blockquote.spam").before('<a href="#" class="showSpam">Show message</a>');$("blockquote.spam").parent().find("a.showSpam").click(function(){$(this).nextAll("blockquote.spam").toggle();if($(this).text()=='Show message'){$(this).text('Hide message')}else{$(this).text('Show message')}return false});AllUsers.micrositeSelectedNavigation()},addDateWidgets:function(){var a=new Date();var b=a.getFullYear()-1;$(".date-picker").datePicker({inputClick:false,startDate:'01/01/'+b});$(".date-picker-nopastdates").datePicker({inputClick:false})},attachEvents:function(){var e=encodeURIComponent;var d=document;var t=d.title;var b=/(company|product)\/([A-Z][0-9]{9})/;if(d.URL.match(b)){$("#content a[href^=http]").not("a.outbound").click(function(){d.URL.match(b);AllUsers.trackOutboundLink(RegExp.$1,RegExp.$2,this.href)})}$("a.outbound").click(function(){var a=this.id.split(":");AllUsers.trackOutboundLink(a[0],a[1],this.href)});$("form.downloadRequest").submit(function(){pageTracker._trackPageview('/download/'+this.downloadUrl.value)});$("h3.trigger").click(function(){$(this).next().toggle();$(this).toggleClass('triggerexpanded');$(this).toggleClass('trigger')});$("h3.trigger").mouseover(function(){$(this).addClass("triggerhover")});$("h3.trigger").mouseout(function(){$(this).removeClass("triggerhover")});$("#subjectNav h3").click(function(){$("#subjectNav ul").toggle('fast');$("#subjectNav h3").toggleClass('collapso');$("#subjectNav h3").toggleClass('expando')});$("a.delicious").click(function(){var a=AllUsers;a.openWin(a.serviceUrl(this.href)+'?v=4&noui&jump=close&url='+$.getURLParam(this.href,"url")+'&title='+e(t));return false});$("a.citeulike").click(function(){var a=AllUsers;a.openWin(a.serviceUrl(this.href)+'?url='+$.getURLParam(this.href,"url")+'&title='+e(t),{width:800,height:550});return false});$("a.furl").click(function(){var a=AllUsers;a.openWin(a.serviceUrl(this.href)+'?u='+$.getURLParam(this.href,"u")+'&t='+e(t));return false});$("a.connotea").click(function(){AllUsers.openWin('http://www.connotea.org/addpopup?continue=confirm&uri='+$.getURLParam(this.href,"uri")+'&title='+e(t),{width:660,height:600});return false});$("a.bibsonomy").click(function(){var a=AllUsers;var h=a.serviceUrl(this.href)+'?c=b&jump=yes&url='+$.getURLParam(this.href,"url")+'&description='+e(t);if(!utils.isEmpty(a.getSelection())){h+='&extended='+e(a.getSelection())}a.openWin(h,{width:750,height:500});return false});$("a.magnolia").click(function(){var a=AllUsers;var h='http://ma.gnolia.com/bookmarklet/popup/add?url='+$.getURLParam(this.href,"url")+'&title='+e(t);if(!utils.isEmpty(a.getSelection())){h+='&description='+e(a.getSelection())}a.openWin(h,{width:800,height:550});return false});$("a.digg").click(function(){var a=AllUsers;var h=this.href;if(!utils.isEmpty(a.getSelection())){h+='&description='+e(a.getSelection())}a.openWin(h,{width:800,height:550});return false});$("#previouslyRegistered").prepend('<a href="#" class="close">Close</a>');$("#previouslyRegistered a.close").click(function(){$("#previouslyRegistered").slideUp('fast');$("#previouslyRegistered a.close").css({'background-color':'#aa9'});return false})},trackOutboundLink:function(a,b,c){var d='/outbound/'+a+'/'+b+'/'+c;pageTracker._trackPageview(d)},getSelection:function(){var a='';if($.browser.msie){a=document.selection.createRange().text}else if($.browser.safari||$.browser.mozilla){a=window.getSelection()}return String(a).replace(/%20{2,}/g,'%20').replace(/^%20|%20$/g,'')},openWin:function(a,b){if(b===undefined){b={width:700,height:400}}window.open(a,'socialBookmarks','scrollbars=yes,toolbar=no,width='+b.width+',height='+b.height)},serviceUrl:function(a){return a.split('?')[0]},restrictArticleElementWidth:function(){var a=$(".articleElement img").width();if(a>200){$(".articleElement").width(a)}},enhanceInstituteLogin:function(){var c=$("meta[name=title]").attr("content");var d={iop:"You're about to sign in with your "+c+" username and password.",cws:"You're about to sign in with an Institute of Physics username and password."};var e={iop:"Sign in here",cws:"Go back to "+c+" sign-in"};var f={iop:"Institute username",cws:c+" username"};var g={iop:"Institute password",cws:c+" password"};var h='<div id="toggleLogin">'+'<p>Please choose from the following sign-in methods:</p>'+'<ul>'+'<li><a href="#" id="cws" class="selected">'+c+' sign-in</a></li>'+'<li><a href="#" id="iop">IOP Member sign-in</a></li>'+'</ul>'+'<p id="preLogin">'+d.iop+'</p>'+'</div>';$("#instituteLogin").parent().hide().before(h);AllUsers.toggleLoginLabels(f.cws,g.cws);$("#iopForgotPassword").hide();$("#toggleLogin a").click(function(){var a=$(this).attr('id');var b=a=='iop'?'cws':'iop';$(this).addClass('selected');$("#"+b).removeClass('selected');$("#toggleLogin p#preLogin").empty().prepend(d[b]);AllUsers.toggleLoginLabels(f[a],g[a]);if(b=='cws'){$("#instituteLogin").check();$("#cwsForgotPassword").hide();$("#iopForgotPassword").show()}else{$("#instituteLogin").uncheck();$("#iopForgotPassword").hide();$("#cwsForgotPassword").show()}return(false)})},toggleLoginLabels:function(a,b){$("label[for=userName]").empty().prepend(a);$("label[for=passWord]").empty().prepend(b)},showCharsRemaining:function(a){if(typeof(a)=='string'){a=document.getElementById(a)}var b=$(a).parent().find('span em').text();var c=0;if($(a).parent().is('.stealth')){c=Math.round(b*0.75)}var d=utils.normalizeCRLF(a.value).length;if(d>c){var e=b-d;var f=(e==1||e==-1)?'character':'characters';var g,css;if(e>=0){g=e+' '+f+' remaining';css={'background-color':'#ffd','color':'#000'}}else{g='Please remove '+(e*-1)+' '+f;css={'background-color':'#000','color':'white'}}$("label[for="+a.id+"] em").empty().append(g).css(css)}else{$("label[for="+a.id+"] em").empty()}},micrositeSelectedNavigation:function(){if($("body").hasClass("newMicrosite")&&$.browser.msie===false){var b=$("#micrositeContainer").attr("class");$("ul.main-navigation li a").each(function(){var a=$(this).attr("href").split("/").pop();if(a===b){$(this).parent().addClass("selected")}})}}};$(document).ready(AllUsers.init);