
$(document).ready(function() {
		
	jQuery.fn.extend({
      deconnectionanimate: function(speed){
           var t = $(this);
            if(t.css("display") == "none") 
                  t.show(speed);
            else 
                  t.animate({ 
				        height:'toggle',
				        opacity:'toggle'
				      }, speed);
      }
	});
});


function logoffFromEvent(contextPath)
{
	
	var txtToSend = '<table border="0" cellspacing="0" cellpadding="5"><tr><td><img src="'+contextPath+'/custom/img/kernel/_imgWarning.gif" border="0" /></td><td style="font-weight: bold; color: #FFFFFF;">	Souhaitez-vous vous déconnecter ? 	</td></tr></table>' ;
	
	$.prompt(txtToSend,{
		prefix: 'jqiGrey',
		show:'deconnectionanimate',
		promptspeed:'slow',
		zIndex :1500, 
		buttons:{Confirmer:true, Annuler:false}, 
		submit: function(v,m){
			if(v)
			{
				$.ajax({  url: contextPath + '/security_logout_action',  async: true, cache:false}) ;

				$.prompt('<table border="0" cellspacing="0" cellpadding="5"><tr><td><img src="'+contextPath+'/custom/img/kernel/_imgConfirm.gif" border="0" /></td><td style="font-weight: bold; color: #A12020;">	Vos données sont sécurisées et sauvegardées !</span>	</td></tr></table>',{
						prefix: 'brownJqi',
						show:'deconnectionanimate',
						buttons:{Fermer:false},
						submit: function(v,m){
							val = window.close() ;
							if(!val) window.location = contextPath ;
							return true;
						},
						callback:function (v,m) {
							return true;
						}}) ;
			}	
			
			return true ;
		},
		callback:function (v,m) {
			return true;
		}
		
	}); 
	
	return false ;
}
