/*! ga-loader external -- analytics (chez) resoneo (point) com */
/*jslint browser: true, sloppy: true, newcap: true, nomen: true, maxerr: 500, indent: 4 */
/* minima */
window._gaq = window._gaq || [];
window.ga_p = "jettours.com";
/* defines the hostname of the live site */
window.ga_d = true;
/* enables debug information when not on the live site */
/* fonctions utilitaires  */
function rs_trackErrorThroughEvent(exception, fct) { /* remontée des erreurs éventuelles pour détection des pbs */
    _gaq.push(['_trackEvent', 'Erreur JS ' + (fct || 'native'), exception + ' name: ' + (exception.name || 'Error') + ' #mess: ' + (exception.message || 'n/a') + ' #nav: ' + navigator.userAgent , ' #url: ' + document.location.href + '#ref: ' + document.referrer , , true]);
}
/*
 * domain string for cookie depending on the prod domain
 */
function rs_getDomainForCookie(domainprod) {
    if (window.location.hostname.indexOf(domainprod) > -1) {
        return "; domain=." + domainprod;
    }
    else {
        return "";
    }
}
/*
 * Create Cookie
 */
function rs_createSessionCookie(name, value, domainprod) {
    document.cookie = name + "=" + value + "; path=/" + rs_getDomainForCookie(domainprod);
}
/*
 * Reads Cookie value
 */
function rs_readCookie(n) {
    var nameEQ = n + "=";
    var ca = document.cookie.split(';');
    var i = 0;
    for (i = 0; i < ca.length; i += 1) {
        var c = ca[i];
        while (c.charAt(0) === ' ') {
            c = c.substring(1, c.length);
        }
        if (c.indexOf(nameEQ) === 0) {
            return c.substring(nameEQ.length, c.length);
        }
    }
    return null;
}
/* Updates user profile based on the input value, current value and internal business logic
 *  researchers|shoppers|bookers */
function rs_setProfile(valeur) {
    if ((!_gat) || valeur.length === 0) {
        return;
    }
    try {
        var visitorProfile = rs_readCookie('rs_p');
        /* logic */
        /* current value isn't set  */
        if (visitorProfile === null) {
            rs_createSessionCookie('rs_p', valeur, window.ga_p);
            _gaq.push(['_setCustomVar', 1, 'profile', valeur, 2]);
        }
        /* same value or value = first level : no change */
        else if (valeur === visitorProfile || valeur === 'researchers') {
        }
        /* promoted to second level only */
        else if (visitorProfile === 'researchers' && valeur !== 'bookers') {
            rs_createSessionCookie('rs_p', valeur, window.ga_p);
            _gaq.push(['_setCustomVar', 1, 'profile', 'shoppers', 2]);
        }
        else if (valeur === 'bookers') {
            rs_createSessionCookie('rs_p', valeur, window.ga_p);
            _gaq.push(['_setCustomVar', 1, 'profile', 'bookers', 2]);
        }
    }
    catch (e) {
        rs_trackErrorThroughEvent(e, 'rs_setProfile');
    }
}
(function () {
    /* traitement de Google Images en amont du code standard */
    _gaq.push(['_addOrganic', 'google', 'q', true, 'google images', '/imgres?']);
    /* moteurs de recherche francophones */
    _gaq.push(['_addOrganic', 'cuil', 'q', true], ['_addOrganic', 'cluuz', 'q', true], ['_addOrganic', 'myway', 'searchfor', true], ['_addOrganic', 'mywebsearch', 'searchfor', true], ['_addOrganic', 'gooofullsearch', 'Keywords', true], ['_addOrganic', 'lo.st', 'x_query', true], ['_addOrganic', 'news.google.fr', 'q', true], ['_addOrganic', 'voila', 'kw', false], ['_addOrganic', 'exalead', 'q', true], ['_addOrganic', 'yauba', 'q', true], ['_addOrganic', 'yougoo', 'q', true], ['_addOrganic', 'hooseek', 'recherche', true], ['_addOrganic', 'ecosia', 'q', true], ['_addOrganic', 'ecofree', 'q', true], ['_addOrganic', 'ethicle', 'q', true], ['_addOrganic', 'skynet', 'q', true], ['_addOrganic', 'udark', 'q', true], ['_addOrganic', 'wibeez', 'q', true], ['_addOrganic', 'veosearch', 'q', true], ['_addOrganic', 'incredimail', 'q', true], ['_addOrganic', 'sweetim', 'q', true], ['_addOrganic', 'conduit', 'q', true], ['_addOrganic', 'searcheo', 'q', true], ['_addOrganic', 'babylon', 'q', true], ['_addOrganic', 'imesh', 'q', true], ['_addOrganic', 'fastbrowsersearch', 'q', true], ['_addOrganic', 'magentic', 'q', true], ['_addOrganic', 'search.free.fr', 'q', true], ['_addOrganic', 'vizzeo', 'q', true], ['_addOrganic', 'bluewin.ch', 'searchTerm', true], ['_addOrganic', 'google', 'as_q', true]);
    /* parametres generiques */
    _gaq.push(['_setAllowAnchor', true], ['_gat._anonymizeIp']);
    /* script */
    var ga_s = (document.location.hostname.indexOf(window.ga_p) > 0 && window.ga_d) ? '.google-analytics.com/ga.js' : '.google-analytics.com/u/ga_debug.js';
    (function () {
        var ga = document.createElement('script');
        ga.type = 'text/javascript';
        ga.async = true;
        ga.src = ('https:' === document.location.protocol ? 'https://ssl' : 'http://www') + ga_s;
        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(ga, s);
    }());
    /* paramétrage client */
    if (document.location.hostname.indexOf(window.ga_p) > -1) {
        /* production */
        _gaq.push(['_setAccount', 'UA-7611991-1'], ['_setDomainName', 'jettours.com']);
        try { /* gestion des referrals internes */
            if (/:\/\/www\.jetours\.com\//.test(document.referrer)) {
                _gaq.push(['_setReferrerOverride', '']);
            }
        } catch (e) {
            rs_trackErrorThroughEvent(e, 'Suppression referral internes');
        }
        _gaq.push(['_addIgnoredRef', window.ga_p]);
        /* deux heures d'inactivité */
        _gaq.push(['_setSessionCookieTimeout', 7200000]);
            _gaq.push(['_setCustomVar', 5, 's', 'jet', 3]);

    } else {
        /* compte de recette */
        _gaq.push(['_setAccount', 'UA-7611991-9']);
        _gaq.push(['_setCustomVar', 5, 's', 'assembly', 3]); // flag les visites sur le full launch
    }
}());
