// A class that ignores clicks after the first one.

var Chargement = Class.create();

Chargement.prototype = {

	initialize: function(elementId) {
		Event.observe($(elementId), 'click', this.doClickOnce.bindAsEventListener(this));
	},
        
    doClickOnce: function(e)
    {    	
    	this.popupChargement();
    },

    popupChargement: function()
	{
		if(initPopup())
		{
			var myAjax = new Ajax.Request(
				ctx+"action/DisplayPopupChargement",
				{	method: "get",
					asynchronous: false,
					timeout: 5000,
					onComplete: this.displayReponseChargement
				}
			)
			
			var myGlobalHandlers = {
				onLoading: function(){},
				onComplete: function(){},
				onTimeout: function (){ 
										
							}
			};
			Ajax.Responders.register(myGlobalHandlers);
		}
	},

	displayReponseChargement: function (request)
	{
		// display text
		if (request.responseText.indexOf("idpourrepererlapagebemaxindex")>0) {
		window.location.href=ctx;
		return;
		}
		var	resultat=request.responseText;//.substring(request.responseText.indexOf("</head>")+7,request.responseText.indexOf("</htm"));
		document.getElementById("identPopup").innerHTML=resultat;
//		jQuery(".Popup01").hide();
		renderPopup("#maChargement?clone=false,width=566px,height=auto,type=local");
	}
}
