dynapi.library.include('dynapi.api');
dynapi.library.include('dynapi.library');

function System() {
	this.DynObject = DynObject;
	this.DynObject();
	this._debugEnabled = false;
}
var p=dynapi.setPrototype('System','DynObject');
p.sprintf=function(msg) { // msg, param1, param2,....
	if ( arguments.length<1 ) return '';
	var i;
	for ( i=1 ; i<arguments.length ; i++ ) {
		msg = msg.replace('%'+i,arguments[i]);
	}
	return msg;
}
p.sprintlnf=function(msg) {
	if ( arguments.length<1 ) return '';
	var i;
	msg += '\n';
	for ( i=1 ; i<arguments.length ; i++ ) {
		msg = msg.replace('%'+i,arguments[i]);
	}
	return msg;
}
p.debug=function(msg) {
  if ( this._debugEnabled ){
		if ( this._debugWindow == null ){
			this._debugWindow=window.open(system.getPath()+"debug.html","debugwindow","width=450,height=600,toolbar=no,location=no,directories=no,status=no,menubar=no,dependent=no,hotkeys=yes");
			this._debugWindow.opener=window
		}
		this._debugWindow.document.write(msg+'<br>');
	}
}
p.enableDebug=function(enabled){
	this._debugEnabled = enabled;
}
// todo:Ó¦¸üÑÏ½÷
p.getPath=function(){
	return this.getSourceRoot()+'flybean/';
}
p.getSourceRoot=function(){
	if (!this._sourceRoot){
		var scripts=document.getElementsByTagName("script");
		var src='/flybean/System.js';
		for (var i=0; i<scripts.length; i++){
			if (scripts[i].src.match(src)){
				this._sourceRoot=scripts[i].src.replace(src, "")+'/';
				break;
			}
		}
	}
	return this._sourceRoot;
}	
p.version=function(){
  return System.version;
}
p.ie=document.all
p.ns6=document.getElementById && !document.all
p.isDigit=function(code){
	return (code>=48&&code<=57);
}
p.isMaskChar=function(code){
	return (code>=256 || (code<47&&code!=32));
}
p.getWindowInnerSize=function(){
	var size={};
	if(dynapi.ua.ie)
		size={width:document.body.clientWidth,height:document.body.clientHeight};
	else
		size={width:window.innerWidth,height:window.innerHeight};
	return size;
}
System.version='Copyright by Flybean(flybean@freecoder.org) (c)2005£¬All right reserved!';
System.isSameClass=function(o1,o2){
	if(!o1||!o2) return false;
	try{
		if(o1.getClassName()==o2.getClassName())
			return true;
		else
			return false;
	}
	catch(e){
		return false;
	}
}
System.isInstanceof=function(o,c){
	if(o==null||!o||!c||typeof(c)!='string') return false;
	try{
		do{
			if(o.getClassName()==c) return true;
			o=o.prototype;
		}while(o);
	}
	catch(e){return false;}
	return false;
}
var system=new System();

var l=dynapi.library;
// Set my packages
l.addPackage('flybean',system.getPath());

// flybean.gui
l.addPackage('flybean.gui',system.getPath()+'gui/');
l.add('flybean.gui.JBackground','JBackground.js');
l.add('flybean.gui.JBar','JBar.js',['BorderManager','DragEvent','JBarStyle','JCommand']);
l.add('flybean.gui.JBarStyle','JBar.style.js','JStyle');
l.add(['flybean.gui.JBorder','flybean.gui.JBorderLine'],'JBorder.js');
l.add('flybean.gui.JCommand','JCommand.js','WebAction');
l.add('flybean.gui.JEditor','JEditor.js',['BorderManager','DragEvent','JBar']);
l.add('flybean.gui.JFont','JFont.js');
l.add('flybean.gui.JInnerWindow','JInnerWindow.js','JInnerWindowStyle');
l.add('flybean.gui.JInnerWindowStyle','JInnerWindow.style.js','StyleManager');
l.add('flybean.gui.JCssStyle','JCssStyle.js',['JFont','JBorder','JBackground']);
l.add(['flybean.gui.JPowerForm','flybean.gui.Field','flybean.gui.TextField','flybean.gui.GroupField','flybean.gui.CheckField','flybean.gui.SelectField'],'JPowerForm.js','JPowerFormStyle');
l.add('flybean.gui.JPowerFormStyle','JPowerForm.style.js','StyleManager');
l.add(['flybean.gui.JTab','flybean.gui.JTabpage'],'JTab.js',['BorderManager','JInnerWindow','flybean.gui.JTabStyle']);
l.add('flybean.gui.JTabStyle','JTab.style.js','JStyle');
l.add('flybean.gui.JStyle','JStyle.js',['StyleManager','JCssStyle']);
l.add(['flybean.gui.JTreeFactory','flybean.gui.JTreeHelper','flybean.gui.JTree','flybean.gui.NodeIcon','flybean.gui.AbstractNode','flybean.gui.CheckableJTree','flybean.gui.CheckableTreeNode','flybean.gui.BrowsableJTree','flybean.gui.BrowsableTreeNode','flybean.gui.InputNode'],'JTree.js',['FileReader','XmlDocument','XmlHttpRequestEx']);
l.add('flybean.gui.JWindow','JWindow.js',['BorderManager','DragEvent','ProgressBar','flybean.gui.JInnerWindow','flybean.gui.JStyle','flybean.gui.JWindowStyle','JWindowManager']);
l.add('flybean.gui.JWindowManager','JWindowManager.js',['Cookie','FocusManager']);
l.add('flybean.gui.JWindowStyle','JWindow.style.js','JStyle');

// flybean.util
l.addPackage('flybean.util',system.getPath()+'util/');
if(dynapi.ua.ie){
	l.add('flybean.util.HashMap','HashMap.js','DynObject');
}
l.add('flybean.util.RegExUtil','RegExUtil.js','DynObject');
l.add(['flybean.util.WebAction','flybean.util.JavascriptAction','flybean.util.LinkAction'],'WebAction.js');


// flybean.xml
l.addPackage('flybean.xml',system.getPath()+'xml/');
l.add(['flybean.xml.XmlDocument','IEDocument','MozillaDocument'],'XmlDocument.js');
l.add('flybean.xml.XMLHttpRequestEx','XMLHttpRequestEx.js');
