"LOSAD";
var surveyCookieName = pid + "_done";
  
if(ConfirmitCookies.get(surveyCookieName))
{
  ConfirmitLog(show,logString + " " + pid + " survey cookie present.  exiting.");
  ConfirmitCookies.set("exitsurveynotdisplayed", 'Cookie', {path : '/', secure:true, samesite: 'None'});
  return;
}
  
    	// check for invited session storage element
	if (sessionStorage.getItem("LOSADivt"))
	{
        ConfirmitLog(show,logString + " " + pid + " session variable present.  exiting.");
        ConfirmitCookies.set("exitsurveynotdisplayed", 'Cookie', {path : '/', secure:true, samesite: 'None'});
		return;
	}
  
if(ConfirmitCookies.get(oneDayCookieName))
{
  ConfirmitLog(show,logString+" one survey a day cookie present.  exiting.");
  ConfirmitCookies.set("exitsurveynotdisplayed", 'Cookie', {path : '/', secure:true, samesite: 'None'});
  return;
}


	var confdbu = ""+dataObject.bu;
	var confdbulc = confdbu.toLowerCase();
    var doNEC = false;
    if( confdbulc.indexOf("nec") != -1 )
    {
        doNEC = true;
    }
  
var plang = dataObject.lc ? dataObject.lc : "en";
//var slang = getLang( plang );
var cntry = dataObject.cc ? dataObject.cc : "us";
var slang = getLang( plang, cntry, doNEC, pid );
  
ConfirmitLog(show,logString+"lc from data object: " + plang);
ConfirmitLog(show,logString+"Confirmit language code: " + slang); 

var dstr = JSON.stringify(dataObject);
ConfirmitLog(show,logString+"data Object: " + dstr);

var cfstr = JSON.stringify(configObject);
ConfirmitLog(show,logString+"config Object: " + cfstr);

var dObj = new Object(); // JSON.parse(dstr);
dObj.cc = escape(dataObject.cc);
dObj.lc = escape(dataObject.lc);
dObj.bu = escape(dataObject.bu);
dObj.pn = escape(dataObject.pn);
dObj.rf = escape(dataObject.rf);
dObj.sd = escape(dataObject.sd);
dObj.rg = escape(dataObject.rg);
dObj.views = escape(dataObject.views);
dObj.im = ConfisMobile();
dObj.lt = plt;
dObj.gr = dataObject.gr;
var cp = dataObject.cp 
if( cp )
{
dObj.cp = escape(dataObject.cp);
}

try{ dObj.on = lmd.purchase.orderID; } catch(e) { dObj.on = "" }
try{ dObj.pm = lmd.purchase.paymentMethod; } catch(e) { dObj.pm = "" }

//if( dObj.bu.toUpperCase() == 'B2B')
if( false )
{
 console.log( "bu B2B - switch lc to EN" );
 dObj.lc = 'en';
 plang = "en";
 slang = "9";
}
else
{
 console.log( "bu not B2B - no lc switch" );
}

var useQM = false;
if (!window.QuantumMetricAPI || !window.QuantumMetricAPI.isOn() || !window.QuantumMetricAPI.isUserEnabled() || !window.QuantumMetricAPI.getReplay())
{
	// QM is not present, or not enabled.  Do not run QM.
}
else
{
	// QM present and enabledPlugin
	useQM = true;

}

if( useQM )
{
     var qmgs = "" + QuantumMetricAPI.getSessionID();
     var qmgu = "" + QuantumMetricAPI.getUserID();
	 
	 dObj.qmsid = qmgs
	 dObj.qmuid = qmgu;
}
else										   
{
	console.log( "DF QM NP" );			 
}


  
try { dObj.bt = escape(lmd.bu); } catch(e) { dObj.bt = "missing"; console.log(e) }
try { dObj.bpid = escape(dataObject.bpid); } catch(e) { dObj.bpid = "missing"; console.log(e) }
try { dObj.cn = escape(dataObject.cn); } catch(e) { dObj.cn = "missing"; console.log(e) }
        if(typeof s != "undefined")
        {
                dObj.amc = escape(s.marketingCloudVisitorID);
        }
dObj.env = "L";
  
dObj.csr = screen.width + "x" + screen.height;
dObj.wiw = window.innerWidth;
dObj.l = slang;
dObj.curl = escape(document.location.href);
dObj.chn = escape(document.location.hostname);
  
var sp = dataObject.sp 
if( sp )
{
dObj.sp = escape(dataObject.sp);
}
  
if(test)
{
dObj.test = 1;
dObj.jpgtest = 1;
}
  dObj.usrt = escape(lmd.userType);
  try{ dObj.ueml = escape(lmd.user.emailID); } catch { dObj.ueml = 'NA'; }
  
var delay = configObject.delay ? configObject.delay : 4;
var cookieExpireDays = configObject.expire ? configObject.expire : 30; 
//var pct = configObject.incidence ? parseInt(configObject.incidence) : 30;
var pct = (configObject.incidence || globalSurveyConfig.incidence) ? configObject.incidence ? configObject.incidence : globalSurveyConfig.incidence : 30;
console.log("CONF: Delay: " + delay);
console.log("CONF: Pct Itcp: " + pct);
  
