var Survey = {
  AdResearch: {
    active: true, // Turns the survey on and off
    surveys: [] // listing of surveys
  },
  ShowResearch: {
    active: true,
    surveys: []
  },
  debug: false,
  debugLog: ""
};


//
// syntax for ad listings below:
// be VERY careful not to add trailing commas anywhere
//
//    // listing of active advertisers
//    // can be empty for PREWAVE surveys
//    activeAds:
//    [
//      "Allstate",
//      "BestBuy",
//      "CloroxTAB",
//      "CrescentRolls"
//    ],
//
//    // if empty, looks like:
//    activeAds: 
//    [
//    ],
//
//
//    // move ads from active to inactive when closed
//    // can be empty for PREWAVE surveys
//    inactiveAds: 
//    [
//      "AquaFresh", // closed mm/dd/yyyy
//      "CapitalOne"  // closed mm/dd/yyyy
//    ],
//
//    // if empty, looks like:
//    inactiveAds: 
//    [
//    ],
//
//    // allow renaming of advertiser in survey
//    // can be empty for PREWAVE surveys
//    // NOTE: You MUST INCLUDE both original and new names in the list
//    // NOTE: of activeAds above in order for all variations to be
//    // NOTE: detected
//    adRenames: 
//    [
//      { 
//        originalName: "CrescentRolls", 
//        newName: "PillsburyGrand" 
//      },
//      { 
//        originalName: "CloroxTAB", 
//        newName: "Clorox" 
//      }
//    ]
//
//    // if empty, looks like:
//    adRenames: 
//    [
//    ]
//


