/* Updated 9/12/13 by ML
Last Updated 7/22/13 by Sc */
$(document).ready(function(){bobMod.control();});var bobMod=(function(opts,$){var bob={showCount:{shows:0},feedCount:0,feeds:[],hiding:true,hdlnurl:"/noscan/public/headlineapp/headlines",closeClick:false,opts:opts};bob.control=function(){var wl=window.location,news="www",emed="emedicine",refe="reference",newsViewArt=/viewarticle\/\d+/,newsViewColl=/viewcollection\/\d+/;$.fn.ellipsis=$.fn.ellipsis||bob.ellipsis;if(typeof bobRun==="undefined"){bobRun="";}if(bobRun==="false"||$("#nwsltr_bar").length>0){return;}if(wl.host.match(news)&&(wl.href.match(newsViewArt)||wl.href.match(newsViewColl)&&(bobRun===true||bobRun===""))){bob.whichVertical="news";bob.$targetDiv=$("#articleContent");}if(typeof ref_contentId!=="undefined"&&(bobRun===true||bobRun==="")){bob.whichVertical="refe";bob.showCount.refHash=window.location.hash;bob.$targetDiv=$("#drugdbmain");}if(bob.whichVertical!==undefined){bob.setup();}};bob.setup=function(){var bobEl;bob.hrcol=bob.$targetDiv.height();bob.rcoltpoffst=bob.$targetDiv.offset().top;bobEl=[$('
'),$(''),$('Also on Medscape - Don\'t miss…
'),$(''),$(''),$(''),$('Don\'t miss on Medscape Reference…
')];$("#footercontents").append(bobEl[0]);if(bob.whichVertical==="news"){$(bobEl[0]).append(bobEl[1].addClass("news-close")).append(bobEl[2]);bob.btmrcol=(bob.rcoltpoffst+bob.hrcol)*0.43;$("#blowOutBox").addClass("news-border");}if(bob.whichVertical==="refe"){$(bobEl[0]).append(bobEl[1].addClass("ref-close")).append(bobEl[6]);bob.btmrcol=(bob.rcoltpoffst+bob.hrcol)*0.55;$("#blowOutBox").addClass("ref-border");}$(bobEl[0]).append(bobEl[3]);$(bobEl[3]).append(bobEl[4]).append(bobEl[5]);bob.testHeight();bob.clicks();bob.jsonphdlnget(bob.hdlnurl);bob.scroll();};bob.jsonphdlnget=function(hdlnurl){hdlnurl+="?timestamp="+new Date().getTime().toString();var scriptFrag=document.createDocumentFragment();var script=document.createElement("script");script.setAttribute("src",hdlnurl);script.setAttribute("type","text/javascript");scriptFrag.appendChild(script);document.body.appendChild(scriptFrag);};bob.randomHeadline=function(){var rand=Math.floor(Math.random()*bob.feeds.length);return rand;},bob.headlineapplist=function(){var randomHeadline=bob.randomHeadline();if(bob.feeds.length===0){return;}if(window.location.pathname==bob.feeds[randomHeadline].uri&&bob.feeds.length>1){bob.feeds.splice(randomHeadline);bob.headlineapplist(bob.feeds);}else{$("#blowOutBox .bobThmb").attr("src",bob.feeds[randomHeadline].thumb);$("#blowOutBox .a-bobThmb").attr("href","http://"+bob.feeds[randomHeadline].dom+bob.feeds[randomHeadline].uri);$("#blowOutBox .bobHeadline").attr("href","http://"+bob.feeds[randomHeadline].dom+bob.feeds[randomHeadline].uri).html(bob.feeds[randomHeadline].ti);$(document).trigger("headLineBoxWritten");if($.browser.mozilla&&$.browser.version=="19.0"){$("#blowOutBox").css("display","none");$("#blowOutBox").css("right","0px");}$("#blowOutBox .bobHeadline").ellipsis();}};bob.feed=function(obj){bob.feedCount++;for(var key in obj){if(typeof obj[key]==="object"){for(var prop in obj[key]){if(obj[key][prop].hasOwnProperty("uri")&&obj[key][prop].hasOwnProperty("thumb")&&obj[key][prop].hasOwnProperty("dom")&&obj[key][prop].hasOwnProperty("ti")){bob.feeds.push(obj[key][prop]);}}}}bob.headlineapplist();};bob.scroll=function(){$(window).scroll(function(){bob.toggle();});};bob.clicks=function(){$("#bobClose").click(function(e){wmdPageLink("ar-bob_x");bob.headlineClose();});$(".bobHeadline").click(function(e){wmdTrack("ar-bob_hdl");});$(".a-bobThmb").click(function(e){wmdTrack("ar-bob_img");});};bob.toggle=function(){var docScrollTop=$(document).scrollTop(),winHeight=$(window).height();if((docScrollTop>bob.btmrcol)&&bob.hiding===true){if(bob.whichVertical==="refe"&&(window.posbottom<1199||window.location.hash!==bob.showCount.refHash)){return;}if(bob.testPagination()){return"pagination";}else{bob.show();}}if(docScrollTop0&&bob.whichVertical==="refe"&&bob.showCount.refHash!==window.location.hash){return;}if($(".bobHeadline").attr("href")===""){return;}if($.browser.mozilla&&$.browser.version=="19.0"){$("#blowOutBox").show();}else{$("#blowOutBox").animate({right:"15px"},450).clearQueue();}if(bob.showCount.shows===0){wmdPageLink("ar-bob-imp");bob.showCount.shows++;}bob.hiding=false;};bob.hide=function(){if($.browser.mozilla&&$.browser.version=="19.0"){$("#blowOutBox").hide();}else{$("#blowOutBox").animate({right:"-320px"},450).clearQueue();}bob.hiding=true;};bob.headlineClose=function(){bob.closeClick=true;bob.hide();};bob.ellipsis=$.fn.ellipsis=function(){return this.each(function(){var el=$(this);if(el.css("overflow")=="hidden"){var text=el.html();var multiline=$(this);var t=$(this.cloneNode(true)).hide().css("position","absolute").css("overflow","visible").width(multiline?el.width():"auto").height(multiline?"auto":el.height());el.after(t);function height(){return t.height()>el.height();}function width(){return t.width()>el.width();}var func=multiline?height:width;while(text.length>0&&func()){text=text.substr(0,text.length-1);t.html(text+"...");}el.html(t.html());t.remove();}});};$(document).bind("headLineBoxWritten",function(){bob.toggle();});$(document).bind("contentElModified",function(){bob.testHeight();});return bob;})(bobMod||"no opts",jQuery);