/* -------------------------------------------------------------------------- */
/** 
 *    @fileoverview
 *       Processing infomational balloon.
 *
 *    @version rev012.2008-06-05
 *    @requires common.js
 *    @requires balloon.js
 *    @requires effect.js
 *    @requires processingInfo.css
 */
/* -------------------------------------------------------------------------- */


var BA_PROCESSING_INFO;



/* -------------------- Setting for BAProcessingInfo -------------------- */

var BA_PROCESSING_INFO_THROBBER_IMG = {
	src    :'/common/img/pic_throbber.gif',
	width  : 18,
	height : 17,
	alt    : '',
	title  : ''
};



/* -------------------- Constructor : BAProcessingInfo inherits BABalloon -------------------- */

function BAProcessingInfo() {
	this.id           = 'BAProcessingInfo';
	this.offsetX      = 0;
	this.offsetY      = 0;
	this.delay        = 0;
	this.sustain      = 0;
	this.posRevise    = { X : false, Y : false };
	this.effect       = null;
	this.throbber     = BA_PROCESSING_INFO_THROBBER_IMG;

	if (BA.env.isDOMReady) {
		this.init();
	}
}

BAProcessingInfo.prototype           = new BABalloon;
BAProcessingInfo.prototype.initSuper = BAProcessingInfo.prototype.init;
BAProcessingInfo.prototype.showSuper = BAProcessingInfo.prototype.show;
BAProcessingInfo.prototype.hideSuper = BAProcessingInfo.prototype.hide;

BAProcessingInfo.prototype.init = function() {
	this.initSuper();
	this.setPositionFixed();
	this.setThrobber();

	if (typeof BAEffect == 'object') {
		this.effect = new BAEffect.Opacity(this.node, 500);
	}
}

BAProcessingInfo.prototype.setThrobber = function() {
	if (this.throbber && this.throbber.src && this.throbber.width && this.throbber.height) {
		var img = new BATag('img');
		img.setAttributeBA('src'   , this.throbber.src   );
		img.setAttributeBA('width' , this.throbber.width );
		img.setAttributeBA('height', this.throbber.height);
		img.setAttributeBA('alt'   , this.throbber.alt   || '');
		img.setAttributeBA('title' , this.throbber.title || '');
		this.setContent(img);
	}
}

BAProcessingInfo.prototype.show = function(content) {
	this.moveToCenter();
	this.showSuper();
	if (this.effect) { 
		this.effect.changeTo(0);
		this.effect.fadeTo(80);
	}
}

BAProcessingInfo.prototype.hide = function() {
	if (this.effect) { 
		this.effect.fadeOut(_hideMain, this);
	} else {
		_hideMain.call(this);
	}
	
	function _hideMain() {
		this.moveTo(-10000, -10000);
		this.hideSuper();
	}
}






/* -------------------- Main : register start-up -------------------- */

if (typeof BA == 'object' && typeof BABalloon == 'function' && BA.ua.isDOMReady) {
	BAAddOnload(function() {
		BA_PROCESSING_INFO = BASingleton(BAProcessingInfo);
	});
}