//
// Listing of running ad surveys, will be tested for eligibility
// in random order until one is eligible or all possible surveys are exhausted
//
Survey.AdResearch.surveys = [
  {
    cookie: "fma12001_12002",  // cookie id for preventing multiple survey takes
    active: true, // Turns the survey on and off

    // Full url for PREWAVE surveys; Domain and path for TARGETED surveys
    // this is glad/nintendo special pre-wave
    url: "http://d.surveysonline.com/survey/fma/fma12001",

    // include SWID cookie value as swid=XXX when invoking URL?
    includeSWID: true,

    percentage: 1.0, // capture rate for this ad survey; 0 to 1.0 scale
    targeted: false, // for prewave = false, postwave = true

    // listing of active advertisers
    // can be empty for PREWAVE surveys
    activeAds: 
    [
    ],

    // move ads from active to inactive when closed
    // can be empty for PREWAVE surveys
    inactiveAds: 
    [
    ],

    // allow renaming of advertiser in survey
    // can be empty for PREWAVE surveys
    // NOTE: You MUST INCLUDE both original and new names in the list
    // NOTE: of activeAds above in order for all variations to be
    // NOTE: detected
    adRenames: 
    [
    ]
  },
  {
    // use a post-wave survey setup to intercept people who haven't yet
    // been invited, and who didn't just see LensCrafters
    //
    // NOTE:  this will only invite people who saw one of the known/
    //        monitered advertisers other than LensCrafters.  
    //
    // anyone else will drop through both surveys as ineligible for both
    // surveys.
    //
    // must use same cookie for both surveys
    cookie: "fma12001_12002",  // cookie id for preventing multiple survey takes
    active: true, // Turns the survey on and off

    // Full url for PREWAVE surveys; Domain and path for TARGETED surveys
    url: "http://d.surveysonline.com/survey/fma/fma12002",

    // include SWID cookie value as swid=XXX when invoking URL?
    includeSWID: true,

    percentage: 1.0, // capture rate for this ad survey; 0 to 1.0 scale
    targeted: true, // for prewave = false, postwave = true

    // listing of active advertisers
    // can be empty for PREWAVE surveys
    activeAds:
    [
      "LEXUS/Multi Brand",
      "TOYOTA/SAATCHI & SAATCHI C/O RE:SOURCES",
      "HYUNDAI/Hyundai",
      "NISSAN/NISSAN",
      "UNIVERSITY OF PHOENIX/University of Phoenix",
      "HOME DEPOT/Home Depot",
      "LOWE'S/My Lowes",
      "BUICK/STARCOM C/O RESOURCES",
      "Paramount Pictures",
      "TARGET STORES/TARGET STORES",
      "CHEVROLET/STARCOM C/O RESOURCES",
      "HALLMARK/Hallmark",
      "ALLSTATE/Allstate*",
      "BOEHRINGER/Pradaxa",
      "SPIRIVA/Spiriva",
      "P&G/Gillette",
      "REVLON/Revlon",
      "STERLING JEWLERS/JARED",
      "BMW/BMW",
      "VERIZON WIRELESS/VERIZON WIRELESS"
    ],

    // move ads from active to inactive when closed
    // can be empty for PREWAVE surveys
    inactiveAds: 
    [
      "ParamountPicturesHugo",
      "ParamountPussInBoots"
    ],

    // allow renaming of advertiser in survey
    // can be empty for PREWAVE surveys
    // NOTE: You MUST INCLUDE both original and new names in the list
    // NOTE: of activeAds above in order for all variations to be
    // NOTE: detected
    adRenames: 
    [
      { 
        originalName: "LEXUS/Multi Brand",
        newName: "Lexus"
      },
      {
        originalName: "TOYOTA/SAATCHI & SAATCHI C/O RE:SOURCES",
        newName: "Toyota"
      },
      {
        originalName: "HYUNDAI/Hyundai",
        newName: "Hyundai"
      },
      {
        originalName: "NISSAN/NISSAN",
        newName: "Nissan"
      },
      {
        originalName: "UNIVERSITY OF PHOENIX/University of Phoenix",
        newName: "UniversityofPhoenix"
      },
      {
        originalName: "HOME DEPOT/Home Depot",
        newName: "TheHomeDepot"
      },
      {
        originalName: "LOWE'S/My Lowes",
        newName: "Lowes"
      },
      {
        originalName: "BUICK/STARCOM C/O RESOURCES",
        newName: "Buick"
      },
      {
        originalName: "Paramount Pictures",
        newName: "ParamountPicturesWitchhunters"
      },
      {
        originalName: "TARGET STORES/TARGET STORES",
        newName: "Target*"
      },
      {
        originalName: "CHEVROLET/STARCOM C/O RESOURCES",
        newName: "Chevrolet"
      },
      {
        originalName: "HALLMARK/Hallmark",
        newName: "Hallmark"
      },
      {
        originalName: "ALLSTATE/Allstate*",
        newName: "Allstate"
      },
      {
        originalName: "ALLSTATE/Allstate",
        newName: "Allstate"
      },
      {
        originalName: "BOEHRINGER/Pradaxa",
        newName: "Pradaxa"
      },
      {
        originalName: "SPIRIVA/Spiriva",
        newName: "Spiriva"
      },
      {
        originalName: "P&G/Gillette",
        newName: "Gillette"
      },
      {
        originalName: "REVLON/Revlon",
        newName: "Revlon"
      },
      {
        originalName: "STERLING JEWLERS/JARED",
        newName: "JaredTheGalleriaofJewelry"
      },
      {
        originalName: "BMW/BMW",
        newName: "BMW"
      },
      {
        originalName: "VERIZON WIRELESS/VERIZON WIRELESS",
        newName: "VerizonWireless"
      }
    ]
  }
];


