﻿var urlCheck = 0;
var internalUrlCheck = false;
var surveyUrl = "/kronos.web.corporate/ExitSurvey/tabid/323/Default.aspx";

function InternalLink()
{
    internalUrlCheck = true;
    RequestExitSurvey();
}

function RequestExitSurvey() 
{
    if(urlCheck == 0)
    {
        urlCheck = 1;
        window.setTimeout('__ReceiveCallback()',0); 
    }            
} 

function __ReceiveCallback()
{
    if(internalUrlCheck == false)
    {
       var currentLocation = window.location.pathname;
       var exitSurveyLocation1 = '/YourHealth/LifestyleManagement/Prediabetes/tabid/287/Default.aspx';
       var exitSurveyLocation2 = '/YourCompanysHealth/LifestyleManagement/KronosPrediabetes/tabid/288/Default.aspx';
       var exitSurveyLocation3 = '/kronos.web.corporate/YourHealth/LifestyleManagement/Prediabetes/tabid/287/Default.aspx';
       var exitSurveyLocation4 = '/kronos.web.corporate/YourCompanysHealth/LifestyleManagement/KronosPrediabetes/tabid/288/Default.aspx';
                
       if(currentLocation == exitSurveyLocation1 || 
          currentLocation == exitSurveyLocation2 ||
          currentLocation == exitSurveyLocation3 || 
          currentLocation == exitSurveyLocation4)
       {
           var randomnumber = Math.floor(Math.random()*101);       
       
           if(randomnumber < 0)
           {
                var surveyRequest = window.confirm('We value your feedback about Kronos Prediabetes. \r\n \r\nPlease take our brief 3-question survey. \r\n \r\nProceed');
                
                if(surveyRequest == true)
                { 
                     window.location = surveyUrl;                      
                }   
            } 
        }               
    }
}           