//v1.3.1
var nn_undefined;
function nn_isNull(object) {
return nn_undefined == object || object == null;
}
var nn_domainSuffixes = [ "com", "net", "org", "biz", "info", "gov", "edu", "mil" ];
function nn_arrayContains(nn_array, nn_token) {
for (var nn_i = 0; nn_i < nn_array.length; nn_i++) {
if (nn_array[nn_i] == nn_token) {
return true;
}
}
return false;
}
function nn_removePort(nn_domain) {
var nn_colonIndex = nn_domain.lastIndexOf(':');
if (nn_colonIndex > 0) {
return nn_domain.substring(0, nn_colonIndex);
}
return nn_domain;
}
function nn_getMinimumDomain(nn_domain) {
if (nn_isNull(nn_domain)) {
return null;
}
nn_domain = nn_domain.toLowerCase();
nn_domain = nn_removePort(nn_domain);
var nn_index = nn_domain.length;
while (3 < nn_index && nn_domain.charAt(nn_index - 3) == '.') {
nn_index -= 3;
}
var nn_previousIndex = nn_index;
nn_index = nn_domain.lastIndexOf('.', nn_index - 1);
var nn_token = nn_domain.substring(nn_index + 1, nn_previousIndex);
if (nn_arrayContains(nn_domainSuffixes, nn_token) && nn_index > 0) {
nn_previousIndex = nn_index;
nn_index = nn_domain.lastIndexOf('.', nn_index - 1);
}
if (nn_index == -1 || nn_domain.charAt(nn_index) == '.') {
nn_index ++;
}
if (nn_index == nn_previousIndex) {
return "." + nn_domain;
}
return "." + nn_domain.substring(nn_index);
}
var nn_THREE_YEARS_IN_MILLIS = (1000 * 60 * 60 * 24 * 365 * 3);
/* public */ function nn_Cookie(name) {
/* public */
this.setCookie = nn_Cookie_setCookie;
this.getCookie = nn_Cookie_getCookie;
this.expireCookie = nn_Cookie_expireCookie;
/* 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();
}
function nn_Cookie_createCookieDescriptionWithoutDomain(name, value, expireDate) {
var cookieDescription = name + "=" + escape(value);
cookieDescription += "; path=/";
cookieDescription += "; expires=" + nn_Cookie_getExpirationDateAsString(expireDate);
return cookieDescription;
}
function nn_Cookie_createCookieDescription(name, value, expireDate, domain) {
var cookieDescription = nn_Cookie_createCookieDescriptionWithoutDomain(name, value, expireDate);
if (nn_isNull(domain) && document.domain) {
domain = document.domain;
}
if (!nn_isNull(domain)) {
cookieDescription += "; domain=" + escape(nn_getMinimumDomain(domain));
}
return cookieDescription;
}
/* public */ function nn_Cookie_setCookie(name, value, expireDate, domain) {
nn_Cookie_expireCookie(name);
document.cookie = nn_Cookie_createCookieDescription(name, value, expireDate, domain);
if (nn_isNull(nn_Cookie_getCookie(name))) {
document.cookie = nn_Cookie_createCookieDescriptionWithoutDomain(name, value, expireDate);
}
}
/* private */ 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);
value = unescape(value);
return (value != "") ? value : null;
}
/* public */ function nn_Cookie_expireCookie(name, domain) {
var expiredTime = new Date(new Date().getTime() - 1000*60*60);
document.cookie = nn_Cookie_createCookieDescription(name, "", expiredTime, domain);
if (!nn_isNull(nn_Cookie_getCookie(name))) {
document.cookie = nn_Cookie_createCookieDescriptionWithoutDomain(name, "", expiredTime);
}
}
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.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 (nn_isNull(cookie)) {
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_expireCookie(this.m_cookieName);
nn_Cookie_setCookie(this.m_cookieName, cookieValue);
return cookieValue;
}
/* private */ function nn_DateThrottle_createCookieValue(date, offset) {
var cookieValue = date.getTime() + offset;
return cookieValue.toString();
}
function nn_write_document(str) {
document.write(str);
}
function nn_survey(visitorid) {
var nn_dateThrottle = new nn_DateThrottle();
if ((visitorid % 64 == 0) && !nn_dateThrottle.shouldThrottle()) {
nn_dateThrottle.updateCookie();
nn_write_document("");
}
}
function nn_build_ping_url(filename) {
var nn_now = new Date();
var nn_title;
if (!window.encodeURI) {
nn_title = escape(document.title);
} else {
nn_title = window.encodeURI(document.title);
}
var nn_imageUrl =
"../../../ping.nnselect.com/" + filename +
"@d=" + nn_now.getTime() +
"&c=125" +
"&u=" + escape(document.URL) +
"&t=" + nn_title;
return nn_imageUrl;
}
function nn_send_ping(url) {
if (document.images) {
var nn_image = new Image();
nn_image.src = url;
} else {
nn_write_document("");
}
}
function nn_simple_ping() {
nn_send_ping(nn_build_ping_url("ping.gif"));
}
function nn_ping_and_set_local_cookie() {
nn_write_document("");
}
function nn_set_visitor_cookie(cookieValue) {
nn_Cookie_setCookie("nn_V", cookieValue);
nn_survey(cookieValue);
}
function nn_survey_main() {
var nn_cookieValue = nn_Cookie_getCookie("nn_V");
if (!nn_isNull(nn_cookieValue)) {
if ((nn_cookieValue % 64) == 0) {
nn_simple_ping();
nn_survey(nn_cookieValue);
}
} else {
nn_ping_and_set_local_cookie();
}
}
nn_survey_main();