﻿
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

//=============================================================
//	----------	  [DÉBUT] FLASH 					 ----------
//	----------	  Deprecate : use SWF Object		 ----------
//============================================================= 
function ControlVersion() {
    var version;
    var axo;
    var e;
    try {
        axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
        version = axo.GetVariable("$version");
    } catch (e) {
    }

    if (!version) {
        try {
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
            version = "WIN 6,0,21,0";
            axo.AllowScriptAccess = "always";
            version = axo.GetVariable("$version");

        } catch (e) {
        }
    }

    if (!version) {
        try {
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
            version = axo.GetVariable("$version");
        } catch (e) {
        }
    }

    if (!version) {
        try {
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
            version = "WIN 3,0,18,0";
        } catch (e) {
        }
    }

    if (!version) {
        try {
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            version = "WIN 2,0,0,11";
        } catch (e) {
            version = -1;
        }
    }

    return version;
};
function GetSwfVer() {
    var flashVer = -1;
    if (navigator.plugins != null && navigator.plugins.length > 0) {
        if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
            var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
            var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
            var descArray = flashDescription.split(" ");
            var tempArrayMajor = descArray[2].split(".");
            var versionMajor = tempArrayMajor[0];
            var versionMinor = tempArrayMajor[1];
            if (descArray[3] != "") {
                tempArrayMinor = descArray[3].split("r");
            } else {
                tempArrayMinor = descArray[4].split("r");
            }
            var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
            var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
        }
    }
    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
    else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
    else if (isIE && isWin && !isOpera) {
        flashVer = ControlVersion();
    }
    return flashVer;
};

function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) {
    versionStr = GetSwfVer();
    if (versionStr == -1) {
        return false;
    } else if (versionStr != 0) {
        if (isIE && isWin && !isOpera) {
            tempArray = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
            tempString = tempArray[1]; 		// "2,0,0,11"
            versionArray = tempString.split(","); // ['2', '0', '0', '11']
        } else {
            versionArray = versionStr.split(".");
        }
        var versionMajor = versionArray[0];
        var versionMinor = versionArray[1];
        var versionRevision = versionArray[2];

        if (versionMajor > parseFloat(reqMajorVer)) {
            return true;
        } else if (versionMajor == parseFloat(reqMajorVer)) {
            if (versionMinor > parseFloat(reqMinorVer))
                return true;
            else if (versionMinor == parseFloat(reqMinorVer)) {
                if (versionRevision >= parseFloat(reqRevision))
                    return true;
            }
        }
        return false;
    }
};
function AC_AddExtension(src, ext) {
    if (src.indexOf('?') != -1)
        return src.replace(/\?/, ext + '?');
    else
        return src + ext;
};

function AC_Generateobj(objAttrs, params, embedAttrs) {
    var str = '<object ';
    for (var i in objAttrs)
        str += i + '="' + objAttrs[i] + '" ';
    str += '>';
    for (var i in params)
        str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    str += '<embed ';
    for (var i in embedAttrs)
        str += i + '="' + embedAttrs[i] + '" ';
    str += ' ></embed></object>';

    return str;
};
function AC_FL_RunContent() {
    var ret =
    AC_GetArgs
    (arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
    document.write(AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs));
};

function AC_FL_GetContent() {
    var ret =
    AC_GetArgs
    (arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
    return AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
};

function AC_SW_RunContent() {
    var ret =
    AC_GetArgs
    (arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
    AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
};

function AC_GetArgs(args, ext, srcParamName, classid, mimeType) {
    var ret = new Object();
    ret.embedAttrs = new Object();
    ret.params = new Object();
    ret.objAttrs = new Object();
    for (var i = 0; i < args.length; i = i + 2) {
        var currArg = args[i].toLowerCase();

        switch (currArg) {
            case "classid":
                break;
            case "pluginspage":
                ret.embedAttrs[args[i]] = args[i + 1];
                break;
            case "src":
            case "movie":
                args[i + 1] = AC_AddExtension(args[i + 1], ext);
                ret.embedAttrs["src"] = args[i + 1];
                ret.params[srcParamName] = args[i + 1];
                break;
            case "onafterupdate":
            case "onbeforeupdate":
            case "onblur":
            case "oncellchange":
            case "onclick":
            case "ondblClick":
            case "ondrag":
            case "ondragend":
            case "ondragenter":
            case "ondragleave":
            case "ondragover":
            case "ondrop":
            case "onfinish":
            case "onfocus":
            case "onhelp":
            case "onmousedown":
            case "onmouseup":
            case "onmouseover":
            case "onmousemove":
            case "onmouseout":
            case "onkeypress":
            case "onkeydown":
            case "onkeyup":
            case "onload":
            case "onlosecapture":
            case "onpropertychange":
            case "onreadystatechange":
            case "onrowsdelete":
            case "onrowenter":
            case "onrowexit":
            case "onrowsinserted":
            case "onstart":
            case "onscroll":
            case "onbeforeeditfocus":
            case "onactivate":
            case "onbeforedeactivate":
            case "ondeactivate":
            case "type":
            case "codebase":
                ret.objAttrs[args[i]] = args[i + 1];
                break;
            case "width":
            case "height":
            case "align":
            case "vspace":
            case "hspace":
            case "class":
            case "title":
            case "accesskey":
            case "tabindex":
                ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i + 1];
                break;
            case "name":
                ret.embedAttrs[args[i]] = args[i + 1];
                break;
            case "id":
                ret.objAttrs[args[i]] = args[i + 1];
                break;
            default:
                ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i + 1];
        }
    }
    ret.objAttrs["classid"] = classid;
    if (mimeType) ret.embedAttrs["type"] = mimeType;
    return ret;
};
//================ [FIN] FLASH ================

