﻿//----------------------
function GetScrollPage(){
    var Left;
    var Top;
    var DocRef;

    if( window.innerWidth){
        with( window){
        Left = pageXOffset;
        Top = pageYOffset;
        }
    }
    else{ // Cas Explorer a part
        if( document.documentElement && document.documentElement.clientWidth)
        DocRef = document.documentElement;
        else
        DocRef = document.body;

        with( DocRef){
        Left = scrollLeft;
        Top = scrollTop;
        }
    }
    return({top:Top, left:Left});
} 

function getSizeWindows()
{
    var h = 0;
    var W = 0;

    if (document.body)
    {
        l = (document.body.clientWidth);
        h = (document.body.clientHeight);
    }
    else
    {
        l = (window.innerWidth);
        h = (window.innerHeight);
    }
    return({height:h, width:l});
}

var imgAffiche ="";
var DoitActualise = false;
function affImg(imgPathAaff)
{
    DoitActualise = true;
    var divImg = document.getElementById("AppImg");
    var masqueEcran = document.getElementById("masqueEcran");
    var divVideo = document.getElementById("videoIn");
    imgAffiche =  new Image();
    imgAffiche.src = imgPathAaff;

    divVideo.style.display = "none";
    divImg.style.display = "block";
    masqueEcran.style.display = "block";

    divImg.innerHTML = "<img src='"+imgPathAaff+"' onclick='MasqueImg()'/>" ;

    actualise()

    //alert(divImg.innerHTML);
}

function actualise()
{

    var divImg = document.getElementById("AppImg");
    var pos = GetScrollPage(); 
    var win = getSizeWindows();
    divImg.style.top = pos.top + (win.height / 2 - imgAffiche.height / 2);
    divImg.style.left = pos.left + (win.width / 2 - imgAffiche.width / 2);
    if (DoitActualise==true)
    {
        setTimeout("actualise()",1);
    }
}

function MasqueImg()
{
DoitActualise = false;
var divImg = document.getElementById("AppImg");
var divVideo = document.getElementById("videoIn");

divVideo.style.display = "block";
divImg.style.display = "none";
masqueEcran.style.display = "none";
}