
function mySwitcher(
	aSwitchers,
	fCallback
){
	this._sw = aSwitchers;
	this._callback = fCallback;
}

mySwitcher.ANIMATION_SPEED = 500;

mySwitcher.prototype = {
	init: function() {
		var _my = this;
		
		this.isAni = false;
		
		for (var i=0; i < this._sw.length; i++) {
			jQuery(this._sw[i].sControl).click(function(){

				var _o = this;

				if(!_my.isAni){
					_my.isAni = true;
					
					for (var j=0; j < _my._sw.length; j++) {
						if(_my._sw[j].sControl == "#"+_o.id){
							_o = _my._sw[j];
						}
					}

					_my._callback(_o.sObject, true);
					
					_my.hide(function(){
						_my.isAni = false;
						_my.show(_o);
					});

				}

			})
			if(jQuery(this._sw[i].sObject).css("display") == 'none'){
				this._sw[i].isHide = true;
			}
		};
	},
	
	hide: function(callback){
		var _my = this;

		for (var i=0; i < this._sw.length; i++) {
			if(!this._sw[i].isHide){
				jQuery(this._sw[i].sObject).css({ opacity: 1 }).animate({ opacity: 0 }, _my.ANIMATION_SPEED, function(){
					jQuery(this).hide();
					for (var j=0; j < _my._sw.length; j++) {
						if(jQuery(this).attr('class') == jQuery(_my._sw[j].sObject).attr('class')){
							_my._sw[j].isHide = true;
						}
					};
					_my.checkHide(callback);
				})
			}
		}
	},
	
	checkHide: function(callback){
		var check = 0
		for (var i=0; i < this._sw.length; i++) {
			if(this._sw[i].isHide)
				check++;
		};
		if(check == this._sw.length)
			callback();
	},
	
	show: function(obj){
		var _my = this;

		obj.isHide = false;
		jQuery(obj.sObject).css({ opacity: 0 }).show().animate({ opacity: 1 }, _my.ANIMATION_SPEED, function(){
			_my._callback(obj.sObject, false);
		})
	}
}