/*
* Humax
* version 0.3
* Copyright (C) 2007 M Sheik Uduman Ali, udooz@hotmail.com
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU General Lessar Public License
along with this program (see License.txt); if not, write to udooz@hotmail.com.
*
*/
var Humax={};Humax._rootNamespace=this.window;Error.prototype._errorCode=0;Error.prototype.getErrorCode=function(){return this._errorCode.toString()};Error.prototype.getStackTrace=function(C){var A="Stack trace: <br>\n";var B=C;while(B){A+=this._getFunctionSignature(B)+"<br>\n";B=B.caller}A+="<br>\n\n";return A};Error.prototype._getFunctionSignature=function(B){var D=this._getFunctionName(B);D+="(";for(var C=0;C<B.arguments.length;C++){var A=B.arguments[C];if(typeof A=="function"){A="function "+this._getFunctionName(A)+"(..)"}D+=A;if(C<B.arguments.length-1){D+=", "}}D+=")";return D};Error.prototype._getFunctionName=function(B){if(B.name){return B.name}var A=B.toString();var C=A.substring(A.indexOf("function")+8,A.indexOf("("));C=this._trimString(C);if(C&&C.length>0){return C}return"anonymous"};Error.prototype._trimString=function(B){if(B==""){return B}while(B[0]==" "||B[0]=="\n"){B=B.substr(1)}var A=B.length-1;while(A>0&&B[A]==" "||B[A]=="\n"){A--}return B.substring(0,A+1)};Humax.Error=function(){switch(arguments.length){case 1:return new Error(arguments[0]);case 2:var A=new Error(arguments[1]);A.name=arguments[0];return A;case 3:var A=new Error(arguments[2]);A.name=arguments[0];if(!isNaN(arguments[1])){A._errorCode=arguments[1]}return A;default:var A=new Error("Required arguments not found::Humax.Error.ctor");A.name="ArgumentError";A._errorCode=1100;return A}};Humax.createXmlHttpRequest=function(){if(window.XMLHttpRequest){return Function("","return new XMLHttpRequest();")}else{if(typeof ActiveXObject!="undefined"){var D=["Msxml2.XMLHTTP","Microsoft.XMLHTTP"];var A;for(A=0;A<2;A++){try{var C=new ActiveXObject(D[A]);break}catch(B){}}if(A<2){return Function("","return new ActiveXObject('"+D[A]+"');")}else{throw Humax.Error("RuntimeError",1000,"This browser does not compatible with Humax. Technical Requirement: XmlHttpRequest not found::Humax.createXmlHttpRequest")}}else{throw Humax.Error("RuntimeError",1000,"This browser does not compatible with Humax. Technical Requirement: XmlHttpRequest not found::Humax.createXmlHttpRequest")}}}();Humax._MemberType={Unknown:0,Interface:1,Class:2,Delegate:3,MulticastDelegate:4,Raiya:5};Humax._ScriptLoader=function(){this._xhr=Humax.createXmlHttpRequest()};Humax._ScriptLoader.prototype={_xhr:null,getScript:function(A){this._xhr.open("GET",A,false);try{this._xhr.send(null);if(this._xhr.status==200||this._xhr.status==0){return this._xhr.responseText}}catch(B){}return null}};Humax.Environment=new function(){this.humax={version:"0.3",path:(function(){var E=document.getElementsByTagName("head")[0];var B=E.getElementsByTagName("script");for(var C=0;C<B.length;C++){var A=B[C].src;if(A){var D=A.match(/^(.*?)\/?humax.js/);if(D&&D[1]){return D[1]}else{return"."}}}})()};this.browser=(function(){var D=navigator.userAgent.toLowerCase();var B=parseFloat(navigator.appVersion);var H={name:"",shortName:"",version:"0.0"};var F=false;Error.prototype.source="";F=(D.indexOf("msie")!=-1)&&(D.indexOf("opera")==-1);if(F){H.name="Internet Explorer";H.shortName="IE";if(B<4){H.version="3.0"}else{if(parseInt(B)==4){var E=D.match(/MSIE\s(\d+(.\d+)?)/i);H.version=(E&&E[1])?E[1]:"4.0"}}return H}F=(D.indexOf("firefox")!=-1);if(F){H.name="Mozilla Firefox";H.shortName="FF";var A=D.match(/Firefox\/(\d+(.\d+(.\d+(.\d+)?)?)?)/i);H.version=(A&&A[1])?A[1]:"1.0";Error.prototype.source=Error.prototype.fileName;return H}F=(D.indexOf("opera")!=-1);if(F){H.name="Opera";H.shortName="OP";var C=D.match(/Opera\/(\d+(.\d+)?)/i);H.version=(C&&C[1])?C[1]:"1.0";return H}F=(D.indexOf("safari")!=-1);if(F){H.name="Safari";H.shortName="SF";var G=D.match(/(\d+(.\d+(.\d+)?)?)\sSafari/i);H.version=(G&&G[1])?G[1]:"1.0";Error.prototype.source=Error.prototype.sourceURL;return H}F=navigator.appName.toLowerCase()=="netscape";if(F){H.name="Netscape";H.shortName="NN";H.version=B;return H}H.name=navigator.appName;H.shortName="";H.version=B;return H})();this._scriptLoader=new Humax._ScriptLoader();this._loadedPackages=[]};Humax.Type=function(B,A){if(!(B||A)){throw Humax.Error("ArgumentError",1100,"Required argument memberType, typeName or both not found::Humax.Type.ctor")}this._memberType=B;this._typeName=A;this._baseTypeNames=[];this._interfaceNames=[];this._raiyaNames=[]};Humax.Type.prototype={_memberType:Humax._MemberType.Unknown,_typeName:"",_baseTypeNames:null,_interfaceNames:null,_raiyaNames:null,getName:function(){return this._typeName},is:function(A){if(!A){throw Humax.Error("ArgumentError",1100,"Required argument typeName not found::Humax.Type.is")}if(this._memberType==Humax._MemberType.MulticastDelegate&&A=="Humax.MulticastDelegate"){return true}if(this._memberType==Humax._MemberType.Delegate&&A=="Humax.Delegate"){return true}if(this._typeName==A||this._isBaseOrInterfaceNames(A)){return true}return false},has:function(B){for(var A=0;A<this._raiyaNames.length;A++){if(this._raiyaNames[A]==B){return true}}return false},_addBaseTypeName:function(A){this._baseTypeNames.push(A)},_addInterfaceName:function(A){this._interfaceNames.push(A)},_addRaiyaName:function(B){for(var A=0;A<this._raiyaNames.length;A++){if(this._raiyaNames[A]==B){throw Humax.Error("TypeError",1200,"Facet "+B+" already applied on "+this._typeName)}}this._raiyaNames.push(B)},_isBaseOrInterfaceNames:function(A){for(var B=0;B<this._baseTypeNames.length;B++){if(A==this._baseTypeNames[B]){return true}}for(var B=0;B<this._interfaceNames.length;B++){if(A==this._interfaceNames[B]){return true}}return false}};Humax.Delegate=function(A){this._delegateMethod=Function(A,"");this._typedef=new Humax.Type(Humax._MemberType.Delegate,"Humax.Delegate");this._timerId=0;this._delay=Humax.AppConfig.asyncInvokeDelayTime};Humax.Delegate.prototype={_delegateMethod:null,_targetInvocation:null,_typedef:null,_timerId:0,_delay:0,_asyncResult:null,setTarget:function(A,B){if(!A||typeof A!="function"){throw Humax.Error("ArgumentError",1101,"Invalid argument - targetInvocation. delegateMethod must be a function reference::Humax.Delegate.setTarget")}if(A.length!=this._delegateMethod.length){throw Humax.Error("ArgumentError",1101,"Invalid argument - targetInvocation. targetInvocation does not match with delegate signature::Humax.Delegate.setTarget")}this._targetInvocation={targetInvocation:A,invocationContext:B}},getTarget:function(){return this._targetInvocation},invoke:function(){if(this._timerId==0){if(arguments.length!=this._delegateMethod.length){throw Humax.Error("ArgumentError",1102,"Argument mismatched in the delegate when invoking::Humax.Delegate.invoke")}if(this._targetInvocation.invocationContext){this._targetInvocation.targetInvocation.apply(this._targetInvocation.invocationContext,arguments)}else{this._targetInvocation.targetInvocation.apply(this,arguments)}}else{if(arguments[0]!=null&&typeof arguments[0]!="function"){throw Humax.Error("ArgumentError",1101,"Callback method argument should be a function reference::Humax.Delegate.invoke")}var B=[];for(var A=1;A<arguments.length;A++){B.push(arguments[A])}if(B.length!=this._delegateMethod.length){throw Humax.Error("ArgumentError",1102,"Argument mismatched in the delegate when invoking::Humax.Delegate.invoke")}var C=new Humax.AsyncResult();if(this._targetInvocation.invocationContext){C._source=this._targetInvocation.invocationContext;C._result=this._targetInvocation.targetInvocation.apply(this._targetInvocation.invocationContext,B)}else{C._source=null;C._result=this._targetInvocation.targetInvocation.apply(this,B)}if(arguments[0]!=null){arguments[0](C)}}},beginInvoke:function(){var B=arguments;var A=this;this._timerId=setTimeout(function(){A.invoke.apply(A,B)},this._delay)},cancel:function(){clearTimeout(this._timerId)},getType:function(){return this._typedef}};Humax.MulticastDelegate=function(A){this._delegateMethod=Function(A,"");this._typedef=new Humax.Type(Humax._MemberType.MulticastDelegate,"Humax.MulticastDelegate");this._targetInvocationList=[];this._timerId=0;this._delay=Humax.AppConfig.asyncInvokeDelayTime};Humax.MulticastDelegate.prototype={_delegateMethod:null,_typedef:null,_targetInvocationList:null,_timerId:0,_delay:0,addTarget:function(A,B){if(!A||typeof A!="function"){throw new Error("ArgumentError",1101,"Invalid argument - targetInvocation. targetInvocation must be a function reference::Humax.MulticastDelegate.addTarget")}this._targetInvocationList.push({targetInvocation:A,invocationContext:B})},removeTarget:function(A){if(!A||typeof A!="function"){throw new Error("ArgumentError",1101,"Invalid argument - targetInvocation. targetInvocation must be a function reference::Humax.MulticastDelegate.addTarget")}var C=[];for(var B=0;B<this._targetInvocationList.length;B++){if(this._targetInvocationList[B].targetInvocation==A){continue}C.push(this._targetInvocationList[B])}this._targetInvocationList=C},removeAllTargets:function(){this._targetInvocationList=[]},getTargetList:function(){return this._targetInvocationList},getType:function(){return this._typedef},invoke:function(){if(this._timerId==0){if(arguments.length!=this._delegateMethod.length){throw Humax.Error("ArgumentError",1102,"Argument mismatched in the delegate when invoking::Humax.MulticastDelegate.invoke")}for(var B=0;B<this._targetInvocationList.length;B++){if(this._targetInvocationList[B]){if(this._targetInvocationList[B].invocationContext){this._targetInvocationList[B].targetInvocation.apply(this._targetInvocationList[B].invocationContext,arguments)}else{this._targetInvocationList[B].targetInvocation.apply(this,arguments)}}}}else{if(arguments[0]!=null&&typeof arguments[0]!="function"){throw Humax.Error("ArgumentError",1101,"Callback method argument should be a function reference::Humax.MulticastDelegate.invoke")}var C=null;var A=[];for(var B=1;B<arguments.length;B++){A.push(arguments[B])}if(A.length!=this._delegateMethod.length){throw Humax.Error("ArgumentError",1102,"Argument mismatched in the delegate when invoking::Humax.MulticastDelegate.invoke")}for(var B=0;B<this._targetInvocationList.length;B++){if(this._targetInvocationList[B]){C=new Humax.AsyncResult();if(this._targetInvocationList[B].invocationContext){C._source=this._targetInvocationList[B].invocationContext;C._result=this._targetInvocationList[B].targetInvocation.apply(this._targetInvocationList[B].invocationContext,A)}else{C._source=null;C._result=this._targetInvocationList[B].targetInvocation.apply(this,A)}if(arguments[0]!=null){arguments[0](C)}}}}},beginInvoke:function(){var B=arguments;var A=this;this._timerId=setTimeout(function(){A.invoke.apply(A,B)},this._delay)},cancel:function(){clearTimeout(this._timerId)}};Humax.Event=function(B){if(!B){throw Humax.Error("ArgumentError",1100,"Requirement argument multicastDelegateInstance not found::Humax.Event.ctor")}if(!B.getType().is("Humax.MulticastDelegate")){throw Humax.Error("ArgumentError",1101,"Invalid argument multicastDelegateInstance. It should be of type MulticastDelegate::Humax.Event.ctor")}var A=function(){Humax.MulticastDelegate.prototype.invoke.apply(B,arguments)};A.attach=function(){if(arguments.length==0){throw Humax.Error("ArgumentError",1100,"Requirement argument 'target' not found::Humax.Event.attach")}if(typeof arguments[0]!="function"){throw Humax.Error("ArgumentError",1101,"Invalid argument 'target'.::Humax.Event.attach")}B.addTarget(arguments[0],arguments[1])};A.detach=function(){if(arguments.length==0){throw Humax.Error("ArgumentError",1100,"Requirement argument 'target' not found::Humax.Event.detach")}if(typeof arguments[0]!="function"){throw Humax.Error("ArgumentError",1101,"Invalid argument 'target'.::Humax.Event.detach")}B.removeTarget(arguments[0])};A.detachAll=function(){B.removeAllTargets()};return A};Humax.declareNamespace=function(C){if(!C){throw Humax.Error("ArgumentError",1100,"Required argument 'name' not found::$namespace")}var B=[];var A=Humax._rootNamespace;if(C.indexOf(".")>-1){B=C.split(".")}else{B.push(C)}for(var D=0;D<B.length;D++){var E=B[D];if(!A[E]){A[E]={}}else{if(A[E]&&typeof A[E]!="object"){throw Humax.Error("TypeError",1201,B.slice(0,D).join(".")+" alredy exists and not a namespace::$namespace")}else{throw Humax.Error("TypeError",1201,"Namespace "+C+" already exists::$namespace")}}A=A[E]}};Humax.declareInterface=function(B,F,A){if(!(B||F)){throw Humax.Error("ArgumentError",1100,"Requirement argument type name, targetInterface or both not found::$interface")}var E=F.prototype;for(targetInterfaceProperty in E){if(typeof E[targetInterfaceProperty]!="function"||targetInterfaceProperty.indexOf("_")==0||targetInterfaceProperty.indexOf("$")==0){delete E.targetInterfaceProperty}}E._typedef=new Humax.Type(Humax._MemberType.Interface,B);if(A){if(A instanceof Array){Humax._addInterfaces(E,A)}else{if(arguments.length>2){var D=[];for(var C=2;C<arguments.length;C++){D.push(arguments[C])}Humax._addInterfaces(E,D)}}}E.getType=function(){return E._typedef};Humax._registerTypeToNamespace(B,F)};Humax.declareClass=function(H,I,E,J){if(!(H||I)){throw Humax.Error("ArgumentError",1100,"Required argument type name, target class or both not found::Humax.declareClass")}var C=I.prototype;C._typedef=new Humax.Type(Humax._MemberType.Class,H);if(E){var A=E.prototype;if(!A._typedef){throw Humax.Error("TypeError",1202,"Incompatiable Humax base class for "+H+"::Humax.declareClass")}if(!(A._typedef._memberType==Humax._MemberType.Class||A._typedef._memberType==Humax._MemberType.Delegate)){throw Humax.Error("TypeError",1202,"Incompatiable Humax base class for "+H+"::Humax.declareClass")}C.base=E;Humax._addBaseTypeTree(C,A);if(A._typedef._raiyaNames.length>0){var G=A._typedef._raiyaNames;for(var D=0;D<G.length;D++){C._typedef._raiyaNames.push(G[D])}}for(baseClassProperty in A){if(Humax._isScriptletProperty(baseClassProperty)||C[baseClassProperty]||baseClassProperty.indexOf("_")==0){continue}C[baseClassProperty]=A[baseClassProperty]}Humax._buildBaseFacets(C,A);C.callBaseMethod=function(K){if(arguments.length==1){return A[K].apply(this)}else{if(arguments.length>1){return A[K].apply(this,arguments)}}};for(baseClassStaticProperty in E){var F=baseClassStaticProperty.toString();if(F=="prototype"||F=="include"||F=="apply"){continue}I[baseClassStaticProperty]=E[baseClassStaticProperty]}}if(J){if(J instanceof Array){Humax._addInterfaces(C,J)}else{if(arguments.length>3){var B=[];for(var D=3;D<arguments.length;D++){B.push(arguments[D])}Humax._addInterfaces(C,B)}}}C.getType=function(){return C._typedef};I.include=function(K){if(!K){throw Humax.Error("ArgumentError",1100,"Required argument not found")}if(!K.prototype._typedef||K.prototype._typedef._memberType!=Humax._MemberType.Raiya){throw Humax.Error("TypeError",1202,"Incompatiable raiya type '"+H+"'::include()")}Humax._includeRaiya(K,I)};I.apply=function(K,L){Humax.applyFacet(K,I,L)};Humax._registerTypeToNamespace(H,I)};Humax._includeRaiya=function(C,J){var L=J.prototype;var A=C.prototype;var G=null;var B=null;if((!L._typedef)||L._typedef._memberType!=Humax._MemberType.Class){throw Humax.Error("TypeError",1202,"Incompatiable Humax targetType::Humax._includeRaiya")}if(L._facetHash){var D=L._facetHash;var I=A._typedef._typeName;for(var E=0;E<D.length;E++){if(D[E]._instance._typedef._typeName=="Humax.RaiyaFieldMapFacet"&&D[E]._instance.getRaiyaName()==I){G=D[E]._instance;break}}if(G){B=G.getFieldMap()}}for(raiyaProperty in A){var H=A[raiyaProperty];if(typeof H!="function"||Humax._isScriptletProperty(raiyaProperty)){continue}if(B){var K=new String(H);var F=K.substring(K.indexOf("(")+1,K.indexOf(")"));K=K.substring(K.indexOf("{")+1,K.lastIndexOf("}"));for(raiyaField in B){K=K.replace(new RegExp(raiyaField,"g"),B[raiyaField])}L[raiyaProperty]=Function(F,K)}else{L[raiyaProperty]=H}}L._typedef._addRaiyaName(A._typedef._typeName)};Humax._registerTypeToNamespace=function(B,F){var C=B.split(".");var A=Humax._rootNamespace;for(var D=0;D<C.length-1;D++){var E=C[D];if(!(A[E]&&typeof A[E]=="object")){throw Humax.Error("TypeError",1203,"Namespace name not found for type '"+B+"'::Humax._assignTypesToNamespace")}A=A[E]}var G=C[C.length-1];A[G]=F};Humax._addInterfaces=function(D,B){var A=null;for(var C=0;C<B.length;C++){A=B[C].prototype;if(!A._typedef){throw Humax.Error("TypeError",1202,"Incompatiable Humax type given in the array indexat "+(C+1)+"::Humax._addInterfaces")}if(A._typedef._memberType!=Humax._MemberType.Interface){throw Humax.Error("TypeError",1202,"Incompatiable Humax interface type given in the array indexat "+(C+1)+"::Humax._addInterfaces")}D._typedef._addInterfaceName(A._typedef._typeName);for(baseInterfaceProperty in A){if(Humax._isScriptletProperty(baseInterfaceProperty)||typeof A[baseInterfaceProperty]!="function"||(D[baseInterfaceProperty]&&(typeof D[baseInterfaceProperty]==typeof A[baseInterfaceProperty]))||baseInterfaceProperty.indexOf("_")==0||baseInterfaceProperty.indexOf("$")==0){continue}D[baseInterfaceProperty]=A[baseInterfaceProperty]}Humax._buildBaseFacets(D,A);for(var C=0;C<A._typedef._interfaceNames.length;C++){D._typedef._addInterfaceName(A._typedef._interfaceNames[C])}}};Humax._addBaseTypeTree=function(A,C){A._typedef._addBaseTypeName(C._typedef._typeName);for(var B=0;B<C._typedef._baseTypeNames.length;B++){A._typedef._addBaseTypeName(C._typedef._baseTypeNames[B])}for(var B=0;B<C._typedef._interfaceNames.length;B++){A._typedef._addInterfaceName(C._typedef._interfaceNames[B])}};Humax._isScriptletProperty=function(B){var A="base _typedef _facetHash getType callBaseMethod include apply";if(A.match(B)){return true}return false};Humax._buildBaseFacets=function(A,F){if(F._facetHash){for(aidex in F._facetHash){if(F._facetHash[aidex]._instance.getFacetUsage()&Humax.FacetUsage.AllowToInherit==Humax.FacetUsage.AllowToInherit){var E={_instance:F._facetHash[aidex]._instance,_applyTo:null};if(F._facetHash[aidex]._applyTo instanceof Array){var D=[];for(eidx in F._facetHash[aidex]._applyTo){if(F._facetHash[aidex]._applyTo[eidx].indexOf("_")!=0){D.push(F._facetHash[aidex]._applyTo[eidx])}}E._applyTo=D}else{if(F._facetHash[aidex]._applyTo.indexOf("_")!=0){E._applyTo=F._facetHash[aidex]._applyTo}}if(E._applyTo){if(!A._facetHash){A._facetHash=[]}var B=false;for(tidx in A._facetHash){if(A._facetHash[tidx]._instance==E._instance){B=true;if(A._facetHash[tidx]._applyTo instanceof Array){if(E._applyTo instanceof Array){for(var C=0;C<E._applyTo.length;C++){A._facetHash[tidx]._applyTo.push(E._applyTo[C])}}else{A._facetHash[tidx]._applyTo.push(E._applyTo)}}else{var D=[];D.push(A._facetHash[tidx]._applyTo);if(E._applyTo instanceof Array){for(var C=0;C<E._applyTo.length;C++){D.push(E._applyTo[C])}}else{D.push(E._applyTo)}if(D.length>1){A._facetHash[tidx]._applyTo=D}else{A._facetHash[tidx]._applyTo=D[0]}}break}}if(!B){A._facetHash.push(E)}}}}}};Humax.FacetTargets={All:1,Class:2,Interface:3,Delegate:4,Event:5,Constructor:6,Field:7,Method:8};Humax.FacetUsage={AllowMultiple:1,AllowToInherit:2,AllowAdvices:3};Humax.Facet=function(){this.$target=Humax.FacetTargets.Class|Humax.FacetTargets.Interface;this.$usage=Humax.FacetUsage.AllowMultiple};Humax.Facet.prototype={$target:-1,$usage:-1,beforeAdviceDelegate:null,afterAdviceDelegate:null,aroundAdviceDelegate:null,BeforeAdvice:null,AfterAdvice:null,AroundAdvice:null,getFacetTarget:function(){return this.$target},getFacetUsage:function(){return this.$usage},attachHandlers:function(){this.beforeAdviceDelegate=new Humax.MulticastDelegate("sourceObject, joinPointOriginalArgs");this.afterAdviceDelegate=new Humax.MulticastDelegate("sourceObject, joinPointOriginalArgs");this.aroundAdviceDelegate=new Humax.MulticastDelegate("sourceObject, sourceMethod, joinPointOriginalArgs");this.BeforeAdvice=new Humax.Event(this.beforeAdviceDelegate);this.AfterAdvice=new Humax.Event(this.afterAdviceDelegate);this.AroundAdvice=new Humax.Event(this.aroundAdviceDelegate)},callSource:function(C,A,B){A.apply(C,B)}};Humax.Facet.getFacets=function(A,G){var B=null;var D=null;var F=null;if(!A._typedef||!A._facetHash){return null}D=A._facetHash;if(G){if(G instanceof Array){F=G}else{F=[];for(var E=1;E<arguments.length;E++){F.push(arguments[E])}}}if(D){B=[];for(var E=0;E<D.length;E++){if(F){if(D[E]._applyTo){for(var C=0;C<F.length;C++){if(Humax._targetsExistsInFacetHash(D[E]._applyTo,F[C])){B.push(D[E]._instance);break}}}else{return null}}else{B.push(D[E]._instance)}}}return B};Humax.Facet.getFacet=function(B,A,G){var D=null;var F=null;if(!A._typedef||!A._facetHash){return null}for(var E=0;E<A._facetHash.length;E++){if(A._facetHash[E]._instance._typedef._typeName==B){D=A._facetHash[E]}}if(G){if(G instanceof Array){F=G}else{F=[];for(var E=1;E<arguments.length;E++){F.push(arguments[E])}}}if(D){if(F){if(D._applyTo){for(var C=0;C<F.length;C++){if(Humax._targetsExistsInFacetHash(D._applyTo,F[C])){return D._instance}}}else{return null}}else{D._instance}}};Humax.declareClass("Humax.Facet",Humax.Facet);Humax.applyFacet=function(E,A,D){if(!E){throw Humax.Error("ArgumentError",1100,"Required argument 'facetInstance' not found")}if(!A){throw Humax.Error("ArgumentError",1100,"Required argument 'targetType' not found")}if(!E._typedef||E._memberType!=Humax._MemberType.Class&&!E._typedef.is("Humax.Facet")){throw Humax.Error("TypeError",1202,"Incompatiable Humax facet type::Humax.applyFacet")}var L=A.prototype;if(!L._typedef){throw Humax.Error("TypeError",1202,"Incompatiable Humax targetType::Humax.applyFacet")}if(!L._facetHash){L._facetHash=[]}var H=null;var M=-1;var K=E.getFacetTarget();var I=E.getFacetUsage();var C={_instance:E,_applyTo:null};if(I&Humax.FacetUsage.AllowAdvices==Humax.FacetUsage.AllowAdvices){E.attachHandlers()}if(D){var G=[];var B=[];H=[];if(D instanceof Array){B=D}else{if(arguments.length>2){for(var F=2;F<arguments.length;F++){B.push(arguments[F])}}}for(var F=0;F<B.length;F++){for(targetTypeProperty in L){if(B[F].match(targetTypeProperty)){G.push(targetTypeProperty)}}}for(var F=0;F<L._facetHash.length;F++){if(L._facetHash[F]._instance==E){M=F;H=L._facetHash[F]._applyTo;break}}for(var F=0;F<G.length;F++){if(!L[G[F]]){continue}if(Humax._isScriptletProperty(L[G[F]])){continue}if(I&Humax.FacetUsage.AllowMultiple!=Humax.FacetUsage.AllowMultiple&&Humax._targetsExistsInFacetHash(H,G[F])){continue}if(I&Humax.FacetUsage.AllowAdvices==Humax.FacetUsage.AllowAdvices&&typeof L[G[F]]=="function"&&(K&Humax.FacetTargets.All==Humax.FacetTargets.All||K&Humax.FacetTargets.Method==Humax.FacetTargets.Method)){var J=L[G[F]];L[G[F]]=Humax._formNewFunction(E,J);H.push(G[F]);continue}if(K&Humax.FacetTargets.All==Humax.FacetTargets.All){H.push(G[F]);continue}if(K&Humax.FacetTargets.Delegate==Humax.FacetTargets.Delegate&&L[G[F]]._typedef&&(L[G[F]]._typedef.is("Humax.Delegate")||L[G[F]]._typedef.is("Humax.MulticastDelegate"))){H.push(G[F]);continue}if(K&Humax.FacetTargets.Event==Humax.FacetTargets.Event&&L[G[F]]._typedef&&L[G[F]]._typedef.is("Humax.Event")){H.push(G[F]);continue}if(K&Humax.FacetTargets.Field==Humax.FacetTargets.Field&&typeof L[G[F]]!="function"){H.push(G[F]);continue}if(K&Humax.FacetTargets.Method==Humax.FacetTargets.Method&&typeof L[G[F]]=="function"){H.push(G[F]);continue}}}if(K&Humax.FacetTargets.Constructor==Humax.FacetTargets.Constructor||K&Humax.FacetTargets.All==Humax.FacetTargets.All){H.push("ctor")}C._applyTo=H;if(M>-1){L._facetHash[M]=C}else{L._facetHash.push(C)}};Humax._targetsExistsInFacetHash=function(C,B){if(C instanceof Array){for(var A=0;A<C.length;A++){if(C[A]==B){return true}}return false}return(C==B)};Humax._formNewFunction=function(A,B){return function(){A.BeforeAdvice(this,arguments);if(A.aroundAdviceDelegate.getTargetList().length>0){A.AroundAdvice(this,B,arguments)}else{B.apply(this,arguments)}A.AfterAdvice(this,arguments)}};$raiya=function(A,B){if(!(A||B)){throw Humax.Error("ArgumentError",1100,"Required argument typeName, definition or both not found::Humax.declareRaiya")}var C=function(){};C.prototype=B;var D=C.prototype;D._typedef=new Humax.Type(Humax._MemberType.Raiya,A);D.getType=function(){return targetClassPrototype._typedef};Humax._registerTypeToNamespace(A,C)};Humax.RunTimeMode={Debug:0,Release:1};Humax.AppConfig={codeBase:"",asyncInvokeDelayTime:100,runtimeMode:Humax.RunTimeMode.Debug,customSettings:[],packages:[]};Humax.require=function(A,H){var L=null;var E=null;if(!A){throw Humax.Error("ArgumentError",1100,"Required argument packageName not found")}if(H){L=(E=H.match(/(v(>|<|<=|>=))?(\d+(.\d+(.\d+)?)?)/))?E[3]:null}if(Humax.Environment._loadedPackages[A]&&Humax.Environment._loadedPackages[A]["loaded"]){if(L){var M=false;if(!Humax._isPackageVersionMatch(E[2],Humax.Environment._loadedPackages[A]["version"],L)){throw Humax.Error("RuntimeError",1001,"Version "+Humax.Environment._loadedPackages[A]["version"]+' of package "'+A+'" already imported::$require')}}return }var I=[];var J=null;var D=null;if(E){D=E[2]}J=Humax._getPackagePathFromConfig(A,L,D);if(J!=null){if(A.indexOf(".")>-1){var C=A.substr(0,A.lastIndexOf("."));I.push(C.replace(/\./g,"/").concat("/"+J))}else{I.push(J)}}if(!J){if(L){I.push(A.replace(/\./g,"/").concat("_v"+L[0]+".js"));I.push(A.replace(/\./g,"/").concat(".js"))}else{I.push(A.replace(/\./g,"/").concat(".js"))}}var B=null;for(var G=0;G<I.length;G++){B=Humax._getScriptText(I[G]);if(!B){continue}else{break}}if(!B){throw Humax.Error("RuntimeError",1002,'Package "'+A+'" not found::$require')}Humax.Environment._loadedPackages[A]={loaded:false,version:""};var F=document.getElementsByTagName("head")[0];var K=document.createElement("script");K.id=A;K.type="text/javascript";K.text=B;F.appendChild(K);Humax.Environment._loadedPackages[A]["loaded"]=true};Humax.declarePackage=function(B,A){if(!Humax.Environment._loadedPackages[B]){throw Humax.Error("RuntimeError",1003,"Package "+B+" should be imported $require()::$package")}if(!A){A="0.1"}Humax.Environment._loadedPackages[B]["version"]=A};Humax._getScriptText=function(C){var B=null;if(Humax.AppConfig.codeBase.length>0){var A=null;if(Humax.AppConfig.codeBase.lastIndexOf("/")==Humax.AppConfig.codeBase.length-1){A=Humax.AppConfig.codeBase+C}else{A=Humax.AppConfig.codeBase+"/"+C}B=Humax.Environment._scriptLoader.getScript(modUrl)}if(!B){var D=Humax.Environment.humax.path+"/"+C;B=Humax.Environment._scriptLoader.getScript(D)}return B};Humax._isPackageVersionMatch=function(C,B,A){switch(C){case"<":return B<A;case">":return B>A;case"<=":return B<=A;case">=":return B>=A;default:return B==A}};Humax._getPackagePathFromConfig=function(B,A,C){if(Humax.AppConfig.packages){var E=null;for(var D=0;D<Humax.AppConfig.packages.length;D++){E=Humax.AppConfig.packages[D];if(E.name&&E.name==B){if(A&&E.version&&E.version!=""){if(Humax._isPackageVersionMatch(C,E.version,A)){return E.file}}else{return E.file}}}}return null};$class=function(){if(arguments.length<2){throw Humax.Error("ArgumentError",1100,"Required arguments not found::$class")}var I,E,L,H;I=arguments[0];var K=function(){if(!this.initialize){this.initialize=function(){}}this.initialize.apply(this,arguments)};switch(arguments.length){case 2:K.prototype=arguments[1];break;case 3:var B=false;if(arguments[1] instanceof Array){L=arguments[1]}else{var J=arguments[1].prototype;if(J&&J._typedef){if(J._typedef._memberType==Humax._MemberType.Class){E=arguments[1]}else{if(J._typedef._memberType==Humax._MemberType.Interface){L=[arguments[1]]}else{throw Humax.Error("TypeError",1202,"Incompatiable Humax base class or interface for "+I+"::$class")}}}else{B=true;K.prototype=arguments[1];H=arguments[2]}}if(!B){K.prototype=arguments[2]}break;case 4:var B=false;if(arguments[1] instanceof Array){L=arguments[1]}else{var J=arguments[1].prototype;if(J&&J._typedef){if(J._typedef._memberType==Humax._MemberType.Class){E=arguments[1]}else{if(J._typedef._memberType==Humax._MemberType.Interface){L=[arguments[1]]}else{throw Humax.Error("TypeError",1202,"Incompatiable Humax base class or interface for "+I+"::$class")}}}}if(arguments[2] instanceof Array){if(!L){L=arguments[2]}else{throw new Error("Arguments mismatch in "+I+" - $class")}}else{if(arguments[2].prototype){if(arguments[2].prototype._typedef&&arguments[2].prototype._typedef._memberType==Humax._MemberType.Interface){L=[arguments[2]]}else{throw Humax.Error("ArgumentError",1102,"Arguments mismatched when declaring type "+I+"::$class")}}else{B=true;K.prototype=arguments[2]}}if(B){H=arguments[3]}else{K.prototype=arguments[3]}break;case 5:E=arguments[1];if(arguments[2] instanceof Array){if(!L){L=arguments[2]}else{throw Humax.Error("ArgumentError",1102,"Arguments mismatched when declaring type "+I+"::$class")}}else{if(arguments[2].prototype){if(arguments[2].prototype._typedef&&arguments[2].prototype._typedef._memberType==Humax._MemberType.Interface){L=[arguments[2]]}else{throw Humax.Error("ArgumentError",1102,"Arguments mismatched when declaring type "+I+"::$class")}}}K.prototype=arguments[3];H=arguments[4]}var C=K.prototype;C._typedef=new Humax.Type(Humax._MemberType.Class,I);if(E){var A=E.prototype;if(A.initialize){C.base=function(){return A.initialize.apply(this,arguments)}}else{C.base=E}Humax._addBaseTypeTree(C,A);if(A._typedef._raiyaNames.length>0){var G=A._typedef._raiyaNames;for(var D=0;D<G.length;D++){C._typedef._raiyaNames.push(G[D])}}for(baseClassProperty in A){if(Humax._isScriptletProperty(baseClassProperty)||C[baseClassProperty]||baseClassProperty.indexOf("_")==0){continue}C[baseClassProperty]=A[baseClassProperty]}Humax._buildBaseFacets(C,A);C.callBaseMethod=function(M){return A[M].apply(this,arguments)};for(baseClassStaticProperty in E){var F=baseClassStaticProperty.toString();if(F=="prototype"||F=="include"||F=="apply"){continue}K[baseClassStaticProperty]=E[baseClassStaticProperty]}}if(L){Humax._addInterfaces(C,L)}C.getType=function(){return C._typedef};K.include=function(M){if(!M||!M.prototype._typedef||M.prototype._typedef._memberType!=Humax._MemberType.Raiya){throw Humax.Error("TypeError",1202,"Incompatiable raiya or not specified for "+I+"::include()")}Humax._includeRaiya(M,K)};K.apply=function(M,N){Humax.applyFacet(M,K,N)};if(H){for(staticProperty in H){K[staticProperty]=H[staticProperty]}}Humax._registerTypeToNamespace(I,K)};$interface=function(){var B=null;var A;var D=function(){};switch(arguments.length){case 2:A=arguments[0];D.prototype=arguments[1];break;case 3:A=arguments[0];D.prototype=arguments[2];if(arguments[1] instanceof Array){B=arguments[1]}else{B=[arguments[1]]}break;default:throw Humax.Error("ArgumentError",1100,"Required argument not found::$interface")}var C=D.prototype;for(targetInterfaceProperty in C){if(typeof C[targetInterfaceProperty]!="function"||targetInterfaceProperty.indexOf("_")==0||targetInterfaceProperty.indexOf("$")==0||targetInterfaceProperty!="initialize"){delete C.targetInterfaceProperty}}C._typedef=new Humax.Type(Humax._MemberType.Interface,A);if(B){Humax._addInterfaces(C,baseInterfaceArray)}C.getType=function(){return C._typedef};Humax._registerTypeToNamespace(A,D)};$namespace=function(A){Humax.declareNamespace(A)};$package=function(B,A){Humax.declarePackage(B,A)};$require=function(B,A){Humax.require(B,A)};Humax._loadAppConfig=function(){var D=Humax.Environment.humax.path+"/appconfig.js";var A=Humax.Environment._scriptLoader.getScript(D);if(!A){return }var C=document.getElementsByTagName("head")[0];var B=document.createElement("script");B.id="appcofig";B.type="text/javascript";B.text=A;C.appendChild(B)}();$class("Humax.AsyncResult",{_result:null,_source:null,initialize:function(){},getResult:function(){return this._result},getSource:function(){return this._source}});Humax.Timer=function(B,C,A){if(!B){throw new Humax.Exception("Required parameter 'targetInvocationMethod' is null","Humax.ArgumentNullException")}else{if(typeof B!="function"){new Humax.Exception("Required parameter 'targetInvocationMethod' is null","Humax.InvalidArgumentException")}else{this._targetInvocationMethod=B}}if(C){this._interval=C}else{this._interval=500}this._timerId=null;if(!A){this.start()}};Humax.Timer.prototype={_timerId:null,_interval:null,_targetInvocationMethod:null,start:function(){if(Humax.Environment.browser.shortName=="IE"&&Humax.Environment.browser.version=="4.0"){this._timerId=window.setInterval(new String(this._targetInvocationMethod),this._interval)}else{this._timerId=window.setInterval(this._targetInvocationMethod,this._interval)}},stop:function(){window.clearInterval(this._timerId)},changeInterval:function(A){this.stop();this._interval=A;this.start()}};Humax.declareClass("Humax.Timer",Humax.Timer);Humax.RaiyaFieldMapFacet=function(B,A){if(!(B||A)){throw Humax.Error("ArgumentError",1100,"Required arguments not found::Humax.RaiyaFieldMapFacet.ctor")}this.base();this.$usage=Humax.FacetUsage.AllowMultiple|Humax.FacetUsage.AllowToInherit;this.$target=Humax.FacetTargets.Class;this._raiyaName=B;this._fieldMap=A};Humax.RaiyaFieldMapFacet.prototype={getRaiyaName:function(){return this._raiyaName},getFieldMap:function(){return this._fieldMap}};Humax.declareClass("Humax.RaiyaFieldMapFacet",Humax.RaiyaFieldMapFacet,Humax.Facet);