var strSite='654';var strPattern=/applied.php/;var strCookieName='atb-app-654';

function ReportStats() {
    var strReferrer = getCookie(strCookieName);
    var strUrl = window.location.href;
    var strRequest = "http://stats.allthetopbananas.com/log.aspx?r=" + encodeURIComponent(strReferrer) + "&p=" + encodeURIComponent(strUrl) + "&s=" + encodeURIComponent(strSite);
    document.write("<script language=\"javascript\" type=\"text/javascript\" src=\"" + strRequest + "\"></script>");
}

function setCookie(name, value) {
    document.cookie = name + "=" + escape(value) + "; path=/";
}

function getCookie(name) {

    var start = document.cookie.indexOf(name + "=");

    var len = start + name.length + 1;

    if ((!start) && (name != document.cookie.substring(0, name.length))) {
        return null;
    }

    if (start == -1) {
        return null;
    }
    
    var end = document.cookie.indexOf(";", len);

    if (end == -1) {
        end = document.cookie.length;
    }
    
    return unescape(document.cookie.substring(len, end));
}

function CheckActivity() {

    //Sort out cookie containing referrer information if req'd
    if (!getCookie(strCookieName)) {
        setCookie(strCookieName, document.referrer, null);
    }

    //See if an application is in progress
    if (document.URL.toLowerCase().match(strPattern)) {
        ReportStats();
    }

}

CheckActivity();
