function getWindowHeight() {
    var windowHeight=0;
    if (typeof(window.innerHeight)=='number') {
        windowHeight=window.innerHeight;
    }
    else {
     if (document.documentElement&&
       document.documentElement.clientHeight) {
         windowHeight = document.documentElement.clientHeight;
    }
    else {
     if (document.body&&document.body.clientHeight) {
         windowHeight=document.body.clientHeight;
      }
     }
    }
    return windowHeight;
}

function getWindowWidth() {
    var WindowWidth=0;
    if (typeof(window.innerWidth)=='number') {
        WindowWidth=window.innerWidth;
    }
    else {
     if (document.documentElement&&
       document.documentElement.clientWidth) {
         windowWidth = document.documentElement.clientWidth;
    }
    else {
     if (document.body&&document.body.clientWidth) {
         windowWidth=document.body.clientWidth;
      }
     }
    }
    return windowWidth;
}
 
function cc_ActiveBackground()
{   
    window.onresize = '';
    window.onscroll = '';
    $('inactive-bg').style.display = 'none';
}

function cc_InactiveBackground()
{   
    window.onresize = cc_InactiveBackground_Disp;
    window.onscroll = cc_InactiveBackground_Disp;
    cc_InactiveBackground_Disp();
}

function cc_InactiveBackground_Disp()
{
    var windowHeight    = getWindowHeight();
    var windowWidth     = getWindowWidth();

    var x = document.documentElement.scrollLeft;
    var y = document.documentElement.scrollTop;

    $('inactive-bg').style.top      = y+'px';
    $('inactive-bg').style.left     = x+'px';
    $('inactive-bg').style.height   = windowHeight+'px';
    $('inactive-bg').style.width    = windowWidth+'px';
    $('inactive-bg').style.display  = 'block';
    
    $('popupDiv').style.top = (y+(windowHeight/2)-150)+'px';
}
 
function modalPopUp()
{   
    var windowHeight = getWindowHeight();

    var y = document.documentElement.scrollTop;

    var titre    = modalPopUp.arguments[0];
    var contenu  = modalPopUp.arguments[1];
    
    if( contenu.substring(0,8) == 'DIVLOAD-' )
        contenu = $( contenu.substring(8,contenu.length) ).innerHTML;

    var script   = modalPopUp.arguments[2];
    var dwidth   = modalPopUp.arguments[3];
    
    cc_InactiveBackground();
    
    var popupDiv        = $('popupDiv');
    var popupDivContent = $('popupDivContent');
    var popupDivTitle   = $('popupDivTitle');

    popupDiv.style.top = (y+(windowHeight/2)-150)+'px';
    popupDiv.style.display = 'block';
    if( !dwidth ) dwidth = 300;
    popupDiv.style.width = dwidth + 'px';

    popupDivTitle.innerHTML = titre;
    popupDivContent.innerHTML = contenu;

    if( script )
        eval(script);
}

function modalPopUpClose()
{
    cc_ActiveBackground();
    $('popupDiv').style.display = 'none';
}