//Functions to embed flash
var swfobject = function () { var D = "undefined", r = "object", S = "Shockwave Flash", W = "ShockwaveFlash.ShockwaveFlash", q = "application/x-shockwave-flash", R = "SWFObjectExprInst", x = "onreadystatechange", O = window, j = document, t = navigator, T = false, U = [h], o = [], N = [], I = [], l, Q, E, B, J = false, a = false, n, G, m = true, M = function () { var aa = typeof j.getElementById != D && typeof j.getElementsByTagName != D && typeof j.createElement != D, ah = t.userAgent.toLowerCase(), Y = t.platform.toLowerCase(), ae = Y ? /win/.test(Y) : /win/.test(ah), ac = Y ? /mac/.test(Y) : /mac/.test(ah), af = /webkit/.test(ah) ? parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, X = ! +"\v1", ag = [0, 0, 0], ab = null; if (typeof t.plugins != D && typeof t.plugins[S] == r) { ab = t.plugins[S].description; if (ab && !(typeof t.mimeTypes != D && t.mimeTypes[q] && !t.mimeTypes[q].enabledPlugin)) { T = true; X = false; ab = ab.replace(/^.*\s+(\S+\s+\S+$)/, "$1"); ag[0] = parseInt(ab.replace(/^(.*)\..*$/, "$1"), 10); ag[1] = parseInt(ab.replace(/^.*\.(.*)\s.*$/, "$1"), 10); ag[2] = /[a-zA-Z]/.test(ab) ? parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0 } } else { if (typeof O.ActiveXObject != D) { try { var ad = new ActiveXObject(W); if (ad) { ab = ad.GetVariable("$version"); if (ab) { X = true; ab = ab.split(" ")[1].split(","); ag = [parseInt(ab[0], 10), parseInt(ab[1], 10), parseInt(ab[2], 10)] } } } catch (Z) { } } } return { w3: aa, pv: ag, wk: af, ie: X, win: ae, mac: ac} } (), k = function () { if (!M.w3) { return } if ((typeof j.readyState != D && j.readyState == "complete") || (typeof j.readyState == D && (j.getElementsByTagName("body")[0] || j.body))) { f() } if (!J) { if (typeof j.addEventListener != D) { j.addEventListener("DOMContentLoaded", f, false) } if (M.ie && M.win) { j.attachEvent(x, function () { if (j.readyState == "complete") { j.detachEvent(x, arguments.callee); f() } }); if (O == top) { (function () { if (J) { return } try { j.documentElement.doScroll("left") } catch (X) { setTimeout(arguments.callee, 0); return } f() })() } } if (M.wk) { (function () { if (J) { return } if (!/loaded|complete/.test(j.readyState)) { setTimeout(arguments.callee, 0); return } f() })() } s(f) } } (); function f() { if (J) { return } try { var Z = j.getElementsByTagName("body")[0].appendChild(C("span")); Z.parentNode.removeChild(Z) } catch (aa) { return } J = true; var X = U.length; for (var Y = 0; Y < X; Y++) { U[Y]() } } function K(X) { if (J) { X() } else { U[U.length] = X } } function s(Y) { if (typeof O.addEventListener != D) { O.addEventListener("load", Y, false) } else { if (typeof j.addEventListener != D) { j.addEventListener("load", Y, false) } else { if (typeof O.attachEvent != D) { i(O, "onload", Y) } else { if (typeof O.onload == "function") { var X = O.onload; O.onload = function () { X(); Y() } } else { O.onload = Y } } } } } function h() { if (T) { V() } else { H() } } function V() { var X = j.getElementsByTagName("body")[0]; var aa = C(r); aa.setAttribute("type", q); var Z = X.appendChild(aa); if (Z) { var Y = 0; (function () { if (typeof Z.GetVariable != D) { var ab = Z.GetVariable("$version"); if (ab) { ab = ab.split(" ")[1].split(","); M.pv = [parseInt(ab[0], 10), parseInt(ab[1], 10), parseInt(ab[2], 10)] } } else { if (Y < 10) { Y++; setTimeout(arguments.callee, 10); return } } X.removeChild(aa); Z = null; H() })() } else { H() } } function H() { var ag = o.length; if (ag > 0) { for (var af = 0; af < ag; af++) { var Y = o[af].id; var ab = o[af].callbackFn; var aa = { success: false, id: Y }; if (M.pv[0] > 0) { var ae = c(Y); if (ae) { if (F(o[af].swfVersion) && !(M.wk && M.wk < 312)) { w(Y, true); if (ab) { aa.success = true; aa.ref = z(Y); ab(aa) } } else { if (o[af].expressInstall && A()) { var ai = {}; ai.data = o[af].expressInstall; ai.width = ae.getAttribute("width") || "0"; ai.height = ae.getAttribute("height") || "0"; if (ae.getAttribute("class")) { ai.styleclass = ae.getAttribute("class") } if (ae.getAttribute("align")) { ai.align = ae.getAttribute("align") } var ah = {}; var X = ae.getElementsByTagName("param"); var ac = X.length; for (var ad = 0; ad < ac; ad++) { if (X[ad].getAttribute("name").toLowerCase() != "movie") { ah[X[ad].getAttribute("name")] = X[ad].getAttribute("value") } } P(ai, ah, Y, ab) } else { p(ae); if (ab) { ab(aa) } } } } } else { w(Y, true); if (ab) { var Z = z(Y); if (Z && typeof Z.SetVariable != D) { aa.success = true; aa.ref = Z } ab(aa) } } } } } function z(aa) { var X = null; var Y = c(aa); if (Y && Y.nodeName == "OBJECT") { if (typeof Y.SetVariable != D) { X = Y } else { var Z = Y.getElementsByTagName(r)[0]; if (Z) { X = Z } } } return X } function A() { return !a && F("6.0.65") && (M.win || M.mac) && !(M.wk && M.wk < 312) } function P(aa, ab, X, Z) { a = true; E = Z || null; B = { success: false, id: X }; var ae = c(X); if (ae) { if (ae.nodeName == "OBJECT") { l = g(ae); Q = null } else { l = ae; Q = X } aa.id = R; if (typeof aa.width == D || (!/%$/.test(aa.width) && parseInt(aa.width, 10) < 310)) { aa.width = "310" } if (typeof aa.height == D || (!/%$/.test(aa.height) && parseInt(aa.height, 10) < 137)) { aa.height = "137" } j.title = j.title.slice(0, 47) + " - Flash Player Installation"; var ad = M.ie && M.win ? "ActiveX" : "PlugIn", ac = "MMredirectURL=" + O.location.toString().replace(/&/g, "%26") + "&MMplayerType=" + ad + "&MMdoctitle=" + j.title; if (typeof ab.flashvars != D) { ab.flashvars += "&" + ac } else { ab.flashvars = ac } if (M.ie && M.win && ae.readyState != 4) { var Y = C("div"); X += "SWFObjectNew"; Y.setAttribute("id", X); ae.parentNode.insertBefore(Y, ae); ae.style.display = "none"; (function () { if (ae.readyState == 4) { ae.parentNode.removeChild(ae) } else { setTimeout(arguments.callee, 10) } })() } u(aa, ab, X) } } function p(Y) { if (M.ie && M.win && Y.readyState != 4) { var X = C("div"); Y.parentNode.insertBefore(X, Y); X.parentNode.replaceChild(g(Y), X); Y.style.display = "none"; (function () { if (Y.readyState == 4) { Y.parentNode.removeChild(Y) } else { setTimeout(arguments.callee, 10) } })() } else { Y.parentNode.replaceChild(g(Y), Y) } } function g(ab) { var aa = C("div"); if (M.win && M.ie) { aa.innerHTML = ab.innerHTML } else { var Y = ab.getElementsByTagName(r)[0]; if (Y) { var ad = Y.childNodes; if (ad) { var X = ad.length; for (var Z = 0; Z < X; Z++) { if (!(ad[Z].nodeType == 1 && ad[Z].nodeName == "PARAM") && !(ad[Z].nodeType == 8)) { aa.appendChild(ad[Z].cloneNode(true)) } } } } } return aa } function u(ai, ag, Y) { var X, aa = c(Y); if (M.wk && M.wk < 312) { return X } if (aa) { if (typeof ai.id == D) { ai.id = Y } if (M.ie && M.win) { var ah = ""; for (var ae in ai) { if (ai[ae] != Object.prototype[ae]) { if (ae.toLowerCase() == "data") { ag.movie = ai[ae] } else { if (ae.toLowerCase() == "styleclass") { ah += ' class="' + ai[ae] + '"' } else { if (ae.toLowerCase() != "classid") { ah += " " + ae + '="' + ai[ae] + '"' } } } } } var af = ""; for (var ad in ag) { if (ag[ad] != Object.prototype[ad]) { af += '<param name="' + ad + '" value="' + ag[ad] + '" />' } } aa.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + ah + ">" + af + "</object>"; N[N.length] = ai.id; X = c(ai.id) } else { var Z = C(r); Z.setAttribute("type", q); for (var ac in ai) { if (ai[ac] != Object.prototype[ac]) { if (ac.toLowerCase() == "styleclass") { Z.setAttribute("class", ai[ac]) } else { if (ac.toLowerCase() != "classid") { Z.setAttribute(ac, ai[ac]) } } } } for (var ab in ag) { if (ag[ab] != Object.prototype[ab] && ab.toLowerCase() != "movie") { e(Z, ab, ag[ab]) } } aa.parentNode.replaceChild(Z, aa); X = Z } } return X } function e(Z, X, Y) { var aa = C("param"); aa.setAttribute("name", X); aa.setAttribute("value", Y); Z.appendChild(aa) } function y(Y) { var X = c(Y); if (X && X.nodeName == "OBJECT") { if (M.ie && M.win) { X.style.display = "none"; (function () { if (X.readyState == 4) { b(Y) } else { setTimeout(arguments.callee, 10) } })() } else { X.parentNode.removeChild(X) } } } function b(Z) { var Y = c(Z); if (Y) { for (var X in Y) { if (typeof Y[X] == "function") { Y[X] = null } } Y.parentNode.removeChild(Y) } } function c(Z) { var X = null; try { X = j.getElementById(Z) } catch (Y) { } return X } function C(X) { return j.createElement(X) } function i(Z, X, Y) { Z.attachEvent(X, Y); I[I.length] = [Z, X, Y] } function F(Z) { var Y = M.pv, X = Z.split("."); X[0] = parseInt(X[0], 10); X[1] = parseInt(X[1], 10) || 0; X[2] = parseInt(X[2], 10) || 0; return (Y[0] > X[0] || (Y[0] == X[0] && Y[1] > X[1]) || (Y[0] == X[0] && Y[1] == X[1] && Y[2] >= X[2])) ? true : false } function v(ac, Y, ad, ab) { if (M.ie && M.mac) { return } var aa = j.getElementsByTagName("head")[0]; if (!aa) { return } var X = (ad && typeof ad == "string") ? ad : "screen"; if (ab) { n = null; G = null } if (!n || G != X) { var Z = C("style"); Z.setAttribute("type", "text/css"); Z.setAttribute("media", X); n = aa.appendChild(Z); if (M.ie && M.win && typeof j.styleSheets != D && j.styleSheets.length > 0) { n = j.styleSheets[j.styleSheets.length - 1] } G = X } if (M.ie && M.win) { if (n && typeof n.addRule == r) { n.addRule(ac, Y) } } else { if (n && typeof j.createTextNode != D) { n.appendChild(j.createTextNode(ac + " {" + Y + "}")) } } } function w(Z, X) { if (!m) { return } var Y = X ? "visible" : "hidden"; if (J && c(Z)) { c(Z).style.visibility = Y } else { v("#" + Z, "visibility:" + Y) } } function L(Y) { var Z = /[\\\"<>\.;]/; var X = Z.exec(Y) != null; return X && typeof encodeURIComponent != D ? encodeURIComponent(Y) : Y } var d = function () { if (M.ie && M.win) { window.attachEvent("onunload", function () { var ac = I.length; for (var ab = 0; ab < ac; ab++) { I[ab][0].detachEvent(I[ab][1], I[ab][2]) } var Z = N.length; for (var aa = 0; aa < Z; aa++) { y(N[aa]) } for (var Y in M) { M[Y] = null } M = null; for (var X in swfobject) { swfobject[X] = null } swfobject = null }) } } (); return { registerObject: function (ab, X, aa, Z) { if (M.w3 && ab && X) { var Y = {}; Y.id = ab; Y.swfVersion = X; Y.expressInstall = aa; Y.callbackFn = Z; o[o.length] = Y; w(ab, false) } else { if (Z) { Z({ success: false, id: ab }) } } }, getObjectById: function (X) { if (M.w3) { return z(X) } }, embedSWF: function (ab, ah, ae, ag, Y, aa, Z, ad, af, ac) { var X = { success: false, id: ah }; if (M.w3 && !(M.wk && M.wk < 312) && ab && ah && ae && ag && Y) { w(ah, false); K(function () { ae += ""; ag += ""; var aj = {}; if (af && typeof af === r) { for (var al in af) { aj[al] = af[al] } } aj.data = ab; aj.width = ae; aj.height = ag; var am = {}; if (ad && typeof ad === r) { for (var ak in ad) { am[ak] = ad[ak] } } if (Z && typeof Z === r) { for (var ai in Z) { if (typeof am.flashvars != D) { am.flashvars += "&" + ai + "=" + Z[ai] } else { am.flashvars = ai + "=" + Z[ai] } } } if (F(Y)) { var an = u(aj, am, ah); if (aj.id == ah) { w(ah, true) } X.success = true; X.ref = an } else { if (aa && A()) { aj.data = aa; P(aj, am, ah, ac); return } else { w(ah, true) } } if (ac) { ac(X) } }) } else { if (ac) { ac(X) } } }, switchOffAutoHideShow: function () { m = false }, ua: M, getFlashPlayerVersion: function () { return { major: M.pv[0], minor: M.pv[1], release: M.pv[2]} }, hasFlashPlayerVersion: F, createSWF: function (Z, Y, X) { if (M.w3) { return u(Z, Y, X) } else { return undefined } }, showExpressInstall: function (Z, aa, X, Y) { if (M.w3 && A()) { P(Z, aa, X, Y) } }, removeSWF: function (X) { if (M.w3) { y(X) } }, createCSS: function (aa, Z, Y, X) { if (M.w3) { v(aa, Z, Y, X) } }, addDomLoadEvent: K, addLoadEvent: s, getQueryParamValue: function (aa) { var Z = j.location.search || j.location.hash; if (Z) { if (/\?/.test(Z)) { Z = Z.split("?")[1] } if (aa == null) { return L(Z) } var Y = Z.split("&"); for (var X = 0; X < Y.length; X++) { if (Y[X].substring(0, Y[X].indexOf("=")) == aa) { return L(Y[X].substring((Y[X].indexOf("=") + 1))) } } } return "" }, expressInstallCallback: function () { if (a) { var X = c(R); if (X && l) { X.parentNode.replaceChild(l, X); if (Q) { w(Q, true); if (M.ie && M.win) { l.style.display = "block" } } if (E) { E(B) } } a = false } } } } ();

function TouTV() { };
TouTV.Src = function () { };
TouTV.Src.prototype.swf_embed = function (_sDivId, _sSwfSource, _sFlashVars, _sSwfId, _nWidth, _nHeight, _sSwfWmode) {
    var _sSwf = (_sSwfSource == null) ? "" : _sSwfSource; // sans extension .swf
    var _sVars = (_sFlashVars == null) ? "" : _sFlashVars;
    var _sId = (_sSwfId == null) ? "PlayerCamera" : _sSwfId;
    var _nW = (_nWidth == null) ? 200 : _nWidth;
    var _nH = (_nHeight == null) ? 150 : _nHeight;
    var _sWmode = (_sSwfWmode == null) ? "opaque" : _sSwfWmode;
    var _sEmbedHtml = "";

    if (_sSwfSource != "") {
        if (AC_FL_GetContent == 0) {
            alert('This page requires AC_RunActiveContent.js. In Flash, run Apply Active Content Update in the Commands menu to copy AC_RunActiveContent.js to the HTML output folder.');
        } else {
            _sEmbedHtml += "<span style='display:none'>Radio-Canada.ca</span>";
            _sEmbedHtml += AC_FL_GetContent(
						'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
						'width', _nW,
						'height', _nH,
						'src', _sSwf,
						'movie', _sSwf,
						'quality', 'high',
						'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
						'align', 'middle',
						'play', 'true',
						'loop', 'true',
						'scale', 'noScale',
						'wmode', _sWmode,
						'devicefont', 'false',
						'id', _sId,
						'bgcolor', '#000000',
						'name', _sId,
						'menu', 'false',
						'allowScriptAccess', 'always',
						'salign', '',
						'FlashVars', _sVars
						); //end AC code

            if (_sDivId != null) $(_sDivId).innerHTML = _sEmbedHtml;
            else return _sEmbedHtml;
        }
    }
};
TouTV.Src.prototype.swf_embedVersion = function (_sDivId, _sSwfSource, _sFlashVars, _sSwfId, _nWidth, _nHeight, _sSwfWmode, _aFlashVersion, _sAlt) {
    var _sSwf = (_sSwfSource == null) ? "" : _sSwfSource; // sans extension .swf
    var _sVars = (_sFlashVars == null) ? "" : _sFlashVars;
    var _sId = (_sSwfId == null) ? "PlayerCamera" : _sSwfId;
    var _nW = (_nWidth == null) ? 200 : _nWidth;
    var _nH = (_nHeight == null) ? 150 : _nHeight;
    var _sWmode = (_sSwfWmode == null) ? "opaque" : _sSwfWmode;
    var requiredMajorVersion = (_aFlashVersion != null && _aFlashVersion != undefined) ? _aFlashVersion[0] : 6; // 9
    var requiredMinorVersion = (_aFlashVersion != null && _aFlashVersion != undefined) ? _aFlashVersion[1] : 0; // 0
    var requiredRevision = (_aFlashVersion != null && _aFlashVersion != undefined) ? _aFlashVersion[2] : 65; // 115
    var hasProductInstall = DetectFlashVer(6, 0, 65);
    var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
    var _sAltContenu = (_sAlt != "" && _sAlt != null && _sAlt != undefined) ? _sAlt : "<div  style=\"background-color:#fff;border:1px grey solid;padding:3px;\"><p>Le plugiciel <b>&laquo; Flash " + requiredMajorVersion + "." + requiredMinorVersion + "." + requiredRevision + " &raquo;</b> n'est pas install&eacute; sur votre ordinateur.<br/><a href='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' target='_blank'>Cliquez ici pour le t&eacute;l&eacute;charger</a>.</p><p><b>Note pour les utilisateurs Macintosh:</b> Il se peut que vous deviez red&eacute;marrer votre ordinateur une fois l'installation termin&eacute;e.</p></div>";


    if (!hasRequestedVersion && hasProductInstall) {
        var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
        var MMredirectURL = window.location;
        document.title = document.title.slice(0, 47) + " - Flash Player Installation";
        var MMdoctitle = document.title;
        this.isSwfInstall = true;
        if (isIE) {
            this.swf_embed(_sDivId, "/lib/v3/swf/playerProductInstall", "MMredirectURL=" + MMredirectURL + '&MMplayerType=' + MMPlayerType + '&MMdoctitle=' + MMdoctitle + "", "installFlashPlayer", _nWidth, _nHeight, _sSwfWmode);
        } else {
            if (_sDivId != null) {
                $(_sDivId).innerHTML = _sAltContenu;
            } else {
                return _sAltContenu;
            }
        }
    } else if (hasRequestedVersion) {
        if (_sDivId != null) {
            this.swf_embed(_sDivId, _sSwfSource, _sFlashVars, _sSwfId, _nWidth, _nHeight, _sSwfWmode);
        } else {
            return this.swf_embed(_sDivId, _sSwfSource, _sFlashVars, _sSwfId, _nWidth, _nHeight, _sSwfWmode);
        }
    } else {
        if (_sDivId != null) $(_sDivId).innerHTML = _sAltContenu;
        else return _sAltContenu;
    }
};
TouTV.Src.prototype.swf_write = function (_sEmbedhtml) {
    document.write(_sEmbedhtml);
};
TouTV.Src.prototype.swfobject = {
    altDefault: "<div  style=\"background-color:#fff;border:1px grey solid;padding:3px;\"><p>Le plugiciel <b>&laquo; Flash [flashVersion] &raquo;</b> n'est pas install&eacute; sur votre ordinateur.<br/><a href='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' target='_blank'>Cliquez ici pour le t&eacute;l&eacute;charger</a>.</p><p><b>Note pour les utilisateurs Macintosh:</b> Il se peut que vous deviez red&eacute;marrer votre ordinateur une fois l'installation termin&eacute;e.</p></div>",
    conter: 0,
    embedSWF: function () {
        var _oParam = new Object();
        if (typeof (arguments[0]) == "undefined") {
            return;
        } else {
            _oParam.url = arguments[0];
        }
        if (typeof (arguments[1]) == "undefined" || arguments[1] == null || arguments[1] == '') {
            var _altContent = "swfAltContent-" + this.conter;
            this.conter++;
            document.write('<div id="' + _altContent + '"></div>');
            _oParam.altContentDiv = _altContent;
        } else {
            _oParam.altContentDiv = arguments[1];
        }
        if (typeof (arguments[2]) == "undefined") {
            return;
        } else {
            _oParam.width = arguments[2];
        }
        if (typeof (arguments[3]) == "undefined") {
            return;
        } else {
            _oParam.height = arguments[3];
        }
        if (typeof (arguments[4]) == "undefined") {
            _oParam.flashVersion = "9.0.0";
        } else {
            _oParam.flashVersion = arguments[4];
        }
        if (typeof (arguments[5]) == "undefined") {
            _oParam.autoUpdate = false;
        } else {
            _oParam.autoUpdate = arguments[5];
        }
        _oParam.flashvars = arguments[6];
        _oParam.params = arguments[7];
        if (_oParam.params == null || _oParam.params == "") _oParam.params = new Object();
        _oParam.params.AllowScriptAccess = 'always';
        _oParam.params.wmode = "transparent";
        _oParam.attributes = arguments[8];

        if ($(_oParam.altContentDiv).innerHTML == '') $(_oParam.altContentDiv).innerHTML = this.altDefault.replace("[flashVersion]", _oParam.flashVersion);

        swfobject.embedSWF(
				_oParam.url,
				_oParam.altContentDiv,
				_oParam.width,
				_oParam.height,
				_oParam.flashVersion,
				_oParam.autoUpdate,
				_oParam.flashvars,
				_oParam.params,
				_oParam.attributes
			);
    }
};
var toutv = new TouTV.Src();
function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
// this fixes an issue with the old method, ambiguous values
// with this test document.cookie.indexOf( name + "=" );
function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}
﻿//Main js
//add MaxMind js

var sas_tmstp = Math.round(Math.random() * 100000000);
toutv.tileDART = 0;
toutv.getRelease = function () {
	//var release = ["HaIl7k4utinEL_GFZgJDD0WaqcjUZD5s", "YbYmAmnW__2C4tCTfv4LJN2IFwbccoZC", "cD81K3bLkemSmCqltXe9vB9E5eOm8kfk"];
	return "http://release.theplatform.com/content.select?" +
		toutv._obj2Str_keyValuePair({
			"pid": toutv.releaseUrl,  //release[Math.floor(Math.random() * 1)],
			"genre": toutv.genre,
			"show": toutv.show,
			"Tracking": true,
			"Embedded": true,
			//            "dart":"dev",
			//		    "sz": "852x480",
			//            "key":"telus",
			"page": toutv.currentPage(),
			"random": sas_tmstp,
			//"format": "SMIL",
			"MBR": true
		}, "&");
};
//Dart_motsClesObj : création de l'objet des keywords pour Dart
toutv.Dart_motsClesObj = function () {
	var _duree = Math.round(((toutv.mediaData) ? toutv.mediaData.Length : 0) / 60000);
	//ajouter zero devan le temps(en minutes) pour  faciliter tagging dans DART
	_duree = (_duree < 10) ? "00" + _duree : (_duree < 100) ? _duree = "0" + _duree : _duree;
	var _niv = toutv._CheckValueSize(toutv.UrlPremierNiveau);
	_niv = (_niv == 'accueil') ? 1 : (_niv == 'player') ? 3 : 2;
	var _epiNb = (toutv.mediaData) ? ('00' + toutv.mediaData.EpisodeNumber) : '';
	_epiNb = _epiNb.substr(_epiNb.length - 3, 3);
	var _oPubMotCle = {
		sEmi: toutv._CheckValueSize(toutv._parseString(toutv.show)),
		sSai: (toutv.mediaData) ? toutv.mediaData.SeasonNumber : "",
		sNiv: _niv,
		sSou: (toutv.mediaData) ? toutv.mediaData.Partner : '',
		sCha: (toutv.mediaData) ? toutv.mediaData.Network : '',
		uPay: this._CheckValueSize(this.paysMaxMind().substring(0, 2)),
		uPro: this._CheckValueSize(this.provinceMaxMind()),
		uVil: this._CheckValueSize(this.villeMaxMind()),
		sTyp: 'video',
		avDif: 'differe',
		avInt: 'true',
		sepi: _epiNb,
		avDur: _duree,
		bKid: (toutv.mediaData) ? toutv.mediaData.EstContenuJeunesse : '',
		sKey: '',
		rcThm: toutv._CheckValueSize(toutv._parseString(toutv.genre)),
	    rcSThm: (toutv.DART_rcSthm) ? toutv._CheckValueSize(toutv._parseString(toutv.DART_rcSthm)) : '',
		rcSuj: '',
		rcReg: '',
		rcRet: '',
		rcKey1: "",
		rcKey2: "",
		rcKey3: "",
		rcZon: "",
		sIdSA: "",
		avSt: (toutv.mediaData) ? toutv.mediaData.Network : '',
		ttGenre: toutv._CheckValueSize(toutv._parseString(toutv.genre))
	};
	return _oPubMotCle;
}


//showPageTag : affiche une alerte pour le débogage avec un call dans la barre d'adresse : javascript:RadioCanada.Lib.oSrc.oPub.showPageTag();
if (typeof (RadioCanada) == "undefined") {
	RadioCanada = {};
	RadioCanada.Mod = {};
	RadioCanada.Mod.oPub = {};
	RadioCanada.Lib = {};
	RadioCanada.Lib.oSrc = {};
	RadioCanada.Lib.oSrc.oPub = {};
}
RadioCanada.Lib.oSrc.oPub.showPageTag = function () {

	alert(
				'\n\nDART - Tou.tv : \n---------------------------------------------\n' +
		  toutv._obj2Str_keyValuePair(toutv.Dart_motsClesObj(), '\n')
		  );

}
RadioCanada.Mod.oPub.showPageTag = RadioCanada.Lib.oSrc.oPub.showPageTag;
toutv.getKeyValue = function () {
	return toutv._obj2Str_keyValuePair({
		"genre": toutv.genre,
		"show": toutv.show,
		"niveau": toutv.UrlPremierNiveau,
		"season": (toutv.mediaData) ? toutv.mediaData.SeasonNumber : "",
		"episode": (toutv.mediaData) ? toutv.mediaData.EpisodeNumber : "",
		"combo": (toutv.comboParam) ? toutv.comboParam : "",
		"pays": toutv.paysMaxMind(),
		"ville": toutv.villeMaxMind(),
		"page": toutv.currentPage()
	}, ";", "%3D");
};
//_CheckValueSize : retourne la valeur si inférieur ou égale à 55 chars sinon les 55 premier chars
toutv._CheckValueSize = function (_value) {
	return _value.substring(0, 55); ;
}

//_removeChar : efface les chars dans la string text
toutv._removeChar = function (text, chars) {
	text = text.replace(' ', '+');
	return text.replace(new RegExp('(' + chars.replace(/(.)/g, '\\$1|') + '\\\')', 'g'), '_').replace(/ {2,}/g, '_');
};

//_parseString : remplacer les caratères dangereux par son équivalent ASCII
toutv._parseString = function (str) {
	var arr = "éÉàÀèÈôÔçÇîÎêÊûÛëËïÏöÖ:<>$?|".split("");
	var ar2 = "eEaAeEoOcCiIeEuUeEiIoO______".split("");
	str = toutv._removeChar(str, '&^@%#`|     ,"*()=.[]');
	for (var i = 0; i < arr.length; i++) {
		str = str.replace(arr[i], ar2[i], 'g');
	}
	return escape(str).substr(0, 70);
};
toutv.provinceMaxMind = function () {
	return (typeof (geoip_region) != "undefined") ? geoip_region() : "";
};
//on rewrite url pour pre mid end avec adInsertion plugin
toutv.getUrlDart = function (pos) {
	var _pos = ';pos=' + pos;
	//var _pos = ';pos=end';
	keyValue = toutv._obj2Str_keyValuePair(toutv.Dart_motsClesObj(), ';') + _pos;
	return GetDartURLCall('pfadx', '852x480', keyValue, Math.round(Math.random() * 100000000));
	//return "http://ad.doubleclick.net/pfadx/raca.tou.tv;key=toutv;avdur=002;sz=852x480;ord=" + Math.round(Math.random() * 100000000);
};

//remplace slash foward avec encoding 
toutv._urlEscape = function (_url) {
	_url = _url.substr(7);
	while (_url.contains("/")) {
		_url = _url.replace(/\//, '%2F');
	}
	return _url.split("?")[0].split("#")[0];
};
// object key-value to string 
toutv._obj2Str_keyValuePair = function (_obj, _separateur) {
	var _strReturn = "";
	var _eq = (arguments.length >= 3) ? arguments[2] : "=";
	var first = true;
	if (typeof (_obj) != 'undefined') {
		for (var t in _obj) {
			if (!first) {
				_strReturn += _separateur;
			} else {
				first = false;
			}
			_strReturn += t + _eq + _obj[t];
		}
	}
	return _strReturn;
};
// format de bu retourner
toutv.getSizeFormat = function getSizeFormat(region) {
	return toutv.pubStaticInfo[region].sizeFormat;
};

toutv.paysMaxMind = function () {
	return (typeof (geoip_country_code) != "undefined" && typeof (geoip_region) != "undefined") ? geoip_country_code() + '_' + geoip_region() : "";
};
toutv.villeMaxMind = function () {
	return (typeof (geoip_city) != "undefined") ? toutv.parseString(geoip_city()) : "";
};
// replace  certains caracteres indesires
toutv.parseString = function (str) {
	var arr = "éÉàÀèÈôÔçÇîÎêÊûÛëËïÏöÖ :<>$?|".split("");
	var ar2 = "eEaAeEoOcCiIeEuUeEiIoO_______".split("");
	str = toutv.removeChar(str, '&^@%#`|     ,');
	for (var i = 0; i < arr.length; i++) {
		str = str.replace(arr[i], ar2[i], 'g');
	}
	return escape(str).substr(0, 70);
};
toutv.removeChar = function (text, chars) {
	return text.replace(new RegExp('(' + chars.replace(/(.)/g, '\\$1|') + '\\\')', 'g'), '_').replace(/ {2,}/g, '_');
};
// legacy
toutv.motscles = function () {
	//alert("Mot cles\n ");
	var motscles = toutv._obj2Str_keyValuePair({
		"Mot cles ": "",
		"genre": toutv.genre,
		"show": toutv.show,
		"niveau": toutv.UrlPremierNiveau,
		"episode": toutv.mediaData ? toutv.mediaData.EpisodeNumber : '',
		"season": toutv.mediaData ? toutv.mediaData.SeasonNumber : '',
		"pays": toutv.paysMaxMind(),
		"ville": toutv.villeMaxMind(),
		"page": toutv.currentPage()
	}, "\n");
	alert(motscles);
};
/*
GetDartURLCall : retourne le url d'un call de pub vers Dart
*/
function GetDartURLCall(adType, adSize, keyValue, DartOrd) {
	var Site, Zone, URLCall, Interstitiel;

	Site = 'raca.tou.tv';

	//ajout '_'(underscore) pour les zone qui commence avec le chiffre
	Zone = toutv._CheckValueSize(toutv._parseString(toutv.show)).replace(/(^[0-9].+$)/, '_$1'); // toutv._parseString(toutv.show);


	//Protection : Si on dépasse les limites de Dart alors on fait quand même le call sans les valeurs problèmatiques

	//adType : ne doit pas dépasser 5 caractères et doit être en minuscule
	if (adType.length > 5) adType = 'adi';
	adType = adType.toLowerCase();

	//SiteName + ZoneName : ne doit pas dépasser 64 caractères
	if ((Site.length + Zone.length) > 64) Zone = '';

	//KeyValue : la longeur total des Keys et les values ne doit pas dépasser 511 caractères (on doit se donner un buffer de 61 chars pour les keyvalue non custom)
	if (keyValue.length > 450) keyValue = '';

	//adsize : ne doit pas dépasser 15 caractères et doit être en minuscule
	if (adSize.length > 15) adSize = '1x1';
	adSize = adSize.toLowerCase();

	if (adSize != '852x480') toutv.tileDART++;
	//Si on affiche la première pub alors on met le call pour l'interstitiel
	var Interstitiel = (toutv.tileDART == 1) && adType == 'adi' ? 'dcopt=ist;' : '';
	var _tile = ';tile=' + toutv.tileDART; //(adSize == '852x480') ? '' :
	return 'http://ad.doubleclick.net/' + adType + '/' + Site + '/' + Zone + ';' + Interstitiel + keyValue + ';sz=' + adSize + _tile + ';ord=' + DartOrd + '?';


};
//retourn iframe
toutv.getPubDART = function (region, keyValue, _timestamp, url) {
	if (keyValue == '') keyValue = toutv._obj2Str_keyValuePair(toutv.Dart_motsClesObj(), ';');
	var _oPubInfo = toutv.getSizeFormat(region);
	var _sReturn = "";
	var _urlDART = (typeof (url) == 'undefined') ? GetDartURLCall(toutv.pubStaticInfo[region].format, _oPubInfo._sz, keyValue, _timestamp) : url;
	//';dcmt=text/html'; ??? returned  content-type 
	if (_oPubInfo._sz == "728x90") _sReturn += '<div class="srcPubBg">';
	if (toutv.pubStaticInfo[region].format == 'adj') {
		_sReturn += '<scr' + 'ipt type="text/javascript"  src="';
		_sReturn += _urlDART;
		_sReturn += '">' + '<' + '/' + 'sc' + 'ript' + '>';
		document.write(_sReturn);
		return;
	} else {
		//_sReturn += '	<div class="srcPub srcPub' + _oPubInfo._sz + '">';
		_sReturn += '<iframe src="' + _urlDART + '"';
		_sReturn += ' width="' + _oPubInfo._w + '" height="' + _oPubInfo._h + '" marginwidth="0"  marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" allowTransparency="true"></iframe>';
		//_sReturn += '	</div>';
	}
	if (_oPubInfo._sz == "728x90") _sReturn += '</div>';

	return _sReturn;
};
//legacy
toutv.getCatfish = function (sas_pageid, sas_formatid, sas_target) {
	var _oPubInfo = toutv.getSizeFormat('Banner1000x90');

	sas_master = (toutv.sas_masterflag == 1) ? 'M' : 'S';
	toutv.sas_masterflag = 0;

	var _sReturn = "";

	_sReturn += '	<div id="catfish">';
	_sReturn += '		<iframe src="/iframe_catfish.html?' + sas_pageid + '/' + sas_formatid + '/' + sas_master + '/' + sas_tmstp + '/' + sas_target + '?" style="width: 100%; left: 0px; top: -1px; height: ' + _oPubInfo._h + 'px;" width="100%" height="' + _oPubInfo._h + '" marginwidth="0"  marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" allowTransparency="true"></iframe>';
	_sReturn += '	</div>';

	return _sReturn;
}

toutv.currentPage = function () {
	return document.location.href.split("?")[0].replace(new RegExp(/^http:\/\//), '').replace(new RegExp(/\//g), "_");
},
toutv.isInternal = function () {
	//alert(document.referrer.indexOf("tou.tv"));
	return document.referrer.indexOf("tou.tv") != -1 || document.referrer.indexOf("static.tou.tv") != -1;
};
//ajouter pleusieurs formats sur la page
toutv.pubIframe = function () {
	var oDiv = document.getElementById(toutv.pubStaticInfo["Banner300x250"].name);
	if (oDiv != null) {
		oDiv.innerHTML = toutv.getPubDART("Banner300x250", '', sas_tmstp);
	}
	oDiv = document.getElementById(toutv.pubStaticInfo["Banner728x90"].name);
	if (oDiv != null) {
		oDiv.innerHTML = toutv.getPubDART("Banner728x90", '', sas_tmstp);
	}
};
// afficher la pub avent que le player embarque
toutv.previewPub = function (pubRegion, _timestamp) {
	var oDiv = document.getElementById(toutv.pubStaticInfo[pubRegion].name);
	if (oDiv != null) {
		var pubBB = document.getElementById(toutv.pubStaticInfo[pubRegion].preview);
		if (pubBB != null) {
			pubBB.innerHTML = toutv.getPubDART(pubRegion, '', _timestamp);
		} else {
			pubBB = document.createElement("div");
			pubBB.id = toutv.pubStaticInfo[pubRegion].preview;
			pubBB.innerHTML = toutv.getPubDART(pubRegion, '', _timestamp);
			//var infoDiv = oDiv.getElementsByTagName("div")[0];
			//infoDiv.style.display = "none";
			oDiv.appendChild(pubBB);
		}
	}
};
// dictionaire de pub
toutv.pubStaticInfo = {
	'Banner300x250': {
		// div gerer par player
		'name': 'bigBox',
		'format': 'adi',
		//div de preview
		'preview': 'bigBox', 
		'sizeFormat': { '_w': 300, '_h': 250, 'isJs': false, '_sz': 300 + "x" + 250 }
	},
	'Banner728x90': {
		'name': 'leaderboard',
		'format': 'adi',
		'preview': 'previewLeaderBoard',
		'sizeFormat': { '_w': 728, '_h': 90, 'isJs': false, '_sz': 728 + "x" + 90 }
	},
	'Banner1000x90': {
		'name': 'catfish',
		'format': 'adi',
		'preview': 'previewCatfish',
		'sizeFormat': { '_w': 1000, '_h': 90, 'isJs': false, '_sz': 1000 + "x" + 90 }
	},
	'Banner852x60': {
		'name': 'commanditaireDiv',
		'format': 'adj',
		'preview': 'commanditaireDiv',
		'sizeFormat': { '_w': 852, '_h': 60, 'isJs': false, '_sz': 852 + "x" + 60 }
	},
	'Default': {
		'name': 'pixel',
		'format': 'adi',
		'preview': 'pixel',
		'sizeFormat': { '_w': 1, '_h': 1, 'isJs': false, '_sz': 1 + "x" + 1 }
	}
};
// affiche plusieurs formats de pub
toutv.callPub = function (regions, _timestamp) {
	for (var i in regions)
		toutv.previewPub(regions[i], _timestamp);
};
// affiche seulement ilot 
toutv.pubIframeStatic = function (_timestamp) {
	if (!toutv.isPreviewPub) {
		toutv.isPreviewPub = true;
		toutv.callPub(['Banner300x250'], _timestamp);
	}
};
// page loaded event
function onPageLoad() {
	//tpController.setSmil(toutv.getRelease());
	if (typeof (toutv.isPlayer) != "undefined" && toutv.isPlayer === true) {
		// page player pub goes from SMIL
		if (!toutv.isInternal()) {
			toutv.pubIframeStatic(sas_tmstp);
			toutv.sas_masterflag = 1;
			//$('div#clipInfoDiv').css("visibility", "hidden");
		} else {
			//toutv.previewPub('Banner852x60', sas_tmstp);
			//$('div#previewBigBox').css("visibility", "hidden");

		}
		onLoadFunction();
	} else {
		// page no player
		toutv.pubIframe();
	}
};
var played, paused, muted;
var nMediaPlaying = 15;
played = paused = muted = false;
// continue  un page loaded
function onLoadFunction() {

	if (!tpController) {

		// The controller may not be ready at window.onLoad,
		// so we'll keep trying until it is. 
		window.setTimeout(onLoadFunction, 50);
		return;
	}
	toutv.SetImage();
	//toutv.isInternal() ? tpController.setRelease(toutv.getRelease()) : 
	toutv.CreateRelease();

	tpController.addEventListener("OnReleaseStart", MyEventListener);
	tpController.addEventListener("OnLoadRelease", MyEventListener);
	tpController.addEventListener("OnSetReleaseUrl", MyEventListener);
	tpController.addEventListener("OnStreamSwitched", MyEventListener);
	tpController.addEventListener("OnMediaEnd", MyEventListener);
	tpController.addEventListener("OnMediaStart", MyEventListener);
	tpController.addEventListener("OnMediaError", MyEventListener);
	tpController.addEventListener("OnMediaComplete", MyEventListener);
	tpController.addEventListener("OnMediaPlaying", MyEventListener);

	if (toutv.callbackPdkReady)
		for (var index in toutv.callbackPdkReady)
			toutv.callbackPdkReady[index]();
};
toutv.SetImage = function () {
	tpController.setPreviewImageUrl(toutv.imageA);
};
toutv.onMediaPlaying = function (evt) {
	if (nMediaPlaying == 10) {
		nMediaPlaying = 0;
		tpDebug("OnMediaPlaying");
	}
	nMediaPlaying++;
};
toutv.onMediaError = function (evt) {
	tpDebug("from :" + evt.originator.controlId);
	tpDebug("url :" + evt.data.URL);
};
//legacy
toutv.changePubSource = function (_divName, _oImage) {
	if (_oImage) {
		var divPubPreview = document.getElementById(_oImage.divBanner);
		divPubPreview.innerHTML = "<a href='" + _oImage.imgClick + "' ><img src='" + _oImage.imgUrl + "' /></a>";
	} else {
		var oDiv = document.getElementById(_divName);
		if (oDiv != null) {
			var _divs = oDiv.getElementsByTagName("div");
			_divs[0].style.display = "block";
			oDiv.removeChild(_divs[1]);
		}
	}
};
// Verifie si le media est la pub
toutv.notPub = function (evt) {
	try {

		// Verifier si le clip est une pub. Si isAd = true, c'est une pub.
		return !evt.data.baseClip.isAd;

		//return evt.data.length > 70000;
		//return !(evt.data.baseClip.moreInfo.href.indexOf("ad.doubleclick.net.com") != -1);
		//return !(evt.data.baseClip.banners.length > 0);
	} catch (e) {
		return false;
	}
};
// legacy
toutv.checkBanners = function (evt, banners) {
	for (var b = 0; b <= banners.length; b++) {
		var result = toutv.checkBaseClip(evt, banners[b]);
		switch (result) {
			case 1:
				toutv.isPreviewPub = true;
				var _oImage = { "imgUrl": evt.data.baseClip.banners[b].src, "imgClick": evt.data.baseClip.banners[b].href, "divBanner": toutv.pubStaticInfo[banners[b]].preview };
				toutv.changePubSource(toutv.pubStaticInfo[banners[b]].name, _oImage);
				break;
			case 0:
				if (toutv.isInternal()) {
					toutv.pubIframeStatic();
				}
				break;
			case 2:
				toutv.isPreviewPub = false;
				toutv.pubIframeStatic();
				break;
			case -1:
				toutv.pubIframeStatic();
				break;
		}
	}
};
//legacy
toutv.checkBaseClip = function (evt, region) {
	// 1 -pub recu
	// 0 pub vide
	// -1 not  pub
	// 2 flash bigbox
	for (var info in evt.data.baseClip.banners) {
		if (region == evt.data.baseClip.banners[info].region) {
			var src = evt.data.baseClip.banners[info].src;
			if (src.indexOf("flashBigBox123") != -1) {
				toutv.comboParam = evt.data.baseClip.banners[info].href;

				return 2;
			}
			return src != "" ? 1 : 0;
		}
	}
	return -1;
};

onMediaStart = function (evt) {
	//toutv.checkBanners(evt, ["Banner300x250", "Banner728x90"]);
	tpDebug("from :" + evt.originator.controlId);
	var _notPub = toutv.notPub(evt);
	if (_notPub && !toutv.isStatsVideoSet) {
		toutv.isStatsVideoSet = true;
		//        $.each(["leaderBoard", "bigBox"], function (index, value) {
		//            $("#"+value).empty();
		//        });

		setTimeout("statsToProfilsVideo();", 500);
		//tpController.setBandwidthPreferences(new Object({ minBitrate: 1000000, maxBitrate: 2.147483647E9 }));

		$(window).unload(function () {
			var currentDuree = new Number(Get_Cookie("duree")) * 1000;

			Set_Cookie("duree", 0, '', '/', '', '');
			if (currentDuree > 0) {
				var percentage = 0;
				try {
					percentage = (currentDuree / toutv.mediaData.LengthStats) * 100;
				} catch (e) { }
				var _dcsqry = statsVideoDetail();
				_dcsqry.a00playDuration = currentDuree;
				_dcsqry.a13percentComplete = percentage;
				var _playerData = toutv._obj2Str_keyValuePair(_dcsqry, "%26", "%3D");
				var currentDuree = new Number(Get_Cookie("duree"));
				statsToClics(
						'clic_action', toutv.mediaData.TitleID,
						'clic_contenu', 'toutv.mediaData.TitleID',
						'dcsqry', _playerData,
						'WT.ti', toutv.mediaData.TitleID + '_' + toutv.show,
						'WT.clic', 'video_play',
						'WT.sp', 'toutv_video_detail'
						);
			}
		});
	} else {
		//        'name': 'previewBigBox',
		//        'format': 'adi',
		//        'preview': 'previewBigBox',
		//        'sizeFormat': { '_w': 300, '_h': 250, 'isJs': false, '_sz': 300 + "x" + 250 }

		if (!_notPub) {
			var _format = toutv.pubStaticInfo['Banner300x250'];
			var _url = toutv.currentPubUrl.replace('sz=852x480', 'sz=' + _format.sizeFormat._sz).replace('pfadx', _format.format);

			var _iframe = toutv.getPubDART('Banner300x250', '', '', _url);
			var _div = document.getElementById(_format.name);
			_div.innerHTML = _iframe;
		}
	}
};

// Ajout fonction qui permet de faire du traitement
// Lorsqu'un clip est termine
onMediaComplete = function (evt) {
    // Si stat pub video deja comptabilise et clip courant n'est pas une pub
    if (toutv.isStatsVideoSet && toutv.notPub(evt)) {
        // Le video est visionne au complet
        if (evt.data.baseClip.lengthPlayed >= evt.data.mediaLength) {
            // Determiner le nom et la saison de l'emission
            // Enlever le premier '/' slash
            var _pathname = this.location.pathname.substring(1, this.location.pathname.length);
            // Separer emission de saison par le separateur '/'
            var _emission = _pathname.split('/');

            var _saison;
            if (_emission.length >= 2) {
                _saison = _emission[1].substr(0, 3);
            }

            // Enregistrer les statistiques vidéo pour Léon, 19-2 et 2e saison de En Audition avec Simon lorsque l'usager
            // refait jouer le contenu dans le player (après l'avoir visionné au complet).
            if (_emission[0] == "19-2" || _emission[0] == "leon" || (_emission[0] == "en-audition-avec-simon" && _saison == "S02")) {
                toutv.isStatsVideoSet = false;
            }
        }
    }
};

// gestionaire de evenemenet
function MyEventListener(evt) {
	if (evt.type != "OnMediaPlaying") {
		tpDebug("type :" + evt.type);
	}
	switch (evt.type) {
		case "OnMediaPlaying":

			if (nMediaPlaying == 15) {
				tpDebug("type :" + evt.type);
				//toutv.webTrends();
				nMediaPlaying = 0;
				// if pub (<45 sec exit)
				if (evt.data.duration < 45000) { return; }
				var currentDuree = new Number(Get_Cookie("duree"));
				Set_Cookie("duree", currentDuree + 5, '', '/', '', '');
			}
			nMediaPlaying++;
			break;
		case "OnLoadRelease":
			if (toutv.isInternal()) {
			}
			break;
		case "OnMediaStart":
			onMediaStart(evt);
			break;
		case "OnPlayerLoaded":
			break;
		case "OnSetReleaseUrl":
			//$('div#clipInfoDiv').css("visibility", "visible");
			//$('div#previewBigBox').css("visibility", "hidden");
			break;
		case "OnReleaseStart":
			try {
				if (evt.data.baseClips[0].URL.indexOf("Unavailable.flv") != -1) {
					var elmPlayer = document.getElementById("playerDiv");
					elmPlayer.innerHTML = "";
					var elmImgGeo = document.createElement("img");
					var message = new Object();
					message.className = " episode";
					if ((evt.data.baseClips[0].description.indexOf("You are not in a geographic region that has access to this content.") != -1)) {
						elmImgGeo.src = 'http://static.tou.tv/medias/images/2005-10-19_INVINC_0006_01_A.jpeg';
						message.titre = "Conformément aux droits de diffusion, ce document vidéo peut être vu au Canada seulement.";
					} else {
						message.titre = "Oups! Une erreur est survenue nous empêchant d'afficher le contenu  demandé.";
						message.texte = "Cliquez <a href='/'>ici</a> pour revenir à l'accueil et poursuivre votre visite.";
						elmImgGeo.src = 'http://static.tou.tv/medias/images/2005-09-28_INVINC_0003_04_A.jpeg';
					}
					//elmPlayer.appendChild(elmImgGeo);
					elmPlayer.appendChild(toutv.getPanneau(message));
					if (toutv.isInternal())
						toutv.pubIframeStatic();
				}
			} catch (e) { }
			break;
		case "OnSetPlayerMessage":

			break;
		case "OnMediaError":
			onMediaError(evt);
			break;
		case "OnStreamSwitched":
			break;
		case "OnMediaEnd":
		    break;
		case "OnMediaComplete":
		    onMediaComplete(evt);
		    break;
	}
};
//legacy
toutv.hidepub = function () {
	var pub = ["leaderBoard", "bigBox"];
	document.getElementById("leaderBoard").innerHTML = "";
	document.getElementById("bigBox").innerHTML = "";
	//$.each(pub, function (index, value) {
	//    $("#"+value).empty();
	//});
};
toutv.getPartenaire = function () {
	return (toutv.mediaData.Network == 'CBFT' || toutv.mediaData.Network == 'ARTV') ? 'R-C' : 'Partanaire';
};
toutv.clickStatsCarrousel = function clickStatsCarrousel(contenu, action) {
	statsToClics(
	'clic_action', 'Carroussel_' + action,
	'clic_contenu', contenu,
	'WT.ti', 'Carroussel_' + action,
	'WT.clic', toutv.UrlPremierNiveau);
};
toutv.clickStatsTeaser = function clickStatsTeaser(contenu) {
	statsToClics(
	'clic_action', 'Teaser_' + toutv.emission,
	'clic_contenu', contenu,
	'WT.ti', 'Teaser_' + toutv.show,
	'WT.clic', toutv.UrlPremierNiveau);
};
toutv.changePage = function (url) {
	var _form = document.createElement("form");
	_form.method = "get";
	_form.action = url;
	document.body.appendChild(_form);
	_form.submit();
};
toutv.CreateRelease = function () {
	var release = new Object();
	release.thumbnailUrl = toutv.imageA;
	release.URL = toutv.getRelease();
	//tpController.resetPlayer();
	if (toutv.isInternal()) {
		tpController.setRelease(release)
	} else {
		tpController.loadRelease(release);
	}

};
//message =new Object({titre:'',texte:'',className:'episode,carrousel,emission'});
toutv.getPanneau = function (message) {
	var _elmDivChild = document.createElement("div");
	_elmDivChild.className = "erreurflash" + message.className;
	var _elmP1 = document.createElement("p");
	_elmP1.className = "titreerror";
	_elmP1.innerHTML = message.titre;
	_elmDivChild.appendChild(_elmP1);
	if (message.texte) {
		var _elmP2 = document.createElement("p");
		_elmP2.className = "txterror";
		_elmP2.innerHTML = message.texte;
		_elmDivChild.appendChild(_elmP2);
	}
	return _elmDivChild;
};
TouTV.Src.prototype.getFeedCarrousel = function () {
	return toutv.CarrouselData;
};
TouTV.Src.prototype.getFeedTeaser = function () {
	return toutv.TeaserData;
};
function getFeedTeaser() {
	return toutv.TeaserData;
};
function getFeedCarrousel() {
	return toutv.CarrouselData;
};
function PID2Release(pid) {
	return "http://release.theplatform.com/content.select?pid=" + pid + "format=SMIL&MBR=true";
};
// fire a chaque appel au pub. Construction d url a run time.
toutv.posPre = 1; toutv.posMid = 1; toutv.posEnd = 1;
toutv.addZero = function (num) { return (num < 10 ? '0' + num : num); }
function rewriteDartUrl(url) {
	try {
		//url = 'http://ad.doubleclick.net/pfadx/raca.tou.tv/trauma;sEmi=trauma;sSai=2;sNiv=3;sSou=null;sCha=CBFT;uPay=CA;key=tagcom;uPro=QC;uVil=Lasalle;sTyp=video;avDif=differe;avInt=true;avDur=044;bKid=false;sKey=;rcThm=series-teleromans;rcSThm=;rcSuj=;rcReg=;rcRet=;rcKey1=;rcKey2=;rcKey3=;rcZon=;sIdSA=;avSt=CBFT;ttGenre=series-teleromans;pos=pre;sz=852x480;tile=1;ord=75560372';
		var _pos = url.match(';pos=(pre|mid|end);');
		var _currentPos = ';pos=' + _pos[1] + (_pos[1] == 'pre' ? toutv.posPre++ : (_pos[1] == 'mid' ? toutv.addZero(toutv.posMid++) : toutv.posEnd++));
		keyValue = toutv._obj2Str_keyValuePair(toutv.Dart_motsClesObj(), ';') + _currentPos;
		url = GetDartURLCall('pfadx', '852x480', keyValue, Math.round(Math.random() * 100000000));

		//add key=toutv
		//var _url = url.replace('uPay=CA', 'uPay=CA;key=toutv');//tagcom
		var _url = url;
		if (_pos[1] == 'mid') {
			var _time = _url.match('ord=([0-9]+)');
			//replace timestamp for mid
			_url = _url.replace(_time[1], Math.round(Math.random() * 100000000));
		}
		//do tile incrementation
		var _tile = url.match('tile=([0-9]+);');
		toutv.currentPubUrl = _url;
		var _urlTileInc = _url.replace(_tile[0], 'tile=' + (++toutv.tileDART) + ';');
		toutv.currentPubUrl = _url.replace(_tile[0], 'tile=' + (++toutv.tileDART) + ';');
		return _urlTileInc;
	} catch (e) {
		return "";
	}
};
window.onload = onPageLoad;

﻿toutv.Lib={};
toutv.Lib.Stats = {
    init: function () {

    },
    toStatProd: function (_sAction, _sContenu) {
        var _sWtCall = statsToClics(
			'clic_action', "cav-" + _sAction,
			'clic_contenu', _sContenu,
			'WT.ti', "cav-" + _sAction + " :: " + _sContenu,
			'WT.clic', 'clics_statprod'
		);
        while (_sWtCall.indexOf("&") != -1) _sWtCall = _sWtCall.replace("&", "###");
        while (_sWtCall.indexOf("###") != -1) _sWtCall = _sWtCall.replace("###", "<br /><br />&");
        //flow("oStats.toStatProd() :: " + _sWtCall);
        //this.trace(_sWtCall);
    },
    toClics: function (_sLayout, _sAction) {
        var _sWtCall = statsToClics(
			'clic_action', _sLayout + "_" + _sAction,
			'WT.ti', _sLayout + "_" + _sAction,
			'WT.clic', 'Clics_audiovideoPlayer'
		);
        _sWtCall = _sWtCall.replaceAll("&", "<br />&");
        _sWtCall = _sWtCall.replaceAll("%26", "<br />&nbsp;&nbsp;%26");
    },
    toProfils: function (_oStats) {
        var _sURI = _oStats.mediaName; // clip url ou accronyme
        var _sMedia = _oStats.mediaType; // 'video' ou 'audio'
        var _sDiffusion = _oStats.diffusion; // 'direct' , 'differe', 'webdiffusion', 'AvantdiffTV'
        var _sGUI = _oMedia.oInst.layout;
        var _sLang = _oMedia.oInst.lang;
        var _sNomEmission = _oMedia.sEmission ? _oMedia.sEmission : "";
        var _sWtCall = statsToProfils(
			'DCS.dcsuri', _sURI,
			'profil', 'global;sc;sc_audiovideo;sc_audiovideo_' + _sDiffusion + ';sc_audiovideo_' + _sMedia + ';GUI_' + _sGUI + ';lang_' + _sLang + ';av_nomEmission_' + _sNomEmission,
			'titrepage', '',
			'descriptiondansurl',
			    'media=' + _sMedia +
			    '&diffusion=' + _sDiffusion +
			    '&GUI=' + _sGUI +
			    '&chaine=' + _oMedia.sChaine +
			    '&emi=' + _oMedia.sEmission +
			    '&dt=' + _oMedia.sDate +
			    '&decoupe=' + _oMedia.sDecoupe
		);

        _sWtCall = _sWtCall.replaceAll("&", "<br />&");
        _sWtCall = _sWtCall.replaceAll("%26", "<br />&nbsp;&nbsp;%26");
    }
};
toutv.Lib.Stats.init();
/////////////////////////////////////////
// H2H Interactif
//	www.h2hinteractif.com
//	
//	SimpleSmart - Plugin PDK
/////////////////////////////////////////

var rc_bFirstReloadBigbox = true;
var rc_bFirstReloadLeaderBoard = true;
var rc_bFirstReloadCatfish = true;

var pdkFullScreen = false;

var rc_onload = null;
var rc_onresize = null;

var rc_nbBigboxNull = 0;
var rc_nbLeaderBoardNull = 0;
var rc_nbCatfishNull = 0;

var rc_pendingEvents = [];

var rc_catfishHeight = 0;

var rc_timestamp = 0;

var rc_timerCatfish = null;

var rc_idDivCatfish = "catFish";
var rc_idDivBigbox = "bigBox";
var rc_idDivLeaderBoard = "leaderBoard";

var rc_ilotScript = {};

/////////////////////////////////////////////////
//	M�thodes utilitaires
/////////////////////////////////////////////////

function isArray(obj) {
    try { return obj.constructor.toString().indexOf("Array") != -1; }
    catch (e) { return false; }
}

function isEntier(obj) {
    try { return obj.toString().match(/^[0-9]+$/); }
    catch (e) { return false; }
}

function rc_getDocument(doc) {
    if (!doc) return null;

    if (doc.contentDocument) return doc.contentDocument;
    else if (doc.contentWindow) return doc.contentWindow.document
    else return doc.document;
}

function rc_getFirstIFrame(tagId) {
    var balise = document.getElementById(tagId);
    if (balise) {
        var iframes = balise.getElementsByTagName('iframe');
        for (var i = 0; i < iframes.length; i++)
            return iframes[i];
    }

    return null;
}

function rc_getHTMLBigbox(src, w, h) {
    return rc_getHTMLIframe(
		src,
		{
		    width: "300",
		    height: "250"
		},
		{
		    allowTransparency: "true"
		}
	);
}
function rc_getHTMLLeaderBoard(src, w, h) {
    return rc_getHTMLIframe(
		src,
		{
		    width: "728",
		    height: "90"
		},
		{
		    allowTransparency: "true"
		}
	);
}

function rc_getHTMLBigbox(src, w, h) {
    return rc_getHTMLIframe(
		src,
		{
		    "width": "300px",
		    "height": "0px"
		},
		{
		    "allowTransparency": "true"
		}
	);
}

function rc_getHTMLCatfish(src) {
    return rc_getHTMLIframe(
		src,
		{
		    "overflow": "hidden",
		    "width": "100%",
		    "left": "0px",
		    "top": "-1px"
		},
		{
		    "allowTransparency": "true"
		}
	);
}

function rc_getHTMLIframe(src, styles, attributs) {
    var strStyles = "";
    var strAttributs = "";

    if (styles)
        for (var key in styles)
            strStyles += key + ":" + styles[key] + ";";

    if (attributs)
        for (var key in attributs)
            strAttributs += key + '="' + attributs[key].replace('px', '') + '" ';

    return '<iframe style="' + strStyles + '" src="' + src + '" frameborder="0" scrolling="no" vspace="0" hspace="0" marginheight="0" marginwidth="0" ' + strAttributs + '></iframe>';
}

function rc_getBigBox() { return rc_getFirstIFrame(rc_idDivBigbox); }
function rc_getLeaderBoard() { return rc_getFirstIFrame(rc_idDivLeaderBoard); }
function rc_getCatfish() { return rc_getFirstIFrame(rc_idDivCatfish); }

function rc_getWndHeight() {
    if (typeof (window.innerHeight) != "undefined")
        return window.innerHeight;
    else
        return document.documentElement.clientHeight;
}

/////////////////////////////////////////////////
//	�v�ments en provenance de PDK/SimpleSmart.swf
/////////////////////////////////////////////////

function simplesmart_handleFullScreen(e) {
    pdkFullScreen = e.data;
}

function simplesmart_handleAdErr(e) {
    if (e.data.type != "COMMANDITAIRE")
        return;

    var div = document.getElementById('commanditaireDiv');
    if (div)
        div.style.display = "none";
}

function simplesmart_handleNoAd(e) {
    if (pdkFullScreen)
        return;

    rc_timestamp = Math.round(Math.random() * 10000000000);
    rc_reloadBigbox();
    rc_reloadCatfish();
}

function simplesmart_handleAdBegin(e) {
    if (pdkFullScreen)
        return;

    if (e.data.type == "COMMANDITAIRE") {
        if (e.data.couleur) {
            var zeros = "";

            for (var i = e.data.couleur.toString().length; i < 6; i++)
                zeros += "0";

            var couleurHtml = "#" + zeros + e.data.couleur.toString();

            rc_changerCouleurEpisodes(couleurHtml);
            var borderplayer = document.getElementById('borderplayer');
            if (borderplayer)
                borderplayer.style.borderColor = couleurHtml;

            // Change la couleur du fond de l'espace publicitaire (dans commanditairewidget) & des informations sur la vid�o(pluginwidget)
            tpController.callFunction("changerCouleur", ["0x" + e.data.couleur], ["*"]);
        }

        if (e.data.URLBackground) {
            var tag = document.getElementById("body");

            tag.style.backgroundImage = "URL(" + e.data.URLBackground + ")";

            if (e.data.URLBackgroundCountView) {
                var backgroundCount = document.createElement("img");
                backgroundCount.setAttribute("src", e.data.URLBackground);

                backgroundCount.style.display = "none";
                backgroundCount.width = backgroundCount.height = 0;

                tag.appendChild(backgroundConut);
            }
        }
    }
    else {
        rc_ilotScript = e.data.ilotScript;

        rc_timestamp = e.data.timestampRequest;

        rc_reloadBigbox();

        if (e.data.type != "PREROLL")
            rc_reloadCatfish();
    }
}

/////////////////////////////////////////////////

function rc_init() {
    if (rc_onload)
        rc_onload();

    try {
        if (sas_tmstp)
            rc_timestamp = sas_tmstp;
    }
    catch (e) { }

    rc_createCatfishFrame();

    if (toutv) {
        if (!rc_loadPdk(true))
            if (!isArray(toutv.callbackPdkReady))
                toutv.callbackPdkReady = [rc_loadPdk];
            else
                toutv.callbackPdkReady.push(rc_loadPdk);
    }
    else
        rc_loadPdk();

    rc_onresize = window.onresize;
    window.onresize = rc_resizeWnd;
}

function rc_loadPdk(tryOnce) {
    if (!tpController) {
        if (tryOnce)
            return false;

        window.setTimeout(rc_loadPdk, 50);

        return false;
    }

    tpController.addEventListener("onAdBegin", simplesmart_handleAdBegin);
    tpController.addEventListener("onNoAd", simplesmart_handleNoAd);
    tpController.addEventListener("onAdErr", simplesmart_handleAdErr);
    tpController.addEventListener("OnShowFullScreen", simplesmart_handleFullScreen);

    rc_jsReady = true;
    tpController.dispatchEvent("onSimpleSmartJsReady", []);

    // Envoie les messages en attentes
    for (var index in rc_pendingEvents) {
        var e = rc_pendingEvents[index];
        tpController.dispatchEvent(e.event, e.params);
    }

    return true;
}


/////////////////////////////////////////////////

function rc_reloadIframe(iframe) {
    if (!iframe)
        return;

    var nouveauFrame = iframe.cloneNode(true);
    var parentFrame = iframe.parentNode;

    var oldSrc = nouveauFrame.src;
    nouveauFrame.src = nouveauFrame.src.replace(/([0-9]+\/[0-9]+\/[0-9]+\/)([^\/]*\/)[0-9]+/, "$1S/" + rc_timestamp.toString());

    iframe.parentNode.removeChild(iframe);
    parentFrame.appendChild(nouveauFrame);

    return nouveauFrame;
}

function rc_reloadBigbox() {
    var bigbox = document.getElementById(rc_idDivBigbox);

    // Support des liaisons � m�me le XML (depuis 0.5)
    if (rc_ilotScript && typeof (rc_ilotScript.bigbox) != 'undefined') {
        if (!bigbox)
            return;

        rc_bFirstReloadBigbox = true;

        if ($.browser.safari) {
            $.get(
				'/iframe.html?!' + Math.random(),
				function (data) {
				    bigbox.innerHTML = rc_getHTMLBigbox('about:blank');
				    var iframeDoc = rc_getDocument(rc_getBigBox());

				    iframeDoc.open();
				    iframeDoc.write(data + rc_ilotScript.bigbox.replace("[timestamp]", rc_timestamp));
				    iframeDoc.close();
				}
			);
        }
        else
            bigbox.innerHTML = rc_getHTMLBigbox('/iframe.html?!' + escape(rc_ilotScript.bigbox.replace("[timestamp]", rc_timestamp)));
    }
    else {
        if (rc_bFirstReloadBigbox) {
            if (!bigbox)
                return;

            bigbox.innerHTML = rc_getHTMLBigbox('/iframe.html?12080/90030/1839/S/' + rc_timestamp.toString() + '/' + toutv.getSmartTarget() + '?');
            rc_bFirstReloadBigbox = false;

            return;
        }

        var bigbox = rc_getBigBox();
        if (!bigbox) {
            if (rc_nbBigboxNull++ <= 10)
                setTimeout("rc_reloadBigbox()", 250);

            return;
        }

        bigbox.style.height = "0px";

        rc_reloadIframe(bigbox);
    }
}

function rc_createCatfishFrame() {
    var catfish = document.getElementById(rc_idDivCatfish);
    if (catfish)
        return;

    catfish = document.createElement('div')
    catfish.setAttribute('id', rc_idDivCatfish);

    catfish.innerHTML = rc_getHTMLCatfish('iframe_catfish.html?12080/90030/1847/S/' + rc_timestamp.toString() + '/' + toutv.getSmartTarget() + '?');

    document.getElementsByTagName('body')[0].appendChild(catfish);
}

function rc_reloadCatfish(reload) {
    rc_catfishHeight = 0;
    var catfishDiv = document.getElementById(rc_idDivCatfish);

    if (rc_ilotScript && typeof (rc_ilotScript.catfish) != 'undefined') {
        rc_bFirstReloadCatfish = true;

        catfishDiv.innerHTML = catfishDiv, rc_ilotScript.catfish.replace("[timestamp]", rc_timestamp), rc_getCatfish();
    }
    else {
        if (rc_bFirstReloadCatfish) {
            var catfish;

            if (catfishDiv)
                catfish = catfishDiv;
            else {
                catfish = document.createElement('div')
                catfish.setAttribute('id', rc_idDivCatfish);
                document.getElementsByTagName('body')[0].appendChild(catfish);
            }

            rc_bFirstReloadCatfish = false;

            setTimeout('rc_createCatfishFrame();', 250);

            return;
        }

        var catfish = rc_getCatfish();
        if (!catfish) {
            if (rc_nbCatfishNull++ <= 10)
                setTimeout("rc_reloadCatfish()", 250);

            return;
        }

        // Recharge le catfish plus tard pour qu'il soit en premier plan
        if (!reload && rc_getBigBox() && rc_getLeaderBoard() && !rc_timerCatfish)
            rc_timerCatfish = setTimeout('rc_reloadCatfish(true);', 250);
        else {
            if (rc_timerCatfish) {
                clearTimeout(rc_timerCatfish);
                rc_timerCatfish = null;
            }

            catfish = rc_reloadIframe(catfish);
            rc_timerCatfish = null;
        }
    }
}

/////////////////////////////////////////////////

function rc_resizeWnd() {
    if (rc_onresize)
        rc_onresize();

    var catfish = rc_getCatfish();
    if (!catfish)
        return;

    catfish.style.top = (rc_getWndHeight() - rc_catfishHeight) + "px";
}

// Redimensionne les publicit�s dans un iframe
function rc_resizeAd(iframe, width, height) {
    if (!iframe)
        return;

    var catfish = rc_getCatfish();

    // Catfish
    if (iframe == catfish) {
        iframe.style.top = (rc_getWndHeight() - height) + "px";
        iframe.style.height = height + "px";
        iframe.style.position = "fixed";

        rc_catfishHeight = height;

        return;
    }

    // Bigbox
    // Le catfish est en attente de rafra�issement
    if (rc_timerCatfish)
        rc_reloadCatfish(true);

    if (width >= 0) {
        iframe.width = width;

        iframe.style.width = width + (isEntier(width) ? "px" : "");
    }

    if (height >= 0) {
        iframe.height = height;

        iframe.style.height = height + (isEntier(height) ? "px" : "");
    }
}

/////////////////////////////////////////////////

function rc_changerCouleurEpisodes(couleur) {
    var colonneGauche = document.getElementById("colonnegauche");
    if (!colonneGauche)
        return false;

    var liens = colonneGauche.getElementsByTagName("a");
    for (var i = 0; i < liens.length; i++) {
        var lien = liens[i];

        if (lien.className.indexOf("vignettesgrandes") >= 0)
            lien.style.backgroundColor = couleur;
    }

    return true;
}

rc_onload = window.onload;
window.onload = rc_init;﻿//=============================================================
//	----------	  [D�BUT] Advanced SmartSource 						 ----------
//=============================================================
// START OF Advanced SmartSource Data Collector TAG
// Copyright (c) 1996-2007 WebTrends Inc. All rights reserved.
// V8.0d
// $DateTime: 2007/02/14 15:39:59 $
var gService = false;
var gTimeZone = -5;
function dcsCookie() {
    if (typeof (dcsOther) == "function") {
        dcsOther();
    }
    else if (typeof (dcsPlugin) == "function") {
        dcsPlugin();
    }
    else if (typeof (dcsFPC) == "function") {
        dcsFPC(gTimeZone);
    }
};

function dcsGetCookie(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 dcsGetCrumb(name, crumb) {
    var aCookie = dcsGetCookie(name).split(":");
    for (var i = 0; i < aCookie.length; i++) {
        var aCrumb = aCookie[i].split("=");
        if (crumb == aCrumb[0]) {
            return aCrumb[1];
        }
    }
    return null;
};

function dcsGetIdCrumb(name, crumb) {
    var cookie = dcsGetCookie(name);
    var id = cookie.substring(0, cookie.indexOf(":lv="));
    var aCrumb = id.split("=");
    for (var i = 0; i < aCrumb.length; i++) {
        if (crumb == aCrumb[0]) {
            return aCrumb[1];
        }
    }
    return null;
};

function dcsFPC(offset) {
    if (typeof (offset) == "undefined") {
        return;
    }
    if (document.cookie.indexOf("WTLOPTOUT=") != -1) {
        return;
    }
    var name = gFpc;
    var dCur = new Date();
    var adj = (dCur.getTimezoneOffset() * 60000) + (offset * 3600000);
    dCur.setTime(dCur.getTime() + adj);
    var dExp = new Date(dCur.getTime() + 315360000000);
    var dSes = new Date(dCur.getTime());
    WT.co_f = WT.vt_sid = WT.vt_f = WT.vt_f_a = WT.vt_f_s = WT.vt_f_d = WT.vt_f_tlh = WT.vt_f_tlv = "";
    if (document.cookie.indexOf(name + "=") == -1) {
        if ((typeof (gWtId) != "undefined") && (gWtId != "")) {
            WT.co_f = gWtId;
        }
        else if ((typeof (gTempWtId) != "undefined") && (gTempWtId != "")) {
            WT.co_f = gTempWtId;
            WT.vt_f = "1";
        }
        else {
            WT.co_f = "2";
            var cur = dCur.getTime().toString();
            for (var i = 2; i <= (32 - cur.length); i++) {
                WT.co_f += Math.floor(Math.random() * 16.0).toString(16);
            }
            WT.co_f += cur;
            WT.vt_f = "1";
        }
        if (typeof (gWtAccountRollup) == "undefined") {
            WT.vt_f_a = "1";
        }
        WT.vt_f_s = WT.vt_f_d = "1";
        WT.vt_f_tlh = WT.vt_f_tlv = "0";
    }
    else {
        var id = dcsGetIdCrumb(name, "id");
        var lv = parseInt(dcsGetCrumb(name, "lv"));
        var ss = parseInt(dcsGetCrumb(name, "ss"));
        if ((id == null) || (id == "null") || isNaN(lv) || isNaN(ss)) {
            return;
        }
        WT.co_f = id;
        var dLst = new Date(lv);
        WT.vt_f_tlh = Math.floor((dLst.getTime() - adj) / 1000);
        dSes.setTime(ss);
        if ((dCur.getTime() > (dLst.getTime() + 1800000)) || (dCur.getTime() > (dSes.getTime() + 28800000))) {
            WT.vt_f_tlv = Math.floor((dSes.getTime() - adj) / 1000);
            dSes.setTime(dCur.getTime());
            WT.vt_f_s = "1";
        }
        if ((dCur.getDay() != dLst.getDay()) || (dCur.getMonth() != dLst.getMonth()) || (dCur.getYear() != dLst.getYear())) {
            WT.vt_f_d = "1";
        }
    }
    WT.co_f = escape(WT.co_f);
    WT.vt_sid = WT.co_f + "." + (dSes.getTime() - adj);
    var expiry = "; expires=" + dExp.toGMTString();
    document.cookie = name + "=" + "id=" + WT.co_f + ":lv=" + dCur.getTime().toString() + ":ss=" + dSes.getTime().toString() + expiry + "; path=/" + (((typeof (gFpcDom) != "undefined") && (gFpcDom != "")) ? ("; domain=" + gFpcDom) : (""));
    if (document.cookie.indexOf(name + "=") == -1) {
        WT.co_f = WT.vt_sid = WT.vt_f_s = WT.vt_f_d = WT.vt_f_tlh = WT.vt_f_tlv = "";
        WT.vt_f = WT.vt_f_a = "2";
    }
};

// Code section for Enable Event Tracking
function dcsParseSvl(sv) {
    sv = sv.split(" ").join("");
    sv = sv.split("\t").join("");
    sv = sv.split("\n").join("");
    var pos = sv.toUpperCase().indexOf("WT.SVL=");
    if (pos != -1) {
        var start = pos + 8;
        var end = sv.indexOf('"', start);
        if (end == -1) {
            end = sv.indexOf("'", start);
            if (end == -1) {
                end = sv.length;
            }
        }
        return sv.substring(start, end);
    }
    return "";
};

function dcsIsOnsite(host) {
    //	Martin Rancourt | 2008-11-24 : 
    //	On accepte tout pour le moment
    return 1;
    /*
    var doms = "www.radio-canada.ca,musique.radio-canada.ca,elections.radio-canada.ca,publique.radio-canada.ca";
    var aDoms=doms.split(',');
    for (var i=0;i<aDoms.length;i++){
    if (host.indexOf(aDoms[i])!=-1){
    return 1;
    }
    }
    return 0;
    */
};
function dcsIsHttp(e) {
    return (e.href && e.protocol && (e.protocol.indexOf("http") != -1)) ? true : false;
};

function dcsTypeMatch(path, typelist) {
    var type = path.substring(path.lastIndexOf(".") + 1, path.length);
    var types = typelist.split(",");
    for (var i = 0; i < types.length; i++) {
        if (type == types[i]) {
            return true;
        }
    }
    return false;
};

function dcsEvt(evt, tag) {
    var e = evt.target || evt.srcElement;
    while (e.tagName && (e.tagName != tag)) {
        e = e.parentElement || e.parentNode;
    }
    return e;
};

function dcsBind(event, func) {
    if ((typeof (window[func]) == "function") && document.body) {
        if (document.body.addEventListener) {
            document.body.addEventListener(event, window[func], true);
        }
        else if (document.body.attachEvent) {
            document.body.attachEvent("on" + event, window[func]);
        }
    }
};
function dcsET() {
    var e = (navigator.appVersion.indexOf("MSIE") != -1) ? "click" : "mousedown";
    dcsBind(e, "dcsDownload");
    dcsBind(e, "dcsDynamic");
    dcsBind(e, "dcsFormButton");
    dcsBind(e, "dcsOffsite");
    dcsBind(e, "dcsAnchor");
    dcsBind("mousedown", "dcsRightClick");
};

function dcsMultiTrack() {
    if (arguments.length % 2 == 0) {
        for (var i = 0; i < arguments.length; i += 2) {
            if (arguments[i].indexOf('WT.') == 0) {
                WT[arguments[i].substring(3)] = arguments[i + 1];
            }
            else if (arguments[i].indexOf('DCS.') == 0) {
                DCS[arguments[i].substring(4)] = arguments[i + 1];
            }
            else if (arguments[i].indexOf('DCSext.') == 0) {
                DCSext[arguments[i].substring(7)] = arguments[i + 1];
            }
        }
        var dCurrent = new Date();
        DCS.dcsdat = dCurrent.getTime();
        dcsFunc("dcsCookie");
        dcsTag();
    }
};

// Add event handlers here

function dcsAdv() {
    dcsFunc("dcsET");
    dcsFunc("dcsCookie");
    dcsFunc("dcsAdSearch");
    dcsFunc("dcsTP");
};
// END OF Advanced SmartSource Data Collector TAG

//================ [FIN] Advanced SmartSource ================


var agDomain = new Array("sdc2.radio-canada.ca", "sdc3.radio-canada.ca");
var gDcsId = "dcs5w0txb10000wocrvqy1nqm_6n1p";
var gFpcDom = "tou.tv";
var gFpc = "WEBTRENDS_toutv";
var gConvert = true;


//=============================================================
//	----------	  [D�BUT] Basic SmartSource 						 ----------
//=============================================================

// START OF Basic SmartSource Data Collector TAG
// Copyright (c) 1996-2007 WebTrends Inc. All rights reserved.
// V8.0
// $DateTime: 2007/02/14 15:39:59 $
// Implanter par Martin Rancourt | 2008-11-24 : 

var gImages = new Array;
var gIndex = 0;
var comS_gImages = new Array;
var comS_gIndex = 0;
var comS_id = 3005684;
var DCS = new Object();
var WT = new Object();
var DCSext = new Object();
var gQP = new Array();
var gI18n = false;
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};
    //var I18NRE={"%25":/\%/g};
}

function dcsVar() {
    var dCurrent = new Date();
    WT.tz = dCurrent.getTimezoneOffset() / 60 * -1;
    if (WT.tz == 0) {
        WT.tz = "0";
    }
    WT.bh = dCurrent.getHours();
    WT.ul = navigator.appName == "Netscape" ? navigator.language : navigator.userLanguage;
    if (typeof (screen) == "object") {
        WT.cd = navigator.appName == "Netscape" ? screen.pixelDepth : screen.colorDepth;
        WT.sr = screen.width + "x" + screen.height;
    }
    if (typeof (navigator.javaEnabled()) == "boolean") {
        WT.jo = navigator.javaEnabled() ? "Yes" : "No";
    }
    if (document.title) {
        WT.ti = gI18n ? dcsEscape(dcsEncode(document.title), I18NRE) : document.title;
    }
    WT.js = "Yes";
    WT.jv = dcsJV();
    if (document.body && document.body.addBehavior) {
        try {
            document.body.addBehavior("#default#clientCaps");
            WT.ct = document.body.connectionType || "unknown";
            document.body.addBehavior("#default#homePage");
            WT.hp = document.body.isHomePage(location.href) ? "1" : "0";
        } catch (e) {
            WT.ct = "unknown";
        }
    }
    else {
        WT.ct = "unknown";
    }
    if (parseInt(navigator.appVersion) > 3) {
        if ((navigator.appName == "Microsoft Internet Explorer") && document.body) {
            WT.bs = document.body.offsetWidth + "x" + document.body.offsetHeight;
        }
        else if (navigator.appName == "Netscape") {
            WT.bs = window.innerWidth + "x" + window.innerHeight;
        }
    }
    WT.fi = "No";
    if (window.ActiveXObject) {
        for (var i = 10; i > 0; i--) {
            try {
                var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
                WT.fi = "Yes";
                WT.fv = i + ".0";
                break;
            }
            catch (e) {
            }
        }
    }
    else if (navigator.plugins && navigator.plugins.length) {
        for (var i = 0; i < navigator.plugins.length; i++) {
            if (navigator.plugins[i].name.indexOf('Shockwave Flash') != -1) {
                WT.fi = "Yes";
                WT.fv = navigator.plugins[i].description.split(" ")[2];
                break;
            }
        }
    }
    if (gI18n) {
        WT.em = (typeof (encodeURIComponent) == "function") ? "uri" : "esc";
        if (typeof (document.defaultCharset) == "string") {
            WT.le = document.defaultCharset;
        }
        else if (typeof (document.characterSet) == "string") {
            WT.le = document.characterSet;
        }
    }
    WT.tv = "8.0.2";
    WT.sp = ";";
    DCS.dcsdat = dCurrent.getTime();
    DCS.dcssip = window.location.hostname;
    DCS.dcsuri = window.location.pathname;
    if (window.location.search) {
        DCS.dcsqry = window.location.search;
        if (gQP.length > 0) {
            for (var i = 0; i < gQP.length; i++) {
                var pos = DCS.dcsqry.indexOf(gQP[i]);
                if (pos != -1) {
                    var front = DCS.dcsqry.substring(0, pos);
                    var end = DCS.dcsqry.substring(pos + gQP[i].length, DCS.dcsqry.length);
                    DCS.dcsqry = front + end;
                }
            }
        }
    }
    if ((window.document.referrer != "") && (window.document.referrer != "-")) {
        if (!(navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) < 4)) {
            DCS.dcsref = gI18n ? dcsEscape(window.document.referrer, I18NRE) : window.document.referrer;
        }
    }
};
var RE = { "%26": /\&/g };
function dcsA(N, V) {
    return "&" + N + "=" + dcsEscape(V, RE);
};

function dcsEscape(S, REL) {
    if (typeof (REL) != "undefined") {
        var retStr = new String(S);
        for (var R in REL) { retStr = retStr.replace(REL[R], R); }
        return retStr;
    } else {
        return escape(S);
    }
};

function dcsEncode(S) {
    return (typeof (encodeURIComponent) == "function") ? encodeURIComponent(S) : escape(S);
};

function dcsCreateImage(dcsSrc, _comS_src) {
    /// Webtrends
    if (document.images) { gImages[gIndex] = new Image; gImages[gIndex].src = dcsSrc; gIndex++; }
    else { document.write('<IMG ALT="" BORDER="0" NAME="DCSIMG" WIDTH="1" HEIGHT="1" SRC="' + dcsSrc + '">'); }

    /// ajout d'un call a comscore
    /// Le call est fait juste une fois, si _comS_src est pr�sent
    if (typeof (_comS_src) != "undefined" && _comS_src != null) {
        if (document.images) {
            ////// D�SUET DEPUIS LE NOUVEAU CODE COMSCORE //////
            // alert('image1');
            // comS_gImages[comS_gIndex] = new Image;
            // comS_gImages[comS_gIndex].src = _comS_src;
            // comS_gIndex++;
        }
        else {
            // alert('image2');
            document.write('<IMG ALT="" BORDER="0" NAME="DCSIMG" WIDTH="1" HEIGHT="1" SRC="' + _comS_src + '">');
        }
    }
    return dcsSrc;
};

function dcsMeta() {
    var elems;
    if (document.all) {
        elems = document.all.tags("meta");
    }
    else if (document.documentElement) {
        elems = document.getElementsByTagName("meta");
    }
    if (typeof (elems) != "undefined") {
        var length = elems.length;
        for (var i = 0; i < length; i++) {
            var name = elems.item(i).name;
            var content = elems.item(i).content;
            var equiv = elems.item(i).httpEquiv;
            if (name.length > 0) {
                if (name.indexOf("WT.") == 0) {
                    var encode = false;
                    if (gI18n) {
                        var params = ["mc_id", "oss", "ti"];
                        for (var j = 0; j < params.length; j++) {
                            if (name.indexOf("WT." + params[j]) == 0) {
                                encode = true;
                                break;
                            }
                        }
                    }
                    WT[name.substring(3)] = encode ? dcsEscape(dcsEncode(content), I18NRE) : content;
                }
                else if (name.indexOf("DCSext.") == 0) {
                    DCSext[name.substring(7)] = content;
                }
                else if (name.indexOf("DCS.") == 0) {
                    DCS[name.substring(4)] = (gI18n && (name.indexOf("DCS.dcsref") == 0)) ? dcsEscape(content, I18NRE) : content;
                }
            }
            else if (gI18n && (equiv == "Content-Type")) {
                var pos = content.toLowerCase().indexOf("charset=");
                if (pos != -1) {
                    WT.mle = content.substring(pos + 8);
                }
            }
        }
    }
};

function dcsTag() {
    if (document.cookie.indexOf("WTLOPTOUT=") != -1) return;
    if (typeof (WT.sp) != "undefined" && WT.sp.indexOf("groupeRC") != -1) {

        /////////////// VIEUX BOUT DE CODE COMSCORE ///////////////
        //	    if (WT.sp.indexOf("toutv_video") != -1 && DCS.dcsuri != null && DCS.dcsuri != "undefined") {
        //	        // alert('est un vid�o');
        //          var _comS_pageHref = DCS.dcsuri;
        //			var _comS_src = "http://beacon.scorecardresearch.com/scripts/beacon.dll?" +
        //				"C1=" + ((WT.sp.indexOf("toutv_video") != -1) ? 1 : 2) + "&" + 
        //				"C2="+comS_id+"&" + 
        //				"C3=&" + 
        //				"C4=" + escape(_comS_pageHref) + "&" + 
        //				"C5=&" + 
        //				"C6=&" + 
        //				"C7=" + escape(_comS_pageHref) + "&" + 
        //				"C8=" + escape(document.title) + "&" + 
        //				"C9=" + escape(document.location.href) + "&" +
        //				"rn=" + Math.floor(Math.random() * 99999999);
        //        } else {
        //            //alert('pas un vid�o');
        //          try{var _comS_pageHref = top.window.location.href;}catch(e){var _comS_pageHref = window.location.href;};
        //			var _comS_src = "http://beacon.scorecardresearch.com/scripts/beacon.dll?" +
        //				"C1=" + ((WT.sp.indexOf("toutv_video") != -1) ? 1 : 2) + "&" + 
        //				"C2="+comS_id+"&" + 
        //				"C3=&" + 
        //				"C4=" + escape(_comS_pageHref) + "&" + 
        //				"C5=&" + 
        //				"C6=" + WT.sp.split(";")[1] + "&" + 
        //				"C7=" + escape(window.location.href) + "&" + 
        //				"C8=" + escape(document.title) + "&" + 
        //				"C9=" + escape(document.referrer) + "&" +
        //				"rn=" + Math.floor(Math.random() * 99999999);
        //		}

        if (WT.sp.indexOf("toutv_video") != -1 && DCS.dcsuri != null && DCS.dcsuri != "undefined") {
            var _comS_pageHref = DCS.dcsuri;
            var __cs_c1 = ((WT.sp.indexOf("toutv_video") != -1) ? 1 : 2);
            var __cs_c2 = comS_id;
            var __cs_c3 = "";
            var __cs_c4 = 9293153;
            var __cs_c5 = "";
            var __cs_c6 = WT.sp.split(";")[1];
            var __cs_c15 = "";
            var __cs_params = ["c1=", __cs_c1, "&c2=", __cs_c2, "&c3=", __cs_c3, "&c4=", __cs_c4, "&c5=", __cs_c5, "&c6=", __cs_c6, "&c15=", __cs_c15].join('');
            //document.write(unescape("%3Cscript src='" + (document.location.protocol == "https:" ? "https://sb" : "http://b") + ".scorecardresearch.com/beacon.js?" + __cs_params + "' %3E%3C/script%3E"));
            $.getScript('http://b.scorecardresearch.com/beacon.js?' + __cs_params);

        } else {
            try { var _comS_pageHref = top.window.location.href; } catch (e) { var _comS_pageHref = window.location.href; };
            var __cs_c1 = ((WT.sp.indexOf("toutv_video") != -1) ? 1 : 2);
            var __cs_c2 = comS_id;
            var __cs_c3 = "";
            var __cs_c4 = 9293153;
            var __cs_c5 = "";
            var __cs_c6 = WT.sp.split(";")[1];
            var __cs_c15 = "";
            var __cs_params = ["c1=", __cs_c1, "&c2=", __cs_c2, "&c3=", __cs_c3, "&c4=", __cs_c4, "&c5=", __cs_c5, "&c6=", __cs_c6, "&c15=", __cs_c15].join('');
            //document.write(unescape("%3Cscript src='" + (document.location.protocol == "https:" ? "https://sb" : "http://b") + ".scorecardresearch.com/beacon.js?" + __cs_params + "' %3E%3C/script%3E"));
            $.getScript('http://b.scorecardresearch.com/beacon.js?' + __cs_params);
        }

    }
    else {
        var _comS_src = null;
    }

    var P = "";
    for (var N in DCS) {
        if (DCS[N]) P += dcsA(N, DCS[N]);
    }
    var keys = ["co_f", "vt_sid", "vt_f_tlv"];
    for (var i = 0; i < keys.length; i++) {
        var key = keys[i];
        if (WT[key]) { P += dcsA("WT." + key, WT[key]); delete WT[key]; }
    }
    for (N in WT) { if (WT[N]) P += dcsA("WT." + N, WT[N]); }
    for (N in DCSext) { if (DCSext[N]) P += dcsA(N, DCSext[N]); }
    if (P.length > 2048 && navigator.userAgent.indexOf('MSIE') >= 0) P = P.substring(0, 2040) + "&WT.tu=1";

    for (var i = 0; i < agDomain.length; i++) {
        var _sP = "http" + (window.location.protocol.indexOf('https:') == 0 ? 's' : '') + "://" + agDomain[i] + (gDcsId == "" ? '' : '/' + gDcsId) + "/dcs.gif?" + P;
        if (i == agDomain.length - 1) {
            if (typeof (oSrc) != 'undefined') oSrc.alert("stats", _sP.replaceAll("&", "<br />&"));
            if (_comS_src != null && typeof (oSrc) != 'undefined') oSrc.alert("stats", '<span style="color:blue;">' + _comS_src.replaceAll("&", "<br />&") + '</span>');
            return dcsCreateImage(_sP, _comS_src);
        } else {
            if (typeof (oSrc) != 'undefined') oSrc.alert("stats", '<span style="color:#CCC;">' + _sP.replaceAll("&", "<br />&") + '</span>');
            dcsCreateImage(_sP);
        }
    }
};

function dcsJV() {
    var agt = navigator.userAgent.toLowerCase();
    var major = parseInt(navigator.appVersion);
    var mac = (agt.indexOf("mac") != -1);
    var ff = (agt.indexOf("firefox") != -1);
    var ff0 = (agt.indexOf("firefox/0.") != -1);
    var ff10 = (agt.indexOf("firefox/1.0") != -1);
    var ff15 = (agt.indexOf("firefox/1.5") != -1);
    var ff2up = (ff && !ff0 && !ff10 & !ff15);
    var nn = (!ff && (agt.indexOf("mozilla") != -1) && (agt.indexOf("compatible") == -1));
    var nn4 = (nn && (major == 4));
    var nn6up = (nn && (major >= 5));
    var ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var ie4 = (ie && (major == 4) && (agt.indexOf("msie 4") != -1));
    var ie5up = (ie && !ie4);
    var op = (agt.indexOf("opera") != -1);
    var op5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
    var op6 = (agt.indexOf("opera 6") != -1 || agt.indexOf("opera/6") != -1);
    var op7up = (op && !op5 && !op6);
    var jv = "1.1";
    if (ff2up) jv = "1.7";
    else if (ff15) jv = "1.6";
    else if (ff0 || ff10 || nn6up || op7up) jv = "1.5";
    else if ((mac && ie5up) || op6) jv = "1.4";
    else if (ie5up || nn4 || op5) jv = "1.3";
    else if (ie4) jv = "1.2";
    return jv;
};

function dcsFunc(func) {
    if (typeof (window[func]) == "function") window[func]();
};

//================ [FIN]  Basic SmartSource ================

// *********************************************************
// Méthodes Webtrends pour les appels de type CLIC     
// *********************************************************

function CT(action, contenu) {
    if (typeof (contenu) == 'undefined') contenu = '';
    statsToClics(
    'clic_action', action,
    'clic_contenu', contenu,
    'WT.ti', action,
    'WT.clic', toutv.UrlPremierNiveau);
    return false;
};

function CTMenu(titre, elem) {

    var action = titre + elem.href.split("/").pop();
    statsToClics(
    'clic_action', action,
    'clic_contenu', elem.href,
    'WT.ti', action,
    'WT.clic', toutv.UrlPremierNiveau);
    return false;
};
// Cette méthode est appellée pour les clics sur les
// vignettes et titres d'épisode (page accueil, genre, émission)
function CTItem(titre, elem) {

    //var action = titre + "_" + elem.id.split("_")[2];
    var action = title + "_" + document.title;
    statsToClics(
    'clic_action', action,
    'clic_contenu', elem.href,
    'WT.ti', action,
    'WT.clic', toutv.UrlPremierNiveau);
    return false;
};

function CTFilAriane(elem) {

    var fil = elem.href.split("/").pop();
    var action = "FilAriane_" + (fil == "" ? "accueil" : fil);
    statsToClics(
    'clic_action', action,
    'clic_contenu', (fil == "" ? "accueil" : elem.href),
    'WT.ti', action,
    'WT.clic', toutv.UrlPremierNiveau);
    return false;
};
function createImageDCS(P) {
    var _elemImage = document.createElement("img");
    _elemImage.alt = "";
    _elemImage.style.border = "0px";
    _elemImage.NAME = "DCSIMG";
    _elemImage.style.width = "1px";
    _elemImage.style.height = "1px";
    for (var i = 0; i < agDomain.length; i++) {
        var _sP = "http" + (window.location.protocol.indexOf('https:') == 0 ? 's' : '') + "://" + agDomain[i] + (gDcsId == "" ? '' : '/' + gDcsId) + "/dcs.gif?" + P;
        _elemImage.src = _sP;
        document.body.appendChild(_elemImage);
    }
};
function createImageVideoStats(P) {
    for (var i = 0; i < agDomain.length; i++) {
        var _sP = "http" + (window.location.protocol.indexOf('https:') == 0 ? 's' : '') + "://" + agDomain[i] + (gDcsId == "" ? '' : '/' + gDcsId) + "/dcs.gif?" + P;
        var image = new Image(1, 1);
        image.src = _sP;
    };
};
//version amelioree
function removeChars(text, chars) {
    return text.replace(new RegExp('(' + chars.replace(/(.)/g, '\\$1|') + '\\\')', 'g'), ' ').replace(/ {2,}/g, ' ');
};
function statsVideoDetail() {
    return {
        "a01genre": toutv.genre,
        "a02emission": toutv.show,
        "a03saisonNbr": toutv.mediaData.SeasonNumber,
        "a04episodeNbr": toutv.mediaData.EpisodeNumber,
        "a05dateEmission": toutv.mediaData.AirDateFormated,
        "a06titre": escape(removeChars(toutv.mediaData.Title, ",&^@%#*")),
        "a07network": toutv.mediaData.Network,
        "a08partenaire": toutv.mediaData.Copyright ? escape(removeChars(toutv.mediaData.Copyright, ",&^@%#*")) : "",
        "a09length": toutv.mediaData.LengthStats,
        "a10type": escape(toutv.mediaData.ClipType),
        "a11media": "video",
        "a12diffusion": toutv.mediaData.LiveOnDemand,
        "a13plateforme": "SiteWeb",
        "a14typeExclusivite": toutv.typeExclusivite,
        "a15osVersion": ""
    };
};
function statsToProfilsVideo() {
    var dcsqry = statsVideoDetail();
    var P = "";
    //profils
    P += dcsA("WT.sp", "toutv_video");
    //date unix format
    //P += dcsA("dcsdat", new Date());
    // domain
    P += dcsA("dcssip", "v|");
    // video url
    P += dcsA("dcsuri", toutv.mediaData.TitleID);
    P += dcsA("dcsqry", toutv._obj2Str_keyValuePair(dcsqry, "%26", "%3D"));
    P += dcsA("dcsdat", (new Date()).getTime());

    // titre
    P += dcsA("WT.ti", toutv.show + "_" + toutv.mediaData.TitleID);
    // genre
    P += dcsA("WT.cg_n", toutv.genre);
    // emission
    P += dcsA("WT.cg_s", toutv.show);

    //for (var N in DCS) {if (N != "dcsuri" && DCS[N]) P+=dcsA(N,DCS[N]);}
    //var keys=["co_f","vt_sid","vt_f_tlv"];
    //for (var i=0;i<keys.length;i++){var key=keys[i];if (WT[key]){P+=dcsA("WT."+key,WT[key]);delete WT[key];}}
    //for (N in WT) { if (WT[N]) if (N != "sp") P += dcsA("WT." + N, WT[N]); }
    //for (N in DCSext) {if (DCSext[N]) if (N != "dcsuri") P += dcsA(N, DCSext[N]);  }
    //if (P.length>2048&&navigator.userAgent.indexOf('MSIE')>=0)P=P.substring(0,2040)+"&WT.tu=1";
    createImageVideoStats(P);
    //createImageDCS(P);
    //  dcsTag
    var _comS_pageHref = DCS.dcsuri;
    var __cs_c1 = 1;
    var __cs_c2 = comS_id;
    var __cs_c3 = "";
    var __cs_c4 = 9293153;
    var __cs_c5 = toutv.genre;
    var __cs_c6 = "tou.tv"; // WT.sp.split(";")[1];
    var __cs_c15 = "";
    var __cs_params = ["c1=", __cs_c1, "&c2=", __cs_c2, "&c3=", __cs_c3, "&c4=", __cs_c4, "&c5=", __cs_c5, "&c6=", __cs_c6, "&c15=", __cs_c15].join('');
    var __script = document.createElement("script");
    __script.type = "text/javascript";
    __script.src = unescape((document.location.protocol == "https:" ? "https://sb" : "http://b") + ".scorecardresearch.com/beacon.js?" + __cs_params);
    document.getElementsByTagName("head")[0].appendChild(__script);
    // end dcsTag
};

function statsToProfils() {
    DCS.dcsqry = null;
    DCS = new Object();
    WT = new Object();
    DCSext = new Object();
    dcsVar();
    dcsMeta();

    for (var I = 0; I < arguments.length; I++) {
        switch (arguments[I].toLowerCase()) {

            case "titrepage":
                WT.ti = dcsEscape(arguments[I + 1]);
                DCS.dcsqry = null; //annule les querystring si on reset l'url de la page
                break;
            case "descriptiondansurl":
                if (typeof (DCS.dcsqry) == "undefined" || DCS.dcsqry == null) DCS.dcsqry = "?" + dcsEscape(arguments[I + 1]);
                else DCS.dcsqry += "%26" + dcsEscape(arguments[I + 1]);
                break;
            case "":
                break;
            case "profil":
                WT.sp = dcsEscape(arguments[I + 1]);
                break;
            case "dcs.dcsuri":
                DCS.dcsuri = dcsEscape(arguments[I + 1]);
                break;
        }
    }
    dcsFunc("dcsAdv");
    return dcsTag();
};
statsToProfils();
function statsToClics() {
    DCS.dcsqry = null;

    dcsVar();
    dcsMeta();

    DCS = new Object();
    WT = new Object();
    DCSext = new Object();

    DCS.dcsuri = dcsEscape("vide.html");

    //variables possibles  transmettre
    var variables = ['clic_action', 'clic_contenu', 'WT.ti', 'WT.clic', "WT.sp", "dcsqry"];

    for (var I = 0; I < arguments.length; I++) {
        for (var J = 0; J < variables.length; J++) {
            if (arguments[I] == variables[J]) {
                switch (arguments[I].toLowerCase()) {
                    case "wt.ti":
                        WT.ti = dcsEscape(arguments[I + 1]);
                        break;
                    case "wt.clic":
                        WT.clic = dcsEscape(arguments[I + 1]);
                        if (WT.clic == 'accueil') WT.clic = 'clic_pa_toutv';
                        break;
                    default:
                        DCSext[arguments[I]] = arguments[I + 1];
                        break;
                }
            }
        }
    }

    dcsFunc("dcsAdv");
    return dcsTag();
};
//var _sWtCall2 = statsToClics('clic_action', "ProdSourceScript", 'clic_contenu', ' F:\\tv\\tou\\static\\www\\wwwroot\\lib\\v1\\js\\base.js', 'WT.ti', "ProdSourceScript :: " + ' F:\\tv\\tou\\static\\www\\wwwroot\\lib\\v1\\js\\base.js', 'WT.clic', 'clics_statprod'); 