if( pct < 100 )
{
	// check nth visitor session variable on each page.  if not present, set nth visitor.
	if (sessionStorage.getItem(pid + "_nth"))
	{
	  var nthvisitor  = sessionStorage.getItem(pid + "_nth") == "1" ? true : false;
	  ConfirmitLog(show,logString + "session nth visitor: " + nthvisitor);
	}
	else
	{
	  var nthvisitor  = Math.random() < pct/100;
	  ConfirmitLog(show,logString + "nth visitor check: " + nthvisitor);
	  sessionStorage.setItem(pid + "_nth",nthvisitor ? "1" : "0");   // 1 to show, 0 to not show
	}
	
	if(!nthvisitor)
	{
		ConfirmitLog(show,logString + "not nth visitor.  exiting.");
		ConfirmitCookies.set("exitsurveynotdisplayed", 'Incident check', {path : '/', secure:true, samesite: 'None'});
		return;
	}
		ConfirmitLog(show,logString + "nth visitor check passed.  running.");	
}
else
{
	ConfirmitLog(show,logString + "defaulting to 100% incidence.");
}
	
	
var invite = "DomainExitML2";

  
ConfirmitLog(show,logString+"data Object: " + JSON.stringify(dObj));

var fn = function () {
	
var cfstr = "Ecomm|Exit Survey|" + pid;

try{
lmd.survey = {};
lmd.survey.surveytype = cfstr;
lmd.survey.interaction = "Exit survey Invite : invitation";
}
catch(e)
{
	console.log( 'error setting lmd: ' + e );
}

 var dnow = new Date();
 var topis = (dnow.getTime() - parseInt(plt) )/1000;
 dObj.topis = topis;

			  const rptcfg = { //FOR INVITE COUNTS TO SHOW ON METRICS PAGE
				countInvitePresented: true,
				countInviteAccepted: true,
				countInviteClosed: true,
				countInviteDeclined: true
			  }
              
    ConfirmitLog(show,"showing invite")
	var ctx = api(rptcfg);
  	ctx.invite(invite);
	ctx.container(container);
    ctx.survey(pid);
	ctx.data(dObj);
	ctx.show();
	
	tldobj = dObj;
	console.log( dObj );
		
	sessionStorage.setItem("LOSADivt","1");
	ConfirmitCookies.set(oneDayCookieName, '1', {path : '/', expiry : 86400, secure:true, samesite: 'None'});
	ConfirmitCookies.set(surveyCookieName, '1', {path : '/', expiry : parseInt(cookieExpireDays)*86400, secure:true, samesite: 'None'});

	var confdbu = ""+dataObject.bu;
	var confdbulc = confdbu.toLowerCase();
    var doNEC = false;
    if( confdbulc.indexOf("nec") != -1 )
    {
        doNEC = true;
    }
	if( doNEC )
	{
		ConfirmitCookies.set(surveyCookieName, '1', {path : '/', expiry : parseInt(cookieExpireDays)*86400, secure:true, samesite: 'None', domain:'nec-lavie.jp'});
	}
	else
	{	
		ConfirmitCookies.set(surveyCookieName, '1', {path : '/', expiry : parseInt(cookieExpireDays)*86400, secure:true, samesite: 'None', domain:'lenovo.com'});
	}
	
ctx.events.showInvite.on(
  function() { 
    var itxts = getTxts(plang,cntry);
     console.log("set line1")
    document.getElementsByClassName('cf-invite__title')[0].innerHTML = itxts.l1;
     console.log("set line2")
    document.getElementsByClassName('cf-invite__content')[0].innerHTML = itxts.l2;
     console.log("set b1")
    document.getElementsByClassName('cf-invite__button--accept')[0].innerHTML = itxts.b1;
     console.log("set b2")
    document.getElementsByClassName('cf-invite__button--decline')[0].innerHTML = itxts.b2;
     console.log("set a1")
    document.getElementsByClassName('cf-invite-wrapper')[0].setAttribute('aria-label', itxts.al1);
     console.log("set a2")
    document.getElementsByClassName('cf-invite__close')[0].setAttribute('aria-label', itxts.al2);
     console.log("set a3")
    document.getElementsByClassName('cf-invite__button--accept')[0].setAttribute('aria-label', itxts.al3);

    try { _satellite.track('survey-invite-prompt'); } catch(e) {console.log( 'satellite not loaded' );}
	try { _satellite.track("survey-invite-interaction"); } catch(e) {console.log( 'satellite not loaded' );}
  });
 
ctx.events.closeInvite.on(
  function() { 
    console.log('invite closed');

	try{
	lmd.survey.interaction = "Exit survey Invite : close";
	try { _satellite.track("survey-invite-interaction"); } catch(e) {console.log( 'satellite not loaded' );}
	}
	catch(e)
	{
		console.log( 'error setting lmd: ' + e );
	}
	
  });

ctx.events.declineInvite.on(
  function() { 
    console.log('invite declined'); 
	
	try{
	lmd.survey.interaction = "Exit survey Invite : decline";
	try { _satellite.track("survey-invite-interaction"); } catch(e) {console.log( 'satellite not loaded' );}
	}
	catch(e)
	{
		console.log( 'error setting lmd: ' + e );
	}
	
  });
  
ctx.events.acceptInvite.on(
  function() { 
    console.log('invite accepted'); 
	
	try{
	lmd.survey.interaction = "Exit survey Invite : accept";
	try { _satellite.track("survey-invite-interaction"); } catch(e) {console.log( 'satellite not loaded' );}
	}
	catch(e)
	{
		console.log( 'error setting lmd: ' + e );
	}
	
  });

ctx.events.completeSurvey.on(
  function() { 
    console.log('survey completed'); 
  });
  
};



setTimeout(fn, delay*1000);
}

};Ә