/***********************************************************************/

function AjouteMsg(msg,ajout) {
	if (msg!='') msg=msg+'<br>'+ajout; else msg=msg+ajout;
	return msg;
}

/***********************************************************************/

function Centre(Obj) {
	x=($(window).width()-Obj.width())/2;
	y=$(window).scrollTop()+($(window).height()-Obj.height())/2;	
	Obj.css({'left':x+'px','top':y+'px'});
}

/***********************************************************************/

function GoPopup(width,height,html) {		
	var Obj=$('#popup');
	Obj.width(width);
	Obj.height(height);
	Obj.html(html);
	
	Centre(Obj);

	Obj.css({'opacity':'0','left':x+'px','top':y+'px','visibility':'visible'});			
	Obj.show();	
	Obj.animate({opacity:1},{duration:300});	
}

function ClosePopup() {
	var Obj=$('#popup');
	Obj.animate({opacity:0},{duration:300,complete:function(){Obj.hide(); Obj.html('');}});		
}

function LienClosePopup(mode) {
	if (mode==1) result="<a onClick='ClosePopup()'>annuler</a>";	
	if (mode==2) result="<div id='fermer' onClick='ClosePopup()'></div><div style='clear:both; line-height:1px;' onClick='ClosePopup()'><br></div>";
	return result;
}

/***********************************************************************/

var PopupMsgTimer1;
var PopupMsgTimer2;

function GoPopupMsg(msg) {
	var Obj=$('#popup_msg');
	
	var html='';
	var img='';
	
	if (msg=='') msg=Obj.html();
	if (msg!='') {		
		if (msg.toLowerCase().indexOf("erreur")!=-1) {
			Obj.css({'border-color':'red'});
			img="info_e.gif";
		} else {
			Obj.css({'border-color':'green'});
			img="info.gif";
		}
		html="<table><tr><td><img src='/images2/"+img+"'></td><td>"+msg+"</td></tr></table>";		
		Obj.html(html);

		x=$(window).width()-Obj.width()-30;
		y=GetScrollY(Obj);	
		
		Obj.stop(true,false);	
		Obj.css({'opacity':'0','left':x+'px','top':y+'px','visibility':'visible'});				
		Obj.show();
		Obj.animate({opacity:1},{duration:1000});	
		PopupMsgTimer2=setTimeout("ClosePopupMsg()",5000);
		PopupMsgTimer1=setInterval("SetScrollY($('#popup_msg'))",150);
	}
}

function ClosePopupMsg() {	
	var Obj=$('#popup_msg');
	clearInterval(PopupMsgTimer1);
	clearTimeout(PopupMsgTimer2);
	Obj.stop(true,false);	
	Obj.animate({opacity:0},{duration:800,complete:function(){Obj.hide(); Obj.html('');}});		
}

function GetScrollY(Obj) {
	return $(window).height()+$(window).scrollTop()-Obj.height()-30;
}

function SetScrollY(Obj) {
	$(Obj).animate({top:GetScrollY(Obj)+'px'},{duration:100});
}

/***********************************************************************/

function GoPopup_progress() {	
	var Obj=$('#popup_progress');
	Centre(Obj);
	Obj.css({'visibility':'visible'});				
}

function ClosePopup_progress() {	
	$('#popup_progress').css({'visibility':'hidden'});		
}

/***********************************************************************/
