/* ******************************************************
Last Updated 10/2/13 4:50pm by EB
Previous Update 9/19/13 by JS
****************************************************** */
/* Set Vars For Moving Layers */
var theTop = 70;
var old = theTop;
var headerh = 0;
var windowhost = "http://"+(window.location.host);
/* For scroll header transform */
$(window).scroll(function() {
});
/*Header Dropdown Function*/
$(document).ready(function() {
if($.browser.msie && $.browser.version==8){
$("body").addClass('isIE8');
}
$('#rightheaderlinks').bind('click', function() {
$('#headerrightlinkdd').removeClass('hidesetingdd');
$('#headerrightlinkdd').addClass('showsetingdd');
});
$('#rightheaderlinks').bind('mouseover', function() {
$('#headerrightlinkdd').removeClass('hidesetingdd');
$('#headerrightlinkdd').addClass('showsetingdd');
});
$('#rightheaderlinks').bind('mouseout',function() {
$('#headerrightlinkdd').removeClass('showsetingdd');
$('#headerrightlinkdd').addClass('hidesetingdd');
});
$('#currentSpecialty, #specialtyDropDown').bind('mouseover', function() {
$('#specialtyDropDown').show();
});
$('#currentSpecialty, #specialtyDropDown').bind('mouseout',function() {
$('#specialtyDropDown').hide();
});
/* View Pub Hack For Right Rial Links */
if (document.getElementById('viewpub_publisher')) {
var vp_pub_a = $('#pubintro a#viewpub_publisher').attr('href');
var vp_pub_txt = $('#pubintro a#viewpub_publisher').html();
$('#journalnav ul:nth-child(2)').append('
'+vp_pub_txt+'');
}
if (document.getElementById('viewpub_subscribe')) {
var vp_scribe_a = $('#pubintro a#viewpub_subscribe').attr('href');
var vp_scribe_txt = $('#pubintro a#viewpub_subscribe').html();
$('#journalnav ul:nth-child(2)').append(''+vp_scribe_txt+'');
}
if (document.getElementById('viewpub_submit')) {
var vp_sub_a = $('#pubintro a#viewpub_submit').attr('href');
var vp_sub_txt = $('#pubintro a#viewpub_submit').html();
$('#journalnav ul:nth-child(2)').append(''+vp_sub_txt+'');
}
if (!$.cookie("todaylayershow")) {
setTimeout(function(){
if($("#maincolboxdrugdbheader").length!=1 && $("#whiteoutlayer").length!=1 && $("#layerAd1").length!=1 && $("#layerAd2").length!=1 && $("#nDlayer_modal").length!=1) {
$("#todaylayer").show();
var expDate=new Date();
expDate.setFullYear(2030,0,1);
$.cookie("todaylayershow", "false", {domain: '.medscape.com', expires: expDate, path: '/'});
$('body').bind('click').click(function(event) {
$("#todaylayer").hide();
// return false;
});
}
},1000)
}
addBrandAlert();
});
/* /Header Dropdown Function*/
function hideTodayLayer(){
$("#todaylayer").hide();
}
/* Random List of li */
function showuniquelist(thelist, numselect) {
var listitems = new Array();
listitems = document.getElementById(thelist).getElementsByTagName('li');
var totallist = listitems.length;
var numofitems = listitems.length - 1;
if (totallist <= numselect) {
}
else {
var Count = 0;
var NumUnique = numselect;
var Current = new Array(NumUnique);
for (i = 0; Count < NumUnique; Count++) {
var Found = false;
var rndValue = get_random(numofitems);
for (j = 0; j < Current.length; j++) {
if (Current[j] == rndValue) {
Found = true;
break;
}
}
if (Found) {
Count--;
}
else {
Current[Count] = rndValue;
}
}
for (i = 0; i < listitems.length; i++) {
listitems[i].style.display = "none";
}
for (yi = 0; yi <= numselect; yi++) {
listitems[yi].style.display = "block";
}
}
}
/* Utility Functions */
function get_random(numofitems) {
var MaxValue = numofitems;
var ranNum = Math.round(MaxValue*Math.random());
return ranNum;
}
function getElementClass(element) {
if (element.getAttribute("class")) {
return element.getAttribute("class");
} else if (element.getAttribute("className")) {
return element.getAttribute("className");
}
}
function setElementClass(element, classValue) {
if (element.setAttribute("class", classValue)) {
element.setAttribute("class", classValue);
} else if (element.setAttribute("className", classValue)) {
element.setAttribute("className", classValue);
}
}
function OpenPopup(newLoc, newHeight, newWidth) {
newWin = open("",newLoc,"scrollbars=yes,resizable=yes,height=" + newHeight + ",width=" + newWidth);
}
function resizeWin(newLoc, newHeight, newWidth) {
newWin = open("",newLoc,"scrollbars=yes,resizable=yes,height=" + newHeight + ",width=" + newWidth);
}
/* Utility Function Move Layers */
function movelayers(num)
{
if (window.innerHeight)
{
pos = window.pageYOffset
}
else if (document.documentElement && document.documentElement.scrollTop)
{
pos = document.documentElement.scrollTop
}
else if (document.body)
{
pos = document.body.scrollTop
}
if (pos < theTop)
{
pos = theTop;
}
else
{
pos += 50;
}
if (pos == old)
{
document.getElementById(num).style.top = (pos + 'px');
}
else
{
old = pos;
movelayers(num);
}
}
/* Layer and Src iframe loader */
function loadidetailiframe(idetailurl, detailiframewidth, detailiframeheight, detailiframetop, detailiframeleft) {
var newDiv2 = parent.document.createElement("div");
newDiv2.setAttribute("id", "whiteoutlayer");
newDiv2.innerHTML = " ";
var my_div2 = parent.document.getElementById("bodypadding");
parent.document.body.insertBefore(newDiv2, my_div2);
var framecover = document.getElementById("idetailiframewrapper");
setElementClass(framecover, 'active');
parent.document.getElementById("idetailiframe").src = idetailurl;
parent.document.getElementById("idetailwinbg").style.position = "absolute";
parent.document.getElementById("idetailwinbg").style.zIndex = 2000;
parent.document.location = "#";
var add24px = 24;
var add48px = 48;
var idetailwinbgwidth = (detailiframewidth * 1) + (add24px * 1);
var idetailwinbgheight = (detailiframeheight * 1) + (add48px * 1);
parent.document.getElementById("idetailwinbg").style.width = (idetailwinbgwidth + 'px');
parent.document.getElementById("idetailwinbg").style.height = (idetailwinbgheight + 'px');
parent.document.getElementById("idetailwinbg").style.top = detailiframetop;
parent.document.getElementById("idetailwinbg").style.left = detailiframeleft;
parent.document.getElementById("idetailiframe").style.width = (detailiframewidth + 'px');
parent.document.getElementById("idetailiframe").style.height = (detailiframeheight + 'px');
}
function removeidetailiframe() {
if ((window.pixnumtrack) && (pixnumtrack <= 6)) {
var oIframe = document.getElementById("idetailiframe");
var oDoc = oIframe.contentWindow || oIframe.contentDocument;
if (oDoc.document) {
oDoc = oDoc.document;
}
var timespentpxval = oDoc.getElementById("pxcntnum").value;
var rornval = oDoc.getElementById("rorn").value;
var cnttrack = "http://bi.medscape.com/pi/1x1/bi_action_tracking.gif?company=0&department=0&series=0&promo_act=0&action="+rornval+"_CLOSE&action_id=" + timespentpxval + "&ccid=&eguid=&is_test=0&" + new Date().getTime();
preload_image = new Image(1,1);
preload_image.src = cnttrack;
}
if ($('#rollover_ad').length > 0) {
setTimeout("adRollTime=0",500);
var rotrack = "http://bi.medscape.com/pi/1x1/bi_action_tracking.gif?company=0&department=0&series=0&promo_act=0&action=ro-to-play&action_id=ro-close&ccid=&eguid=&is_test=&nocache=" + new Date().getTime();
preload_image = new Image(1,1);
preload_image.src = rotrack;
}
parent.document.getElementById("idetailiframe").src = "http://www.medscape.com/files/public/blank.html";
var framecover = document.getElementById("idetailiframewrapper");
setElementClass(framecover, 'inactive');
if (document.getElementById("whiteoutlayer")) {
var element = document.getElementById("whiteoutlayer");
while (element.firstChild) {
element.removeChild(element.firstChild);
}
document.getElementById("whiteoutlayer").id = "";
}
}
/* Remove OSUN Notice */
function removeosun(state) {
if (document.getElementById) {
var osunid = document.getElementById("medlayerad");
setElementClass(osunid, state);
}
}
/* NEW Remove OSUN Notice (generic to all new layer ads) */
function removeosun2(state,layid) {
if (document.getElementById) {
var osunid = document.getElementById(layid);
setElementClass(osunid, state);
}
}
/* Functions For Header Instant Look-up and Database Selection */
var dataCopy;
var textCopy;
var typedInputNew = "";
var combolimit = 0;
var qrldrugpath;
var qrlpath;
var ILtimer;
function closeil() {
setTimeout("$('#ilfulllist').hide();", 300);
}
function openil() {
if (document.getElementById('searchdbvalue').value == "2") {
$('#il_combo_nor').hide();
$('#searchtextinput').css("color","black");
if (document.getElementById("searchtextinput").value.length > 0) {
instantlook();
}
if ($('ul#combolist').children().size() > 1) {
$('#il_combo_nor').hide();
}
else if ($('ul#combolist').children().size() == 0 && document.getElementById("searchtextinput").value.length != 0) {
$('#il_combo_nor').show();
}
}
}
function il_call() {
if (document.getElementById('searchdbvalue').value == "2") {
instantlook();
}
}
function instantlook() {
if (typeof(qrllog) != "undefined") {
if (qrllog == "1") {
qrldrugpath = "drug";
qrlpath = "article";
}
else if (qrllog == "0") {
qrldrugpath = "refdrug";
qrlpath = "refarticle";
}
}
else {
qrldrugpath = "refdrug";
qrlpath = "refarticle";
}
typedInputNew = document.getElementById("searchtextinput").value;
if (typedInputNew.indexOf("&") != -1) {
typedInputNew = typedInputNew.replace("&", "\\&");
}
if (typedInputNew.indexOf("+") != -1) {
typedInputNew = typedInputNew.replace("+", "\\+");
}
if (typedInputNew.indexOf("(") != -1) {
typedInputNew = typedInputNew.replace("(", "\\(");
}
if (typedInputNew.indexOf(")") != -1) {
typedInputNew = typedInputNew.replace(")", "\\)");
}
if (typedInputNew.indexOf("#") != -1) {
typedInputNew = typedInputNew.replace("#", "\\#");
}
if (typedInputNew.indexOf("/") != -1) {
typedInputNew = typedInputNew.replace("/", "\\/");
}
if (typedInputNew.indexOf("'") != -1) {
typedInputNew = typedInputNew.replace("'", "\\'");
}
//alert(typedInputNew);
if (typedInputNew.length == 0) {
$('#il_combo_nor').hide();
document.getElementById("combolist").innerHTML="";
combolimit = 0;
}
else if (document.getElementById('searchtextinput').value==textCopy)
{
showResults(dataCopy);
}
else {
var text = document.getElementById('searchtextinput').value;
textCopy=text;
if (text.indexOf("&") != -1) {
text = text.replace("&", "%26");
}
if (text.indexOf("+") != -1) {
text = text.replace("+", "%2B");
}
if (text.indexOf("(") != -1) {
text = text.replace("(", "%20");
}
if (text.indexOf(")") != -1) {
text = text.replace(")", "%20");
}
if (text.indexOf("#") != -1) {
text = text.replace("#", "%23");
}
if (text.indexOf("/") != -1) {
text = text.replace("/", "%2F");
}
//alert("Server Call");
var url = 'http://www.medscape.com/api/quickreflookup/LookupService.ashx?q=' + text + '&sz=10&type=all&metadata=uri,contentid&format=json&jsonp=showResults';
var callback = 'showResults';
jsonp(url, callback);
}
}
function showResults(data)
{
dataCopy=data;
document.getElementById("combolist").innerHTML="";
if (data.types.length >= 1) {
for(i=0;i" + data.types[0].references[i].text + "";
document.getElementById("combolist").appendChild(resultline);
combolimit = combolimit+1;
$('#il_combo_nor').hide();
}
}
else if (data.types[0].references[i].type=="10418")
{
if (combolimit==20)
{
continue;
}
var resultline = document.createElement("li");
resultline.innerHTML="" + data.types[0].references[i].text + "";
document.getElementById("combolist").appendChild(resultline);
combolimit = combolimit+1;
$('#il_combo_nor').hide();
}
else if (data.types[0].references[i].type=="10419")
{
if (combolimit==20)
{
continue;
}
var resultline = document.createElement("li");
resultline.innerHTML="" + data.types[0].references[i].text + "";
document.getElementById("combolist").appendChild(resultline);
combolimit = combolimit+1;
$('#il_combo_nor').hide();
}
else if (data.types[0].references[i].type=="10420")
{
if (combolimit==20)
{
continue;
}
var resultline = document.createElement("li");
resultline.innerHTML="" + data.types[0].references[i].text + "";
document.getElementById("combolist").appendChild(resultline);
combolimit = combolimit+1;
$('#il_combo_nor').hide();
}
else if (data.types[0].references[i].type=="10421")
{
if (combolimit==20)
{
continue;
}
var resultline = document.createElement("li");
resultline.innerHTML="" + data.types[0].references[i].text + "";
document.getElementById("combolist").appendChild(resultline);
combolimit = combolimit+1;
$('#il_combo_nor').hide();
}
else if (data.types[0].references[i].type=="10422")
{
if (combolimit==20)
{
continue;
}
var resultline = document.createElement("li");
resultline.innerHTML="" + data.types[0].references[i].text + "";
document.getElementById("combolist").appendChild(resultline);
combolimit = combolimit+1;
$('#il_combo_nor').hide();
}
else if (data.types[0].references[i].type=="10423")
{
if (combolimit==20)
{
continue;
}
var resultline = document.createElement("li");
resultline.innerHTML="" + data.types[0].references[i].text + "";
document.getElementById("combolist").appendChild(resultline);
combolimit = combolimit+1;
$('#il_combo_nor').hide();
}
}
}
$('#ilfulllist').show();
if (combolimit < 1) {
$('#il_combo_nor').show();
}
combolimit = 0;
}
function searchCp(site,callback) {
var cpSrchData = new Object();
cpSrchData.appname = "search";
cpSrchData.activityName = site;
cpSrchData.search = encodeURIComponent($('#searchtextinput').val());
if ($('meta[name=metasegvar]').length > 0)
{
if (segVarParam("artid") != "0") {
cpSrchData.activityId = segVarParam("artid");
}
}
postCp(cpSrchData,callback);
}
function subsearchheadertrack() {
if (document.getElementById('searchdbvalue').value == "1") {
wmdTrack('hd-srch_nws');
$("form[name=SearchFormHeader] input[name=newSearchHeader]").val('1');
$("form[name=SearchFormHeader]").attr('action','http://search.medscape.com/news-search');
//fix for chrome requiring two clicks on submit
setTimeout(function(){
searchCp("news",function() {document.forms["SearchFormHeader"].submit();});
},1);
}
if (document.getElementById('searchdbvalue').value == "2") {
wmdTrack('hd-srch_ref');
$("form[name=SearchFormHeader] input[name=newSearchHeader]").val('1');
$("form[name=SearchFormHeader]").attr('action','http://search.medscape.com/reference-search');
setTimeout(function(){
searchCp("reference",function() {document.forms["SearchFormHeader"].submit();});
},1);
}
if (document.getElementById('searchdbvalue').value == "3") {
wmdTrack('hd-srch_edu');
$("form[name=SearchFormHeader] input[name=newSearchHeader]").val('1');
$("form[name=SearchFormHeader]").attr('action','http://search.medscape.com/education-search');
setTimeout(function(){
searchCp("education",function() {document.forms["SearchFormHeader"].submit();});
},1);
}
if (document.getElementById('searchdbvalue').value == "4") {
wmdTrack('hd-srch_mdl');
$("form[name=SearchFormHeader] input[name=newSearchHeader]").val('1');
$("form[name=SearchFormHeader]").attr('action','http://search.medscape.com/medline-search');
setTimeout(function(){
searchCp("medline",function() {document.forms["SearchFormHeader"].submit();});
},1);
}
}
function togglesearchdbtext(searchdb, value) {
if (document.getElementById) {
var swapsearchdb = searchdb;
changeSeachDB('searchdbtext', swapsearchdb);
$("#searchdbvalue").val(value);
togglesearchdb('inactive');
$("#searchtextinput").focus();
}
}
function togglesearchdb(state) {
if (state == "active") {
$('#searchdblayer').show();
}
else if (state == "inactive") {
$('#searchdblayer').hide();
}
}
function changeSeachDB(id, str) {
if(document.getElementById(id)) {
document.getElementById(id).innerHTML = str;
}
}
function jsonp(url,callback)
{
if (url.indexOf("?") > -1)
url += "&jsonp=";
else
url += "?jsonp=";
url += callback + "×tamp=";
url += new Date().getTime().toString(); // prevent caching
var script = document.createElement("script");
script.setAttribute("src",url);
script.setAttribute("type","text/javascript");
document.body.appendChild(script);
}
function addBrandAlert() {
/* if ($(".medscape_today").length !=0) { // Today page
var url = windowhost +"/noscan/public/brandalert/merge-desktop-today.json"
$.ajax({
url: url,
type:"GET"
}).done(function(data){
if(data){
var bavpurl = data[0].uri.replace("browser", "headline");
$('#topNews .col2:last ul:first').html('
'+data[0].ti+''+data[0].pu+'
');
if(data.length==2) {
$('#topNews div.col2:nth-last-child(2) .bucketR ul').html('
'+data[1].ti+''+data[1].pu+'
');
}
}
})
} else { */
if ($(".homestar").length != 0 && $(".medscape_today").length == 0 && $("#cardiology").length == 0) { // News homepages
var url = windowhost + "/noscan/public/brandalert/merge-desktop-l.json" //left col
$.ajax({
url: url,
type: "GET"
}).done(function (data) {
if (data) {
var bavpurl = data[0].uri.replace("browser", "headline");
$('#left .leftBucketContent .leftBucketL ul li:eq(0)').after('
' + data[0].ti + '' + data[0].pu + '
');
if (data.length == 2) {
$('body #left .leftBucketContent:eq(0) .leftBucketR ul li:eq(0)').after('
' + data[1].ti + '' + data[1].pu + '
');
}
}
});
var url = windowhost + "/noscan/public/brandalert/merge-desktop-r.json" //right col
$.ajax({
url: url,
type: "GET"
}).done(function (data) {
if (data) {
var bavpurl = data[0].uri.replace("browser", "headline");
$('#right').prepend('');
}
});
}
if ($("#cardiology").length != 0) { // THO Cardio homepage
var url = windowhost + "/noscan/public/brandalert/merge-desktop-l.json" //left col
$.ajax({
url: url,
type: "GET"
}).done(function (data) {
if (data) {
var bavpurl = data[0].uri.replace("browser", "headline");
$('#heartwire ul.colLeft li:eq(1)').after('
' + data[0].ti + '' + data[0].pu + '
');
if (data.length == 2) {
$('#heartwire ul.colRight li:eq(0)').after('
' + data[1].ti + '' + data[1].pu + '
');
}
}
});
var url = windowhost + "/noscan/public/brandalert/merge-desktop-r.json" //right col
$.ajax({
url: url,
type: "GET"
}).done(function (data) {
if (data) {
var bavpurl = data[0].uri.replace("browser", "headline");
$('#right .rightAd').after('');
}
});
}
if ($("#ref_homepage").length != 0) { // Referene homepages
var url = windowhost + "/noscan/public/brandalert/merge-desktop-ref.json"
$.ajax({
url: url,
type: "GET"
}).done(function (data) {
if (data) {
var bavpurl = data[0].uri.replace("browser", "headline");
$('#ref_homepage .leftBucketContent ul li:eq(1)').after('
' + data[0].ti + '' + data[0].pu + '
');
}
});
}
if ($("#featurebarcontainer").length != 0 && typeof (data) != 'null') { //news article
var url = windowhost + "/noscan/public/brandalert/merge-desktop-news-article.json"
$.ajax({
url: url,
type: "GET"
}).done(function (data) {
if (data) {
var bavpurl = data[0].uri.replace("browser", "headline");
$('#featurebarcontainer ul li:eq(3)').remove();
$('#featurebarcontainer ul').prepend('
' + data[0].ti + '' + data[0].pu + '
');
}
});
}
/* } */
}
/* SWFObject v2.1 Copyright (c) 2007-2008 Geoff Stearns, Michael Williams, and Bobby van der Sluis*/var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("