
/*
	ADAPTATION DU CODE
	
	http://www.pjhyett.com/posts/190-the-lightbox-effect-without-lightbox
*/

function showBox()
{
	if (window.addEventListener)
	{
		window.addEventListener("resize", resizeBox, false);
		window.addEventListener("scroll", resizeBox, false);
	}
	else if (window.attachEvent)
	{
		window.attachEvent("onresize", resizeBox);
		window.attachEvent("onscroll", resizeBox);
	}
	
	document.getElementById('overlayPopBox').style.visibility = "visible";
	document.getElementById('boxPopBox').style.visibility = "visible";
	
	resizeBox();
	
	setTimeout("showFrame()", 1200);
}

function hideBox()
{
	if (window.removeEventListener)
	{
		window.removeEventListener("resize", resizeBox, false);
		window.removeEventListener("scroll", resizeBox, false);
	}
	else if (window.detachEvent)
	{
		window.detachEvent("onresize", resizeBox);
		window.detachEvent("onscroll", resizeBox);
		window.detachEvent("onresize", resizeBox);
		window.detachEvent("onscroll", resizeBox);
	}
	
    document.getElementById('iframePopBox').style.visibility = "hidden";
    document.getElementById('overlayPopBox').style.visibility = "hidden";
    document.getElementById('boxPopBox').style.visibility = "hidden";
	
    return false;
}

function showFrame()
{
	document.getElementById('iframePopBox').style.visibility = "visible";
	document.getElementById('iframePopBox').style.display = "";
}

function resizeBox()
{
	center('overlayPopBox');
	center('boxPopBox');
	
	return false;
}

function center(element)
{
    try{
        elementById = document.getElementById(element);
    }catch(e){
        return;
    }

    var my_width  = 0;
    var my_height = 0;

    if ( typeof( window.innerWidth ) == 'number' ){
        my_width  = window.innerWidth;
        my_height = window.innerHeight;
    }else if ( document.documentElement && 
             ( document.documentElement.clientWidth ||
               document.documentElement.clientHeight ) ){
        my_width  = document.documentElement.clientWidth;
        my_height = document.documentElement.clientHeight;
    }
    else if ( document.body && 
            ( document.body.clientWidth || document.body.clientHeight ) ){
        my_width  = document.body.clientWidth;
        my_height = document.body.clientHeight;
    }

    elementById.style.position = 'absolute';
    elementById.style.zIndex = 99;

    var scrollY = 0;

    if ( document.documentElement && document.documentElement.scrollTop ){
        scrollY = document.documentElement.scrollTop;
    }else if ( document.body && document.body.scrollTop ){
        scrollY = document.body.scrollTop;
    }else if ( window.pageYOffset ){
        scrollY = window.pageYOffset;
    }else if ( window.scrollY ){
        scrollY = window.scrollY;
    }

    var widthDimension = elementById.offsetWidth;
    var heightDimension = elementById.offsetHeight;

    var setX = ( my_width  - widthDimension  ) / 2;
    var setY = ( my_height - heightDimension ) / 2 + scrollY;

    setX = ( setX < 0 ) ? 0 : setX;
    setY = ( setY < 0 ) ? 0 : setY;

	if (element != "overlayPopBox")
	{
		elementById.style.left = setX + "px";
		elementById.style.top  = setY + "px";
	}
	else
	{
		elementById.style.left = 0 + "px";
		elementById.style.top  = setY - 20 + "px";
	}

    elementById.style.display  = 'block';
}

