/*
	Author: Stephen W. Cote
	Email: wranlon@hotmail.com
	
	Copyright 2002, All Rights Reserved.
	
	Do not copy, archive, or distribute without prior written consent of the author.
*/

_js_package("org.cote.js.ui.object");

org.cote.js.ui.object.container={
	newInstance:function(parent_object,use_object){
		/*
			ui.object.newInstance draws on js.object.newInstance.
			j.o.n implements the event and style code, and draws on the base
			generic object class definition.
		*/
		var n = org.cote.js.ui.object.newInstance("spec_container","0.1b");
		
		if(typeof parent_object!="object") parent_object = document.body;
		n.parent_object = parent_object;
	
		n._init=function(u){
			var t=this,v,d,_m=org.cote.js.message.MessageService,c;
			c = t.object_config;

			t.style_manager = org.cote.js.dom.css.StyleManager.newInstance(t);

			v = t._load_style_names(c.style_name_id);
			if(typeof u=="object"){
				d = u;
			}
			else{
				d = document.createElement("div");
				t.parent_object.appendChild(d);
			}
			
			t.style_manager.init(d,c.style_names["maincont"]);

/*			org.cote.js.dom.event.addEventListener(d,"mouseover",t._prehandle_mouseover,0);*/

			_m.subscribe(t,"destroy","_handle_window_destroy",window);
			
			c.pointers.container = d;
			
			t.ready_state = 4;
			

		};

		n._handle_window_destroy=function(){
			this.destroy();
		};

		n.destroy=function(){
			var t=this,c;
			c=t.object_config;
			if(t.ready_state == 4){
				if(t.parent_object && t.parent_object != c.pointers.container){
					t.parent_object.removeChild(c.pointers.container);
				}
				org.cote.js._application_scope.remove_object(t);			
			}
			t.ready_state = 0;
		};

		n.getContainer=function(){
			return this.object_config.pointers.container;
		};

		n._init(use_object);


		return n;
	}
}


