var trkDomain = "tracking.louvre-hotels.fr";
var trkVersion = "1";

function trkGetCookieValue(name) {
    var pos = document.cookie.indexOf(name + "=");
    if (pos != -1) {
        var start = pos + name.length + 1;
        var end = document.cookie.indexOf(";", start);
        if (end == -1) {
            end = document.cookie.length;
        }
        return unescape(document.cookie.substring(start, end));
    }
    return null;
}
function trkGetPart(cookieParts, crumb) {
    for (var i = 0; i < cookieParts.length; i++) {
        var aCrumb = cookieParts[i].split("=");
        if (crumb == aCrumb[0]) {
            return aCrumb[1];
        }
    }
    return null;
}
function trkGetVisitorId(cookieName) {
    var cookie = trkGetCookieValue(cookieName);
    if (cookie == null) return null;
    return cookie.substring(0, cookie.indexOf(":lv="));
}
function trkGetVisitor() {
    var name = "lvtor";
    var nowDate = new Date();
    var adj = (nowDate.getTimezoneOffset() * 60000);
    nowDate.setTime(nowDate.getTime() + adj);
    var cookExp = new Date(nowDate.getTime() + 315360000000);
    var dSes = new Date(nowDate.getTime());
    TRK.lvtorId = TRK.newSs = TRK.prevVw = TRK.prevSs = "";
    if (document.cookie.indexOf(name + "=") == -1) {
        //no cookie
        TRK.lvtorId = nowDate.getTime().toString(16);
        for (var i = 0; i < 10; i++) {
            TRK.lvtorId += Math.floor(Math.random() * 16.0).toString(16);
        }
        TRK.newSs = "1";
    }
    else {
        var id = trkGetVisitorId(name);
        var cookieParts = trkGetCookieValue(name).split(":");
        var lv = parseInt(trkGetPart(cookieParts, "lv"));
        var ss = parseInt(trkGetPart(cookieParts, "ss"));
        if ((id == null) || (id == "null") || isNaN(lv) || isNaN(ss)) {
            return;
        }
        TRK.lvtorId = id;
        var dLst = new Date(lv);
        TRK.prevVw = Math.floor((dLst.getTime() - adj) / 1000);

        dSes.setTime(ss);
        if ((nowDate.getTime() > (dLst.getTime() + 1800000)) || (nowDate.getTime() > (dSes.getTime() + 28800000))) {
            //Last visit was more than 30 minutes ago
            TRK.prevSs = Math.floor((dSes.getTime() - adj) / 1000);
            dSes.setTime(nowDate.getTime());
            TRK.newSs = "1";
        }
    }

    TRK.lvtorId = escape(TRK.lvtorId);
    var expiry = "; expires=" + cookExp.toGMTString();
    document.cookie = name + "=" + TRK.lvtorId + ":lv=" + nowDate.getTime().toString() + ":ss=" + dSes.getTime().toString() + expiry + "; path=/";
    if (!navigator.cookieEnabled || document.cookie.indexOf(name + "=") == -1) {//cookie refused by browser
        TRK.lvtorId = TRK.newSs = TRK.prevVw = TRK.prevSs = "";
        TRK.nocookies = "1";
    }
}


