//Forrester Site Survey

function processForresterSurvey(strURL,strSamplePercentage) {
    //BUSINESS RULE: Do NOT show survey if ANY survey has been served to this user within one year.
    //NOTE: ALL surveys now use a generic survey shown cookie that persists for 365 days.
    //      See ScriptLib.js survey functions.
    //NOTE: Forrester survey sample percentage is configurable in db.

    //FORRESTER SURVEY SWITCH
    var blnRunForresterSurvey = true;

    var blnSurveyShown = false;

    //NOTE: this method is defined in scriptLib.js
    blnSurveyShown = isSurveyShown();

    if(blnRunForresterSurvey && (! blnSurveyShown)) {
        showForresterSurvey(strURL,strSamplePercentage);
    }
}

function showForresterSurvey(strURL,strSamplePercentage) {

    var strSurveyURL = strURL;
    var strWinName = "ForresterSurvey";
    var strWinOptions = "directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no,height=550,width=570";

    var iSamplePercentage = parseInt(strSamplePercentage);

    //generate a random integer from 0-99
    var ranNum = Math.floor(Math.random() * 100);

    if(ranNum < iSamplePercentage) {

        //NOTE: survey window is a popunder!
        var objForresterPopWin = window.open(strSurveyURL,strWinName,strWinOptions);
        objForresterPopWin.blur();
        window.focus();

        //NOTE: this method is defined in scriptLib.js
        setSurveyShownCookie();
    }
}

