﻿if(!window.Csp) window.Csp = {}; Csp.StringBuilder = function(value) { this.strings = new Array(); this.append(value); }; Csp.StringBuilder.prototype = { append: function(value) { if(value) this.strings.push(value); }, toString: function() { return this.strings.join(""); } }; Csp.Lsp = function(closeNormalImg, closeHoverImg, addNormalImg, addHoverImg, delayShow, delayHide, nextShow, repeatShow) { this.closeNormalImage = closeNormalImg; this.closeHoverImage = closeHoverImg; this.addNormalImage = addNormalImg; this.addHoverImage = addHoverImg; this.delayShow = delayShow; this.delayHide = delayHide; this.nextShow = nextShow; this.repeatShow = repeatShow; }; Csp.Lsp.searchProviderUrl = "http:/" + "/www.live.com/live/search/search.xml"; Csp.Lsp.cookieStI = "stI"; Csp.Lsp.cookieStUA = "stUA"; Csp.Lsp.cookieEnabled = true; Csp.Lsp.startWidth = 350; Csp.Lsp.startHeight = 110; Csp.Lsp.startOpacity = 0.1; Csp.Lsp.widthChange = 10; Csp.Lsp.heightChange = 4; Csp.Lsp.opacityChange = 0.1; Csp.Lsp.width = 423; Csp.Lsp.height = 133; Csp.Lsp.opacity = 1; Csp.Lsp.animationInterval = 30; Csp.Lsp.prototype.closeTileTimerId; Csp.Lsp.prototype.openTileTimerId; Csp.Lsp.prototype.addButtonTimerId; Csp.Lsp.prototype.tempWidth = 0; Csp.Lsp.prototype.tempHeight = 0; Csp.Lsp.prototype.tempOpacity = 0; Csp.Lsp.prototype = { setTileElementDisplay: function(e, display) { var c = $("lspClose"); if(c) { c.style.display = display; } var a = $("lspAdd"); if(a) { a.style.display = display; } var d = $("lspDontShow"); if(d) { d.style.display = display; } }, openTile: function (e, autohide) { var t = $("lspTile"); if(t) { if(t.style.display == "none") { this.tempWidth = Csp.Lsp.startWidth; this.tempHeight = Csp.Lsp.startHeight; this.tempOpacity = Csp.Lsp.startOpacity; this.hideTicklerLink(); this.setTileElementDisplay(e, "none"); t.style.display = "block"; } if(document.all) t.filters.item("DXImageTransform.Microsoft.Alpha").opacity = Csp.Lsp.startOpacity * 100; else t.style.MozOpacity = Csp.Lsp.startOpacity; if(Csp.Lsp.startWidth <= Csp.Lsp.width) t.style.width = Csp.Lsp.startWidth + "px"; if(Csp.Lsp.startHeight <= Csp.Lsp.height) t.style.height = Csp.Lsp.startHeight + "px"; Csp.Lsp.startWidth += Csp.Lsp.widthChange; Csp.Lsp.startHeight += Csp.Lsp.heightChange; Csp.Lsp.startOpacity += Csp.Lsp.opacityChange; if(Csp.Lsp.startWidth > Csp.Lsp.width) Csp.Lsp.startWidth = Csp.Lsp.width; if(Csp.Lsp.startHeight > Csp.Lsp.height) Csp.Lsp.startHeight = Csp.Lsp.height; if(Csp.Lsp.startOpacity > Csp.Lsp.opacity) Csp.Lsp.startOpacity = Csp.Lsp.opacity; if(Csp.Lsp.startWidth != Csp.Lsp.width || Csp.Lsp.startHeight != Csp.Lsp.height || Csp.Lsp.startOpacity != Csp.Lsp.opacity) { var that = this; setTimeout(function(e){that.openTile(e, autohide);}, Csp.Lsp.animationInterval); } if(Csp.Lsp.startWidth == Csp.Lsp.width && Csp.Lsp.startHeight == Csp.Lsp.height && Csp.Lsp.startOpacity == Csp.Lsp.opacity) { Csp.Lsp.startWidth = this.tempWidth; Csp.Lsp.startHeight = this.tempHeight; Csp.Lsp.startOpacity = this.tempOpacity; this.tempWidth = Csp.Lsp.width; this.tempHeight = Csp.Lsp.height; this.tempOpacity = Csp.Lsp.opacity; this.setTileElementDisplay(e,"block"); if(typeof(dcsMultiTrack) == "function") dcsMultiTrack('DCS.dcssip',document.domain,'DCS.dcsuri',getSub()+'/searchprovider/tileimpression','DCS.dcsqry','','WT.ti','Search Provider Tile: Impression','WT.dl','4','DCSext.ngn_spn','Live.com Search Provider Tile','DCSext.ngn_spdl','imp','DCSext.wt_linkid',''); if(this.nextShow > 0) { var d0 = this.getExpirationDate(this.nextShow); this.setCookie(Csp.Lsp.cookieStI, d0, d0); } var _this = this; if(autohide) this.closeTileTimerId = setTimeout(function (e){ _this.closeTile(e, true); }, (this.delayHide * 1000)); } } }, closeTile: function(e, displayTicklerLink) { var t = $("lspTile"); if(t) { this.setTileElementDisplay(e, "none"); if(Csp.Lsp.startWidth <= Csp.Lsp.width) t.style.width = Csp.Lsp.width + "px"; if(Csp.Lsp.startHeight <= Csp.Lsp.height) t.style.height = Csp.Lsp.height + "px"; if(document.all) t.filters.item("DXImageTransform.Microsoft.Alpha").opacity = Csp.Lsp.opacity * 100; else t.style.MozOpacity = Csp.Lsp.opacity; Csp.Lsp.width -= Csp.Lsp.widthChange; Csp.Lsp.height -= Csp.Lsp.heightChange; Csp.Lsp.opacity -= Csp.Lsp.opacityChange; if(Csp.Lsp.width <= Csp.Lsp.startWidth) Csp.Lsp.width = Csp.Lsp.startWidth; if(Csp.Lsp.height <= Csp.Lsp.startHeight) Csp.Lsp.height = Csp.Lsp.startHeight; if(Csp.Lsp.opacity <= Csp.Lsp.startOpacity) Csp.Lsp.opacity = Csp.Lsp.startOpacity; if(Csp.Lsp.width != Csp.Lsp.startWidth || Csp.Lsp.height != Csp.Lsp.startHeight || Csp.Lsp.opacity != Csp.Lsp.startOpacity) { var _this = this; setTimeout(function (e){ _this.closeTile(e, displayTicklerLink); }, Csp.Lsp.animationInterval); } if(Csp.Lsp.width == Csp.Lsp.startWidth && Csp.Lsp.height == Csp.Lsp.startHeight && Csp.Lsp.opacity == Csp.Lsp.startOpacity) { Csp.Lsp.width = this.tempWidth; Csp.Lsp.height = this.tempHeight; Csp.Lsp.opacity = this.tempOpacity; clearTimeout(this.closeTileTimerId); t.style.display = "none"; if(displayTicklerLink) this.showTicklerLink(); } } }, cancelCloseTile: function() { if(this.closeTileTimerId) clearTimeout(this.closeTileTimerId); }, showTile: function(e) { this.openTile(e, false); return false; }, hideTile: function() { var temp = $("lspTile"); if(temp) { Csp.Lsp.hideDisplay(temp); } }, addEvent: function(oName, eName, fName) { if(window.attachEvent) oName.attachEvent("on" + eName, fName); if(window.addEventListener) oName.addEventListener(eName, fName, false); }, handleCloseMFEvents: function (e) { if(!e) e = (e) ? e : (window.event ? window.event : ""); var elem = (e && e.srcElement) ? e.srcElement : e.target; if(e.type.toLowerCase() == "focus" || e.type.toLowerCase() == "blur") { var closeImg = elem.getElementsByTagName("img"); if(closeImg && closeImg.length == 1) elem = closeImg[0]; } if(e.type.toLowerCase() == "mouseover" || e.type.toLowerCase() == "focus") elem.src= this.closeHoverImage; else elem.src=this.closeNormalImage; }, handleCloseTile: function(e) { this.closeTile(e, true); if(typeof(dcsMultiTrack) == "function") dcsMultiTrack('DCS.dcssip',document.domain,'DCS.dcsuri',getSub()+'/searchprovider/close','DCS.dcsqry','','WT.ti','Search Provider Tile: Close','WT.dl','4','DCSext.ngn_spn','Live.com Search Provider Tile','DCSext.ngn_spdl','close','DCSext.wt_linkid',''); }, setEvents: function(e) { var c = $("lspClose"); if(c) { this.addEvent(c, "click", Csp.Lsp.createDelegate(this, this.handleCloseTile)); this.addEvent(c, "focus", Csp.Lsp.createDelegate(this, this.handleCloseMFEvents)); this.addEvent(c, "blur", Csp.Lsp.createDelegate(this, this.handleCloseMFEvents)); c.href = "javascript:void(0);"; var closeImg = c.getElementsByTagName("img"); if(closeImg && closeImg.length == 1) { this.addEvent(closeImg[0], "mouseover", Csp.Lsp.createDelegate(this, this.handleCloseMFEvents)); this.addEvent(closeImg[0], "mouseout", Csp.Lsp.createDelegate(this, this.handleCloseMFEvents)); } } var a = $("lspAdd"); if(a) { var aAddBtn = a.getElementsByTagName("a"); if(aAddBtn) { this.addEvent(aAddBtn[0], "click", Csp.Lsp.createDelegate(this, this.handleAddClick)); this.addEvent(aAddBtn[0], "focus", Csp.Lsp.createDelegate(this, this.handleAddMFEvents)); this.addEvent(aAddBtn[0], "blur", Csp.Lsp.createDelegate(this, this.handleAddMFEvents)); aAddBtn[0].href="javascript:void(0);"; var aAddImg = aAddBtn[0].getElementsByTagName("img"); if(aAddImg) { this.addEvent(aAddImg[0], "mouseover", Csp.Lsp.createDelegate(this, this.handleAddMFEvents)); this.addEvent(aAddImg[0], "mouseout", Csp.Lsp.createDelegate(this, this.handleAddMFEvents)); } } } var d = $("lspDontShow"); if(d) { var dLink = d.getElementsByTagName("a"); if(dLink && dLink.length == 1) { this.addEvent(dLink[0], "click", Csp.Lsp.createDelegate(this, this.handleDontShow)); dLink[0].href = "javascript:void(0);"; } } var ticklerLink = $("lspLinkText"); if(ticklerLink) { this.addEvent(ticklerLink, "click", Csp.Lsp.createDelegate(this, this.captureTicklerLinkClick)); ticklerLink.href = "javascript:void(0);"; } var ticklerTile = $("lspTile"); if(ticklerTile) this.addEvent(ticklerTile, "mouseover", Csp.Lsp.createDelegate(this, this.cancelCloseTile)); }, handleAddMFEvents: function (e) { if(!e) e = (e) ? e : (window.event ? window.event : ""); var elem = (e && e.srcElement) ? e.srcElement : e.target; if(elem) { if(e.type.toLowerCase() == "focus" || e.type.toLowerCase() == "blur") { var aAddImg = elem.getElementsByTagName("img"); if(aAddImg) elem = aAddImg[0]; } if(e.type.toLowerCase() == "mouseover" || e.type.toLowerCase() == "focus") elem.src=this.addHoverImage; else elem.src=this.addNormalImage; } }, isSupportedBrowser: function () { var userAgent = window.navigator.userAgent.toLowerCase(); if((userAgent.indexOf("msie 7.0") != -1 || userAgent.indexOf("firefox/2.") != -1) && userAgent.indexOf('netscape') == -1) return true; return false; }, showTicklerLink: function() { var temp2 = $("lspLink"); if(temp2) Csp.Lsp.showDisplay(temp2); }, captureTicklerLinkClick : function() { var temp = $("lspLink"); if(typeof(dcsMultiTrack) == "function") dcsMultiTrack('DCS.dcssip',document.domain,'DCS.dcsuri',getSub()+'/searchprovider/linkclick','DCS.dcsqry','','WT.ti','Search Provider Tile: Link Click','WT.dl','4','DCSext.ngn_spn','Live.com Search Provider Link','DCSext.ngn_spdl','click','DCSext.wt_linkid',''); clearTimeout(this.openTileTimerId); this.showTile(); }, hideTicklerLink: function() { var temp = $("lspLink"); if(temp) Csp.Lsp.hideDisplay(temp); }, handleDontShow: function(e) { if(this.repeatShow > 0) { var d1 = this.getExpirationDate(this.repeatShow); this.setCookie(Csp.Lsp.cookieStUA, d1, d1); } if(typeof(dcsMultiTrack) == "function") dcsMultiTrack('DCS.dcssip',document.domain,'DCS.dcsuri',getSub()+'/searchprovider/dontshow','DCS.dcsqry','','WT.ti','Search Provider Tile: Don%27t show again','WT.dl','4','DCSext.ngn_spn','Live.com Search Provider Tile','DCSext.ngn_spdl','dontshow','DCSext.wt_linkid',''); this.closeTile(e, false); if(this.repeatShow > 0) this.hideTicklerLink(); }, handleAddClick:function (e) { if(typeof(dcsMultiTrack) == "function") dcsMultiTrack('DCS.dcssip',document.domain,'DCS.dcsuri',getSub()+'/searchprovider/add','DCS.dcsqry','','WT.ti','Search Provider Tile: Add Live Search','WT.dl','4','DCSext.ngn_spn','Live.com Search Provider Tile','DCSext.ngn_spdl','add','DCSext.wt_linkid',''); if(this.repeatShow > 0) { var d2 = this.getExpirationDate(this.repeatShow); this.setCookie(Csp.Lsp.cookieStUA, d2, d2); } window.external.AddSearchProvider(Csp.Lsp.searchProviderUrl); var that = this; this.addButtonTimerId = setTimeout(function(e){ that.closeTile(e, false);}, 100); if(this.repeatShow > 0) this.hideTicklerLink(); }, hasValidNamedCookie: function(name, showAgainDays) { if(document.cookie.indexOf(name) == -1 || showAgainDays == 0) return false; if(document.cookie.indexOf(name) != -1) { return this.hasValidCookieValue(name, showAgainDays); } return true; }, hasValidCookieValue: function(name, days) { var cookieDate = this.getCookie(name); var cookieMilliSec = Date.parse(cookieDate); var currentDate = new Date(); currentDate.setDate(currentDate.getDate() - days); var updatedDateInMilliSec = Date.parse(currentDate.toUTCString()); if(updatedDateInMilliSec > cookieMilliSec) return false; return true; }, getCookie: function(name) { var aCookie = document.cookie.split("; "); for (var i=0; i < aCookie.length; i++) { var aCrumb = aCookie[i].split("="); if (name == aCrumb[0]) return unescape(aCrumb[1]); } return null; }, setCookie : function(name, value, date) { if(Csp.Lsp.cookieEnabled) { var domain = document.domain; if(domain && domain != null) { domain = domain.toLowerCase(); domain = domain.indexOf(".microsoft.com") != -1 ? ";domain=.microsoft.com" : ""; } document.cookie = name + "=" + escape(value) + ";expires=" + date + ";path=/" + domain; } }, getExpirationDate: function(days) { var d3 = new Date(); d3.setDate(d3.getDate() + days); return d3.toUTCString(); }, writeMetaTags: function() { if(this.isSupportedBrowser()) { if(this.hasValidNamedCookie(Csp.Lsp.cookieStUA, this.repeatShow) == false) { document.write("<meta name='DCSext.ngn_spn' content='Live.com Search Provider Link'><meta name='DCSext.ngn_spdl' content='imp'>"); } } }, Render: function() { if(this.isSupportedBrowser()) { if(this.hasValidNamedCookie(Csp.Lsp.cookieStUA, this.repeatShow) == false) { this.setEvents(); this.showTicklerLink(); } else { return; } if(this.hasValidNamedCookie(Csp.Lsp.cookieStI, this.nextShow) == false) { if(this.nextShow > 0) { var d4 = this.getExpirationDate(this.nextShow); this.setCookie(Csp.Lsp.cookieStI, d4, d4); } if(this.delayHide > 0) { var _that = this; this.openTileTimerId = setTimeout(function(e){_that.openTile(e, true);}, (this.delayShow * 1000)); } } } } }; $ = function(id) { return document.getElementById(id); }; Csp.Lsp.createDelegate = function(instance, method) { return function() { return method.apply(instance, arguments); } }; Csp.Lsp.hideDisplay = function(obj) { obj.style.display = "none"; }; Csp.Lsp.showDisplay = function(obj) { obj.style.display = "block"; }; getSub = function() { var path = location.pathname; path = path.toLowerCase(); if(path.indexOf("default.aspx") != -1) path = path.substring(0, path.indexOf("default.aspx")); var sb = new Csp.StringBuilder(); sb.append("/"); var buildPath = path.split("/"); buildPath.reverse(); if(buildPath[2]) sb.append(buildPath[2]); sb.append("/"); if(buildPath[1]) sb.append(buildPath[1]); path = sb.toString(); return path; };