﻿function rK(){nd = new Date(); return rs(5) + nd.getTime() + rs(5)}
function sa2() { t = window.innerHeight; if (t != undefined) { t = window.innerHeight + "-" + window.innerWidth } else { t = document.body.clientHeight + "-" + document.body.clientWidth }; return t }
function sa(){return screen.availHeight + "-" + screen.availWidth}
function rs(len) { cs = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; RS = ''; for (var i = 0; i < len; i++) { rnum = Math.floor(Math.random() * cs.length); RS += cs.substring(rnum, rnum + 1); } return RS; }
function setCookie(name, value, path, nDays, domain, secure) {
    var today = new Date();
    var expires = new Date();
    var curCookie = ""
    //fixDate(today)
    if (nDays == null || nDays == 0) nDays = 365; // one year
    expires.setTime(today.getTime() + 3600000 * 24 * nDays);
    curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "")
  + ((path) ? "; path=" + path : "") +
  ((domain) ? "; domain=" + domain : "") +
  ((secure) ? "; secure" : "")
    document.cookie = curCookie
}
function getCookie(name) {
    var prefix = name + "="
    var cookieStartIndex = document.cookie.indexOf(prefix)
    if (cookieStartIndex == -1)
        return null
    var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
    if (cookieEndIndex == -1)
        cookieEndIndex = document.cookie.length
    return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}
if (getCookie("UIKey_TM") == undefined) { setCookie("UIKey_TM", rK(20)) }
if (TM_mapping == undefined) { var TM_mapping = "" }
var TM_Status = ""
var TM_newvisit = false
var TM_unqiuevisits = 0
var TM_PagesInThisSession = 0
var docref = escape(document.referrer)
var doctitle = escape(document.title)
var httphost = document.location.href
var httproot=""
if (httphost.indexOf("localhost") == -1) { httproot = "http://www.thinkmarket.co.uk/" }
var UIKey_TM = getCookie("UIKey_TM");
   (function() {
       var tm = document.createElement('script'); tm.type = 'text/javascript'; tm.async = true;
       tm.src = httproot + 'UserInt_TM.aspx?ui=' + UIKey_TM + '&sa=' + sa() + '&sa2=' + sa2() + '&depth=' + screen.colorDepth;
       if (TM_mapping != undefined) { tm.src=tm.src+"&mapping="+TM_mapping+"&referrer="+docref+"&title="+doctitle }
       var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(tm, s);
   })();
