var DL_HideSelects = true;
var DL_HideObjects = false;
var DL_HideIframes = false;
var DL_ie = document.all && navigator.userAgent.indexOf("Opera") == -1;
var DL_Banner; // Will be bound to the DIV element representing the layer
var DL_ScrollState = 0;
var DL_width, DL_height, DL_dimension;
function DL_GetWH() {
//
// per: http://www.quirksmode.org/viewport/compatibility.html
//
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.body) {
DL_width = document.body.clientWidth;
DL_height = document.body.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();
function DL_reposition(){
// Make sure the layer is where it should be vertically.
// This is executed in a loop.
var scrollpos;
var edge = 0;
//
// Scroll Pos per: http://www.quirksmode.org/viewport/compatibility.html
//
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.body) {
// relative sanity
scrollx = document.body.scrollTop;
scrolly = document.body.scrollLeft;
edge = document.body.clientHeight;
}
if (DL_ie || document.getElementById){
DL_Banner.style.top = (parseInt(scrollx) + parseInt(edge) + -300)+'px';
DL_Banner.style.left = (parseInt(scrolly) + DL_Banner.absolute)+'px';
}
}
function DL_DoHideSelects() {
// Optional: Hide all the Select (drop-down menu) controls on the page.
// If this isn't done, selects can be visible on top of the invitation layer.
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. State 0 means it hasn't appeared yet,
// state -1 means it's finished and should not appear again.
DL_GetWH();
switch (DL_ScrollState) {
case 0: // Layer has not yet appeared
DL_Banner.style.visibility = 'visible';
// 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 in the center.
// The window might have been resized. We must reposition the layer.
if (new Date() - DL_PauseStart < 20000) {
DL_GetWH();
DL_Banner.absolute = (DL_dimension - 295);
DL_reposition();
setTimeout('DL_Scroll()', 50);
} else {
DL_ScrollState = 2;
DL_Scroll();
}
break;
case 5:
DL_reposition();
// Delay removed. Hover in the gutter forever.
//if (new Date() - DL_PauseStart < 10000) { // hover for 10 seconds
DL_Banner.style.left = (DL_width - 250 - 4)+'px';
setTimeout('DL_Scroll()', 50);
//} else {
// DL_ScrollState = 2;
// DL_Scroll();
//}
break;
}
}
function DL_GotoSurvey() {
// To the rest of the parameters, append a link back to the current document
window.top.location.href="http://amch.questionmarket.com/adsc/d0/dynamiclinkf.php?survey_server=survey.questionmarket.com&survey_num=0&site=1604&code=0&frame=&dl_logo=&invite=no&link="+escape(window.location.href)+"&orig="+escape(window.location.href);
}
function DL_Close() {
// Set a flag so that the animation loop will stop running
DL_ScrollState = 2;
DL_Scroll();
}
function DL_Init() {
// Set a timer to load the survey after the given delay
setTimeout('DL_Scroll()', 1000);
}
function DL_FlashInstalled() {
// Detect swf plugin. Adapted from http://javascript.about.com/library/scripts/blflashdetect.htm
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/opinion_li-250x250-1l-eng-nul.gif';
// Inside the DIV tag: the image. Outside: the imagemap.
DL_InsertObject('', '');
}
function DL_InsertSwf() {
// Variation 2: The invitation is a Flash object.
// First, make sure the browser can handle Flash.
if (DL_FlashInstalled()) {
// Inside the DIV tag: the object. Outside: nothing; Flash handles its own click events.
DL_InsertObject('', '');
DL_Init();
} else {
// If Flash is disabled or not installed, use a gif instead.
var imgname = "http://amch.questionmarket.com/static/opinion_li-250x250-1l-eng-nul.gif";
DL_InsertGif(imgname.slice(0, -3)+"gif");
}
}
function DL_InsertObject(nonDivText, divText) {
// Create a new element using DOM.
// The 'insert' tag is a meaningless container.
var insert = document.createElement('span');
// Create a DIV element within 'insert'. This is our dlayer.
insert.innerHTML = nonDivText + '
' + divText + '
';
// Add 'insert' and its DIV to the document body
var b = document.getElementsByTagName('body').item(0);
b.appendChild(insert);
// Bind the DIV to the global variable DL_Banner, so other functions can use it
DL_Banner = document.getElementById('dhtmlbanner');
}
var DL_already_ran;
if (!DL_already_ran) {
DL_InsertGif();
DL_already_ran = 1;
}