var nn_undefined; function nn_isNull(object) { return nn_undefined == object || object == null; } var nn_THREE_YEARS_IN_MILLIS = (1000 * 60 * 60 * 24 * 365 * 3); var nn_waitForCookieFunctor = null; /* public */ function nn_Cookie(name) { /* public */ this.setCookie = nn_Cookie_setCookie; this.getCookie = nn_Cookie_getCookie; this.expireCookie = nn_Cookie_expireCookie; this.registerCallbackForWhenCookieExists = nn_Cookie_registerCallbackForWhenCookieExists; /* private */ this.m_name = name; } /* private */ function nn_Cookie_getExpirationDate(expireDate) { if (!nn_isNull(expireDate)) { return expireDate; } else { return new Date(new Date().getTime() + nn_THREE_YEARS_IN_MILLIS); } } /* private */ function nn_Cookie_getExpirationDateAsString(expireDate) { return nn_Cookie_getExpirationDate(expireDate).toGMTString(); } /* public */ function nn_Cookie_setCookie(name, value, expireDate, domain) { var cookieDescription = name + "=" + escape(value); cookieDescription += "; path=/"; cookieDescription += "; expires=" + nn_Cookie_getExpirationDateAsString(expireDate); if (!nn_isNull(domain)) { cookieDescription += "; domain=" + escape(domain); } document.cookie = cookieDescription; } /* public */ function nn_Cookie_getCookie(name) { var key = name + "="; var startOfCookie = document.cookie.indexOf("; " + key); if (-1 != startOfCookie) { startOfCookie += 2; } else if (0 == document.cookie.indexOf(key)) { startOfCookie = 0; } else { return null; } var endOfCookie = document.cookie.indexOf(";", startOfCookie); if (endOfCookie == -1) { endOfCookie = document.cookie.length; } var value = document.cookie.substring(startOfCookie + key.length, endOfCookie); return unescape(value); } /* public */ function nn_Cookie_expireCookie(name, domain) { var expiredTime = new Date(new Date().getTime() - 1); nn_Cookie_setCookie(name, "", expiredTime, domain); } /* public */ function nn_Cookie_registerCallbackForWhenCookieExists(callback) { nn_waitForCookieFunctor = new nn_WaitForCookieFunctor(this.m_name, callback); nn_waitForCookieFunctor.execute(); } /* private */ function nn_WaitForCookieFunctor(cookieName, callback) { /* public */ this.execute = nn_WaitForCookieFunctor_execute; /* private */ this.m_cookieName = cookieName; this.m_callback = callback; } /* private */ function nn_WaitForCookieFunctor_execute() { nn_waitForCookieFunctor = this; if (!nn_isNull(nn_Cookie_getCookie(this.m_cookieName))) { this.m_callback(); } else { setTimeout("nn_waitForCookieFunctor.execute()", 500); } } var nn_DATE_THROTTLE_COOKIE_NAME = "nnselect"; var nn_ONE_DAY_IN_MILLIS = 1000 * 60 * 60 * 24; function nn_DateThrottle() { // public this.shouldThrottle = nn_DateThrottle_shouldThrottle; // private this.getOrCreate = nn_DateThrottle_getOrCreate; this.getCookie = nn_DateThrottle_getCookie; this.createCookie = nn_DateThrottle_createCookie; this.updateCookie = nn_DateThrottle_updateCookie; this.createCookieValue = nn_DateThrottle_createCookieValue; this.getRandomNumberBetween = nn_DateThrottle_getRandomNumberBetween; this.m_cookieName = nn_DATE_THROTTLE_COOKIE_NAME; } /* public */ function nn_DateThrottle_shouldThrottle() { var cookieValue = parseInt(this.getOrCreate()); var now = new Date().getTime(); var dateToStartSurvey = cookieValue + (nn_ONE_DAY_IN_MILLIS * 7); return (now < dateToStartSurvey); } /* private */ function nn_DateThrottle_getOrCreate() { var cookie = this.getCookie(); if (cookie == null) { cookie = this.createCookie(); } return cookie; } /* private */ function nn_DateThrottle_getCookie() { return nn_Cookie_getCookie(this.m_cookieName); } /* private */ function nn_DateThrottle_createCookie() { var now = new Date(); var offset = nn_ONE_DAY_IN_MILLIS * -8; var cookieValue = this.createCookieValue(now, offset); nn_Cookie_setCookie(this.m_cookieName, cookieValue); return cookieValue; } /* private */ function nn_DateThrottle_updateCookie() { var now = new Date(); var cookieValue = this.createCookieValue(now, 0); nn_Cookie_setCookie(this.m_cookieName, cookieValue); return cookieValue; } /* private */ function nn_DateThrottle_createCookieValue(date, offset) { var cookieValue = date.getTime() + offset; return cookieValue.toString(); } /* private */ function nn_DateThrottle_getRandomNumberBetween(min, max) { var range = max - min; var number = Math.round(Math.random() * range) + min; return number; } var nn_cookie_value = new nn_Cookie("V").getCookie("V"); var nn_have_cookie = !nn_isNull(nn_cookie_value); var nn_matches_ratio = false; if (nn_have_cookie) { var visitorId = parseInt(nn_cookie_value); nn_matches_ratio = ((visitorId % 64) == 0) } if (!nn_have_cookie || nn_matches_ratio) { var nn_now = new Date(); var nn_title; if (nn_isNull(window.encodeURI)) { nn_title = escape(document.title); } else { nn_title = window.encodeURI(document.title); } var nn_imageUrl = "../../../ping.nnselect.com/ping.gif" + "@d=" + nn_now.getTime() + "&c=119" + "&u=" + escape(document.URL) + "&t=" + nn_title; if (document.images) { var nn_image = new Image(); nn_image.src = nn_imageUrl; } else { document.write(""); } var nn_dateThrottle = new nn_DateThrottle(); if (!nn_dateThrottle.shouldThrottle()) { nn_dateThrottle.updateCookie(); document.write(""); } }