var Class = function(properties){
	var klass = function(){
		for (var p in this){
			if (this[p]) this[p]._proto_ = this;
		}
		if (arguments[0] != 'noinit' && this.initialize) return this.initialize.apply(this, arguments);
	};
	klass.extend = this.extend;
	klass.implement = this.implement;
	klass.prototype = properties;
	return klass;
};

Class.empty = function(){};

Class.create = function(properties){
	return new Class(properties);
};

/****************************** LOAD ONCE *****************************/if(!fw){

String.prototype.makeSafe = function(){
	return this
	.replace(/</g, '&lt;')
	.replace(/>/g, '&gt;')
	.replace(/"/g, '&quot;')
	.replace(/\n/g, '<BR>');
}

var fw = {
	
	addLoadListener: function(fn){
		if(window.addEventListener)
			window.addEventListener('load', fn, false);
		else if(window.attachEvent)
			window.attachEvent('onload', fn);	
	},

	Instances: {
		list: [],
		add: function(self, cID, type, parent) {
			this.list.push({
				'self': self,
				'cID': cID || self.containerID,
				'type': type || self.type,
				'parent': parent || self.options.parent
			});
			return this.list[this.list.length-1];
		},
		get: function(cID) {
			for (var i = 0; i < this.list.length; i++) {
				if (this.list[i].cID == cID)
				return this.list[i].self;
			}
			return null;
		},
		getAll: function(type) {
			var all = [];
			for (var i = 0; i < this.list.length; i++) {
				if (this.list[i].type == type || !type)
				all.push(this.list[i]);
			}
			return all;
		}
	},
	
	Libs: {
		loaded: '',
		load: function(libs){
			this.libs = libs;
			while(this.libs.length>0){
				var loc = this.libs.shift();
				if(this.loaded.indexOf(loc)>-1)
					continue;
				this.loaded += loc;
				document.write('<script type="text/javascript" src="'+loc+'"><'+'/script>');
			}
		}
	},
	
	Css: {
		loaded: '',
		load: function(href, options){
			options = options || {};
			if(this.loaded.indexOf(href)>-1) return;
			if(options.draw)
				document.write('<link rel="stylesheet" type="text/css" href="' + href + '">');
			else {
				var l = document.createElement('link');
				l.rel = 'stylesheet';
			    l.type = 'text/css';
				l.href = href;
				(options.el || document.getElementsByTagName('head')[0] || document.body).appendChild(l);
			}
			this.loaded += href;
		}
	},
	
	jjax: {
		req: function(url, options){
			this.url = '';
			this.options = options || {};
			for(var i in this.options.postBody)
				this.url +=	((this.url=='') ? '' : '&') + i + '=' + this.options.postBody[i];
			this.url = url + (this.options.postBody ? '?' : '') + this.url;
			this.send();
		},
		send: function(){
			var script = document.createElement('script');
			script.src = this.url;
			script.type = "text/javascript";
			this.options.appendTo ? this.options.appendTo.appendChild(script) : document.body.appendChild(script);
		}
	},
	
	Request: {
		getParameter: function(name){
			var s = window.location.search;
			if(!s) return '';
			var param = s.split(name + '=')[1];
			if(!param) return '';
			return 	param.split('&')[0].replace(/\+/g, ' ').replace(/&amp;/g, '&');
		}
	}
}

/*****************************************************************************/}
