<application-components>
	<!--
		The context of the script is the new instance of the application component
		this = context object
		this.getReadyState() = {int_state}
		this.getObjectType() = {str_type}
		this.getObjectVersion() = {str_version}
		this.getObjectId() = {str_id}
		this.getObjectConfig():{
			pointers:{
			
			},
			status:{
			
			}
		}
		
		this.getContainerId() = {str_id}
		
		A component definition SHOULD use a hash structure, but SHOULD NOT use the requisite opening and closing braces.
		Those are added automatically, and are left out here so that components can be compiled into the enginelater on.
		This uses NOT a valid hash structure, but the contets
		
		
		component_init:function(){
			/* invoked when the component code has been merged with a new application component instance */
		},
		component_destroy:function(){
			/* invoked prior to the window closing, the host container being destroyed, on another request to destroy the component, or when a sigterm signal was sent */
		}
	-->
		
	<application-component id = "demo_component_1">
		<![CDATA[

				component_init:function(){
					var oid = this.getObjectId(),
						eid = this.getContainerId(),
						cn = this.getComponentName(),
						_e = org.cote.js.engine.EngineService,
						o,
						e,
						_x = org.cote.js.xml;
					;
					o = _e.getEngine(eid);
					if(_e.isEngine(o)){
						e = o.getContainer();
						var oP = document.createElement("p");
						var oBr = document.createElement("br");
						var oA = document.createElement("a");
						oA.setAttribute("href","javascript:switch_config('" + oid + "','demonstration_7:next')");
						oA.appendChild(document.createTextNode("Next ..."));
						oP.appendChild(document.createTextNode(cn + ' is using component id ' + oid + ' and is contained in an engine with the id ' + eid));
						oP.appendChild(oBr);
						oP.appendChild(oA);
						e.appendChild(oP);
					}
					else{
						org.cote.js.message.MessageService.sendMessage("Invalid container id","200.4");
					}

					//alert(oid + ' in ' + eid + ' for ' + cn + ' init');
				},

				component_destroy:function(){
					var oid = this.getObjectId(),
						cn = this.getComponentName()
					;

//					alert("Destroy component " + cn + " with id " + oid);
				}


		]]>
		
	</application-component>
	<application-component id = "demo_component_2">
		<![CDATA[

				component_init:function(){
					var oid = this.getObjectId(),
						eid = this.getContainerId(),
						cn = this.getComponentName(),
						_e = org.cote.js.engine.EngineService,
						o,
						e,
						_x = org.cote.js.xml;
					;
					o = _e.getEngine(eid);
					if(_e.isEngine(o)){
						e = o.getContainer();
						var oP = document.createElement("p");
						var oBr = document.createElement("br");
						var oA = document.createElement("a");
						oA.setAttribute("href","javascript:switch_config('" + oid + "','demonstration_7:setup')");
						oA.appendChild(document.createTextNode("... Back"));
						oP.appendChild(document.createTextNode(cn + ' is using component id ' + oid + ' and is contained in an engine with the id ' + eid));
						oP.appendChild(oBr);
						oP.appendChild(oA);
						e.appendChild(oP);
					}
					else{
						org.cote.js.message.MessageService.sendMessage("Invalid container id","200.4");
					}

					//alert(oid + ' in ' + eid + ' for ' + cn + ' init');
				}

		]]>
	</application-component>
</application-components>
