var popUpUri = null;
var popUpPage = null;
var popUpWidth = null;
var popUpHeight = null;

function popUpWindow(uri) 
{
	popUpUri = uri;
	
	document.getElementById("popUpOverlay").style.height=document.body.clientHeight;
	
	if (document.getElementById('accueilAlert') == null){
		location.href=popUpUri;
	}else {
		if (document.getElementById('accueilAlert').value=="tarification"){
            location.href='#';
            popUpWindowURL("messageTarification", 600, 150);
			openPopUp();				
		}else {
			if (document.getElementById('accueilAlert').value=="souscription"){
                location.href='#';
                popUpWindowURL("messageSouscription", 600, 150);
				openPopUp();
			} else {				
				location.href=popUpUri;
			}
		}						
	}
}

function popUpWindow_(uri) 
{
	popUpUri = uri;
	
	if (document.getElementById('accueilAlert') == null){
		location.href=popUpUri;
	}else {
		if (document.getElementById('accueilAlert').value=="tarification"){
            location.href='#';
            popUpWindowURL("messageTarification", 600, 150);
			_openPopUp();

		}else {
			if (document.getElementById('accueilAlert').value=="souscription"){
                location.href='#';
                popUpWindowURL("messageSouscription", 600, 150);
				_openPopUp();
			} else {				
				location.href=popUpUri;
			}
		}						
	}
}


function popUpWindowURL(page, width, height){		
	
	popUpPage = page;
	popUpWidth = width;
	popUpHeight = height;
	
	document.getElementById(page).style.display="";	
	
	document.getElementById("popUpContent").style.width=width;
	document.getElementById("popUpContent").style.height=height;			
	
	_setContentLocation2();

	_openPopUp2();				
}

function _openPopUp2()
{	
	document.getElementById("popUpOverlay").style.display="block";
	document.getElementById("popUpContent").style.display="block";
	document.getElementById("popUpOverlay").style.visibility="visible";
	document.getElementById("popUpContent").style.visibility="visible";
}

function closePopUpWindow2(relocating)
{    
	
  document.getElementById("popUpContent").style.display="none";
  document.getElementById("popUpOverlay").style.display="none";
  
  document.getElementById("popUpOverlay").style.visibility="hidden";
  document.getElementById("popUpContent").style.visibility="hidden";
  
  document.getElementById(popUpPage).style.display="none";
  
  if (relocating==true) location.href=popUpUri;
  
}	

function _setContentLocation2()
{
	
	var brwWindowWidth = window.innerWidth;				
	
	if (brwWindowWidth==null) brwWindowWidth = document.body.clientWidth;				
	
	var contentWidth = document.getElementById("popUpContent").style.width.replace(/px/, "");			
			
}

window.onresize = resize2;

function resize2()
{		
	if (document.getElementById("popUpOverlay").style.display=="block")
	{
		closePopUpWindow2(false);						
		popUpWindowURL(popUpPage, popUpWidth, popUpHeight);
			
	}
}

function appendToPopUpWindow2(page)
{	
	var pageContent = document.getElementById(page);
	document.getElementById("popUpTdContainer").appendChild(pageContent);	
}