
/*
	"Hemi" JavaScript Framework
	Engine for Web Applications 3.1
	Composite file "hemi.comp.js" release: 3.1.1
	Copyright 2002 - 2010. All Rights Reserved.
	Author: Stephen W. Cote
	Email: sw.cote@gmail.com
	Project: http://www.whitefrost.com/Hemi/
	BSD License: http://www.whitefrost.com/Hemi.license.txt
*/
(function(){H.namespace("object.xhtml",H,{bind:
function(o){return H.object.xhtml.newInstance(o.parentNode,o);},newInstance:
function(hp,xn,cid,rid,cc,cn,cp,cf){if(!xn)return null;if(!hp&&D.TO(xn))hp=document;if(!cid){if(xn.nodeType==1&&typeof xn.getAttribute!=D.U){cid=xn.getAttribute("id");if(cid==null||cid.length==0)cid=xn.getAttribute("name");if(cid==null||cid.length==0)cid=0;}else cid=0;}if(!cc)cc=0;if(D.TS(cc))cc=H.lookup(cc);var n=H.FN("base_object","xhtml_component","3.1.1");n.o={c:0,r:hp,cc:cc,a:0};n.p={rid:rid,cid:cid,cn:cn,cp:cp,cf:cf,lcp:0,qt:0,mp:0};n.getComponentCollection=function(){return this.o.cc;};n.getIsComponentLinked=function(){return this.p.lcp;};n.getContainer=function(){return this.o.c;};n.getComponentId=function(){return this.p.cid;};n.getReferenceId=function(){return this.p.rid;};n.getApplicationComponent=function(){var _p=this.o;if(_p.a)return _p.a;return 0;};n.setApplicationComponent=function(a){var _p=this.o;if(!_p.a)_p.a=a;};n.sigterm=function(){this.destroy();};n.destroy=function(){var _p,t=this,_s;_p=t.o;_s=t.p;if(t.r!=5){if(_p.cc&&_s.cid)_p.cc.synchronizeComponent(t);if(_p.a)_p.a.destroy();if(_p.c&&_p.r&&_p.c.parentNode==_p.r&&(!_s.cf||_s.cf!="self"))_p.r.removeChild(_p.c);H.registry.service.removeObject(t);_p.c=0;_p.r=0;_p.cc=0;_p.a=0;t.r=5;}};n.init_component=function(){var t=this,o,p,_s=t.p,_p=t.o,_ac=H.lookup("hemi.app.comp"),_am=H.lookup("hemi.app.module"),i,d,a,dc,dp,_dw=H.lookup("hemi.app.dwac");if(D.TO(hp)&&D.TO(xn)&&(!_s.cf||_s.cf!="self"))o=H.xml.setInnerXHTML(hp,xn,1,0,1);else if(D.TO(xn))o=xn;else o=hp;if(!H.IsAttributeSet(o,"hemi-id"))o.setAttribute("hemi-id",n.i);if(_s.rid&&o&&!o.getAttribute("space-id"))o.setAttribute("space-id",_s.rid);t.o.c=o;i=(_s.cn?_s.cn:(_ac?(o.getAttribute(_ac.p.x)?o.getAttribute(_ac.p.x):o.getAttribute(_ac.p.c)):0));if(i){if(_s.cp){dp=_s.cp;}else if(_ac&&H.IsAttributeSet(o,_ac.p.x)){if(i.match(/\.xml/)){dp=i;i=i.match(/(component\.)?([\S][^\.\/]*)\.xml/)[2];}else{dp=H.hemi_base+"Components/component."+i.toLowerCase()+".xml";}}else if(_ac&&(a=o.getAttribute(_ac.p.q))&&a.length>0){dp=a;}else{a=o.getAttribute(_ac.p.g);if(!a||a.length==0)a=_ac.p.k;}if(dp&&_ac){_p.a=_ac.bindComponent(t.i,i,dp,0,1);}else{H.message.service.S("Component binding to "+dp+" for "+i+" using "+a+" failed.","200.4");}}else if(_ac&&(dp=o.getAttribute(_ac.p.t))){_p.a=_ac.newInstance(0,0,this.getObjectId(),0,0,1);_p.a.setTemplateIsSpace(1);if(!dp.match(/\.xml$/)&&!dp.match(/\//))_s.qt="Templates/"+dp+".xml";else _s.qt=dp;_p.a.importComponentDefinition("",0,_s.rid);}else if(_am&&(p=H.GetSpecifiedAttribute(o,"module"))&&p!=null)_s.mp=p;else if(_dw&&(i=o.getAttribute(_dw.atkey))!=null&&i.length>0){_p.a=_dw.newInstance(t,o.getAttribute(_dw.aturi),o.getAttribute(_dw.attid),o.getAttribute(_dw.attk));}t.r=4;};n.post_init=function(){var _s=this.p,_p=this.o;if(_p.cc&&D.TF(_p.cc.addComponent)&&_p.cc.addComponent(this,_s.rid))_s.lcp=1;else _p.cc=0;if(_p.a){if(_s.qt)_p.a.loadTemplate(_s.qt);if(D.TF(_p.a.post_init))_p.a.post_init(this,_s.rid);}else if(_s.mp)H.app.module.service.NewModule(_s.mp,this);};H.registry.service.addObject(n);n.init_component();return n;}});}());
/* End Hemi Framework 3.1 */
