function showIoPopupCentree(url, ptitle, pwidth, pheight){
	showIoPopup(url, ptitle, pwidth, pheight);
	centrerModalBox();
}

function showIoPopupCentreeFormulaire(url, ptitle, pForm, pwidth){
	Modalbox.show(url,{overlayOpacity:0.50,transitions:false,title: ptitle, overlayClose: false, width: pwidth, method: 'post', params:Form.serialize(pForm)});
	centrerModalBox();
}

function showIoPopupCentreeFormulaireGet(url, ptitle, pForm, pwidth){
	Modalbox.show(url,{overlayOpacity:0.50,transitions:false,title: ptitle, overlayClose: false, width: pwidth, params:Form.serialize(pForm)});
	centrerModalBox();
}

function showIoPopupCentreePDF(url, ptitle, pwidth, pheight){
	url = '<object data="'+url+'#statusbar=0&toolbar=0&messages=0&navpanes=0" height="99%" width="100%" type="application/pdf" ></object>';
	showIoPopupCentree(url, ptitle, pwidth, pheight);
}

function showIoPopup(url, ptitle, pwidth, pheight){
	Modalbox.show(url,{overlayOpacity:0.50,transitions:false,title: ptitle, overlayClose: false, width: pwidth, height:pheight});
}

function showIoPopupCentreePanier(url, ptitle, pwidth,pheight) {
	Modalbox.show(url,{overlayOpacity:0.50,transitions:false,title: ptitle, overlayClose: false, width: pwidth, height:pheight,afterLoad: function() { majTitrePanier();ajusterLargeurPopup(); }, afterHide: function() { majInfoBtnPanier();}});
	centrerModalBox();
}

function centrerModalBox(){
	var tailleFenetre = getWindowHeight();
	var taillePopup = document.getElementById('MB_window').offsetHeight;
	var margeHaute = Math.max(20,(tailleFenetre - taillePopup)/2);
	document.getElementById('MB_window').style.marginTop=margeHaute+'px';
}

function ajusterLargeurPopup(){
	// Si la fen�tre est petite , fixer la marge � gauche � 10px
	var widthFenetre = getWindowWidth();
	var widthPopup =  document.getElementById('MB_window').offsetWidth;
	if ((widthFenetre - widthPopup) < 60 ){
		 document.getElementById('MB_window').setStyle({left : '10px'});
	}
}

function getWindowHeight(){
	var theHeight;
	// Window dimensions:

	if (window.innerHeight) {
	theHeight=window.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight) {
	theHeight=document.documentElement.clientHeight;
	}
	else if (document.body) {
	theHeight=document.body.clientHeight;
	}

	return theHeight
}

function getWindowWidth(){
	var theWidth;
	// Window dimensions:

	if (window.innerWidth) {
		theWidth=window.innerWidth;
		}
		else if (document.documentElement && document.documentElement.clientWidth) {
		theWidth=document.documentElement.clientWidth;
		}
		else if (document.body) {
		theWidth=document.body.clientWidth;
		}

	return theWidth;
}

function showMessageInformation(message,temp){
	Modalbox.show('<div>'+message+'</div>',{width:message.length*8, height: 50, verticalOffset:10, slideDownDuration:0,slideUpDuration:0,overlayClose:false,transitions:false,overlayOpacity:.0,title:' '});
	centrerModalBox();
	setTimeout("Modalbox.hide()",temp);
	document.getElementById('MB_window').className='messageInformation';
}

function showOKMessageInformation(message){

	var msg = '<div>'+message+'</div><div class="button"><a href="#" onclick="javascript:Modalbox.hide();return false;"><span><span>OK</span></span></a></div>';

	Modalbox.show(msg,{width:message.length*4, height: 90, slideDownDuration:0,slideUpDuration:0,overlayClose:false,transitions:false,overlayOpacity:.0,title:' '});
	centrerModalBox();
	document.getElementById('MB_window').className='messageInformation';
}

function showValidationMessageInformation(message, action) {

	var msg = '<div>'+message+'</div><div class="buttons"><div class="button buttonLeft"><a href="#" onclick="javascript:'+ action +'return false;"><span><span>Oui</span></span></a></div>';
	msg += '<div class="button buttonRight"><a href="#" onclick="javascript:Modalbox.hide();return false;"><span><span>Non</span></span></a></div></div>'

	Modalbox.show(msg,{width:message.length*4, height: 90, slideDownDuration:0,slideUpDuration:0,overlayClose:false,transitions:false,overlayOpacity:.0,title:' '});
	centrerModalBox();
	document.getElementById('MB_window').className='messageInformation';
}

