// LOAD SCREEN ATTRIBUTES

var myWidth = 0, myHeight = 0, myScroll = 0; myScrollWidth = 0; myScrollHeight = 0;

//SETTING UP OUR POPUP   
//0 means disabled; 1 means enabled;   
var popupVideoStatus = 0;  
var popupPubStatus = 0;  
var popupJeuStatus = 0;  
var popupDocStatus = 0;  

function loadScreen() {

    if (document.all) {

        // IE

        myWidth  = (document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.clientWidth;

        myHeight = (document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight;

        myScroll = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;

    } else {

        // NON-IE

        myWidth = window.innerWidth;

        myHeight = window.innerHeight;

        myScroll = window.pageYOffset;

    }

    if (window.innerHeight && window.scrollMaxY) { 

        // NON-IE

        myScrollWidth = document.body.scrollWidth;

        myScrollHeight = window.innerHeight + window.scrollMaxY;

    } else if (document.body.scrollHeight > document.body.offsetHeight) { 

        // IE

        myScrollWidth = document.body.scrollWidth;

        myScrollHeight = document.body.scrollHeight;

    } else { 

        // IE MAC

        myScrollWidth = document.body.offsetWidth;

        myScrollHeight = document.body.offsetHeight;

    }

}






//loading popup with jQuery magic!
function loadPopup(strPopupId)
{
	loadScreen();
	
	centerPopup(strPopupId);
	
	jQuery("#backgroundPopup").css({
	"opacity": "0.7",
	"width": myScrollWidth+"px",
	"height": myScrollHeight+"px"	
	});
	jQuery("#backgroundPopup").fadeIn("slow");
			
	
	if (strPopupId == "Video")
		//loads popup only if it is disabled
		if(popupVideoStatus==0)
		{
			jQuery("#popup"+strPopupId).fadeIn("slow");
			popupVideoStatus = 1;
		}
	if (strPopupId == "Pub")
		//loads popup only if it is disabled
		if(popupPubStatus==0)
		{
			jQuery("#popup"+strPopupId).fadeIn("slow");
			popupPubStatus = 1;
		}	
	if (strPopupId == "Jeu")
		//loads popup only if it is disabled
		if(popupJeuStatus==0)
		{
			jQuery("#popup"+strPopupId).fadeIn("slow");
			popupJeuStatus = 1;
		}
	if (strPopupId == "Doc")
		//loads popup only if it is disabled
		if(popupDocStatus==0)
		{
			jQuery("#popup"+strPopupId).fadeIn("slow");
			popupDocStatus = 1;
		}		
		

			
}


//disabling popup with jQuery magic!
function disablePopup(strPopupId)
{
	if (strPopupId == "Video")
		//disables popup only if it is enabled
		if(popupVideoStatus==1)
		{
			jQuery("#backgroundPopup").fadeOut("slow");
			jQuery("#popup"+strPopupId).fadeOut("slow");
			popupVideoStatus = 0;
		}
	if (strPopupId == "Pub")
		//disables popup only if it is enabled
		if(popupPubStatus==1)
		{
			jQuery("#backgroundPopup").fadeOut("slow");
			jQuery("#popup"+strPopupId).fadeOut("slow");
			popupPubStatus = 0;
		}	
	if (strPopupId == "Jeu")
		//disables popup only if it is enabled
		if(popupJeuStatus==1)
		{
			jQuery("#backgroundPopup").fadeOut("slow");
			jQuery("#popup"+strPopupId).fadeOut("slow");
			popupJeuStatus = 0;
		}		
}


//centering popup
function centerPopup(strPopupId)
{


	
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	
	var popupHeight = jQuery("#popup"+strPopupId).height();
	var popupWidth = jQuery("#popup"+strPopupId).width();
	//centering
	/*jQuery("#popup"+strPopupId).css({
	"position": "absolute",
	"top": windowHeight/2-popupHeight/2,
	"left": windowWidth/2-popupWidth/2
	});*/
	
	jQuery("#popup"+strPopupId).css({
	"position": "absolute",
	"top": ((myHeight / 2)-(popupHeight / 2)+myScroll)+"px",
	"left": ((myWidth / 2)-(popupWidth / 2))+"px"
	});
	
	//only need force for IE6

	jQuery("#backgroundPopup").css({
	"height": windowHeight, "width": windowWidth
	}
	);
	


}

