﻿function $(pcn) {
    var pcx, pcd = document; if (!(pcx = pcd[pcn]) && pcd.all) { pcx = pcd.all[pcn]; }; if (!pcx && pcd.getElementById) { pcx = pcd.getElementById(pcn); }; return pcx;
}
function add_load(adsense_init) {
    if (typeof window.addEventListener != 'undefined') { window.addEventListener('load', adsense_init, false); }
    else if (typeof document.addEventListener != 'undefined') { document.addEventListener('load', adsense_init, false); }
    else if (typeof window.attachEvent != 'undefined') { window.attachEvent('onload', adsense_init); }
    else { if (typeof window.onload == 'function') { var existing = onload; window.onload = function () { existing(); adsense_init(); }; } else { window.onload = adsense_init; } }
}
function Center_Elem1(elem) {
    var sTop;
    var sLeft;
    if (document.documentElement && document.documentElement.scrollTop) {
        sTop = document.documentElement.scrollTop;
        sLeft = document.documentElement.scrollLeft;
    }
    else {
        sTop = document.body.scrollTop;
        sLeft = document.body.scrollLeft;
    }
    elem.style.Left = sLeft + parseInt("-" + parseInt(elem.offsetWidth / 2)) + "px";
    elem.style.Top = sTop + parseInt("-" + parseInt(elem.offsetHeight / 2)) + "px";
}
function Center_Elem(elem) {
    var sTop = document.documentElement.scrollTop || document.body.scrollTop;
    var sLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
    elem.style.marginLeft = sLeft + parseInt("-" + parseInt(elem.offsetWidth / 2)) + "px";
    elem.style.marginTop = sTop + parseInt("-" + parseInt(elem.offsetHeight / 2)) + "px";
}
function GCS(elem, t) {
    if (t == 'b' && elem.value == "") { 
    elem.style.background = 'url(/img/gcs_watermark.gif) no-repeat scroll left center rgb(255, 255, 255)'; }
    else {
        elem.style.background = 'rgb(255, 255, 255)';
    }
}
function Add_BLnk(t1,t2,t3) { document.write('<a href="/terms.aspx">' + t1 + '</a> | <a href="/privacy.aspx">' + t2 + '</a> | <a href="/contact_us.aspx">' + t3 + '</a>');}
function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}
function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}
function eraseCookie(name) {
    createCookie(name, "", -1);
}
function ExecVids() {
    var coll = document.getElementsByTagName("div");
    for (var i = 0; i < coll.length; i++) {
        if (coll[i].className == "ivid") {

            var Vid = coll[i];
            //eraseCookie(Vid.id);
            if (iOpenVid(Vid.id) == false) {
                Vid.innerHTML = '<div class="ivid0"><div class="pad10px">' + document.title + '</div><img src="/img/ividshare.gif" class="ividb1" onclick="iVidShare(\'' + Vid.id + '\');" /><br><img src="/img/ividplay.jpg" class="ividb2" onclick="iVidPlay(\'' + Vid.id + '\');" /></div>';
            }
            else {
                iVidPlay(Vid.id);
            }
        }
    }
}
function iOpenVid(Vidid) {
    if (msv == 0 || (readCookie(Vidid) == "1") || (readCookie("visfb") != "1")) { return true; }
    return false;
}
function iVidShare(Vidid) {
    ff = window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(location.href), 'sharer', 'toolbar=0,status=0,width=600,height=300');
    window.setTimeout(function () {createCookie(Vidid, "1", 2);},3000);
}
function iVidPlay(Vidid) {
    if (iOpenVid(Vidid)) {
        var itype = Vidid.substring(0, 1);
        var ivid = Vidid.substring(1);

        switch (itype) {
            case '1':
                $(Vidid).innerHTML = '<div align="center"><iframe width="620" height="380" frameborder="0" src="http://www.youtube.com/embed/' + ivid + '" allowfullscreen=""></iframe></div>';
                break;
            case '2':
                $(Vidid).innerHTML = '<div align="center"><object height="380" width="620"><param value="true" name="allowfullscreen" /><param value="http://www.facebook.com/v/' + ivid + '" name="movie" /><embed height="380" width="620" allowfullscreen="true" src="http://www.facebook.com/v/' + ivid + '" type="application/x-shockwave-flash"></embed></object></div>';
                break;
            case '3':
                $(Vidid).innerHTML = '<div align="center"><iframe frameborder="0" width="620" height="380" src="http://www.dailymotion.com/embed/video/' + ivid + '"></iframe></div>';
                break;
            case '4':
                $(Vidid).innerHTML = '<div align="center"><object width="620" height="380"><param name="movie" value="http://www.liveleak.com/e/' + ivid + '"></param><param name="wmode" value="transparent"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.liveleak.com/e/' + ivid + '" type="application/x-shockwave-flash" wmode="transparent" allowscriptaccess="always" width="620" height="380"></embed></object></div>';
                break;
            default:
                Alert("Video id Error");
        }
    }
    else {
        alert("Vous devez partager cette video pour activer la Lecture");
    }
}

var Mtime;
function sbo_pos() { var tt = ((document.documentElement.scrollTop + document.body.scrollTop == document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop); if (tt > 125) { tt = tt - 125 + 47; $('sbo').style.top = tt + "px"; } else { $('sbo').style.top = "47px"; } }
function sbo_move() {
    if ($('sbo')) {
        window.onscroll = function () { clearTimeout(Mtime); Mtime = setTimeout("sbo_pos()", 100); }
        window.onresize = function () { clearTimeout(Mtime); Mtime = setTimeout("sbo_pos()", 100); }
    }
}
add_load(sbo_move);
var ttty;
function ccc() {
    Center_Elem($(CnxDiv_Id));
    ttty = window.setTimeout(ccc, 50);
}
var CNX = function () {
    var opned = false;
    var tt;
    var cc;
    return {
        show: function () {
            if (typeof CnxDiv_Id != 'undefined') {
                tt = $(CnxDiv_Id);
                if (opned) {
                    Center_Elem(tt);
                } else {
                    tt.style.display = 'block';
                    Center_Elem(tt);
                    opned = true;
                }
                ccc();
            }
        },
        hide: function () {
            if (!tt) { tt = $(CnxDiv_Id); }
            tt.style.display = 'none';
            opned = false;
            ttty = null;
        }
    };
} ();