//
// Listing of shows and their survey URLs
//
// show/episode combinations here are mutually exclusive
//
// i.e. you can't list one show in two different surveys
// where the list of episodes overlaps (including the case
// of not specifying any episodes which in turn matches all
// episodes).
//
// the list of shows is checked in order for the first match
// of show name and episode so specifying overlapping combinations
// of show + episode means that the second and subsequent overlapping
// show + episode combinations will never be matched or used.
//
Survey.ShowResearch.surveys = [
  // example of surveying on a single episode
  {
    name: "show1",
    active: false, 
    cookie: "show1_101",  // cookie id for preventing multiple survey takes
    percentage: 0.5, // intercept rate for this show survey; 0.0 to 1.0 scale
    url: "show1_101",

    // include SWID cookie value as swid=XXX when invoking URL?
    includeSWID: true,
    episodes: ["101"]
  },

  // example of surveying on multiple episodes
  {
    name: "show1",
    active: false, 
    cookie: "show1_106_107",  // cookie id for preventing multiple survey takes
    percentage: 0.5, // intercept rate for this show survey; 0.0 to 1.0 scale
    url: "show1_106_107",

    // include SWID cookie value as swid=XXX when invoking URL?
    includeSWID: true,
    episodes: ["106","107"]
  },

  // example of surveying on all episodes
  {
    name: "show2",
    active: false, 
    cookie: "show2",  // cookie id for preventing multiple survey takes
    percentage: 0.5, // intercept rate for this show survey; 0.0 to 1.0 scale

    // include SWID cookie value as swid=XXX when invoking URL?
    includeSWID: true,
    url: "show2"
  }
];

///////////////////////////////////////////////////////////////////////////////
// Do not edit below this line
///////////////////////////////////////////////////////////////////////////////

