

/****************************************************************************************
 * 
 * 								EDIT TOOL FACTORY
 * 
 * @author Rhonda Kammer
 ****************************************************************************************
 * The file is appropriately named edit_tool_factory but the class name is make_tool.
 * This class receives a request from emporis html templates to produce an editing tool at
 * a particular HTML element (that have been fitted with publish functions) whose id is 
 * brought in through element_id parameter.
 * 
 * This class is not meant to be used by the outside world. It is a class which is indirectly
 * invoked by the pubishers child editor, because editor prints this method call in emporis
 * templates based on publish tags placed by template designers in Emporis HTML templates.
 * All methods and variables are private although make_tool could be invoked from page embedded 
 * javascript this is NOT the way it is meant to be used.
 * 
 * See publisher and editor php classes.
 *
 *
 *****************************************************************************************/

function make_tool(url, element_id){
	
	//alert( "tool factory called: id: " + element_id  + ' url: ' + url);
	
	/******** private variables ************/
	var _tool_to_make 			= "";			//tool requested in url
	var _tool_list    			= "";			//an array of tools gotten from _raw_list
	var _raw_list				= "";			//list of tools sent via url
	var _original_url 			= url;
	var _original_element_id 	= element_id; 	//the html element id requesting the tool
	
	/******** public variables ************/
	this.tool_handle			= "";
	this.ec						= "";
	
	
	/******************************************************
	 * 
	 *          make_tool constructor
	 * 
	 *****************************************************/
	parse_url();
	_tool_list = make_tool_list_array();
	
	
	/******************************************************
	 * 
	 *  		private function definitions
	 * 
	 ******************************************************/
	switch(_tool_to_make){
		case 'edit_callout':			
			this.ec = new edit_callout_class( _original_url, _original_element_id, _tool_list );
			ec.make_edit_callout();
			//alert( "tool factory called: tool_list: " + _tool_list );
		break;
	}
	
	
	function parse_url( ){
		_tool_to_make = get_url_variable( 'pub_task', _original_url );
		_raw_list     = get_url_variable( 'tool_list', _original_url );		
	}
	
	
	function make_tool_list_array( ){
		var vars = _raw_list.split("_");
    	return vars;
	}
	

}//cl mt