/*
var Scheduler = Class.create();
Scheduler.prototype = {
	
	initialize: function (){
		this.processList = new Array();
		this.self = this;
		
//		this.runner = new PeriodicalExecuter( function (){ this.runProcs(); }, 1 );
	},

	addProcess: function ( newProc ){
		newProc.id = this.processList.length;
		this.processList[ newProc.id ] = newProc;
	},
	
	removeProcess: function ( proc ){
		if( proc instanceof Process ){
			this.processList = this.processList.without( proc ).compact();
		}else{
			return false;
		}
	},
	
	runProcs: function (){
		try{
			for( var i=0; i < this.processList; i++ ){
				if( this.processList[i].status < 0 ){
					this.processList[i].run();
				}
			}
		}catch( e ){
			log( "Scheduler.ProcRunner: "+e.message );
		}
	}
}

var BaseProcess = Class.create();
BaseProcess.prototype = {
	initialize: function (){
		superInit();
	},
	
	superInit: function (){
		this.id;
	
		this.status = this.STATUS_READY;
		this.type 	= this.TYPE_XML;
		this.result = new String();
		
		this.bizId;
		this.dispatch;
		this.url;
		this._aj; 	// carries the Prototype.js Ajax object 
	},
	
	runAjax: function (){
		log( "i'm runnin baby!" );
	},

	addParameter: function ( key, value ){
		a[key] = value;
		this.params = this.params.merge( $H(a) );
	},
	
	success: function ( req ){
		this.result = req.responseText;
	},
	
	complete: function ( req ){
		this.status = this.STATUS_DONE;
	},
	
	loading: function ( req ){
		this.status = this.STATUS_RUNNING;
		log( "loading..." );
	},
	
	loaded: function ( req ){
		this.status = this.STATUS_RUNNING;
		log( "loaded..." );		
	},
	
	interactive: function ( req ){
		this.status = this.STATUS_RUNNING;
		log( "interactive..." );		
	},
	
	failure: function ( req ){
		this.status = this.STATUS_FAILED;
	},
	
	// Constant variables
	// status
	STATUS_READY	: 0,
	STATUS_RUNNING	: 1,
	STATUS_DONE		: 2,
	STATUS_FAILED	: -1,
	// type
	TYPE_XML		: 0,
	TYPE_HTML		: 1,
	TYPE_JS			: 2
	// other
//	this.BASE_URL	= _CONTEXT_PATH+"/bizmap.do";
}

*/


/**
  *	AjaxPopUpProcess, extends the BaseProcess.
  * Integrated with the window.js, it automatically opens
  * a pop-up window and registers it with _WM.
  */

/*
var AjaxPopUpProcess = Class.create();
Object.extend( AjaxPopUpProcess, BaseProcess );
Object.extend( AjaxPopUpProcess.prototype, {
	initialize: function ( url ){
		this.superInit();
		this.url = url;
		this.runAjax();
	}, 
	
	runAjax: function (){
		this._aj = new Ajax.Request( this.url, 
								{
									method:		'get', 
									onSuccess:	this.openPopUp,
									onFailure:	this.failure
								});
	},
	
	openPopUp: function ( originalRequest ){
		_WM.openWindowBySource( originalRequest.responseText, "Divcan", 700, 100 );
	}
	 
});


var XMLProcess = Class.create();


var UpdaterProcess = Class.create();
UpdaterProcess.prototype = { 

	initialize: function ( pBizId, pDispatch, pPlaceHolder ){
		this.placeHolder = pPlace;
		
		if( pPlace != undefined )
			this.polaceHolder = pPlace;
		if( pDispatch != undefined )
			this.dispatch = pDispatch;
		if( pBizId != undefined )
			this.bizId = pBizId;

		this.type = TYPE_HTML;
	},
	
	run: function (){
		if( this.placeHolder == null ){
			throw new Error( "Placeholder empty for process: "+bizId+"/"+dispatch );
		}
		
		var url = BASE_URL;
		
		var ajaxRunner = new Ajax.Updater({ success: placeHolder },		
											url, 
										  {	method: 		'get', 
											parameters:		params, 
											onComplete: 	complete,
											onLoading:		loading,
											onLoaded:		loaded,
											onInteractive:	interactive,
											onSuccess:		success,
											onFailure:		failure 
										  }
										 );
	}
}

*/


Ajax.Responders.register( {
	onCreate: 	function (){ toggleLoadingIndicator(); },
	onException: function (){ toggleLoadingIndicator(); },
	onComplete: function (){ toggleLoadingIndicator(); }

});


function toggleLoadingIndicator(){
	var loadingBar = $("loadingIndicator");
	
	if( loadingBar ){
//		listObj( loadingBar );
		loadingBar.parentNode.removeChild( loadingBar );
	}else{
		try{
			loadingBar = document.createElement( "DIV" );
			loadingBar.id 					 = "loadingIndicator";
			loadingBar.innerHTML 			 = "Loading...";
			loadingBar.style.fontSize		 = "10px";
			loadingBar.style.color			 = "#FFFFFF";
			loadingBar.style.position		 = "absolute";
			loadingBar.style.top			 = "0px";
			loadingBar.style.right			 = "0px";
			loadingBar.style.height			 = "20px";
			loadingBar.style.backgroundColor = "#CC4444";			
			document.body.appendChild( loadingBar );
		}catch( e ){
		}
	}
}



/*
function runBiz( bizId, bizParams, affectedValue ){
	if( bizParams == "" || bizParams == undefined || bizParams == null ){
		bizParams = "";
	}else{
		bizParams = bizParams + "=" + affectedValue;
	}
	
	var url = _CONTEXT_PATH+"/bizmap.do";
	
	var req = new Ajax.Request( url, 
								{method: 'get', 
								 parameters: "dispatchPage=/common/xmlsucces.jsp&bizID="+bizId+"&"+bizParams,
								 onFailure:  execFail,
								 onComplete: execSuccess
								}
							);
	
}
*/