Survey.Popup = {

  getSWID: function() {
    var results = document.cookie.match ( '(^|;)?SWID=([^;]*)(;|$)' );
    if ( results ) {
      return ( unescape ( results[ 2 ] ) );
    } else {
      return null;
    }
  },
  
  playAd: function(adIndex, breakIndex) {
  	// add survey logic here
    if ( breakIndex > 2 ) {
      this.run();
    }
  },

  run: function() {
    var finalURL = "";
    var cookieId = "";
    var containsActive = false;
    
    // determines if cookie w/ particular id has been set
    var alreadyOffered = function(id) {
      if ( Survey.debug ) { return false; }

      var cookies = document.cookie;
      if (cookies.indexOf(id, 0) >= 0) {
        return true;
      }
      return false;
    };
    
    if (typeof abcdm === "undefined" ||
        typeof abcdm.abc === "undefined" ||
        typeof abcdm.abc.vp2 === "undefined" ||
        typeof abcdm.abc.vp2.AdResearch === "undefined") {
      return;
    }
    
    //
    // show surveys take precedence
    //
    if (Survey.ShowResearch.active == true) {

      var showData = abcdm.abc.vp2.AdResearch.getShowData();

      if (showData != null && 
          showData.hasOwnProperty("show") && 
          showData.hasOwnProperty("episode")) {

        // find matching show + episode if any
        // see comments above about not supporting overlapping
        // show + episode combinations
        for ( var i = 0; i < Survey.ShowResearch.surveys.length; i++ ) {
          var survey = Survey.ShowResearch.surveys[ i ];
          var random = Math.random();

// WScript.Echo( "1: random: " + random + ", percentage = " + survey.percentage + ", i = " + i );

          if ( typeof survey != "undefined" && 
               survey.name == showData.show &&
               survey.active == true &&
               random <= survey.percentage &&
               alreadyOffered( survey.cookie ) == false ) {

            // person saw a show that has an active survey
            // and hasn't seen that survey before
            // and is within percentage of people we wish to invite
          
            // see if we need to test for specific episodes
            if (typeof survey.episodes != "undefined") {

              for ( var j = 0; j < survey.episodes.length; j++) {
                if (survey.episodes[ j ] == showData.episode) {

                  // matched specific episode so stop loop
                  break;
                }
              }

              // see if we matched a specific episode
              if ( j < survey.episodes.length ) {
  
if ( Survey.debug ) { 
  Survey.debugLog += "choose episode specific show survey"; 
  debugSurveyCount[ survey.url ]++;
}
                // matched specific episode so do invite

                // save cookieId so we can set cookie during invite
                cookieId = survey.cookie;

                finalURL = survey.url;
                if ( survey.includeSWID ) {
                  finalURL += "?swid=" + escape( Survey.Popup.getSWID() );
                }
                break;
              }
            } else {

              // not testing for specific episodes, so just do invite

if ( Survey.debug ) { 
  Survey.debugLog += "choose episode independent show survey"; 
  debugSurveyCount[ survey.url ]++;
}
              // save cookieId so we can set cookie during invite
              cookieId = survey.cookie;

              finalURL = survey.url;
              if ( survey.includeSWID ) {
                finalURL += "?swid=" + escape( Survey.Popup.getSWID() );
              }
              break;
            }
          } // found matching show
        } // loop over all show/episode combinations
      }
    }
    
    
    // test for targeted ad surveys
    if (finalURL == "" && // not serving a show survey
        Survey.AdResearch.active == true) {

      // loop through active surveys starting at random one
      var surveyCount = Survey.AdResearch.surveys.length;
      var randomOffset = Math.floor( Math.random() * surveyCount );

      for ( var i = randomOffset; i < (surveyCount + randomOffset); i++ ) {
        var surveyIndex = i % surveyCount;

        var survey = Survey.AdResearch.surveys[ surveyIndex ];
        var random = Math.random();

// WScript.Echo( "2: random: " + random + ", percentage = " + survey.percentage + ", i = " + i + ", randomOffset = " + randomOffset + ", surveyCount = " + surveyCount );

        // see if eligible for this survey
        // only do targeted surveys in this first pass
        if (survey.active == true &&
            survey.targeted == true &&
            random <= survey.percentage &&
            alreadyOffered(survey.cookie) == false) {

          // since its targeted, must test each ad to see if we're 
          // tracking it and append to query string accordingly
          var data = abcdm.abc.vp2.AdResearch.getAdData();
        
          var adData = "";
          if (data !== null && data.length > 0) {
            for ( var j = 0; j < data.length && j < 20; j++ ) {
              var ad = data[ j ];
              var adName = ad.name;

              // see if this ad is found as an active ad
              var adFound = false;
              var adIsActive = false;
              for ( var k = 0; k < survey.activeAds.length; k++ ) {
                if (survey.activeAds[ k ] == adName) {
                  adFound = true;
                  adIsActive = true;
                  break;
                }
              }

              // if not found, see if its an inactive ad
              if ( ! adFound ) {
                for ( var k = 0; k < survey.inactiveAds.length; k++ ) {
                  if (survey.inactiveAds[ k ] == adName) {
                    adFound = true;
                    adIsActive = false;
                    break;
                  }
                }
              }

              // only track ads that we're interested in passing to survey
              // regardless of whether they're currently active or closed
              if ( adFound ) {

                // rename ad if necessary
                if ( ! ( typeof survey.adRenames === "undefined" ) ) {
                  for ( var k = 0; k < survey.adRenames.length; k++ ) {
                    if ( survey.adRenames[ k ].originalName == adName ) {
                      adName = survey.adRenames[ k ].newName;
                      break;
                    }
                  }
                }

                // handle new "ad.type" that denotes regular (0) or pause (1)
                // ads
                var adType = 0;
                if ( typeof ad.type === "undefined" ) {
                  adType = 0;
                } else {
                  adType = ad.type;
                }
                
                // append ad info to query string
                adData += 
                  ad.pos + 
                  ":" + 
                  adName + 
                  ":" + 
                  adIsActive +
                  ":" + 
                  adType +
                  ",";
              }
            }
          }
          // strip trailing comma
          if ( adData.length > 0 ) {
            adData = adData.slice(0, adData.length - 1);
          }

          // only invite if we have at least one active targeted ad
          if (adData.indexOf("true") != -1) {
            containsActive = true;
            cookieId = survey.cookie;
            finalURL = survey.url + "?ad_data=" + escape(adData);
            if ( survey.includeSWID ) {
              finalURL += "&swid=" + escape( Survey.Popup.getSWID() );
            }

if ( Survey.debug ) { 
  Survey.debugLog += "choose targeted ad survey"; 
  debugSurveyCount[ survey.url ]++;
}
            break; // stop testing for eligible surveys since we found one
          }

        } // end if this survey was eligible
      } // for each survey
    } // end if targeted ad surveys are active


    // test for untargeted ad surveys
    if (finalURL == "" && // not serving a show survey
        Survey.AdResearch.active == true) {

      // loop through active surveys starting at random one
      var surveyCount = Survey.AdResearch.surveys.length;
      var randomOffset = Math.floor( Math.random() * surveyCount );

      for ( var i = randomOffset; i < (surveyCount + randomOffset); i++ ) {
        var surveyIndex = i % surveyCount;

        var survey = Survey.AdResearch.surveys[ surveyIndex ];
        var random = Math.random();

// WScript.Echo( "3: random: " + random + ", percentage = " + survey.percentage + ", i = " + i );

        // see if eligible for this survey
        // do targeted surveys in this first pass
        if (survey.active == true &&
            survey.targeted == false &&
            random <= survey.percentage &&
            alreadyOffered(survey.cookie) == false) {

          // since not targeted, then just invite
          cookieId = survey.cookie;
          finalURL = survey.url;
          if ( survey.includeSWID ) {
            finalURL += "?swid=" + escape( Survey.Popup.getSWID() );
          }

if ( Survey.debug ) { 
  Survey.debugLog += "choose untargeted ad survey"; 
  debugSurveyCount[ survey.url ]++;
}
          break;

        } // end if this survey was eligible
      } // for each survey
    } // end if untargeted ad surveys are active

    if (finalURL != "" && cookieId != "") {
      
      if ( Survey.debug == true ) {
        Survey.debugLog = finalURL + ", " + Survey.debugLog;
      } else {
        var expDate = new Date ();
        var msecOneYear = (365 * 24 * 60 * 60 * 1000);
        expDate.setTime (expDate.getTime() + msecOneYear);
        document.cookie = 
          cookieId + 
          "=" + 
          "alreadyOffered; expires=" + 
          expDate.toGMTString() + 
          "; path=/; domain=abc.go.com";

        Survey.Intercept.interceptStart( finalURL );

        // old intercept window popup method
        /*
        var win = 
          window.open(
            finalURL,
            'intercept',
            'width=1000,height=450,screenX=175,screenY=75,top=75,left=175,resizable=yes,scrollbars=yes'
          );
        if(win) {
          var expDate = new Date ();
          var msecOneYear = (365 * 24 * 60 * 60 * 1000);
          expDate.setTime (expDate.getTime() + msecOneYear);
          document.cookie = 
            cookieId + 
            "=" + 
            "alreadyOffered; expires=" + 
            expDate.toGMTString() + 
            "; path=/; domain=abc.go.com";
        }
        */
      }
    } else {

      // if no invite, record that for debugging
      if ( Survey.debug == true ) {
        debugSurveyCount[ "noInvite" ]++;
        Survey.debugLog = "noInvite" + ", " + Survey.debugLog;
      }
    }
  }
};

