// -----------------------------------------------------------------------------------
//
//	Anatips v0.1
//	by Christophe Gimenez - http://www.anaema.com
//	Last Modification: 10/2/2008
//
//	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
//      - Free for use in both personal and commercial projects
//      - Attribution requires leaving author name, author link, and the license info intact.
//	
// -----------------------------------------------------------------------------------



var Anawait = { 
	oldStyle: '',
	objContainer: undefined,
	
	waitBegin: function(element){
		wait_container = $('anawait_wait');
		if (!wait_container) {
			objBody = $$('body')[0];
			this.objContainer = objBody.appendChild(Builder.node('div', {
				id: 'anawait_wait'
			}));
			this.objContainer.innerHTML = '<img src="/images/ajax-loader.gif"/>';
		}
		
		height = element.getHeight();
		width = element.getWidth();
		
		this.objContainer.style.top = element.cumulativeOffset().top + 'px';
		this.objContainer.style.left = element.cumulativeOffset().left + 'px';
		this.objContainer.style.width = width + 'px';
		this.objContainer.style.height = height + 'px';
		
		animate = $$('#anawait_wait img').first();		
		animate.style.position = 'relative';
		animate.style.top = (height / 2 - animate.getHeight() / 2) + 'px';
		
		this.oldStyle = element.style;
		//element.hide();
		this.objContainer.style.visibility = "visible";
	},
	
	waitEnd: function(element){
		this.objContainer.style.visibility = "hidden";
		//element.show();		
	}
};

Element.addMethods(Anawait);