// JavaScript Document
function show_ajpopup (content) {
	thePopup = document.getElementById('ajpopup');
	thePopupClose = document.getElementById('ajpopupclose');
	
	thePopup.style.display = 'none';

	thePopup.innerHTML = content;
	
	thePopup.style.visibility = 'hidden';
	thePopup.style.display = 'block';
	//  thePopup.style.top = get_scroll_top()-2 + 'px'; // Haut de fenêtre bordure autour sauf haut
	//	thePopup.style.top = get_scroll_top()-2 + 'px'; // Haut de fenêtre bordure autour sauf haut
	thePopup.style.top = get_scroll_top() + (get_window_height() - thePopup.offsetHeight) /2 + 'px'; // Centré dans la fenêtre
	thePopup.style.left = (get_window_width() - thePopup.offsetWidth) /2 + 'px';

     if (thePopup.offsetHeight > 0.8*get_window_height()) {
         thePopup.style.height = 0.8*get_window_height()+'px';
     	thePopup.style.top = get_scroll_top() + (get_window_height() - thePopup.offsetHeight) /2 + 'px'; // Centré dans la fenêtre
     }
 	
	thePopup.style.visibility = 'visible';

	thePopupClose.style.visibility = 'hidden';
	thePopupClose.style.display = 'block';
	thePopupClose.style.width = thePopup.style.width;
	thePopupClose.style.top = (thePopup.offsetTop - thePopupClose.offsetHeight) + 'px';
	thePopupClose.style.left = thePopup.style.left;
	thePopupClose.style.visibility = 'visible';
}

function center_ajpopup() {
	thePopup = document.getElementById('ajpopup');
	thePopup.style.left = (get_window_width() - thePopup.offsetWidth) /2 + 'px';
}

function hide_ajpopup () {
	document.getElementById('ajpopup').style.display = 'none';
	document.getElementById('ajpopupclose').style.display = 'none';
}

function get_window_width() {
	var window_width;
	if (self.innerWidth) {
		window_width = self.innerWidth;
	} else if (document.documentElement && document.documentElement.clientWidth) {
		window_width = document.documentElement.clientWidth;
	} else if (document.body) {
		window_width = document.body.clientWidth;
	}	
	return window_width;
}

function get_window_height() {
	var window_height;
	if (self.innerHeight) {
		window_height = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		window_height = document.documentElement.clientHeight;
	} else if (document.body) {
		window_height = document.body.clientHeight;
	}	
	return window_height;
}

function get_scroll_top() {
	var theTop;
	if (document.documentElement && document.documentElement.scrollTop) {
		theTop = document.documentElement.scrollTop;
	} else if (document.body) {
		theTop = document.body.scrollTop;
	}
	return theTop;
}
