var gPopupForm; var topPanel = false; var videoRequestDismissCount = parseInt(getCookieValue('videoRequestDismissCount')); if (!videoRequestDismissCount) {videoRequestDismissCount = 0;} // if not defined default to zero var LandingPageURL = getCookieValue('LandingPageURL'); var popupVisible = false; clickedCount = parseInt(getCookieValue('clickedLinkCount')); // load the current click count from the cookie var videoRequested = getCookieValue('VideoRequested'); if (!videoRequested) videoRequested="N"; var ideaKitRequested = getCookieValue('IdeaKitRequested'); if (!ideaKitRequested) ideaKitRequested="N"; var popUrl = ""; // defined in displayVideoRequest // // Define logic for clearing click counts and dismissal counts after a number of days // var lastDismissalDate = new Date(); lastDismissalDate = getCookieValue('lastDismissalDate'); if (!lastDismissalDate) lastDismissalDate=0; var formSubmissionDate = new Date(); formSubmissionDate = getCookieValue('formSubmissionDate'); if (!formSubmissionDate) formSubmissionDate=0; if (ideaKitRequested=="N") { if ((videoRequested=="N") && (lastDismissalDate!=0)) { var dt = new Date(lastDismissalDate); 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; } } } // Function for debugging -- not currently used function getQueryVal(queryIndex) { var retVal = false; if (typeof epURLParts[queryIndex] != 'undefined') { retVal = epURLParts[queryIndex]; } else { } return retVal; } // // Set up the dismiss count logic // var disMissCounts = new Array(); disMissCounts[0] = 3; disMissCounts[1] = 15; disMissCounts[2] = 100; disMissCounts[3] = 10000; disMissCounts[4] = 1000000; // // Set up click counting by attaching an event listener to each link on the page // jQuery(document).ready(function() { setupLinksForCounting(); }); // // Decide which click-based pop-up to display and pop it up // jQuery(window).load(function () { Window.keepMultiModalWindow = true; if (typeof DontShowClickPopup == 'undefined') { DontShowClickPopup = false; } var displayClickBasedPopup = false; if (videoRequestDismissCount < 4) { if (clickedCount >= disMissCounts[videoRequestDismissCount] && clickedCount < disMissCounts[videoRequestDismissCount + 1]) { displayClickBasedPopup = !DontShowClickPopup && videoRequested == 'N'; } } var displayIdeaKitPopup = false; if (videoRequestDismissCount < 4) { if (clickedCount >= disMissCounts[videoRequestDismissCount] && clickedCount < disMissCounts[videoRequestDismissCount + 1]) { displayIdeaKitPopup = !DontShowClickPopup && videoRequested == 'Y' && ideaKitRequested == 'N'; } } if (displayClickBasedPopup) { displayVideoRequest(); } if (displayIdeaKitPopup) { doideaKitPopup = true; displayVideoRequest(); } }); // // 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'); var cookieName = "videoRequestDismissCount"; var cookieValue = getCookieValue(cookieName); if (cookieValue && cookieValue != "NaN") { cookieValue = cookieValue * 1; cookieValue += 1; } else { cookieValue = 1; } createCookie(cookieName, cookieValue, 365); //Dialog.closeInfo(); gPopupForm.close(); popupVisible = false; } }); // // Handle the pop up form submit event with an ajax call // function postDataToServer(FormID) { if (epValidateForm(FormID)) { var postData = getPostArrayFromForm(FormID); var postURL = jQuery('#' + FormID)[0].action; jQuery.ajax({ url: postURL, type:'POST', data: postData, dataType:'html', async:'false', timeOut:10000, success: function(html) { //var popUrl = getPopURL(false); popupVisible = false; pageTracker._trackEvent("popup_div", "good submission", popUrl); // Google's event tracker logExtra = popUrl; logEvent('Form Submitted Good'); createCookie('formSubmissionDate', Date(), 365); gPopupForm.close(); }, error: function() { alert("We experienced an error sending your request, please try again."); } }); } } // // Load in the form and return it as a string // function getPostArrayFromForm(FormID) { var myFormArray = new Array(); myFormArray = Form.serialize(FormID); return myFormArray; } // // Validate the form before submission // function epValidateForm(FormID) { var ret = true; var requiredFields = jQuery('#' + FormID + ' .form_required'); var turnRed = false; var turnBlack = true; if (typeof epOriginalLabelColor != 'undefined') { } else { epOriginalLabelColor = jQuery('#form1 label').css('color'); } //alert (epOriginalLabelColor); requiredFields.each(function(i, v) { switch (v.tagName) { case 'INPUT': if (v.value.trim() == '') { ret = false; turnRed = true; turnBlack = false; //jQuery('#' + v.id).parent().prev().css('color', '#FF0000'); } else { turnRed = false; turnBlack = true; //jQuery('#' + v.id).parent().prev().css('color','#000000'); } break; case 'SELECT': if (v.selectedIndex == 0) { ret = false; turnRed = true; turnBlack = false; //jQuery('#' + v.id).parent().prev().css('color', '#FF0000'); } else { turnRed = false; turnBlack = true; //jQuery('#' + v.id).parent().prev().css('color','#000000'); } break; } if (turnRed) { jQuery("label[for='" + v.id + "']").css('color', '#FF0000'); jQuery("#required_legend").show(); jQuery("#required_legend label").css('color', '#FF0000'); } else if (turnBlack) { jQuery("label[for='" + v.id + "']").css('color', epOriginalLabelColor); jQuery("#required_legend").hide(); } }); if (!ret) { //var popUrl = getPopURL(false); pageTracker._trackEvent("popup_div", "bad submission", popUrl); // Google's event tracker logExtra = popUrl; logEvent('Form Submitted Bad'); } return ret; } function setHiddenLandingScriptVal(L) { jQuery("input[name='LandingScript']").val(L); } function setRequired(FieldID) { jQuery('#' + FieldID).addClass('form_required'); } // // Display the pop up and log an event PopUp Presented // function displayVideoRequest() { popUrl = getPopURL(false); jQuery.ajax({ url: popUrl, type:'GET', dataType:'html', async:'false', timeOut:10000, success: function(html) { gPopupForm = Dialog.info(html, { windowParameters: {id:"gPopupForm", resizable: false, width: 800, height:450, destroyOnClose: true, onShow: function() {setRequired('FirstConTitle'); setRequired('ContactFirst'); setRequired('ContactLast'); setRequired('PrimAdd'); setRequired('PrimCity'); setRequired('State'); setRequired('ZipCode'); setHiddenLandingScriptVal(popUrl); popupVisible = true; jQuery('#form1 label').css('color', epOriginalLabelColor);}}}); } }); pageTracker._trackEvent("popup_div", "presented", popUrl); // Google's event tracker logExtra = popUrl; logEvent('PopUp Presented'); } function dismissVideoRequest() { var cookieName = "videoRequestDismissCount"; var cookieValue = getCookieValue(cookieName); if (cookieValue && cookieValue != "NaN") { cookieValue = cookieValue * 1; cookieValue += 1; } else { cookieValue = 1; } createCookie(cookieName, cookieValue, 365); createCookie('lastDismissalDate', Date(), 365); gPopupForm.close(); popupVisible = false; //var popUrl = getPopURL(false); pageTracker._trackEvent("popup_div", "dismissed", popUrl); // Google's event tracker logExtra = popUrl; logEvent('PopUp Dismissed'); } // // 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); }); } // // Determine which pop up to pop up // function getPopURL(resetCurrentPopup) { if (typeof resetCurrentPopup == 'undefined') { resetCurrentPopup = false; } var popUrl = '/all/popup/generalDivPopup2.html?Clicked=' + clickedCount + '&Dismissed=' + videoRequestDismissCount + '&LandingPageURL=' + LandingPageURL; epOriginalLabelColor = 'black'; if (typeof doSwimSpaPopup != 'undefined' && doSwimSpaPopup == true) { var popUrl = '/all/popup/swimSpaDivPopup1.html'; epOriginalLabelColor = 'black'; } if (typeof doLapPoolPopup != 'undefined' && doLapPoolPopup == true) { var popUrl = '/all/popup/lapPoolDivPopup1.html'; epOriginalLabelColor = 'black'; } if (typeof doWaterWellPopup != 'undefined' && doWaterWellPopup == true) { var popUrl = '/all/popup/waterWellDivPopup1.html'; epOriginalLabelColor = 'black'; } if (typeof doideaKitPopup != 'undefined' && doideaKitPopup == true) { var popUrl = '/all/popup/freeIdeaKitDivPopup1.html'; epOriginalLabelColor = 'black'; } if (typeof doOpenWaterPopup != 'undefined' && doOpenWaterPopup == true) { var popUrl = '/all/popup/openWaterDivPopup1.html'; epOriginalLabelColor = 'black'; } //alert(popUrl); return popUrl; }