Survey.Intercept = {
	//
	// project specific variables - must be customized for each project
	//
	interceptWidth: 360,
	interceptHeight: 253,
	interceptDestinationURL: null,

	interceptImageURL: 
    "http://a.verdict.abc.go.com/abcresearch/intercept.gif",
	interceptBlankURL: 
    "http://a.verdict.abc.go.com/abcresearch/blank.html",

	// upper left x, upper left y, lower right x, lower right y (x1,y1,x2,y2)
	acceptInterceptButtonCoordinates: "110,191,245,206",
	declineInterceptButtonCoordinates: "143,223,217,238",

	//
	// adjust Y coordinate position, speed of flyin/flyout, and pause before flyin
	//
	topOffset: 555,
	flyInStep: 30,
	flyOutStep: 100,
	flyInterval: 1,
	pauseBeforeFlyIn: 1000,
	stopX: -1, // set to -1 to fly in to calculated middle of window

	//
	// calculated values and working variables
	// do not modify
	//
	initialLeft: null,
	currentLeft: null,
	isNetscape: false,
	isInternetExplorer: false,
	isUnknownUserAgent: false,
	interceptTimer: null,

	suppressOneDismissal: false,
	
	calculateStopPoint: function() {

	  // default in case unknown browser
	  var windowWidth = 1024;

	  if ( Survey.Intercept.isNetscape ) {
	    windowWidth = window.innerWidth;
	  }

	  if ( Survey.Intercept.isInternetExplorer ) {

	    windowWidth = document.body.offsetWidth;
	  }

	  // if stopX isn't set to an explicit value, calculate middle
	  // of page to stop it at.
	  if ( Survey.Intercept.stopX == -1 ) {
	    Survey.Intercept.stopX = parseInt( ( windowWidth - Survey.Intercept.interceptWidth ) / 2, 10 );
	  }
	},
	
	hideIntercept: function() {
	  document.getElementById( "floatingIntercept" ).style.display = "none";
	  document.getElementById( "floatingInterceptIframe" ).style.display = "none";
	},

	moveIntercept: function( maxLeft, step, hideWhenDone ) {

	  window.clearTimeout( Survey.Intercept.interceptTimer );

	  if ( Survey.Intercept.currentLeft < maxLeft ) {

	    Survey.Intercept.currentLeft = Survey.Intercept.currentLeft + step;

	    if ( Survey.Intercept.currentLeft > maxLeft ) {
	      Survey.Intercept.currentLeft = maxLeft;
	    }

	    document.getElementById( "floatingIntercept" ).style.left =
	      Survey.Intercept.currentLeft + "px";

	    document.getElementById( "floatingInterceptIframe" ).style.left =
	      Survey.Intercept.currentLeft + "px";

	    if ( Survey.Intercept.currentLeft < maxLeft ) {

	      Survey.Intercept.interceptTimer =
	        window.setTimeout(
	          "Survey.Intercept.moveIntercept( " +
	          maxLeft +
	          ", " +
	          step +
	          ", " +
	          hideWhenDone +
	          " )",
	          Survey.Intercept.flyInterval
	        );

	    } else {

	      if ( hideWhenDone ) {
	        Survey.Intercept.hideIntercept();
	      }

	    }
	  }
	},
	
	flyOutIntercept: function() {
	  if ( ! Survey.Intercept.suppressOneDismissal ) {
	    Survey.Intercept.moveIntercept( 2000, Survey.Intercept.flyOutStep, true );
	  } else {
	    Survey.Intercept.suppressOneDismissal = false;
	  }
	},
	
	displayIntercept: function() {

	      var bodyHtml = document.body.innerHTML;
	      var zMatches = bodyHtml.match( /z[\-]index[\:][\ ]*\d+[\ ]*[\;]/ig );
	      var zMax = 1000;

        /*
	      if ( zMatches != null ) {
	        for ( var i = 0; i < zMatches.length; i++ ) {
	          var zMatch = zMatches[ i ];
	          var z = zMatch.match( /\d+/ )[ 0 ];
	          if ( z > zMax ) zMax = z + 1;
	        }
	      }
        */

	      var interceptDiv = 
	        "<iframe " +
	        "  id=\"floatingInterceptIframe\" " +
	        "  style=\"" +
	        "   position: absolute; " +
	        "   z-index: " + zMax++ + ";" +
	        "   width: " + Survey.Intercept.interceptWidth + ";" +
	        "   height: " + Survey.Intercept.interceptHeight + ";" +
	        "   left: " + Survey.Intercept.initialLeft + "px;" +
	        "   top: " + Survey.Intercept.topOffset + "px;\"" +
	        "  src=\"" + Survey.Intercept.interceptBlankURL + "\" " +
	        "  marginheight=\"0\" " +
	        "  marginwidth=\"0\" "  +
	        "  noresize " +
	        "  frameborder=\"0\""  +
	        "  scrolling=\"no\">" +
	        "</iframe>";

	      interceptDiv += 
	        "<div id=\"floatingIntercept\" " +
	        "style=\"position: absolute; z-index: " + zMax + "; left: " +
	        Survey.Intercept.initialLeft +
	        "px; top: " +
	        Survey.Intercept.topOffset +
	        "px; border: 0; background-color: transparent;\" >";

	      interceptDiv += 
	        "<img src=\"" +
	        Survey.Intercept.interceptImageURL +
	        "\" width=\"" +
	        Survey.Intercept.interceptWidth +
	        "\" height=\"" +
	        Survey.Intercept.interceptHeight +
	        "\" border=\"0\" alt=\"\" usemap=\"#interceptMap\" >";

	      interceptDiv += "<map name=\"interceptMap\">";

	      // decline intercept button
	      interceptDiv += 
	        "<area shape=\"rect\" alt=\"\" coords=\"" +
	        Survey.Intercept.declineInterceptButtonCoordinates +
	        "\" href=\"javascript:Survey.Intercept.flyOutIntercept();\" />";

	      // accept intercept button
	      interceptDiv += 
	        "<area shape=\"rect\" alt=\"\" coords=\"" +
	        Survey.Intercept.acceptInterceptButtonCoordinates +
	        "\" href=\"" +
	        Survey.Intercept.interceptDestinationURL +
	        "\" onclick=\"Survey.Intercept.hideIntercept()\" target=\"_new\" />";

	      // default, do nothing, areas listed above take precedence
	      interceptDiv += 
	        "<area shape=\"rect\" alt=\"\" coords=\"0,0," +
	        Survey.Intercept.interceptWidth +
	        "," +
	        Survey.Intercept.interceptHeight +
	        "\" nohref onclick=\"Survey.Intercept.suppressOneDismissal = true;\" />";

	      interceptDiv += "</map>";

	      interceptDiv += "</div>";

	      var dummyDiv = document.createElement( "div" );
	      dummyDiv.style.position = "absolute";
	      dummyDiv.style.top = "0px";
	      dummyDiv.style.zIndex = 1001;
	      dummyDiv.innerHTML = interceptDiv;

	      document.body.appendChild( dummyDiv );

	      Survey.Intercept.calculateStopPoint();

	      Survey.Intercept.interceptTimer =
	        window.setTimeout(
	          "Survey.Intercept.moveIntercept( " +
	          Survey.Intercept.stopX +
	          ", " +
	          Survey.Intercept.flyInStep +
	          ", " +
	          false +
	          " )",
	          Survey.Intercept.pauseBeforeFlyIn
	        );

/*
do not dismiss intercept unless they click decline button.
code below causes intercept to dismiss if they click anywhere else on page.

	      if ( document.addEventListener )
	        document.addEventListener( "click", Survey.Intercept.flyOutIntercept, false );

	      if ( document.attachEvent )
	        document.attachEvent( "onclick", Survey.Intercept.flyOutIntercept );
*/
	},
	
	interceptStart: function( url ) {
		var browserName = navigator.appName;
		if ( browserName == "Netscape" ) {
		  Survey.Intercept.isNetscape = true;
		} else {
		  if ( browserName == "Microsoft Internet Explorer" ) {
		    Survey.Intercept.isInternetExplorer = true;
		  } else {
		    Survey.Intercept.isUnknownUserAgent = true;
		  }
		}
		
		
	  if (url != null) {
	  	Survey.Intercept.interceptDestinationURL = url;

		  // set the intial width values
		  Survey.Intercept.initialLeft = -2 * Survey.Intercept.interceptWidth;
		  Survey.Intercept.currentLeft = Survey.Intercept.initialLeft;
	  }
	  try {
	    var temp = "";
	    if ( document.body != null ) {
	      temp = document.body.innerHTML;
	    }
	    if ( temp != "" && document.readyState ) {
	      if ( document.readyState != "complete" ) {
	        temp = "";
	      }
	    }
	    if ( temp != "" ) {
	      Survey.Intercept.displayIntercept();
	    } else {
	      window.setTimeout( "Survey.Intercept.interceptStart", 100 );
	    }
	  } catch ( e ) {
	    window.setTimeout( "Survey.Intercept.interceptStart", 100 );
	  }
	}
	
}

