// // Globals // var gPopupForm; // Will be set to the jQuery pop up object var popUrl = ""; // The string url of the pop up defined in displayVideoRequest() var popupVisible = false; // Will not be needed in one minute var in7dayhold = false; // If true, wait 7 days after the form submission before displaying the pop-up for the idea kit. if (typeof(DontShowClickPopup) == 'undefined') {DontShowClickPopup = false;} // May be defined in the main html file if (typeof(timeBasedPopup) =='undefined') {timeBasedPopup="";} // May be defined in the main html file if (typeof(timeBasedTimer1)=='undefined') {timeBasedTimer1= 5000;} if (typeof(timeBasedTimer2)=='undefined') {timeBasedTimer2= 5000;} // // Load in the cookie values // var clickedCount = parseInt(getCookieValue('clickedLinkCount',0)); // load the current click count from the cookie var popupPresentedCount = parseInt(getCookieValue('popupPresentedCount',0)); var LandingPageURL = getCookieValue('LandingPageURL',''); var videoRequested = getCookieValue('VideoRequested','N'); var ideaKitRequested = getCookieValue('IdeaKitRequested','N'); var lastPopupDate = new Date(); lastPopupDate = getCookieValue('lastPopupDate',0); var formSubmissionDate = new Date(); formSubmissionDate = getCookieValue('formSubmissionDate',0); // // Attach an event listener to each link on the page to count clicks // function setupLinksForCounting() { jQuery('a').click(function(){ var cookieName = "clickedLinkCount"; var cookieValue = getCookieValue(cookieName); if (cookieValue && cookieValue != "NaN") { cookieValue = cookieValue * 1; cookieValue += 1; } else { cookieValue = 1; } createCookie(cookieName, cookieValue, 365); }); } // // Define logic for clearing click counts and dismissal counts after a number of days // function checkPopUpCycle() { if (ideaKitRequested=="N") { if ((videoRequested=="N") && (lastPopupDate!=0)) { var dt = new Date(lastPopupDate); dt.setDate(dt.getDate() + 7); if (dt 0) { var tempIndex = ''; var tempVal = ''; var tempArgs; for (var i = 0; i < tempParts.length; i ++) { tempArgs = tempParts[i].split('='); tempIndex = tempArgs[0]; tempVal = tempArgs[1]; epURLParts[tempIndex] = tempVal; } } } return(epURLParts); } function getQueryVal(queryIndex) { var epURLParts = parseLocation(); var retVal = false; if (typeof epURLParts[queryIndex] != 'undefined') { retVal = epURLParts[queryIndex]; } return retVal; } // // Main // // Reset dismissal counts and click counts after 7 days, hold popups for 7days after form submission checkPopUpCycle(); // Set up the dismiss count logic var presentedCounts = new Array(); presentedCounts[0] = 3; presentedCounts[1] = 15; presentedCounts[2] = 100; presentedCounts[3] = 10000; presentedCounts[4] = 1000000; // On Document Ready -- DOM is loaded, page contents are not yet loaded jQuery(document).ready(function() { // Set up click counting by attaching an event listener to each link on the page setupLinksForCounting(); }); // On Window Load -- page contents are loaded jQuery(window).load(function () { // Just in case we need two modal windows - currently not used Window.keepMultiModalWindow = true; // Decide if a click-based pop-up should be displayed if (timeBasedPopup!="") {DontShowClickPopup = true;} // Check to see if B-pack pop up is appropriate var displayClickBasedPopup = false; if (popupPresentedCount < 4) { if (clickedCount >= presentedCounts[popupPresentedCount] && clickedCount < presentedCounts[popupPresentedCount + 1]) { displayClickBasedPopup = !DontShowClickPopup && videoRequested == 'N'; } } // Check to see if D-pack pop up is appropriate var displayIdeaKitPopup = false; if (popupPresentedCount < 4) { if (clickedCount >= presentedCounts[popupPresentedCount] && clickedCount < presentedCounts[popupPresentedCount + 1]) { displayIdeaKitPopup = !DontShowClickPopup && videoRequested == 'Y' && ideaKitRequested == 'N' && !in7dayhold; } } if (displayClickBasedPopup) { displayVideoRequest(); } if (displayIdeaKitPopup) { doideaKitPopup = true; displayVideoRequest(); } // Decide if a time-based pop-up should be displayed if (timeBasedPopup!="") { if(videoRequested != 'Y') { if (popupPresentedCount == 0) setTimeout("displayVideoRequest()", timeBasedTimer1); if (popupPresentedCount == 1) setTimeout("displayVideoRequest()", timeBasedTimer2); } } }); // Add a listener for the window unload event to track pop-up abandons jQuery(window).bind('beforeunload', function() { if (popupVisible) { //var popUrl = getPopURL(false); pageTracker._trackEvent("popup_div", "abandoned", popUrl); // Google's event tracker //logExtra = popUrl; //logEvent('PopUp Abandoned'); //Dialog.closeInfo(); gPopupForm.close(); popupVisible = false; } });