﻿var randID;
var uniqueUser;
var dest = 'http://www.numbernerd.net/images.aspx?';

function _srVoid(){ return; }

function _trackPixel(){
    var url = '', ref = '', s = '', ce = '', je = '', tz = '', ln = '', un = '';
    var date = new Date();
    if(window.location && window.location.href) url = encodeURIComponent(window.location.href);
    if(typeof navigator.javaEnabled != 'undefined') je = (navigator.javaEnabled()) ? '1' : '0';
    if(self.screen) s = screen.width + '+' + screen.height + '+' + screen.colorDepth;
    ref = window.document && window.document.referrer ? encodeURIComponent(window.document.referrer) : '';
    ce = (navigator.cookieEnabled) ? '1' : '0';
    tz = date.getTimezoneOffset();
    ln = window.navigator.userLanguage;

    var img = new Image(1,1);
    img.src = dest + 'an=' + srTrackerId + '&u=' + url + '&r=' + ref + '&s=' + s + '&ce=' + ce + '&je=' + je + '&tz=' + tz + '&ln=' + ln + '&un=' + uniqueUser + '&id=' + escape(randID);
    img.onLoad = function() { _srVoid(); }
}

function _srCookie()
{
    if(!(document.cookie.indexOf('track') > -1))
    {
        var dt = new Date();
        var cookie = 'track=1;';
        
        cookie += 'path=/;';
        cookie += 'expires=' + new Date(dt.getFullYear(), dt.getMonth(), daysInMonth(dt.getMonth() - 1, dt.getFullYear()), 23,59,59).toGMTString() + ';';
        cookie += 'domain=' + escape(document.domain) + ';';
        document.cookie = cookie;
                
        uniqueUser = '1';
    }else{
        uniqueUser = '0';
    }
}

function UpdateTime()
{
    var img = new Image(1,1);
    img.src = dest + 'com=up&id=' + escape(randID) + '&u=' + encodeURIComponent(window.location.href);
    img.onLoad = function() { _srVoid(); }
}

function Track()
{
    startTime = new Date();
    randID = guid();
    _srCookie();
    _trackPixel();
    
    setInterval ( "UpdateTime()", 3000 );     
}

function daysInMonth(month,year) {
    var dd = new Date(year, month, 0);
    return dd.getDate();
}

function S4() {
   return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
}

function guid() {
   return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
}