if(!YAHOO.Mevia){ YAHOO.namespace("Mevia"); }

YAHOO.Mevia.InteractionLightBox = function(postlink_id, updateSendBoxSection, headerTitle, width, height)
{
    
    var handleYes = function()
	{
	     this.submit(); 
	}; 
	
	var handleNo = function()
	{
		 this.cancel(); 
	}; 
	
	var handleSuccess = function(o) { 
	    var response = o.responseText; 
	    response = response.split("<!")[0]; 
		var acknow = YAHOO.util.Dom.get('acknow')
	    acknow.innerHTML = response; 
	}; 
	 
	var handleFailure = function(o) { 
	   // document.getElementById("acknow").innerHTML="Submission failed: " + o.status; 
	}; 
	
	var end=function(){
		YAHOO.Mevia.informationsendbox2.destroy();
	};
	
	var postLinkOn=function(postlinkon_id){
		var plink=getCustomTag(postlinkon_id);
		plink.doPost();
	}
	
	var panelCfg = {
		visible:false,
		constraintoviewport:true,
		fixedcenter: true, 
		zindex:4, 
		modal:true,
		close:true
	}
	
	// if (width) {
	// 	var xpos = (YAHOO.util.Dom.getViewportWidth() / 2 - width / 2);
	// 	panelCfg['x'] = xpos;
	// };
	// if (height) {
	// 	var ypos = (YAHOO.util.Dom.getViewportHeight() / 2 - height / 2);
	// 	panelCfg['y'] = ypos;
	// };

	YAHOO.Mevia.informationsendbox2 = new YAHOO.widget.Panel("informationsendbox2", panelCfg);
	   
   YAHOO.Mevia.informationsendbox2.end=end;
   YAHOO.Mevia.informationsendbox2.postLinkOn=postLinkOn;
   YAHOO.Mevia.informationsendbox2.hideEvent.subscribe(function()
	{
		setTimeout(end, 100);
	});
	
	
 	YAHOO.Mevia.informationsendbox2.plink = getCustomTag(postlink_id);
	YAHOO.Mevia.informationsendbox2.plink.request.setOnSuccess(function(o){
		var json = eval("("+o.responseText+")");
		YAHOO.Mevia.informationsendbox2.setBody("chargement du contenu");
		// YAHOO.Mevia.informationsendbox2.setBody(json[updateSendBoxSection]);
		YAHOO.Mevia.informationsendbox2.setHeader(headerTitle);
		YAHOO.Mevia.informationsendbox2.render(document.body);	
		
		// removing the old listeners, running the destroyer rules, and setting the loading message
		YAHOO.plugin.Dispatcher.process ( YAHOO.Mevia.informationsendbox2.body, "chargement du contenu" );
		/* loading the content */
		YAHOO.plugin.Dispatcher.process( YAHOO.Mevia.informationsendbox2.body, json[updateSendBoxSection]);
		// displaying the panel
		YAHOO.Mevia.informationsendbox2.show();
		// YAHOO.Mevia.informationsendbox2.forceContainerRedraw();
	});
			  
	YAHOO.Mevia.informationsendbox2.plink.doPost();
};

YAHOO.Mevia.confirmLightBox = function(message)
{   
    var handleYes = function()
	{ 
	    this.hide(); 
	}; 
	
	var handleNo = function()
	{ 
	    this.hide(); 
	};
	
	YAHOO.Mevia.confirmLightBox =  new YAHOO.widget.SimpleDialog("confirmLightBox",  
	{
		width				:	"300px", 
		fixedcenter			: 	true, 
		zindex				: 	4, 
		modal				: 	true, 
		visible				: 	false, 
		draggable			: 	false, 
		close				: 	true, 
		text				: 	"Do you want to continue?", 
		icon				: 	YAHOO.widget.SimpleDialog.ICON_HELP, 
		constraintoviewport	: 	true, 
		buttons				: 	[ {
			text		: 	"Yes",
			handler		: 	handleYes,
			isDefault	: 	true
		}, 
		{
			text	: 	"No",
			handler	: 	handleNo
		}] 
	}); 
	YAHOO.Mevia.confirmLightBox.setHeader(message);
	YAHOO.Mevia.confirmLightBox.setBody(message);
	YAHOO.Mevia.confirmLightBox.render(document.body);	
	YAHOO.Mevia.confirmLightBox.show();
};

YAHOO.Mevia.ActionBox = function(postlink_id, updateSendBoxSection, eltId, container)
{
	var handleYes = function()
	{
	     this.submit(); 
	}; 

	var handleNo = function()
	{
		 this.cancel(); 
	}; 

	var handleFailure = function(o)
	{ 
	   // document.getElementById("acknow").innerHTML="Submission failed: " + o.status; 
	}; 

	var end = function()
	{
		YAHOO.Mevia.actionContextMenu.destroy();
	};

	var postLinkOn=function(postlinkon_id)
	{
		var plink=getCustomTag(postlinkon_id);
		plink.doPost();
	}

	YAHOO.Mevia.actionContextMenu = new YAHOO.widget.Panel("actionContextMenu", 	            	            	            
	{
		visible				:	false,
		zindex				:	4,
		close				:	true,
		draggable			: 	false,
		context				:	[eltId, 'tl', 'bl']
	});

   YAHOO.Mevia.actionContextMenu.end=end;
   YAHOO.Mevia.actionContextMenu.postLinkOn=postLinkOn;
   YAHOO.Mevia.actionContextMenu.hideEvent.subscribe(function()
	{
		// YAHOO.Mevia.actionContextMenu.destroy();
		// setTimeout(end, 100);
	});
	
	
 	YAHOO.Mevia.actionContextMenu.plink = getCustomTag(postlink_id);
	YAHOO.Mevia.actionContextMenu.plink.request.setOnSuccess(function(o){
		var json = eval("("+o.responseText+")");
		YAHOO.Mevia.actionContextMenu.setBody("chargement du menu");
		YAHOO.Mevia.actionContextMenu.setHeader("");
		YAHOO.Mevia.actionContextMenu.render(YAHOO.util.Dom.get(container));	
		
		// removing the old listeners, running the destroyer rules, and setting the loading message
		YAHOO.plugin.Dispatcher.process ( YAHOO.Mevia.actionContextMenu.body, "chargement du menu" );
		// displaying the panel
		YAHOO.Mevia.actionContextMenu.show();
		/* loading the content */
		YAHOO.plugin.Dispatcher.process( YAHOO.Mevia.actionContextMenu.body, json[updateSendBoxSection]);
	});

	YAHOO.Mevia.actionContextMenu.plink.doPost();
}
