daqi={};

daqi.core={};
daqi.util={};
daqi.core.Extend=function(){};

daqi.core.Extend.extend=function(destination,source){
	for (var property in source){
		destination[property] = source[property];
	}
	return destination;
};
daqi.core.Extend.extendInner=function(destination,source){
	for (var property in source)
		destination.prototype[property] = source[property];
	return destination;
};
daqi.core.Extend.extendInIn=function(destination,source){
	for (var property in source.prototype)
		destination.prototype[property] = source.prototype[property];
	return destination;
};

$e=daqi.core.Extend.extend;
$ei=daqi.core.Extend.extendInner;
$eii=daqi.core.Extend.extendInIn;



$e(daqi.core,{
	Import:
		function(imports){
			if(typeof imports == "string"){
				var imports=imports.split(";");
				var strimport="";
				for(var i=0;i<imports.length;i++){
					strimport+="var "+imports[i].split(".").pop()+"="+imports[i]+";";
				}
				return strimport;
			}
			else{
				var strimport="";
				for(var i=0;i<imports.length;i++){
					strimport+="var "+imports[i].split(".").pop()+"="+imports[i]+";";
				}
				return strimport;
			}
		},
	Package:
		function(pkg){
			if(pkg!=null){
				var packages=pkg.split(".");
				var parentPkg=window;
				for(var i=0;i<packages.length;i++){
					if(parentPkg[packages[i]]==null){
						var packager={};
						$e(packager,{parentPackager:parentPkg});
						parentPkg[packages[i]]=packager;
					}
					parentPkg=parentPkg[packages[i]];
				}
				parentPkg.path=pkg;
				return parentPkg;
			}
		},
	Object:
		function() {
		
		},	
	SuperClass:
		function(){
			var args=new Array();
			for(var i=0;i<arguments.length;i++){
				args[i]=arguments[i];
			}
			var object=args.shift();
			if(object==null)
				return;
			var methodName=args.shift();
			if(methodName==null)
				return;
			if(object.superCall==null)
				object.superCall=eval(eval(object.clazz).superClass);
			else
				object.superCall=eval(object.superCall.superClass);
			
			var rtValue= object.superCall.prototype[methodName].apply(object,args);
			object.superCall=null;
			return rtValue;
		},
	Class:
		function(packager,className,contents,supper){
			if(typeof packager == "string")
				packager=$pkg(packager);

			if(supper==null)
				supper=daqi.core.Object;

			function clazz(){
				this.clazz=packager.path+"."+className;
				this.superCall=null;
				this.init.apply(this, arguments);
			}
			$eii(clazz,supper);

			$e(clazz,{
				newInstance:
					function(){
						for(var i=0,arg=[];i<arguments.length;i++)
							arg.push("arguments["+i+"]");
						eval("var ins = new "+packager.path+"."+className+"("+arg.join(",")+")");
						return ins;
					},
				clazz:packager.path+"."+className,
				superClass:supper.clazz
			});

			if(contents!=null){
				$ei(clazz,new contents());
			}

			packager[className]=clazz;

			return clazz;
		}
});
$e(daqi.core.Object,{
	newInstance:
		function(){
			for(var i=0,arg=[];i<arguments.length;i++)
				arg.push("arguments["+i+"]");
			eval("var ins = new daqi.core.Object("+arg.join(",")+")");
			return ins;
		}
});
$ei(daqi.core.Object,{
	clone:
		function() {
			return $ei($e({ }, this),this.prototype);
		},
	init:
		function(){
		},
	clazz:"daqi.core.Object"
});

$ei(daqi.core.Package,{
	clsPackage:null
});
$ei(daqi.core.Import,{
	clsImports:null
});

$e(daqi.core.Class,{
	forName:
		function(className){
			return(eval(className));
		}
});

$pkg=daqi.core.Package;
$imp=daqi.core.Import;
$=daqi.core.Class;

$("daqi.core","Interface",function(){
	this.executeObject=null;
});

daqix={};

