var cache;var msgbox;var enCours=false;var MessageBox={Version:'1.11 for jQuery',Date:'06/04/2011',load:function(){if(typeof jQuery=='undefined'){alert("MessageBox ''Version "+MessageBox.Version+"'' requi\350re JQuery !!");return false;}}}
MessageBox.load();messagebox=function(type,params,callback){if(type.toLowerCase()!='ouinon'&&type.toLowerCase()!='alert'&&type.toLowerCase()!='info'&&type.toLowerCase()!='saisie'){params=new Array;params['message']=type;type='info';}else{type=type.toLowerCase();}
if(!params){params=new Array;}else{if(typeof(params)=='string'){var message=params;params=new Array;params['titre']='Message';params['message']=message;params['icone']='attention';params['titre_color']='rouge';}}
params['message']&&params['message'].length<70&&type!='info'?params['message']='<br />'+params['message']:false;$(document).keydown(function(evt){var charCode=(evt.which)?evt.which:event.keyCode;if($('#MESSAGEBOX')&&charCode==9)evt.preventDefault();});switch(type){case'alert':if(enCours==false){enCours=true;!params['titre']?params['titre']='Message':false;!params['titre_color']?params['titre_color']='rouge':false;!params['message_color']?params['message_color']='noir':false;!params['icone']?params['icone']='attention':false;$('body').append('<div id="MESSAGEBOX_CACHE" style="display:none; width:100%; height:100%;"></div>');$('body').append('<div id="MESSAGEBOX" style="display:none"></div>');$('#MESSAGEBOX').append('<div id="MESSAGEBOX_TITRE" class="'+params['titre_color']+'">'+params['titre']+'</div>');$('#MESSAGEBOX').append('<div id="'+params['icone']+'"></div>');$('#MESSAGEBOX').append('<div id="MESSAGEBOX_MESSAGE" class="'+params['message_color']+'"></div>');$('#MESSAGEBOX').append('<div id="MESSAGEBOX_BOUTONS"></div>');$('#MESSAGEBOX_BOUTONS').append('<input type="button" id="MESSAGEBOX_OUI" class="button" value="OK" />');window.setTimeout(function(){$('#MESSAGEBOX_OUI').bind('click',function(){if(callback)callback(false);DestroyElements();});$('#MESSAGEBOX_OUI').focus();},500);$('#MESSAGEBOX_MESSAGE').html(params['message']);$('#MESSAGEBOX_CACHE').show();$('#MESSAGEBOX').show();}
break;case'saisie':if(enCours==false){enCours=true;!params['titre']?params['titre']='Saisie':false;!params['titre_color']?params['titre_color']='bleu':false;!params['message']?params['message']='':false;!params['message_color']?params['message_color']='noir':false;!params['icone']?params['icone']='question':false;$('body').append('<div id="MESSAGEBOX_CACHE" style="display:none; width:100%; height:100%;"></div>');$('body').append('<div id="MESSAGEBOX" style="display:none"></div>');$('#MESSAGEBOX').append('<div id="MESSAGEBOX_TITRE" class="'+params['titre_color']+'">'+params['titre']+'</div>');$('#MESSAGEBOX').append('<div id="'+params['icone']+'"></div>');$('#MESSAGEBOX').append('<div id="MESSAGEBOX_MESSAGE" class="'+params['message_color']+'" style="height:30px; overflow: hidden"></div>');$('#MESSAGEBOX').append('<input id="MESSAGEBOX_SAISIE" type="text" />');$('#MESSAGEBOX').append('<div id="MESSAGEBOX_BOUTONS"  style="margin-top:15px"></div>');$('#MESSAGEBOX_BOUTONS').append('<input type="button" id="MESSAGEBOX_OUI" class="button" value="Valider" />');$('#MESSAGEBOX_BOUTONS').append('<input type="button" id="MESSAGEBOX_NON" class="button" value="Annuler" />');window.setTimeout(function(){$('#MESSAGEBOX_OUI').bind('click',function(){if(callback)callback($('#MESSAGEBOX_SAISIE').val());DestroyElements();});$('#MESSAGEBOX_NON').bind('click',function(){if(callback)callback(false);DestroyElements();});$('#MESSAGEBOX_OUI').focus();},500);window.setTimeout(function(){$('#MESSAGEBOX_SAISIE').focus()},500);$('#MESSAGEBOX_MESSAGE').html(params['message']);$('#MESSAGEBOX_CACHE').show();$('#MESSAGEBOX').show();}
break;case'info':if(enCours==false){enCours=true;!params['message_color']?params['message_color']='blanc':false;!params['duration']?params['duration']=2.5:false;var L=$(document).width()-255;$('body').append('<div id="MESSAGEBOX_INFO" style="top:-70px; left:'+L+'px;"></div>');$('#MESSAGEBOX_INFO').append('<table style="width:100%; height:100%;"><tr><td id="msgbox_td" class="'+params['message_color']+'" align="center" valign="middle"></td></tr></table>');$('#msgbox_td').html(params['message']);$('#MESSAGEBOX_INFO').show();$('#MESSAGEBOX_INFO').animate({'top':'5px'},'slow').delay((params['duration']+1)*1000).animate({'opacity':0,'top':'-70px'},'slow');window.setTimeout(function(){$('#MESSAGEBOX_INFO').remove();enCours=false;},(params['duration']+2.5)*1000)}
break;case'ouinon':if(enCours==false){enCours=true;!params['titre']?params['titre']='Question':false;!params['titre_color']?params['titre_color']='bleu':false;!params['message_color']?params['message_color']='noir':false;!params['icone']?params['icone']='question':false;$('body').append('<div id="MESSAGEBOX_CACHE" style="display:none; width:100%; height:100%;"></div>');$('body').append('<div id="MESSAGEBOX" style="display:none"></div>');$('#MESSAGEBOX').append('<div id="MESSAGEBOX_TITRE" class="'+params['titre_color']+'">'+params['titre']+'</div>');$('#MESSAGEBOX').append('<div id="'+params['icone']+'"></div>');$('#MESSAGEBOX').append('<div id="MESSAGEBOX_MESSAGE" class="'+params['message_color']+'"></div>');$('#MESSAGEBOX').append('<div id="MESSAGEBOX_BOUTONS"></div>');$('#MESSAGEBOX_BOUTONS').append('<input type="button" id="MESSAGEBOX_OUI" class="button" value="Valider" />');$('#MESSAGEBOX_BOUTONS').append('<input type="button" id="MESSAGEBOX_NON" class="button" value="Annuler" />');window.setTimeout(function(){$('#MESSAGEBOX_OUI').bind('click',function(){if(callback)callback(true);DestroyElements();});$('#MESSAGEBOX_NON').bind('click',function(){if(callback)callback(false);DestroyElements();});$('#MESSAGEBOX_OUI').focus();},500);$('#MESSAGEBOX_MESSAGE').html(params['message']);$('#MESSAGEBOX_CACHE').show();$('#MESSAGEBOX').show();}
break;}}
DestroyElements=function(){enCours=false;if($('#MESSAGEBOX_CACHE'))$('#MESSAGEBOX_CACHE').fadeOut('fast').remove();if($('#MESSAGEBOX'))$('#MESSAGEBOX').fadeOut('fast').remove();}
var i=0;imageObj=new Image();images=new Array();images[0]="js/messagebox/gris/alert.png";images[1]="js/messagebox/gris/attention.png";images[2]="js/messagebox/gris/fd_messagebox.png";images[3]="js/messagebox/gris/question.png";images[4]="js/messagebox/gris/button_100x19.png";for(i=0;i<=4;i++){imageObj.src=images[i];}
