msnbc.utils.activateLegacySupport = function(notifyUsage, exportToGlobal) { exportToGlobal = exportToGlobal || true; function note(msg) { if (notifyUsage) msnbc.warn("legacy function: " + msg); }; jQuery.extend(window, (function() { var $legacy = msnbc.namespace("msnbc.legacy"); var $utils = msnbc.namespace("msnbc.utils"); jQuery.extend($legacy, { siteDomainList: {"MSNBC":"www.msnbc.msn.com","NBCSPORTS":"nbcsports.msnbc.com","Today":"today.msnbc.msn.com","CNBC":"www.cnbc.com"}, rssDomainList: {"MSNBC":"rss.msnbc.msn.com","NBCSPORTS":"rss.nbcsports.msnbc.com","Today":"rss.msnbc.msn.com","CNBC":"www.cnbc.com"}, mq_write: function(sDivId) { var oS = new UberSniff(); mq = mq_a[sDivId]; var oMqd = document.getElementById(sDivId); oMqd.innerHTML = mq.mq_as[mq.Current]; if (mq.items > 1) { mq_timer(mq.Time, sDivId); mq.Current++; if (mq.Current > mq.items) mq.Current = 1; } }, mq_timer: function(n, sDiv) { if (mq_a[sDiv].Timer) { clearTimeout(mq_a[sDiv].Timer); } mq_a[sDiv].Timer = 0; if (n > 0) { mq_a[sDiv].Timer = setTimeout("mq_write('" + sDiv + "')", n); } }, seedNewsvine: function(h, d, k) { note("seedNewsvine"); var u = window.location.href; if ((offset = u.indexOf("page")) != -1) { u = u.substring(0, offset - 1); } var t = ''; if (pd_me.sssss != '') t = pd_me.sssss.replace(/[,]/g, '') + ","; if (pd_me.ssss != '') t += pd_me.ssss.replace(/[,]/g, '') + ","; if (pd_me.sss != '') t += pd_me.sss.replace(/[,]/g, '') + ","; if (pd_me.ss != '') t += pd_me.ss.replace(/[,]/g, '') + ","; if (pd_me.s != '') t += pd_me.s.replace(/[,]/g, ''); if (t != '' && k != '') { t = t + "," + k.substring(0, k.length - 1); } else { t = t + k.substring(0, k.length - 1); } t = t.replace(/[^a-zA-z0-9|\x20|\-|,]/g, '').replace(/\x20+/g, '-').toLowerCase(); h = pd_noul(h); d = pd_noul(d); window.open("http://www.newsvine.com/_wine/save?aff=msnbc&h=" + escape(h) + "&e=" + escape(d) + "&u=" + escape(u) + "&t=" + escape(t)); }, /// /// Tests and executes Search. /// /// event /// type of event /// type of search /// /// TODO: compress to one function, except the getQueryVariable call which Om. uses? /// TODO: Get rid of enter-keypress detection? /// TODO: Get working with ' redirectURL = "http://" + siteDomainList[pd_me.site]; ' /// DoSearch: function(searchType) { /*tf*/ var siteDomainList = { "MSNBC": "www.msnbc.msn.com", "NBCSPORTS": "nbcsports.msnbc.com", "Today": "today.msnbc.msn.com", "CNBC": "www.cnbc.com" }; var query = document.getElementById("q"); var siteId = document.getElementById("id"); var st = getQueryVariable("st"); if ((query != null) && (query.value != "")) { if (searchType == 0) { if (st == "") searchType = "1"; else searchType = st; } document.getElementById("q").text = query.value; /*tf*/ var pdme_test = (pd_me.site) ? pdme_test = pd_me.site: pdme_test = "MSNBC"; /*tf*/ msnbc.warn(pdme_test + " pd_me.site setting missing for story; redirecting to 'MSNBC'"); /*tf*/ var r = ""; r += "http://" + siteDomainList[pdme_test]; r += "/?id=" + siteId.value; r += "&q=" + query.value; r += "&p=1"; r += "&st=" + searchType; r += "&sm=user"; window.location = r; } }, Search: function(searchType) { var query = document.getElementById("q1"); document.getElementById("q").value = query.value; DoSearch(searchType); }, CheckEnterPressed: function(event, type) { var characterCode; if (event && event.which) { event = event; characterCode = event.which; } else { event = event; characterCode = event.keyCode; } if (characterCode == 13) { if (type == 1) DoSearch(0); else Search(0); } return (characterCode != 13); }, /// /// Launches Next Gen video player. /// /// doc id off the video tease to open /// guid for emergency switch back to msn /// optional, specify a particular flavor of player to launch vPlayer: function(vDocId, sGuid, sFlavor) { note("vPlayer"); var bEmergency = false; var sHost = "http://" + siteDomainList[pd_me.site]; if (!siteDomainList[pd_me.site]) { sHost = "http://www.msnbc.msn.com"; } var sDefaultFlavor = "21134540"; if (sHost.toLowerCase().indexOf("nbcsports.msnbc.com") > -1 || (location.host.toLowerCase().indexOf("nbcsports.msnbc.com") > -1)) { sDefaultFlavor = "22825103"; sHost = "http://nbcsports.msnbc.com"; } if (sHost.toLowerCase().indexOf("today.msnbc.msn.com") > -1) { sDefaultFlavor = "26184891"; sHost = "http://today.msnbc.msn.com"; } if (!sFlavor) { sFlavor = sDefaultFlavor; } var vUrl = sHost + "/id/" + sFlavor + "/vp/" + vDocId + "#" + vDocId; if (!bEmergency) { var oUser = new UberSniff(); var sLoc = ",location=1"; if (oUser.ie > 6) { sLoc = ",location=0"; } var w = window.open(vUrl, "MSNBCvplayer", "width=1000,height=600,status=1,scrollbars=0,resizable=0,toolbar=0,menubar=0,titlebar=0,directories=0" + sLoc); if (w.focus) { w.focus(); } } else { msnvDwd('00', sGuid, 'us', '', 'm5', 'msnbc', '', '', ''); } }, /// /// Opens a new slideshow. /// /// ID of slideshow document /// /// TODO: Define windows size. /// SSOpen2: function(nId, beginSlide) { if (!nId) { return; } oUser = new UberSniff; var nW = oUser.screenWidth; var sHost = ""; if (pd_me.dt == "ScriptSource") { sHost = siteDomainList[pd_me.site] ? "http://" + siteDomainList[pd_me.site] : "http://www.msnbc.msn.com"; } var sHref = sHost + "/id/" + nId + "/displaymode/1247/"; if (beginSlide) { sHref += "?beginSlide=" + beginSlide; } var sOptions = "resizable=no,top=0,left=0,screenx=0,screeny=0"; var sizeSet = { 1: ",width=760,height=560", 2: ",width=960,height=660", 3: ",width=1160,height=860" }; if (nId.indexOf("workarea") != -1) { for (var i = 1; i <= 3; i++) { window.open(sHref, "_blank", sOptions + sizeSet[i]); } window.open(sHref, "_blank", sOptions); return; } if (nW >= 1180) { sOptions += sizeSet[3]; } else if (nW >= 935) { sOptions += sizeSet[2]; } else if (nW >= 780) { sOptions += sizeSet[1]; } else { window.open(sHref, "_blank"); return; } var xwinopen = window.open(sHref, "_blank", sOptions); if (oUser.nn > 3 || oUser.ie > 3) { xwinopen.focus(); } }, /// /// Opens a Workbench slideshow. /// /// ID of slideshow tease document /// /// Specific slide to go to (optional) /// Optional extra variable /// Optional extra variable /// /// TODO: CALLER: Insert caller information. /// TODO: Use UberSniff throughout here. /// SSOpen: function(nId, nSize, sFrame, sVar1, sVar2) { note("SSOpen"); if (!nId) return; if (!nSize || nSize == '') nSize = 0; oUser = new UberSniff(); var nW = oUser.screenWidth; var sOptions = "resizable=no,top=0,left=0,screenx=0,screeny=0"; var sHref; if (nId.indexOf('workarea') != -1) { sHref = "/id/" + nId + "/displaymode/1107/"; } else { sHref = "http://" + siteDomainList[pd_me.site] + "/id/" + nId + "/displaymode/1107/"; } if (sFrame && sFrame != '') sHref += "framenumber/" + sFrame + "/"; if (sVar1 && sVar1 != '') sHref += "var1/" + sVar1 + "/"; if (sVar2 && sVar2 != '') sHref += "var2/" + sVar2 + "/"; var bNew = true; if (((nSize == 0) || (nSize == 2)) && nW >= 935) { sOptions += ",width=935,height=685"; sHref += "s/2/"; } else if (((nSize == 0) || (nSize == 1)) && nW >= 780) { sOptions += ",width=780,height=519"; sHref += "s/1/"; } else { bNew = false; } gEnabled = (new tryCatch( "if (gEnabled!=undefined) return gEnabled; else return false;", "return false;")).trycatch(); if (gEnabled) { // TODO: Refactor to share with glinkClick? var ua = window.navigator.userAgent; if (ua.indexOf('Win') != -1) { var ie = ua.indexOf('MSIE'); if (ie != -1) { if (! (parseFloat(ua.slice(ie + 5)) < 5)) { if (liveEnv) { destUrl = "http://" + siteDomainList[pd_me.site]; } else { destUrl = location.protocol + "//" + location.host; } var evSrc = window.document.activeElement; var cmNode = evSrc; while (cmNode != null) { if (cmNode.tagName == "SPAN") { if (cmNode.getAttribute("subCM") != null) subCM = cmNode.getAttribute("subCM") + subCM; if (cmNode.getAttribute("CM") != null) break; } cmNode = cmNode.parentElement; } var ceNode = evSrc; while (ceNode != null) { if (ceNode.getAttribute("CE") != null) break; ceNode = ceNode.parentElement; } if (cmNode != null && ceNode != null) { var highlight = "SLIDE SHOW", path = sHref, surl = ""; switch (evSrc.tagName) { case "A": highlight = evSrc.innerText; break; case "IMG": var aTag = evSrc; while (aTag != null) { if (aTag.tagName == "A") { break; } aTag = aTag.parentElement; } highlight = evSrc.alt; break; } if (pd_me.id != '3053415') surl = 'id/' + pd_me.id + '/'; if (highlight.length > 0) highlight = "&HL=" + escape(highlight.substring(0, 60)); sHref = defaultG + destUrl + "/" + path + "&&PS=" + pd_me.ps + "&SU=" + escape(destUrl + '/' + surl) + highlight + "&CM=" + escape(cmNode.getAttribute("CM") + subCM) + "&CE=" + escape(ceNode.getAttribute("CE")); } } } } } if (!bNew) { var xwinopen = window.open(sHref, "slideshow"); } else { var xwinopen = window.open(sHref, "slideshow", sOptions); if (oUser.nn > 3 || oUser.ie > 3) { xwinopen.focus(); } } //s_gs(s_account); }, /// /// Creates try-catch wrapper in a JS object to avoid syntax errors in /// downlevel browsers. /// /// Code to execute that might cause an error /// Code to execute if an error occurs /// JS object with try-catch helper methods. /// /// TODO: CALLER: Insert caller information. /// tryCatch: function(sTry, sCatch) { this.trycatch = new Function("try{" + sTry + "}catch(e){" + sCatch + "}"); this.trycatchV = new Function("s1", "try{" + sTry + "}catch(e){" + sCatch + "}"); }, /// /// Fetches CSS for each colorbox/tease type /// /// id of the WB document containing box-specific CSS /// CSS within a linked stylesheet /// /// TODO: Move away from colorboxes. /// getCSS: function(id) { msnbc.log("addCSS suppressed"); /*if (cssList[id] != true) { document.write(''); cssList[id] = true; }*/ }, /// /// Consolidates browser sniffing code in one JS object. /// /// Not passed, used to check for undefined /// JS object with browser sniffing properties. /// /// TODO: CALLER: Insert caller information. /// TODO: add generic IE class for sub-IE8? /// UberSniff: function(sUndefined) { note("UberSniff"); var ua = navigator.userAgent.toLowerCase(); // Identify specific browser versions this.webtv = (ua.indexOf("webtv") > -1); this.ie = (parseFloat(ua.slice(ua.indexOf("msie") + 5))); this.nn = (this.ie) ? ( - 1) : (parseFloat(ua.slice(ua.indexOf("mozilla/") + 8))); this.mac = (ua.indexOf("mac") > -1); this.firefox = (ua.indexOf("firefox") > -1); this.safari = (ua.indexOf("safari") > -1); // Flash version // TODO: Why use navigator.MSNBCFlashVer? if (navigator.MSNBCFlashVer == sUndefined) { if (this.nn <= 0 && this.ie < 5) { // TODO: Why do we say 6 here? navigator.MSNBCFlashVer = 6; } else { if (!this.mac && this.ie > 4) { var oTestVersion = new tryCatch( "oWMPlayer=new ActiveXObject('ShockwaveFlash.ShockwaveFlash.'+s1);return s1;", "return 0;"); navigator.MSNBCFlashVer = -1; for (var nCheckVersion = 9; nCheckVersion > 2; --nCheckVersion) { if (oTestVersion.trycatchV(nCheckVersion)) { navigator.MSNBCFlashVer = nCheckVersion; break; } } } else { if (navigator.plugins['Shockwave Flash']) { navigator.MSNBCFlashVer = (parseInt(navigator. plugins['Shockwave Flash'].description.substr(16))); } else { navigator.MSNBCFlashVer = -1; } } } } this.flash = navigator.MSNBCFlashVer; // Media Player version // TODO: Is the MSNBCMPlayer boolean or a number? if (navigator.MSNBCMPlayer == sUndefined) { if ((this.nn <= 0 && this.ie < 5) || this.mac) { navigator.MSNBCMPlayer = true; } else { if (!this.mac && this.ie > 4) { var oTestVersion = new tryCatch( "oWMPlayer=new ActiveXObject('WMPlayer.OCX');return oWMPlayer.versionInfo;", "return 0;"); if (oTestVersion.trycatch()) { // TODO: Remove duplicate call to trycatch? navigator.MSNBCMPlayer = oTestVersion.trycatch(); } else { for (itest = 0; itest < 9; ++itest) { oTestVersion = new tryCatch( "oWMPlayer=new ActiveXObject('MediaPlayer.MediaPlayer.'+itest);return 1;", "return 0;"); navigator.MSNBCMPlayer = (oTestVersion.trycatch()); if (navigator.MSNBCMPlayer) { // TODO: Break rather than bump iterator? itest = 100; } } } } else { // TODO: Do we need !! below? navigator.MSNBCMPlayer = !!(navigator.mimeTypes && navigator.mimeTypes["video/x-ms-wm"] && navigator.mimeTypes["video/x-ms-wm"].enabledPlugin); } } } this.mplayer = navigator.MSNBCMPlayer; // Screen resolution this.screenHeight = screen.height; this.screenWidth = screen.width; this.colorDepth = (this.nn >= 4) ? screen.pixelDepth: screen.colorDepth; }, /// /// Launches a popup window with specifed content and options. /// /// URL to launch /// Reuse name for popup window /// Popup window options /// /// TODO: CALLER: Insert caller information. /// Called from lots of random code. /// TODO: Do we still need to set self.name? /// TODO: Can we just use OCW name for this? /// OpenChildWindow: function(sPath, sName, sOptions) { note("OpenChildWindow"); var oUser = new UberSniff(); if (self.name == '') { self.name = "cover"; } // TODO: Remove this code to do pre-WB slideshows? if ((sPath.indexOf("/c/") >= 0 && sPath.toLowerCase().indexOf("ssmain") >= 0)) { var sQry = (sPath.indexOf("?") >= 0) ? "&": "?"; var nW = oUser.screenWidth; sOptions = "resizeable=yes,top=0,left=0,screenx=0,screeny=0,width="; sOptions += (nW >= 1024) ? "935,height=700": "675,height=520"; if (nW < 800) { location.href = sPath.replace(/fmt=child/i, "fmt=") + sQry + "res=inline"; return; } else { sPath += sQry + "res=" + ((nW >= 1024) ? "10x7": "8x6"); } } // Open the window and set focus to it var x = window.open(sPath, sName, sOptions); if (oUser.nn > 3 || oUser.ie > 3) { x.focus(); } }, /// /// Launches a popup window with specifed content and options. /// /// URL to launch /// Reuse name for popup window /// Popup window options /// /// TODO: CALLER: Insert caller information. /// Called from lots of random code. /// TODO: Do we still need to set self.name? /// TODO: Can we just set OCW = OpenChildWindow? /// OCW: function(sPath, sName, sOptions) { note("OCW"); OpenChildWindow(sPath, sName, sOptions); }, /// /// Renders a Flash object appropriately for the user's browser. /// /// JS object with properties describing Flash app /// HTML to write to page for Flash object /// /// Call written by components\Flash.xsl. /// TODO: Are there other callers from CDATA etc? /// TODO: Need to document JS object properties, here or in Flash.xsl. /// TODO: Instrumentation appears to no longer be used. Remove? /// writeFlashComponent2: function(oFl) { note("writeFlashComponent2"); // Create new UberSniff object if necessary if (!window.oSniff) oSniff = new UberSniff(); // Set instrumentation properties // TODO: Properties are set but no longer used. Remove? if (oFl.instrumented) { oFl.instrumentInit(); oFl.instrument.flashVer = oSniff.flash; oFl.instrument.browser = ((oSniff.ie > 0) * 1) + ((oSniff.nn > 0) * 2) + ((oSniff.ie < 1 && oSniff.nn < 1) * 3); oFl.instrument.browserVer = ((oSniff.ie > 0) * oSniff.ie) + ((oSniff.nn > 0) * oSniff.nn); } // Set up default links to Flash download var sReturn; var noFlashLink1 = ""; var noFlashLink2 = "
"; if (oFl.downloadLink == "top" || oFl.downloadLink == "") { noFlashLink1 = ""; noFlashLink2 = ""; } else if (oFl.downloadLink == "crop") { if (!oSniff.flash) { oFl.height = oFl.height - 25; } } // Determine what to write out if Flash is not supported // TODO: Refactor to combine the if/else cases? The 1/default cases? if (oFl.altImgWB3) { switch (oFl.defaultType) { case 1: noFlashLink1 = ""; sReturn = "
" + noFlashLink1 + oFl.altImgWB3 + noFlashLink2 + "
"; break; case 2: sReturn = oFl.altImgWB3; break; case 3: sReturn = oFl.htm; break; default: sReturn = "
" + noFlashLink1 + oFl.altImgWB3 + noFlashLink2 + "
"; } } else { switch (oFl.defaultType) { case 1: noFlashLink1 = "
"; sReturn = "
" + noFlashLink1 + "" + noFlashLink2 + "
"; break; case 2: sReturn = "" + oFl.imageMap; break; case 3: sReturn = oFl.htm; break; default: sReturn = "
" + noFlashLink1 + "" + noFlashLink2 + "
"; } } // Do we have a sufficient version of Flash for this application? if (oSniff.flash >= oFl.flashVer) { // Wrap flashvars to allow for empty values // TODO: Can't we set default of this to empty in flashObj2 below? var flashvars = ""; if (oFl.flashVars) { flashvars = oFl.flashVars; } // Select separator for additional parameters on Flash app name // TODO: Just add the additional parameters here? var sSep = (oFl.flashFile.indexOf("?") > -1) ? "&": "?"; var seamlessTabbing = 'true'; if (oFl.hasOwnProperty('seamlessTabbing') && oFl.seamlessTabbing.toLowerCase() == 'false') seamlessTabbing = 'false'; // Write out correct code for browser if (oSniff.mac || oSniff.nn >= 4 || oSniff.webtv) { // Use EMBED tag on Mac, Netscape/Firefox, and WebTV sReturn = "
"; } else if (oSniff.ie >= 4) { // Use OBJECT tag on Internet Explorer // TODO: Remove newlines from below sReturn = "\n"; sReturn += "\n"; sReturn += "\n"; sReturn += "\n"; sReturn += "\n"; sReturn += "\n"; sReturn += "\n"; sReturn += "\n"; sReturn += "\n"; sReturn += "\n"; sReturn += "\n"; sReturn += "\n"; sReturn += "\n"; sReturn += "\n"; sReturn += "\n"; // Prevent News Menu flyouts from hiding this Flash app if // parameters permit this. // TODO: Can we just set this property on OBJECT tag in HTML? if ((oFl.mode.toLowerCase != "window") && (oSniff.ie >= 5)) { sReturn += "document.getElementById('" + oFl.ID + "').nm_bOk=true;"; } } } return sReturn; }, /// /// Creates an JS object for Flash applications with default values. /// /// JS object for Flash application /// /// Call written by components\Flash.xsl. /// TODO: Can we reduce download size by counting on these defaults? /// TODO: Are some of these parameters no longer used? /// TODO: Instrumentation appears to no longer be used. Remove? /// flashObj2: function() { note("flashObj2"); this.flashFile = "filename.swf"; this.altImg = "http://msnbcmedia.msn.com/i/msnbc/Components/Art/SITEWIDE/no_flash.gif"; this.imageMap = ""; this.defaultType = ""; this.url = ""; this.htm = ""; this.height = "400"; this.width = "520"; this.ID = "dw"; this.downloadLink = "top"; this.webTV = "true"; this.play = "true"; this.loop = "false"; this.quality = "best"; this.scale = "noborder"; this.salign = "LT"; this.menu = "false"; this.deviceFont = "false"; this.mode = "opaque"; this.cabVersion = "4,0,0,0"; this.flashVer = 4; this.notCompatImg = "http://www.msnbc.com/images/msnbc/flash_default.gif"; this.instrumented = false; this.instrumentInit = new Function("sMainSection", "sRefferer", "this.instrument=new instrumentObj(sMainSection,sRefferer,'0fa')"); this.debug = true; this.fullScreen = false; this.seamlessTabbing = 'true'; this.render = new Function("return writeFlashComponent2(this)"); var self = this; this.shim; this.write = function() { if (jQuery&&jQuery.browser.mozilla&&jQuery.fn.flash) { // find the script that created this //$(function() { $('#story script').each(function(i,script) { var search = new RegExp(self.ID); var match = search.exec($(script).text()); if (match) { var embedParams = { width:self.width, height:self.height, id:self.ID, play:self.play, loop:self.loop, fullscreen:self.fullScreen, src:self.flashFile+'?'+window.location.host+'&'+self.flashVars }; var pluginOptions = { version:self.flashVer }; $(script).replaceWith(''); $('#'+self.ID).flash(embedParams, pluginOptions); } }); //}); } else { document.write(this.render()); } }; this.innerWrite = function(destination) { var e = document.createElement("div"); e.innerHTML = this.render(); if (destination.firstChild) { destination.replaceChild(e, destination.firstChild); } else { destination.appendChild(e); } }; }, /// /// Creates a encapsulating Flash instrumentation parameters. /// /// Main section ID, never passed? /// Referrer, never passed? /// Parameter prefix, always 0fa? /// JS object encapsulating parameters /// /// TODO: Instrumentation appears to no longer be used. Remove? /// instrumentObj: function(sMain, sRef, sPrefix) { note("instrumentObj"); this.prefix = sPrefix; this.mainSection = sMain; this.referrer = sRef; this.flashVer = "0"; this.browser = "0"; this.browserVer = "0"; this.os = "0"; // TODO: Is instrumentObj.render used? this.render = new Function( "return this.prefix+'='+this.mainSection+this.referrer+this.flashVer+this.browser+this.browserVer+this.os"); }, // // Cookies // /// /// Parses a value associated with the given key out of cookie. /// /// Key for value to be read from cookie /// Value associated with key in cookie /// /// INTERNAL: Called only from several functions in Std.js. /// TODO: Rename for consistency? /// TODO: May return wrong value if one key is a suffix of an earlier key. /// readCookie: function(ck) { note("readCookie"); var anyCookies = document.cookie; var pos = anyCookies.toUpperCase().indexOf(ck.toUpperCase() + "="); var value = ""; if (pos != -1) { var start = pos + ck.length + 1; var end = anyCookies.indexOf(";", start); if (end == -1) { end = anyCookies.length; } value = anyCookies.substring(start, end); value = unescape(value); } return value; }, /// /// Adds a key-value pair to the cookie, with path and domain handled /// correctly for the live site, and expiration in the distant future. /// /// Key name for new item in cookie /// Value name for new item in cookie /// expire date for the cookie /// /// INTERNAL: Called only from several functions in Std.js. /// TODO: Might we want to allow an optional expiry parameter? /// SetCookie: function(sName, sValue, expDate) { note("SetCookie"); var sExpires; if (expDate == "session") { sExpires = ""; } else { sExpires = ";expires=" + (expDate ? expDate: new Date(2021, 10, 4).toGMTString()); } document.cookie = sName + "=" + escape(sValue) + sExpires + ";path=/" + ((location.host.toLowerCase().indexOf("msnbc.msn.com") >= 0) ? ";domain=msnbc.msn.com": ""); }, // // PAGE DATA // pd_me: {}, // Collects properties of this page defer_pd_om: false, // defer call pd_om for some page still using omniture G code cssList: [], // List of CSS stylesheets already rendered curDoc: null, // DEPRECATED: Id of the current document (use pd_me.id) PSTaxonomy: null, // DEPRECATED: Taxonomy value for Newsweek (use pd_me.ps) //s_msn.pageName, // Omniture: Page name as shown in SiteCatalyst //s_msn.pageType, // Omniture: errorPage if 404, else unused //s_msn.channel, // Omniture: Section name //s_msn.campaign, // Omniture: Not used //s_msn.zip, // Omniture: User's zip, from P2 cookie s_account: undefined, // Omniture: Site account, msnbcom in production //s_visitorSampling, // Omniture: Sampling rate, usually 100 //s_msn.prop1, // Omniture: Not used (was headline) //s_msn.prop2, // Omniture: Not used (was deck) //s_msn.prop3, // Omniture: Byline //s_msn.prop4, // Omniture: Section name s_prop4_orig: undefined, // Omniture: Used for link tracking //s_msn.prop5, // Omniture: Subsection name s_prop5_orig: undefined, // Omniture: Used for link tracking //s_msn.prop6, // Omniture: Subsubsection name s_prop6_orig: undefined, // Omniture: Used for link tracking //s_msn.prop7, // Omniture: Layout (template name, handheld, etc.) //s_msn.prop8, // Omniture: Is user personalized (Y/N) //s_msn.prop9, // Omniture: User's zip, from P2 cookie //s_msn.prop10, // Omniture: Connection speed (from MSN Video) //s_msn.prop11, // Omniture: Stock choices, from P1 cookie //s_msn.prop12, // Omniture: Weather choices, from P1 cookie //s_msn.prop13, // Omniture: Local News choice, from P1 cookie / from Stid(Station id) cookie for NBC sports //s_msn.prop14, // Omniture: Sports choices, from P1 cookie //s_msn.prop15, // Omniture: Document ID (Phase 2) //s_msn.prop16, // Omniture: DocType, or external page type (Phase 2) s_prop16_orig: undefined, // Omniture: Used for link tracking //s_msn.prop17, // Omniture: Search terms (Phase 2) //s_msn.prop18, // Omniture: Hour updated (Phase 2) //s_msn.prop19, // Omniture: Local affiliate of page (Phase 2) //s_msn.prop20, // Omniture: Tracking of From (Phase 2) //s_msn.prop21, // Omniture: Tracking of From RS (Phase 2) //s_msn.prop22, // Omniture: Tracking of From RL (Phase 2) //s_msn.prop23, // Omniture: Tracking of From RSS (Phase 2) //s_msn.prop24, // Omniture: Tracking of From ET (Phase 2) //s_msn.prop26, // Omniture: Tracking of the "Name" field of the Source document //s_msn.prop27, // Omniture: Tracking of link location (autobox, databox, tabbox) //s_msn.prop28, // Omniture: Tracking of "dst" in the query string //s_msn.prop30, // Omniture: Tracking Domain Consolidation (Phase 2) //s_msn.prop31, // Omniture: Tracking of "ocid" in the query string //s_msn.prop33, // Omniture: Tracking of From Radio (Phase 2) //s_msn.prop35, // Omniture: Partner Wrapper Name //s_msn.prop39, // Omniture: Flyout user setting //s_msn.prop41, // Omniture: Tracking "AVERAGE RATING | NUMBER OF RATINGS" //s_msn.eVar1, // Omniture: Tracking of From (Phase 2) //s_msn.eVar2, // Omniture: Tracking of From RS (Phase 2) //s_msn.eVar3, // Omniture: Tracking of From RL (Phase 2) //s_msn.eVar4, // Omniture: Tracking of From RSS (Phase 2) //s_msn.eVar5, // Omniture: Tracking of From ET (Phase 2) //s_msn.eVar39; // Omniture: Tracking of From MSN Referrer /// Called at the top of each page to initialize page data and other /// constructs for client-side JavaScript code. /// /// DocType, or external page type /// Device name (html40, msntv, handheld) /// Document ID /// Headline /// Description (aka Abstract) /// Section /// Subsection /// Subsubsection /// Page number, if available /// Page count, if appropriate /// Last update time, as 'hh:mm, dd/mm/yy' in ET (24h) /// Byline, without 'By ' prefix /// Layout name /// Affiliate name, on local pages /// Email promo text for Email This /// ID of Section Navigation /// PS Taxonomy value /// Partner wrapper Name (for NFN) /// News menu default setting /// tv Tags Count /// Adpackage Object /// request Site Name, as "MSNBC", "Today", etc. /// Link Tracking enabled /// the "Name" field of the Source document /// subsubSubSection /// subsubsubSubSection /// request Site Name /// /// The call to this function is usually inserted by BodyTop in /// SectionDescription.xsl. May also be called from non-Workbench pages. /// Unused values can be passed as '' or undefined if a placeholder is needed. /// TODO: Create UberSniff object here? /// pd_top: function(dt, dv, id, h, d, s, ss, sss, pn, pc, t, b, l, af, ep, sn, ps, pw, nd, tvc, adp, snm, olt, sc, ssss, sssss, sitename) { note("pd_top"); // Set up pd_me with values passed in, pd_me may be instanted and filled at other places, so don't remove the if(pd_me==null), by v-starli@microsoft.com 2007/2/13 if (pd_me == null) pd_me = new Object; pd_me.dt = dt; pd_me.dv = pd_str(dv); pd_me.id = curDoc = pd_str(id); pd_me.h = pd_str(h); pd_me.d = pd_str(d); pd_me.s = pd_str(s); pd_me.ss = pd_str(ss); pd_me.sss = pd_str(sss); if (ssss != null) pd_me.ssss = pd_str(ssss); else pd_me.ssss = ''; if (sssss != null) pd_me.sssss = pd_str(sssss); else pd_me.sssss = ''; if (sitename != null) pd_me.site = sitename; else pd_me.site = ''; /// pd_me.site = "MSNBC"; /// pd_me.pn = pd_str(pn); pd_me.pc = pd_str(pc); pd_me.t = pd_str(t); pd_me.b = pd_str(b); pd_me.l = pd_str(l); pd_me.af = pd_str(af); pd_me.ep = pd_str(ep); pd_me.sn = pd_str(sn); pd_me.ps = PSTaxonomy = pd_str(ps); pd_me.pw = pd_str(pw); pd_me.nd = pd_str(nd); pd_me.tvc = tvc; pd_me.snm = pd_str(snm); pd_me.olt = (olt == 'true'); pd_me.sc = pd_str(sc); //adpackage and encapsulated dap call if (null != adp) { pd_me.adp = adp; pd_me.adp.dap = function(adpS) { var adpO = adp[adpS]; if (adpO && adpO.AdGroup && (typeof(dap) == "function")) { dap("&PG=" + adpO.AdGroup + "&AP=" + adpO.AdSizeCode, adpO.Width, adpO.Height); return true; } return false; }; } // Get values from personalization cookies var p1r = readCookie('P1'); var p2r = readCookie('P2'); pd_me.p1 = (p1r + '|||||||||||').split('|'); pd_me.zip = ((p2r.length > 8) && (p2r.substring(0, 4) == 'pi6=')) ? p2r.substring(4, 9) : ''; // Derived: nw true for Newsweek pages pd_me.nw = location.href.indexOf('/site/newsweek') > 0; // Derived: su is site suffix pd_me.su = (pd_me.nw) ? '/site/newsweek': ''; // Derived: isF true for Front pages pd_me.isF = (pd_me.dt == 'Front'); // Derived: isS true for Story/Tools/Handbuilt pages pd_me.isS = ((dt == 'Story') || (dt == 'ToolsHandbuilt')); // Forward: isRp is true for Related Photos pages pd_me.isRp = false; // Other page initialization for html40 device if (dv == 'html40') { // Initialize list of tabs for Most Popular boxes pop_tabBoxes = new Array(); // Add OnLoad hook for next story box pd_me.onlNext = window.onload; window.onload = pd_onl; } // Add stories to IPN / Recommended Stories history /* CH remove - not clear we're using this functionality any more if (pd_me.isS) add_history(pd_me.id, pd_me.sn); */ // Specify a default Omniture account so we can detect when there's no tracking s_account = ''; if (location.href.indexOf('from=rss') > -1) SetCookie("FROMRSS", "true"); //Check for MSN Referrer, and set cookie. var ref = document.referrer; if (ref.indexOf('msn.com') > -1) { if (ref.indexOf('msnbc') < 0) { SetCookie("FROMMSN", "true", "session"); //document.cookie = "FROMMSN=true"; } } // add document onclick event to capture omniture data /** REMOVED BY if (pd_me.olt) { if (document.addEventListener) //Firefox model document.addEventListener('click', linkTrackHandler, false); else if (document.attachEvent) //IE model document.attachEvent('onclick', linkTrackHandler); } */ // add new case for Related Photos - today domain if (snm == "MSNBC" || (snm == "Today" && s == "Related Photos")) BrowserDetect.init(); pd_me.nsa = readCookie('STID'); //nbc sports station id pd_me.nsl = (pd_me.nsa == '' ? 'N': 'Y'); //nbc sports localized // CH: moved into pd_top // TODO: INLINE: Move into pd_top? if (document.cookie.indexOf("TZM=") == -1) { // TODO: Is parseInt necessary here? Why 0-x rather than -x? SetCookie("TZM", parseInt(0 - (new Date().getTimezoneOffset()))); } }, /// /// Called at the top of Related Photos pages to set up parameters for /// Omniture. /// /// Document ID from related story /// Headline from related story /// Section from related story /// Subsection from related story /// Document ID from related photo /// Photo number /// Photo count /// /// The pd_top function must be called before this function. /// The call to this function is inserted by BodyTop in /// SectionDescription.xsl when a Related Photos component exists. /// pd_rp: function(rsId, rsH, rsS, rsSs, rpId, phn, phc, layo) { note("pd_rp"); // Extend pd_me with values passed in pd_me.rsId = rsId; pd_me.rsH = rsH; pd_me.rsS = rsS; pd_me.rsSs = rsSs; pd_me.rpId = rpId; pd_me.phn = phn; pd_me.phc = phc; // fix bug 10048, add value from input layout pd_me.s = "Related Photos"; //s_prop4 pd_me.l = (layo == 'Photo-L') ? layo: 'Photo-R'; //s_prop7 pd_me.dt = (layo == 'Photo-L') ? layo: 'Photo-R'; //s_prop16 pd_me.pw = phn + "|" + phc; //s_prop35 // Set related photos flag pd_me.isRp = true; }, /// /// Called at the top of each page to set up parameters for Omniture. /// /// Account, usually 'msnbcdev' or 'msnbcom' /// Sampling rate, usually 100 /// /// The pd_top function must be called before this function. /// The call to this function is usually inserted by BodyTop in /// SectionDescription.xsl. May also be called from non-Workbench pages. /// pd_om: function(a, s) { note("pd_om"); // Set up base Omniture values s_account = a; if (typeof(s_msn) == "undefined" || s_msn == null) { defer_pd_om = true; return; } //s_visitorSampling = s; s_msn.pageName = ''; s_msn.campaign = ''; s_msn.zip = pd_me.zip; // Set up basic properties s_msn.prop3 = pd_nou(pd_me.b); s_msn.prop4 = pd_nou(pd_me.s); s_prop4_orig = pd_nou(pd_me.s); s_msn.prop5 = pd_nou(pd_me.ss); s_prop5_orig = pd_nou(pd_me.ss); s_msn.prop6 = pd_nou(pd_me.sss); s_prop6_orig = pd_nou(pd_me.sss); s_msn.prop7 = pd_me.l; //CNBC Omniture Settings if (s_account == "CNBCOmnitureAccount") { s_msn.prop8 = "cnbc"; s_msn.prop9 = "cnbc.com"; s_msn.prop10 = pd_nou((pd_me.dt == 'Cagle') ? pd_me.dt: pd_me.s); //For Cagle, we want channel to be doctype ('Cagle') instead of section name s_msn.channel = "free:CNBC.com"; } else { s_msn.prop8 = (pd_me.p1[0] != '') ? 'Y': 'N'; s_msn.prop9 = pd_me.zip; s_msn.prop10 = readCookie('CP'); s_msn.channel = pd_nou((pd_me.dt == 'Cagle') ? pd_me.dt: pd_me.s); //For Cagle, we want channel to be doctype ('Cagle') instead of section name } s_msn.prop11 = pd_me.p1[6]; s_msn.prop12 = pd_me.p1[2]; s_msn.prop13 = pd_me.p1[5]; s_msn.prop14 = pd_me.p1[11]; s_msn.prop15 = pd_me.id; s_msn.prop16 = pd_me.dt; s_prop16_orig = pd_me.dt; s_msn.prop19 = pd_me.af; s_msn.prop26 = pd_me.sc; var tOREF = readCookie("OREF"); if (pd_me.h != 'Page not found') { s_msn.prop30 = tOREF; } document.cookie = "OREF=" + tOREF + ";path=/;expires=" + new Date(1900, 1, 1).toGMTString(); s_msn.prop27 = readCookie('lt'); s_msn.prop28 = pd_bet(location.href, 'dst=', '&', 'true'); s_msn.prop31 = pd_bet(location.href, 'ocid=', '&', 'true'); s_msn.prop35 = pd_me.pw; s_msn.prop46 = pd_me.tvc; if (pd_me.site == "NBCSPORTS") { s_msn.prop13 = readCookie('STID'); s_msn.prop8 = (s_msn.prop13 != '') ? 'Y': 'N'; } // clear cookie var date = new Date(); date.setTime(date.getTime() - 120000); SetCookie('lt', '', date.toGMTString()); // Get flyout user setting var nm = readCookie("NM"); if (nm.length == 0) { s_msn.prop39 = pd_me.nd == '1' ? "ON": "OFF"; } else { switch (nm) { case '1': s_msn.prop39 = 'ON'; break; case '0': s_msn.prop39 = 'OFF'; break; case '1|0': s_msn.prop39 = 'ON|OFF'; break; case '0|1': s_msn.prop39 = 'OFF|ON'; break; default: break; } } // Populate evar39 if FROMMSN = true in the cookie var msnRefer = readCookie("FROMMSN"); if (msnRefer == "true") { s_msn.eVar39 = "msn referrer"; } // Get search terms from referrer var ref = document.referrer, st = ''; if ((ref.indexOf('http://search.msn.com/') == 0) && (ref.indexOf('id=3053419') > 0)) { if (ref.indexOf('search=MSNBC') > 0) { st = 'MSNMSNBC|' + pd_une(pd_bet(ref, '&q=', '+site%3A')); } else { st = 'MSN|' + pd_une(pd_bet(ref, '&q=', '&')); } } else if (ref.indexOf(location.host + '/Apps/Search/ArchiveResults.aspx?id=3053419') > 0) { st = 'MSNBC|' + pd_bet(ref, '&qt=', ''); } else if (ref.indexOf(location.host + '/?search') > 0) { st = 'MSNBC|' + pd_bet(ref, '&q=', ''); st = (st.indexOf('&') > 0) ? st.substring(0, st.indexOf('&')) : ''; } if (st != '') s_msn.prop17 = pd_nou(st); // Get hour property from updated time if (pd_me.t.length > 2) s_msn.prop18 = pd_me.t.substring(0, 2); // Get from properties/events from query string var f1 = pd_bet(location.href, '/from/', '/'); if (f1 != '') { var f2 = pd_me.id + '|from|' + f1.replace('.', '|'); s_msn.prop20 = f2; s_msn.eVar1 = f2; switch (f1.split('.')[0]) { case 'RS': // Recommended stories (IPN) s_msn.prop21 = f2; break; case 'RL': // Related stories (Relevance) s_msn.prop22 = f2; break; case 'RSS': // RSS s_msn.prop23 = f2; break; case 'ET': // Email This s_msn.prop24 = f2; break; case 'radio': // RSS s_msn.prop33 = f2; break; } } // Adjust doc type to page type for Omniture purposes var pt = pd_me.dt; if (pd_me.isRp) pt = (pd_me.l == 'Photo-L') ? pd_me.l: 'Photo-R'; // Implement doctype-specific business rules for pageName, etc. switch (pt) { case 'Error': // Error (404) page tracking s_msn.pageType = "errorPage"; break; case 'Photo-R': case 'Photo-L': // Related Photos s_msn.pageName = pt + '|' + pd_nou(pd_me.rsS.substring(0, 10)) + (pd_me.site != "MSNBC" ? '|' + pd_nou(pd_me.rsSs.substring(0, 10)) : '') + '|' + pd_me.rsId + '|' + pd_nou(pd_me.rsH.substring(0, 50)); s_msn.prop16 = pt; s_msn.prop35 = pd_me.phn + '|' + pd_me.phc; break; // Recipe doc page case 'Recipe': s_msn.pageName = pd_nou(pd_me.s.substring(0, 10)) + (pd_me.site != "MSNBC" ? '|' + pd_nou(pd_me.ss.substring(0, 10)) : '') + '|' + pd_me.id + '|' + 'Recipe ' + pd_nou(pd_me.h.substring(0, 50));; break; case 'Slideshow': if (parseInt(pd_me.pn) > 0) s_msn.prop35 = 'p' + pd_me.pn; else { s_msn.prop35 = '#' + ((pd_bet(location.href, '#', '', 'true').length > 0) ? pd_une(pd_bet(location.href, '#', '', 'true')) : 'slide=1'); } s_msn.pageName = pd_me.dt + '|' + pd_nou(pd_me.s.substring(0, 10)) + (pd_me.site != "MSNBC" ? '|' + pd_nou(pd_me.ss.substring(0, 10)) : '') + '|' + pd_me.id + ((pd_me.id == '8903108') ? ('|' + pd_une(pd_bet(location.href, 'qt=', '&', 'true')).replace(/\|/g, ' ')) : '') + '|' + pd_nou(pd_me.h.substring(0, 50)); break; case 'Fun': s_msn.channel = 'Fun'; var sPage = ''; var FunP = new RegExp("sFile=(\\D*)(\\d*)"); var nset = { "ftr": "Trivia", "fcx": "Crossword", "uj": "Jigsaw", "sudoc": "Sudoku", "co": "Checkout", "nt": "Nile Tiles", "ps": "Poker Solitaire" }; var result = FunP.exec(location.href); if (result != null) { s_msn.prop15 = result[1] + result[2]; if (nset[result[1]] != null) { s_msn.prop5 = nset[result[1]]; sPage = ((s_msn.prop5 != 'Crossword') ? (s_msn.prop5) : 'DailyCrossword'); } else { s_msn.prop5 = 'Comics'; sPage = 'Entertainment ' + s_msn.prop15; } } else { s_msn.prop15 = ''; sPage = 'Comics,Sudoku,Puzzle front'; } s_msn.prop35 = s_msn.prop15 + '|' + sPage; s_msn.pageName = pd_me.dt + '|' + s_msn.prop4 + '|' + s_msn.prop5; break; case 'SportsTools': s_msn.channel = 'SportsTools'; s_msn.prop4 = 'Sports'; s_msn.prop5 = 'Scores/Sched'; var url = location.href; var SptRet = /([^\/]*)\.(?:asp\?|html|asp)(?:frames=\w*)?/i.exec(url); if (SptRet != null) { var sport = /[&|?]sport=(\w*)/i.exec(url); var cat = /&cat=(\w*)/i.exec(url); var team = /&team=(\w*)/i.exec(url); var player = /&player=(\w*)/i.exec(url); var rank = /&rank=(\w*)/i.exec(url); var format = /&format=(\w*)/i.exec(url); s_msn.prop35 = SptRet[1] + '|' + ((sport == null) ? '': sport[1]) + '|' + ((cat == null) ? '': cat[1]) + '|' + ((team == null) ? '': team[1]) + '|' + ((player == null) ? '': player[1]) + '|' + ((rank == null) ? '': rank[1]) + ((format == null) ? '': format[1]); } s_msn.pageName = pd_me.dt + '|' + s_msn.prop4 + '|' + s_msn.prop5; break; default: // Story, Tools/Handbuilt, Front, and Cagle tracking var pn = ''; if (parseInt(pd_me.pn) > 0) pn = 'p' + pd_me.pn; else if (pd_me.dt == 'Cagle') pn = pd_me.pn; //For Cagle, set pn to page name if page name couldn't be parsed as int. s_msn.pageName = ((pd_me.dt == 'ToolsHandbuilt') ? 'HandTool': pd_me.dt) + '|' + pd_nou(pd_me.s.substring(0, 10)) + (pd_me.site != "MSNBC" ? '|' + pd_nou(pd_me.ss.substring(0, 10)) : '') + '|' + pd_me.id + ((pd_me.id == '8903108') ? ('|' + pd_une(pd_bet(location.href, 'qt=', '&', 'true')).replace(/\|/g, ' ')) : '') + '|' + pd_nou(pd_me.h.substring(0, 50)); s_msn.prop35 = pn; break; } s_msn.pageName = s_msn.pageName.toLowerCase(); // Check if weird case (all underscores or start with 5 underscores) happens var reg = /\|((.*_____.*)|(_+))\|/; if (reg.test(s_msn.pageName)) s_msn.pageName = pt + "|Other"; $O.G.Init(); //Gerry Initialization call }, /// /// Consolidated window.onload method for all of Std.js /// /// /// INTERNAL: event hooked by pd_top. /// Currently only called for html40 device. /// There were three different onload functions across Std.js which /// were hooked and chained differently; this caused PS 5244 on /// consolidation because of the evil of multiple Std.js references /// from a single page. /// pd_onl: function() { note("pd_onl"); // Former nxtStoryLoad // Firefox float issue workaround for byline components /* CH REMOVE - will fix with css or won't include byline in v2 if (pd_me.isS) moveByline(); */ // Former /id/7181974 // Show tabs in any Most Popular boxes /* CH REMOVE - Not tabs pop_ShowTabs(); //Check both boxes available boxMove("bba","bb1","bb2"); boxMove("bbb","bb3","bb4"); // Former nmjs07.js if (nm_nIE) nm_done(); */ // Chain to previous event handler if (pd_me.onlNext != null) pd_me.onlNext(); /*CH REMOVE //hide frames with no ads in it, and change the sponsor ad title if there is any, by v-starli@microsoft.com 2007/2/15 HideAdFramesAndChangeTitles(); renderTimestampIcon(); */ }, /// /// Helper function that returns the part of string s after string a and /// before string b. /// /// String to look in /// String that precedes our target /// String that follows our target /// String in s between a and b /// /// INTERNAL: called only from within Std.js. /// pd_bet: function(s, b, a, r) { note("pd_bet"); var i = s.indexOf(b); if (i < 0) return ''; s = s.substring(i + b.length, s.length); if (a == '') return s; i = s.indexOf(a); if (r == 'true') { return (i > 0) ? s.substring(0, i) : s; } else { return (i > 0) ? s.substring(0, i) : ''; } }, /// /// Helper function that converts its argument into a string, handling /// undefined values. /// /// Object to convert /// Value of object as a string, or '' if undefined /// /// INTERNAL: called only from within Std.js. /// pd_str: function(o) { note("pd_str"); return (typeof(o) == 'undefined') ? '': '' + o; }, /// /// Helper function that unescapes strings from URLs /// /// String to unescape /// String unescaped for normal use /// /// INTERNAL: called only from within Std.js. /// pd_une: function(s) { note("pd_une"); return unescape(s.replace(/\+/g, ' ')); }, /// /// Helper function that escapes strings /// /// String to escape /// String escaped for URL use /// /// INTERNAL: called only from within Std.js. /// pd_esc: function(s) { note("pd_esc"); return escape(pd_nou(s)); }, /// /// light version of pd_nou, won't strip character with accent /// /// String to fix up /// String fixed up with no Unicode characters /// /// INTERNAL: called only from within Std.js. /// pd_noul: function(s) { note("pd_noul"); return s.replace(/\u2013/g, '-').replace(/\u2014/g, '-').replace(/\u2018/g, '\'').replace(/\u2019/g, '\'').replace(/\u201C/g, '"').replace(/\u201D/g, '"'); }, /// /// Helper function that removes Unicode chars from strings /// /// String to fix up /// String fixed up with no Unicode characters /// /// INTERNAL: called only from within Std.js. /// pd_nou: function(s) { note("pd_nou"); return pd_noul(s).replace(/[^\x20-\x7F]/g, '_'); }, /// /// Hyperlink tracking function /// /// Area that Link is located in /// Colorbox or Image that link is in. /// e for exit, o for custom, d for download (not used) /// Position of Link in link list, and total # of links (i.e. 1|5) /// value of text, if image then it will be the alt text /// Link being click on /// submits the link values to omniture /// pd_onc: function(area, module, linkType, linkPos, textVal, obj) { note("pd_onc"); // Only do click tracking if Omniture code exists on this page if (typeof(s_account) != "undefined" && s_account != '' && typeof(s_msn) != "undefined") { s_msn.prop48 = area; s_msn.prop49 = s_msn.channel; s_msn.prop50 = module; if (area == 'Related Stories') { s_msn.prop20 = pd_me.id + '|from|RL|' + linkPos; s_msn.prop22 = s_msn.prop20; } if (area == 'Recommended Stories') { s_msn.prop20 = pd_me.id + '|from|RS|' + linkPos; s_msn.prop21 = s_msn.prop20; } s_msn.tl(this, linkType, area + '|' + s_msn.channel + '|' + module + '|' + linkPos + '|' + textVal); } }, // ratings pd_rr: function(ct, ii, it, ai, key, hc, usrR, totalU) { if (!pd_me) return; pd_me.ct = ct; pd_me.ii = ii; pd_me.it = it; pd_me.ai = ai; pd_me.key = key; pd_me.hc = hc; pd_me.rated = false; pd_me.usrRating = usrR; pd_me.totalUsers = totalU; if (typeof(s_msn) != "undefined") { s_msn.prop41 = usrR + "|" + totalU; } }, DateTime: function() { note("DateTime"); var ma = ["Jan", "Feb", "March", "April", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"]; var wa = ["Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat"]; var za = ["ET", "CT", "MT", "PT", "AKT", "HT", "HT"]; this.D2S = function(d, f) { var r = "updated "; if (f) { var c = new Date(); var m = parseInt(((c - d) / 1000) / 60); if (m == 0) { return r + "less than 1 minute ago"; } else if (m < 180 && m > 0) { return r + M2S(m); } } return r + "" + GetT(d) + " " + this.GetTZ(d) + ", " + GetD(d) + ""; }; var M2S = function(m) { var r = ""; if (m > 59) { var h = parseInt(m / 60); m = m - (h * 60); r = h + " hour" + ((h > 1) ? "s": "") + ((m > 0) ? ", ": ""); } return r += ((m > 0) ? (m + " minute" + ((m > 1) ? "s": "")) : "") + " ago"; }; var T2M = function(t) { return parseInt((t - 621355968000000000) / 10000); }; this.T2D = function(t) { return new Date(T2M(t)); }; var GetT = function(d) { var h = d.getHours(); var m = d.getMinutes(); return ((h < 13) ? ((h == 0) ? 12: h) : (h - 12)) + ":" + ((m < 10) ? "0" + m: m) + " " + ((h < 12) ? "a.m.": "p.m."); }; var GetD = function(d) { var m = wa[d.getDay()] + "., " + ma[d.getMonth()] + ". " + d.getDate() + ", " + d.getFullYear(); return m; }; this.GetTZ = function(d) { var o = d.getTimezoneOffset() / 60; var st = (d.toString().lastIndexOf("ST") > -1 || d.toString().lastIndexOf("Standard Time") > -1) ? 5: 4; return (o <= 10 && o >= st) ? za[o - st] : false; }; }, /// ALBERT'S OLD OMNITURE linkTrackHandler: function(e) { /** CH REMOVED var target; var targetNodename; var doLinkTrack = false; if (!e) var e = window.event; if (e.target) target = e.target; // mozilla else if (e.srcElement) target = e.srcElement; // ie if (target) { var bVideo = false; switch (target.nodeName.toUpperCase()) { case "A": doLinkTrack = true; if (target.getAttribute('href').indexOf('msnvDwd(') != -1) {bVideo = true;} break; case "TD"://newsmenu button cells if(target.firstChild) { target = target.firstChild; } if(target.nodeName.toUpperCase()=='A') { doLinkTrack = true; if (target.getAttribute('href').indexOf('msnvDwd(') != -1) {bVideo = true;} } break; case "AREA": doLinkTrack = true; if (target.getAttribute('href').indexOf('msnvDwd(') != -1) {bVideo = true;} break; case "IMG": if (target.parentNode && target.parentNode.nodeName.toUpperCase() == "A") { doLinkTrack = true; if (target.parentNode.getAttribute('href').indexOf('msnvDwd(') != -1) {bVideo = true;} } break; case "INPUT": if (target.getAttribute('type') && target.getAttribute('type').toUpperCase() == "BUTTON") { doLinkTrack = true; if (target.getAttribute('onclick').toString().indexOf('msnvDwd(') != -1) {bVideo = true;} } break; default: doLinkTrack = false; } } if (doLinkTrack) { var ltData = getLinkTrackData(target); if (ltData) { bVideo? s_msn.prop27 = ltData:SetCookie('lt',ltData); } } */ }, getLinkTrackData: function(target) { /* CH REMOVED note("getLinkTrackData"); var ct, cn, pn = null, node = target; // wipe any previous omniture cookie var date = new Date(); date.setTime(date.getTime() - 120000); SetCookie('lt', '', date.toGMTString()); // crawl up dom until 'control type' property is found while (node) { if (node.getAttribute && node.getAttribute('ct')) { if (ct && !pn) { // we already got component type from // a previous node, but project name // is still empty. in this case set // the project name to this newfound // component type pn = node.getAttribute('ct'); break; } else if (!ct) // we're finding a node for the first time { ct = node.getAttribute('ct'); cn = node.getAttribute('cn').substring(0,30); pn = node.getAttribute('pn'); if (pn) { pn = pn.substring(0,15); break; } } } node = node.parentNode; } if (ct) return Omni.LinkTrack.GetDoctype() + '|' + Omni.LinkTrack.GetSection() + '|' + pn + '|' + ct + '|' + cn; */ }, // CH: wrapped this stuff in single object definition Omni: { NewsMenu: { ProjectName: '', Top: '', FirstHeadline: '', FirstFront: '', SecondHeadline: '', ExpandFront: '', ExpandHeadline: '' }, LinkTrack: { /// /// Omniture link track onclick handler for news menu flyout links /// Process linkTrackHandler function and stop event bubble /// /// /// /// OnclickHandler: function(e) { note("OnclickHandler"); if (e) { linkTrackHandler(e); //stop the event bubble up if (e.target) { e.stopPropagation(); //dom/firefox } else if (e.srcElement) { e.cancelBubble = true; //ie } } }, ///// /// LinkTrack.GetDoctype method, returns doc type string /// GetDoctype: function() { note("GetDoctype"); if (s_prop16_orig) { return s_prop16_orig.substring(0, 15); } return ''; }, ///// /// LinkTrack.GetSection method, returns section string /// Determines whether link is from section, sub-section, or sub-sub-section. /// GetSection: function() { note("GetSection"); ///trims the section to 15 characters function TrimSection(str) { if (str) { return str.substr(0, 15); } return ''; } ///Determine section type if (s_prop6_orig) { return TrimSection(s_prop6_orig); } else if (s_prop5_orig) { return TrimSection(s_prop5_orig); } else { return TrimSection(s_prop4_orig); } } } // end .LinkTrack }, // end Omni getTimestampTitle: function(currencyDate) { note("getTimestampTitle"); var time = Math.floor((new Date().getTime() - new Date(parseInt((currencyDate - 621355968000000000) / 10000)).getTime()) / (60 * 1000)); var alt = 'Updated'; if (time > 0) { alt += ' '; var d = Math.floor(time / 1440); var h = Math.floor(time % 1440 / 60); var m = Math.floor(time % 60); if (d == 1) { alt += d + ' day'; } else if (d > 1) { alt += d + ' days'; } if (h == 1) { if (d > 0) { alt += ', '; } alt += h + ' hour'; } else if (h > 1) { if (d > 0) { alt += ', '; } alt += h + ' hours'; } if (m == 0) { if (d == 0 && h == 0) { alt += 'less than 1 minute ago'; } else { alt += ' ago'; } } else if (m == 1) { if (d > 0 || h > 0) { alt += ', '; } alt += m + ' minute ago'; } else { if (d > 0 || h > 0) { alt += ', '; } alt += m + ' minutes ago'; } } return alt; }, BrowserDetect: { init: function() { note("BrowserDetect.init"); this.browser = this.searchString(this.dataBrowser) || "unknown browser"; this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "unknown version"; this.OS = this.searchString(this.dataOS) || "unknown OS"; document.getElementsByTagName("body")[0].className = BrowserDetect.OS + " " + BrowserDetect.browser + " " + BrowserDetect.browser + "-" + Math.floor(BrowserDetect.version) + " " + BrowserDetect.OS + "-" + BrowserDetect.browser; }, searchString: function(data) { note("BrowserDetect.searchString"); for (var i = 0; i < data.length; i++) { var dataString = data[i].string; var dataProp = data[i].prop; this.versionSearchString = data[i].versionSearch || data[i].identity; if (dataString) { if (dataString.indexOf(data[i].subString) != -1) return data[i].identity; } else if (dataProp) return data[i].identity; } }, searchVersion: function(dataString) { note("BrowserDetect.searchVersion"); var index = dataString.indexOf(this.versionSearchString); if (index == -1) return; return parseFloat(dataString.substring(index + this.versionSearchString.length + 1)); }, dataBrowser: [ { string: navigator.vendor, subString: "Apple", identity: "Safari" }, { prop: window.opera, identity: "Opera" }, { string: navigator.userAgent, subString: "Firefox", identity: "Firefox" }, { string: navigator.userAgent, subString: "Netscape", identity: "Netscape" }, { string: navigator.userAgent, subString: "MSIE", identity: "IE", versionSearch: "MSIE" }, { string: navigator.userAgent, subString: "Gecko", identity: "Mozilla", versionSearch: "rv" }, { string: navigator.userAgent, subString: "Mozilla", identity: "Netscape", versionSearch: "Mozilla" } ], dataOS: [ { string: navigator.platform, subString: "Win", identity: "Win" }, { string: navigator.platform, subString: "Mac", identity: "Mac" }, { string: navigator.platform, subString: "Linux", identity: "Linux" } ] }, // GRIDS gridList: [], //adds grid to list of grids that need their height checked addGrid: function(gridName) { note("addGrid"); if (gridList == null) gridList = new Array(); gridList[gridName] = gridName; }, getQueryVariable: function(variable) { note("getQueryVariable"); var query = window.location.search.substring(1); var vars = query.split("&"); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } return ""; } }); // CH refactored to class definition //Generic Hashtable Object $utils.Hashtable = Class.extend({ init: function() { note("Hashtable.init"); this.keys = []; this.values = []; }, //Public Clear Function // - Reset all keys and values Clear: function() { this.keys = new Array(); this.values = new Array(); }, //Public Get Function // - Retrieve a value for a specific key Get: function(key) { try { return (this.values[key]); } catch(e) { return null; } }, //Public Set Function // - Assign and store a value to a specified key Set: function(key, value) { if (key && value) { if (this.values[key] == null) { this.keys[this.keys.length] = key; } this.values[key] = value; } }, //Public Remove Function // - Remove: function(key) { for (var i = 0; i < this.keys.length; i++) { if (key == this.keys[i]) { //remove key from the hash this.values[this.keys[i]] = null; this.keys.splice(i, 1); return; } } }, //Public ContainsKey Function // - Check to see if a specified key exists ContainsKey: function(key) { return (this.Get(key) != null); }, //Public Size Funtion // - Returns the number of key/value pairs in the collection Size: function() { return this.keys.length; } }); // ------GLOBAL SCOPE EXPORT-------- var toGlobal = {}; if (exportToGlobal) { if (exportToGlobal.length) { jQuery.each(exportToGlobal, function() { toGlobal[this] = $legacy[this]; }); } else { jQuery.extend(toGlobal, $legacy); } toGlobal["Hashtable"] = $utils.Hashtable; } // return this object from the closure, effectively: jQuery.extend(window, toGlobal) return toGlobal; })()); // END outer $.extend(); }; msnbc.utils.activateLegacySupport(false, true);