var DL_HideSelects = true; var DL_HideObjects = false; var DL_HideIframes = false; var DL_Banner; // Will be bound to the DIV element representing the layer var DL_ScrollState = 0; var DL_width; var DL_height; var DL_dimension; var DL_insert; var DL_ImgWidth = 336; var DL_ImgHeight = 250; var DL_StartCoordPixels = 30; // Get the window dimensions function DL_GetWH() { // // consider quirks mode. Bail out with 640x480 if nothing else works if (self.innerWidth) { // Mozilla, Safari, Opera, Netscape 4.0 DL_width = self.innerWidth; DL_height = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight > 0) { // IE6 in Strict Mode DL_width = document.documentElement.clientWidth; DL_height = document.documentElement.clientHeight; } else if (document.getElementsByTagName("body").length > 0) { var b = document.getElementsByTagName("body")[0]; DL_width = b.clientWidth; DL_height = b.clientHeight; } // Default to 640x480 if the above information is missing or not well-formed if (parseInt(DL_width) == 0 || parseInt(DL_height) == 0) { DL_width = 640; DL_height = 480; } DL_dimension = DL_width; } DL_GetWH(); // Make sure the layer is where it should be vertically. // This is repeated every 30 milliseconds with setTimeout. function DL_reposition(){ var scrollpos; var edge = 0; if (self.innerHeight) { // all except Explorer // somehow self.pageYOffset is zero at times which messes up for us :( scrollx = self.pageYOffset; scrolly = self.pageXOffset; edge = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight > 0) { // IE 6 in strict mode scrollx = document.documentElement.scrollTop; scrolly = document.documentElement.scrollLeft; edge = document.documentElement.clientHeight; } else if (document.getElementsByTagName("body").length > 0) { var b = document.getElementsByTagName("body")[0]; scrollx = b.scrollTop; scrolly = b.scrollLeft; edge = b.clientHeight; } if (document.getElementById) { // Set coordinates style positions DL_Banner.style.top = (parseInt(scrollx) + edge-(DL_ImgHeight + DL_StartCoordPixels))+'px'; DL_Banner.style.left = (parseInt(scrolly) + DL_Banner.absolute)+'px'; } } function DL_DoHideSelects() { var selects = document.getElementsByTagName('select'); for(i = 0; i < selects.length; i++) { selects[i].style.visibility = 'hidden'; } } function DL_DoHideIframes() { var objects = document.getElementsByTagName('iframe'); for(i = 0; i < objects.length; i++) { objects[i].style.visibility = 'hidden'; } } function DL_DoHideObjects() { var objects = document.getElementsByTagName('object'); for(i = 0; i < objects.length; i++) { if (objects[i].id != 'DL_object') { objects[i].style.visibility = 'hidden'; } } objects = document.getElementsByTagName('embed'); for(i = 0; i < objects.length; i++) { if (objects[i].id != 'DL_embed') { objects[i].style.visibility = 'hidden'; } } } function DL_DoShowSelects() { // The reverse of DL_DoHideSelects selects = document.getElementsByTagName('select'); for(i = 0; i < selects.length; i++) { selects[i].style.visibility = 'visible'; } } function DL_DoShowIframes() { var objects = document.getElementsByTagName('iframe'); for(i = 0; i < objects.length; i++) { objects[i].style.visibility = 'visible'; } } function DL_DoShowObjects() { // The reverse of DL_DoHideObjects objects = document.getElementsByTagName('object'); for(i = 0; i < objects.length; i++) { objects[i].style.visibility = 'visible'; } objects = document.getElementsByTagName('embed'); for(i = 0; i < objects.length; i++) { objects[i].style.visibility = 'visible'; } } var DL_PauseStart = 0; function DL_Scroll() { // Moves the layer // The global DL_ScrollState governs where the layer is in its trajectory. // States: // 0 - Layer has not yet appeared. // 1 - Layer is moving to target location. // 2 - Layer disappears. // 3 - Only for gutter layer, layer is moving to stop at the edge of the screen (in the gutter). // 4 - Layer is pausing at target location. // 5 - Only for gutter layer, layer never disapperas and hovers forever in gutter. // 6 - Flash object is pausing so start it playing. // -1 - Invite is finished and layer should not appear again. DL_GetWH(); switch (DL_ScrollState) { case 0: // Layer has not yet appeared // Change the state. If we have a gutter, and the invitation // image fits in it, switch to state 3. Otherwise, state 1. DL_ScrollState = 1; // Further preparation: set the image to its starting position // and, if desired, hide any s if(DL_HideSelects) { DL_DoShowSelects(); } if(DL_HideIframes) { DL_DoShowIframes(); } if(DL_HideObjects) { DL_DoShowObjects(); } DL_ScrollState = 5; // Hover at edge DL_PauseStart = new Date(); setTimeout(DL_Scroll, 50); } break; case 4: // Layer is pausing at target location // The window might have been resized. We must reposition the layer. if (new Date() - DL_PauseStart < 15000) { DL_GetWH(); DL_Banner.absolute = 200; DL_reposition(); setTimeout(DL_Scroll, 50); } else { DL_ScrollState = 2; DL_Scroll(); } break; case 5: //Layer never disapperas and hovers forever. DL_reposition(); DL_Banner.style.left = (DL_width - DL_ImgWidth - 4)+'px'; setTimeout(DL_Scroll, 50); break; case 6: // Flash object is pausing so start it playing var obj = window.document['DL_object']; try { if (DL_loop < 4 && obj) { obj.Play(); } } catch (err) { DL_loop++; setTimeout(DL_Scroll,100); return; } DL_ScrollState = 4; setTimeout(DL_Scroll,50); break; } } function DL_GotoSurvey() { DL_Close(false); window.open('http://survey.questionmarket.com/surv/866249/ai_start.php?from_node=15687&site=16', "_blank", ""); } function DL_Close(adscout) { if (typeof adscout == 'undefined') { var adscout = true; } (new Image).src=adscout&&"//amch.questionmarket.com/adscgen/adscout_dc.php?site=16&code=&survey_num=866249&ord="+Math.floor((new Date()).getTime()); // Set a flag so animation loop will stop running DL_ScrollState = 2; DL_Scroll(); } function DL_Add(){ DL_InsertGif(); } function DL_FlashInstalled() { // Detect swf plugin. var result = false; if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) { result = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin; } else if (document.all && (navigator.appVersion.indexOf("Mac")==-1)) { // IE Windows only -- check for ActiveX control, have to hide code in eval from Netscape (doesn't like try) eval ('try {var xObj = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if (xObj) result = true; xObj = null; } catch (e) {}'); } return result; } function DL_InsertGif(imgname) { // Variation 1: The invitation is an image. if (!imgname) { imgname = 'http://amch.questionmarket.com/static/cnnmoney_v1_li-336x250-1l-eng-nul.gif'; } // Inside the DIV tag: the image. Outside: the imagemap. DL_InsertObject('', ''); } function DL_InsertSwf() { if (DL_FlashInstalled()) { // Make sure the browser can handle Flash. // Inside the DIV tag: the object. Outside: nothing; Flash handles its own click events. DL_InsertObject('', ' '); setTimeout(DL_Scroll, 500) } else { // If Flash is unavailable, use a gif. DL_ImgWidth = 336; DL_ImgHeight = 250; DL_InsertGif(''); } } function DL_InsertObject(nonDivText, divText) { // Create a new element using DOM. DL_insert = document.createElement('span'); DL_insert.style.position = "static"; // Add 'insert' and its DIV to the document body DL_insert.innerHTML = nonDivText + '
' + divText + '
'; document.getElementsByTagName("body")[0].appendChild(DL_insert); // Bind the DIV to the global variable DL_Banner, so other functions can use it DL_Banner = document.getElementById('dhtmlbanner'); } function DL_CheckExcl() { var str = 'http://money.cnn.com/$|http://www.money.com$|http://cnnmoney.com$|http://money.cnn.com/quote/quote.html\\?symb=TWX$|http://money.cnn.com/data/premarket/index.html|http://money.cnn.com/video/|http://audience.cnn.com/services/money/login.do\\?pid=money.portfolio&url=|http://audience.cnn.com/services/money/regwall/memberprofile.dom|http://bcportfolio.money.cnn.com/custom/cnnmoney2/2/portfolio/view.asp\\?data=|http://bcportfolio.money.cnn.com/custom/cnnmoney2/2/alerts/html-alerts.asp|http://bcportfolio.money.cnn.com/custom/cnnmoney2/2/portfolio/view.asp'; var u = document.URL; var e = str.split("|"); var len = e.length; for (var i=0; i= 0) { // exclude exact url if (u == e[i].substr(0,(e[i].length-1))) { return true; } } else { // exclude subset url if (u.indexOf(e[i]) >= 0) { return true; } } } return false; } if (!window.DL_already_ran && !DL_CheckExcl()) { DL_already_ran = 1; setTimeout(DL_Add, 300); }