
/*
	"Hemi" JavaScript Framework
	Engine for Web Applications 3.1
	Composite file "hemi.comp.js" release: 3.1.9
	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("util.config",H,{newInstance:
function(s,h,a){var n={o:{config:[],cm:[],clh:0},p:{cp:0,l:0,la:0,rn:0,epn:"config",en:"param",ann:"name",avn:"value"}};n.setElementParentName=function(s){this.p.epn=s;};n.setElementName=function(s){this.p.param_child_name=s;};n.setAttrNameName=function(s){this.p.ann=s;};n.setAttrValueName=function(s){this.p.avn=s;};n.clearConfig=function(){var t=this,_p;_p=t.o;_p.config=[];_p.cm=[];};n.destroy=function(){var t=this;if(t.r!=5){H.message.service.unsubscribe(t,"onloadxml","HLX");t.clearConfig();t.o.clh=0;}};n.sigterm=function(){this.destroy();};n.reload=function(){var t=this,_s,_p;t.clearConfig();_s=t.p;_p=t.o;if(_s.cp){t.load(_s.cp,_p.clh,_s.la);}};n.init=function(){var t=this;t.r=4;t.p.l=1;t.p.rn="web-application";};n.load=function(s,h,a){var t=this,o,c;t.o.clh=(D.TF(h)?h:0);t.p.cp=s;t.p.la=a;o=H.xml.getXml(s,null,a,t.i);if(!a)t._parse_config(o);};n.HLX=function(s,v){var t=this;if(v.id==t.i&&t.p.la){this._parse_config(v.xdom);}};n.getParams=function(){return this.o.config;};n.serialize=function(x){var t=this,c,o,l,i=0,x,p;l=t.o.config.length;if(!t.p.rn)return null;if(!x)x=H.xml.newXmlDocument(t.p.rn);p=x.createElement(t.p.epn);x.documentElement.appendChild(p);for(;i<l;i++){if(t.o.config[i].value==null||D.TU(t.o.config[i].value))continue;o=x.createElement(t.p.en);p.appendChild(o);o.setAttribute(t.p.ann,t.o.config[i].name);o.setAttribute(t.p.avn,"#cdata");o.appendChild(x.createCDATASection(t.o.config[i].value));}return x;};n.writeParam=function(o,x,v){var t=this,c,p,n,b=(v==null||D.TU(v));if(!o||!x)return 0;p=o.documentElement.getElementsByTagName(t.p.epn);if(p.length)p=p[0];else{p=o.createElement(t.p.epn);o.documentElement.appendChild(p);}n=H.xml.selectSingleNode(o,t.p.en+"[@"+t.p.ann+"='"+x+"']",p);if(n&&b)p.removeChild(n);else if(!b){if(!n){n=o.createElement(t.p.en);n.setAttribute(t.p.ann,x);p.appendChild(n);}else H.xml.removeChildren(n);n.setAttribute(t.p.avn,"#cdata");n.appendChild(o.createCDATASection(v));}return t.setParam(x,v);};n.setParam=function(x,v){var t=this,c,o,l;if(!t.p.l)return null;if(D.TN(t.o.cm[x]))if(t.o.config[t.o.cm[x]]){t.o.config[t.o.cm[x]].value=v;if(v==null||!D.TU(v))t.o.cm[x]=null;}else return 0;else if(v!=null&&!D.TU(v)){t.o.cm[x]=t.o.config.length;t.o.config[t.o.config.length]={"name":x,"value":v};}return 1;};n.getParam=function(x){var t=this,c,o;if(!t.p.l)return null;if(D.TS(x))x=t.o.cm[x];if(D.TN(x)&&D.TO(t.o.config[x]))return t.o.config[x].value;return null;};n.parseConfig=function(o){return this._parse_config(o);};n._parse_config=function(o){var t=this,c,p,i=0,a,n,v;t.r=3;if(D.TO(o)&&o.documentElement!=null){t.p.l=1;if(!t.p.rn)t.p.rn=o.documentElement.nodeName;a=H.xml.queryNodes(o.documentElement,t.p.epn,t.p.en,0,0);for(;i<a.length;i++){p=a[i];n=p.getAttribute(t.p.ann);if(D.TS(n)&&n.length>0){v=p.getAttribute(t.p.avn);if(!D.TS(v))v="";t.o.cm[n]=t.o.config.length;if(v=="#cdata"&&p.hasChildNodes())v=H.xml.getCDATAValue(p);t.o.config[t.o.config.length]={"name":n,"value":v};}}t.r=4;}if(D.TF(t.o.clh)){t.o.clh("onconfigload",this);}};H.IM(n,"base_object","config_utility","3.1.9");H.registry.service.addObject(n);H.message.service.subscribe(n,"onloadxml","HLX");if(D.TS(h)&&D.TF(window[h])){h=window[h];}if(D.TS(s)){if(!a)a=0;n.load(s,h,a);}else if(D.TO(s)&&s!=null){n._parse_config(s);}else if(D.TU(s)){}return n;}});}());
/* End Hemi Framework 3.1 */

