//fichier contenant les fonctions permettant l'affichage d'un bloc façon popup, sur fond gris opaque

//fonction créant le div d'écran gris
window.onload=function()
{
    // Pass true to gray out screen, false to ungray
    // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
    // in any order.  Pass only the properties you need to set.
    var zindex = 2;
    var opacity = 50;
    var opaque = 0.5;
    var bgcolor = '#000000';
    var dark=document.getElementById('darkenScreenObject');
    var tbody = document.getElementsByTagName("body")[0];
    if (!dark) 
        {
        // The dark layer doesn't exist, it's never been created.  So we'll
        // create it here and apply some basic styles.
        // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
        
        var tnode = document.createElement('div');           // Create the layer.
                    // Left corner of the page
        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
        tnode.style.display='none';                      // Start out Hidden
        tnode.id='darkenScreenObject';                   // Name it so we can find it later
        window.document.body.appendChild(tnode);                            // Add it to the web page
        dark=document.getElementById('darkenScreenObject');  // Get the object.
        }
        tbody.style.height = '100%';
        dark.style.height= '100%';

    dark.innerText = ' ';
    dark.style.opacity=opaque;                      
    dark.style.MozOpacity=opaque;                   
    dark.style.filter='alpha(opacity='+opacity+')'; 
    dark.style.zIndex=zindex;        
    dark.style.backgroundColor=bgcolor;  
	
    dark.style.display= 'none';
    
    //on place les blocs d'infos de chaque story streaming, dans le div d'écran gris
    if (tbody != null)
        {
        //on place chaque box d'infos de story dans le div d'écran gris'
        for (var i =1; i<= 4 ; i++)
            {
                var tdiv = document.getElementById('popupstory' + i);
                if (tdiv != null)
                {
                //on ajoute le div au div de l'écran gris
                window.document.body.appendChild(tdiv);
                }
            }

        //on masque l'écran gris
        
        if (document.getElementById('darkenScreenObject') != null)
            {
            document.getElementById('darkenScreenObject').style.display = 'none';
            document.getElementById('darkenScreenObject').style.visibility = 'hidden';
            }
        }
}


function SetPopUpCenter(position)
    {
    var idDiv = "popupstory" + position;
    if (document.getElementById(idDiv)!=null)
        {

        document.getElementById(idDiv).style.display = 'block';
        document.getElementById(idDiv).style.visibility = 'visible';

        if (document.getElementById('darkenScreenObject')!=null)
            {
            document.getElementById('darkenScreenObject').style.display = 'block';
            document.getElementById('darkenScreenObject').style.visibility = 'visible';
            } 
        }
    }

function closePopUp(position)
    {
    var idDiv = "popupstory" + position;

    if (document.getElementById(idDiv)!=null)
        {
        document.getElementById(idDiv).style.display = "none";
        document.getElementById(idDiv).style.visibility = "hidden";
        
        if (document.getElementById('darkenScreenObject')!=null)
            {
            document.getElementById('darkenScreenObject').display = 'none';
            document.getElementById('darkenScreenObject').style.visibility = "hidden";
            } 
        }
    }