var TRK = new Object();
if (window.RegExp) {
    var RE = { "%09": /\t/g, "%20": / /g, "%23": /\#/g, "%26": /\&/g, "%2B": /\+/g, "%3F": /\?/g, "%5C": /\\/g, "%22": /\"/g, "%7F": /\x7F/g, "%A0": /\xA0/g, "%3D": /\=/g };
    var I18NRE = { "%25": /\%/g };
}

function trkGetClientInfos() {
    var nowDate = new Date();
    
    //Timezone
    TRK.tz = nowDate.getTimezoneOffset() / 60 * -1;
    if (TRK.tz == 0) {
        TRK.tz = "0";
    }

    TRK.ul=navigator.appName == "Netscape" ? navigator.language : navigator.userLanguage;
    //Screen info
    if (typeof (screen) == "object") {
        TRK.cd = navigator.appName == "Netscape" ? screen.pixelDepth : screen.colorDepth;
        TRK.sr = screen.width + "x" + screen.height;
    }
    
    //Body size
    if (parseInt(navigator.appVersion) > 3) {
        if ((navigator.appName == "Microsoft Internet Explorer") && document.body) {
            TRK.bs = document.body.offsetWidth + "x" + document.body.offsetHeight;
        }
        else if (navigator.appName == "Netscape") {
        TRK.bs = window.innerWidth + "x" + window.innerHeight;
        }
    }
    //timestamp
    TRK.stmp = nowDate.getTime();
    //URL
    TRK.host = window.location.hostname;
    TRK.uri = window.location.pathname;
    if (window.location.search) {
        TRK.qry = window.location.search;
        if (TRK.qry.substr(0, 1) == "?")
            TRK.qry = TRK.qry.substring(1);
    }
    //Referrer
    if ((window.document.referrer != "") && (window.document.referrer != "-") && window.document.referrer.indexOf("://" + window.location.hostname + "/")<0) {
        if (!(navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) < 4)) {
            TRK.refr = window.document.referrer;
        }
    }
}


function paramEscape(S) {
    if (typeof (encodeURIComponent) == "function")
        return encodeURIComponent(S);
    else
        if (typeof (escape) == "function")
        return escape(S);
    else {
        var retStr = new String(S);
        for (var R in RE) {
            retStr = retStr.replace(RE[R], R);
        }
        return retStr;
    }
}

function trkAddParam(N, V) {
    return "&" + N + "=" + paramEscape(V, RE);
}

function trkGetMeta() {
    var elems;
    if (typeof (TRK_sc) != "undefined") {
        TRK["sc"] = TRK_sc;
    }
    if (document.all) {
        elems = document.all.tags("meta");
    }
    else if (document.documentElement) {
        elems = document.getElementsByTagName("meta");
    }
    if (typeof (TRK_params) != "undefined") {
        if (typeof (TRK_params) == "string") {
            TRK["param"]=TRK_params;
        }
        else {
            for (N in TRK_params) {
                if (TRK_params[N]) {
                    TRK[N]=TRK_params[N];
                }
            }
        }
    }

    if (typeof (elems) != "undefined") {
        for (var i = 1; i <= elems.length; i++) {
            var meta = elems.item(i - 1);
            if (meta.name) {
                if (meta.name.indexOf('WT.') == 0) {
                    TRK[meta.name.substring(3)] = meta.content;
                }
                else if (meta.name.indexOf('DCSext.') == 0 || meta.name.indexOf('DCS.') == 0) {
                TRK[meta.name] = meta.content;
                }
            }
        }
    }
}
function trkLoadUrl(pUrl) {
    pUrl += trkAddParam("v", trkVersion);
    if (pUrl.length > 2048 && navigator.userAgent.indexOf('MSIE') >= 0 && parseInt(navigator.appVersion) <= 6) {
        pUrl = pUrl.substring(0, 2039) + "&TRK.trunc=1";
    }
    if (document.images) {
        var image = new Image;
        image.src = pUrl;
    }
    else {
        document.write('<img alt="" border="0" width="1" height="1" src="' + pUrl + '" />');
    }
}
function trkBase() {
    return "http" + (window.location.protocol.indexOf('https:') == 0 ? 's' : '') + "://" + trkDomain + "/t.ashx?";
}
function trkSendTag() {
    var P = trkBase();
    for (N in TRK) {
        if (TRK[N]) {
            P += trkAddParam(N, TRK[N]);
        }
    }
    trkLoadUrl(P);
}

function trkAction(actionKind,parameters) {
    var P = trkBase();
    if(typeof(TRK.lvtorId)!="undefined")
        P += trkAddParam("lvtorId", TRK.lvtorId);
    P += trkAddParam("action", actionKind);
    if (typeof (parameters) != "undefined") {
        if (typeof (parameters) == "string") {
            P += trkAddParam("param", parameters);
        }
        else {
            for (N in parameters) {
                if (parameters[N])
                    P += trkAddParam(N, parameters[N]);
            }
        }
    }
    trkLoadUrl(P);
}
try{trkGetClientInfos();
trkGetMeta();
trkGetVisitor();
trkSendTag();
}catch(exc){}