
 // <!-- START JAVASCRIPT

// MAIN SURVEY DEPENDENT VARS
  var strSurveyURL = "http://player.surveynet.com/bin/cancerinvite.pl";  
//  var strSurveyURL = "http://intellipoll-test/demos/training_rmasso/JScriptCancerStudy/cancerinvite.pl";  
  var strDomain = ".cbcf.org";
  var strLLC = "CBCF";
  var intPercent = 15;
  var intMonthsToSaveCookie = 1;

 // comments
  var strReason = "";

// END SURVEY DEPENDENT VARS

// NOTE: THERE ARE 2 MORE PLACES THAT THE CODE IS MODIFIED BELOW.....

  function getCookieVal (intOffset) {
    var strCookieValue = document.cookie.indexOf (";", intOffset);
    if (strCookieValue == -1)
      strCookieValue = document.cookie.length;
    return unescape(document.cookie.substring(intOffset, strCookieValue));
  }

  function GetCookie (strCookieName) {
    var strArg = strCookieName + "=";
    var intArgLength = strArg.length;
    var intCookieLength = document.cookie.length;
    var i = 0;
    while (i < intCookieLength) {
      var j = i + intArgLength;
      if (document.cookie.substring(i, j) == strArg)
        return getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break;
    }
    return null;
  }

  function shiftDate(intMonthAdvance) {
    if (intMonthAdvance == null) {
      intMonthAdvance=0; //No parameter then assume 0
    }
    else {
     intMonthAdvance=parseInt(intMonthAdvance); //Make sure its a number
    }
    var dtmNow=new Date();
    dtmNow.setMonth(dtmNow.getMonth()+intMonthAdvance); //Set Expiration date to advance months from now
    return dtmNow.toGMTString();
  }

  function Is (){
    // CONVERT ALL CHARACTERS TO LOWERCASE TO SIMPLIFY TESTING
    var agt=navigator.userAgent.toLowerCase()

    // *** BROWSER VERSION ***
    this.major = parseInt(navigator.appVersion)
    this.minor = parseFloat(navigator.appVersion)

    this.nav  = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1)))
    this.nav2 = (this.nav && (this.major == 2))
    this.nav3 = (this.nav && (this.major == 3))
    this.nav4 = (this.nav && (this.major == 4))
    this.nav4up = this.nav && (this.major >= 4)
    this.navonly      = (this.nav && (agt.indexOf(";nav") != -1))

    this.ie   = (agt.indexOf("msie") != -1)
    this.ie3  = (this.ie && (this.major == 2))
    this.ie4  = (this.ie && (this.major == 4))
    this.ie4up  = this.ie  && (this.major >= 4)

    this.opera = (agt.indexOf("opera") != -1)

    // *** JAVASCRIPT VERSION CHECK ***
    // USEFUL TO WORKAROUND NAV3 BUG IN WHICH NAV3
    if (this.nav2 || this.ie3) this.js = 1.0
    else if (this.nav3 || this.opera) this.js = 1.1
    else if (this.nav4 || this.ie4) this.js = 1.2
    else if ((this.nav && (this.minor > 4.05)) || (this.ie && (this.major > 4)))
      this.js = 1.2
    else this.js = 0.0 // HACK: always check for JS version with > or >=
  }

  function invitePopupWin() {
    //TEST BROWSER
    var is;
    var isIE3Mac = false;
    // THIS SECTION IS DESIGNED SPECIFICALLY FOR IE3 FOR THE MAC

    if ((navigator.appVersion.indexOf("Mac")!=-1) && (navigator.userAgent.indexOf("MSIE")!=-1) && (parseInt(navigator.appVersion)==3))
       isIE3Mac = true;
    else
       is = new Is();

    // ALLOW THESE BROWSERS TO GET THE POP-UP
    if (!isIE3Mac && (is.nav3 || is.nav4up || is.ie3 || is.ie4up || is.opera)){
      //Test for cookie support
      document.cookie="SupportsCookies=true";
      var SupportsCookies=GetCookie("SupportsCookies");
      if (SupportsCookies!='true'){
        strReason='Cannot set cookie';
        return;
      }

      //CHECK FOR CONSIDERATION
      var TakenTheSurvey=GetCookie("ReceivedCSInviteIBMDW");  // Change cookie name, dependent on survey!!!
      if (! TakenTheSurvey){
        var dtmExpirationDate=shiftDate(intMonthsToSaveCookie);
        document.cookie="ReceivedCSInviteIBMDW=True;path=/;expires="+dtmExpirationDate;  // Change cookie name!!!!!
        var numRandomNumber=(Math.round(Math.random()*1000));
        if ((numRandomNumber <= (intPercent*10)) && (SupportsCookies)){
          strReason = "";
          //Set Cookie To Show that they were considered
          //Pop the window - set size to Intelliquest value
          strSurveyURL = strSurveyURL + "?LLC=" + strLLC +"&JSC=True&JSE=True";
          console=open(strSurveyURL,"console","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=510,height=275,outerwidth=0,outerheight=0,left=100,top=100,alwaysRaised=0,z-lock=0");
        }
        else {strReason='Qualify, but not randomly selected'; }
      }
      else {strReason='Already took survey'; }
    }
    else {strReason='Browser is not compatible'; }
  }

  invitePopupWin();
  //END JAVASCRIPT -->



