
/*
	"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("data.stack",H,{service:null,serviceImpl:
function(){var t=this;t.p={e:0};t.o={t:[],tn:[]};t.add=function(o,n,v,b){var _p=t.o,_r=H.registry.service,_m=H.message.service,l,nl;if(!_r.isRegistered(o))return 0;if(!D.TS(n))return 0;l=_p.t.length;if(!t.p.e&&t.CO(o,n)){if(!b){_m.S("Overstacked "+n+" for "+o.i,"200.4");return 0;}t.remove(o,n);}if(D.TU(_p.tn[n]))_p.tn[n]=[];nl=_p.tn[n].length;_p.tn[n][nl]=l;_p.t[l]={owner_id:o.i,index:l,token_name:n,token_value:v};return 1;};t.getAll=function(n){var _p=t.o;if(!D.TO(_p.tn[n]))return [];return _p.tn[n];};t.getValue=function(n,z){var v=t.get(n,z);return(v?v.token_value:0);};t.get=function(n,z){var _p=t.o,a,v;if(!D.TO(_p.tn[n]))return 0;a=_p.tn[n];if(!D.TN(z))z=0;if(z<0||z>=a.length)return 0;for(;z<a.length;z++){if(D.TN(a[z])&&a[z]>=0)return _p.t[a[z]];}return 0;};t.getValueByOwner=function(o,n){var o=t.getByOwner(o,n);if(!o)return 0;return o.token_value;};t.getByOwner=function(o,n){var _p=t.o,a,i=0,z,y,_r=H.registry.service;if(!_r.isRegistered(o))return 0;if(!D.TO(_p.tn[n]))return 0;a=_p.tn[n];for(;i<a.length;i++){z=a[i];if(!D.TN(z)||z<0||z>_p.t.length||D.TU(_p.t[z])){H.message.service.S("Invalid reference for "+n+" with "+o.i+" at "+i,"200.4");continue;}y=_p.t[z];if(y.owner_id==o.i)return y;}return 0;};t.getAllByOwner=function(o){var _p=t.o,a,i=0,z,y,r=[],_r=H.registry.service,_m=H.message.service;if(!_r.isRegistered(o)){_m.S("Unregistered object","200.4");return r;}for(;i<_p.t.length;i++){if(!D.TO(_p.t[i]))continue;y=_p.t[i];if(y.owner_id==o.i)r[r.length]=y;}return r;};t.clear=function(o){var a=t.getAllByOwner(o),i=0;for(;i<a.length;i++){this.remove(o,a[i].token_name);}};t.remove=function(o,n){var a,i=0,_p=t.o,ti,_r=H.registry.service;if(!_r.isRegistered(o)){H.message.service.S("Owner object is not registered","200.4");return 0;}if(!D.TO(_p.tn[n])){a=[];H.message.service.S("Token Reference does not exist in remove for "+n,"200.1");}else{a=_p.tn[n];}for(;i<a.length;i++){z=a[i];if(!D.TN(z)||z<0||z>_p.t.length||!D.TO(_p.t[z])){continue;}y=_p.t[z];if(y.owner_id==o.i){ti=y.index;_p.tn[n][i]=-1;break;}}if(D.TO(_p.t[ti]))_p.t[ti]=0;};t.CO=function(o,n){return(D.TO(this.getByOwner(o,n))?1:0);};H.IM(t,"base_object","token_ring","3.1.1");H.registry.service.addObject(t);}},1);}());
/* End Hemi Framework 3.1 */
