/** @namespace Tlantic.COMPONO */

/** 
 * @id compono_core
 * @version 1.6.18.25
 */
var compono = {
	/** @id compono_name */
	name:"COMPONO",
	/** @id compono_toString */
	toString:function(){return this.name;},
	/** @id compono_version */
	version:{	
		/** @id compono_version_major */ major:1,
		/** @id compono_version_minor */minor:6,
		/** @id compono_version_added */added:18,
		/** @id compono_version_bugged */bugged:25,
		/** @ignore */ toString:function(){return this.major+"."+this.minor+"."+this.added+"."+this.bugged}
	},
	/** @id compono_create */
	create:function(name){
		return new this.Object(name);
	},
	/** @id compono_Object */
	Object:function(name){
		this.name = name;
		this.core = compono;
		this.toString = compono.toString;
		this.Object = function(name){
			this.name = name;
			this.core = compono;
			this.toString = compono.toString;
			this.Object.prototype = this;
		};
		this.Object.prototype = this;
	},
	/** @ignore */
	prototype:{},
	/** @id compono_getByID */
	getByID:function(id){
		return (typeof(id) == 'string' ? document.getElementById(id) : id);
	},	
	/** @id compono_getAnyByTagName */
	getAnyByTagName:function(_tag,scope){
		function __g(t,s){	return (s || document).getElementsByTagName(t)		};
		if(_tag instanceof Array){
			var z=0,i=0, t=__g(_tag[z],scope),a=[],n;
			while((n=t[i])){
				a.push(n);
				if(i==t.length-1){
					z++; i=0;
					if(_tag[z]){ 
						t = __g(_tag[z],scope);
					};
				}
				else{
					i++;
				}
			}
			return a;
		}else{
			return __g(_tag,scope);
		}
	},
	/** @id compono_getByTagName */
	getByTagName:function(_tag,scope){
		return (scope || document).getElementsByTagName(_tag)[0] || null;
	},	
	/** @id compono_getAnyByClassName */
	getAnyByClassName:function(_tag,_class,_scope) {
		return this.getAnyByAttribute(_tag, "className", _class, _scope)
	},	
	/** @id compono_getByClassName */
	getByClassName:function(_tag,_class,_scope){
		return this.getByAttribute(_tag, "className", _class, _scope)
	},	
	/** @id compono_getByName */
	getByName:function(_name){
		return document.getElementsByName(_name);
	},	
	/** @id compono_getPrevious */
	getPrevious:function(scope) {
		var p = scope.previousSibling;
		while(p.nodeType != 1){
			p = p.previousSibling;
		};
		return p;
	},	 
	/** @id compono_getNext */
	getNext:function(scope) {
		var p = scope.nextSibling;
		while(p.nodeType != 1){
			p = p.nextSibling;
		};
		return p;
	},	
	/** @id compono_getFirst */
	getFirst:function(scope) {
		var p = scope.firstChild;
		while(p.nodeType != 1){
			p = p.nextSibling;
		};
		return p;
	},
	/** @id compono_getLast */
	getLast:function(scope) {
		var p = scope.lastChild;
		while(p.nodeType != 1){
			p = p.previousSibling;
		};
		return p;
	},
	/** @id compono_getElements */
	getElements:function(scope,nodeType) {
		var ar = [];
		if(!nodeType)nodeType=1;
		for(var i=0,n;n=scope.childNodes[i];i++){
			if(n.nodeType == nodeType){
				ar.push(n);
			}
		}
		return ar;
	},
	/** @id compono_getFirst */
	getFirst:function(scope) {
		var p = scope.firstChild;
		while(p.nodeType != 1){
			p = p.nextSibling;
		};
		return p;
	},
	/** @id compono_getLast */
	getLast:function(scope) {
		var p = scope.lastChild;
		while(p.nodeType != 1){
			p = p.previousSibling;
		};
		return p;
	},
	/** @id compono_getElements */
	getElements:function(scope,nodeType) {
		var ar = [];
		if(!nodeType)nodeType=1;
		for(var i=0,n;n=scope.childNodes[i];i++){
			if(n.nodeType == nodeType){
				ar.push(n);
			}
		}
		return ar;
	},
	/** @id compono_removeAllChildNodes */
	removeAllChildNodes:function(scope){
		while(scope.firstChild){
			scope.removeChild(scope.firstChild);
		}		
	},	
	/** @id compono_getAnyByAttribute */
	getAnyByAttribute:function( _tag, _att, _value, _scope){
		var elements, returnElements, v;
		_scope = _scope || document;
		elements = !_tag || _tag == "*" ? document.all : this.getAnyByTagName(_tag, _scope);
		returnElements = [];
		if(_att && _value){
			_value = _value.split(/\s+/);
			var regexp = new RegExp("(^|\\s+)("+ _value.join("|") +")(\\s+|$)","i");
			for(var i=0, element; element = elements[i]; i++){
				v = element.getAttribute(_att) || element[_att];
				if(regexp.test(	v )){
					returnElements.push(element);
				}
			};
			return returnElements;
		}else if(_att){
			for(var i=0, element; element = elements[i]; i++){
				v = element.getAttribute(_att) || element[_att];
				if(v != undefined){
					returnElements.push(element);
				}
			};
			return returnElements;
		};
		return elements;
	},	
	/** @id compono_getByAttribute */
	getByAttribute:function( _tag, _att, _value, _scope){
		var elements, v;
		_scope = _scope || document;
		elements = !_tag || _tag == "*" ? document.all : this.getAnyByTagName(_tag, _scope);
		if(_att && _value){
			_value = _value.split(/\s+/);
			var regexp = new RegExp("(^|\\s+)("+ _value.join("|") +")(\\s+|$)","i");
			for(var i=0, element; element = elements[i]; i++){
				v = element.getAttribute(_att) || element[_att];
				if(regexp.test(	v )){
					return element;
				}
			}
		}else if(_att){
			for(var i=0, element; element = elements[i]; i++){
				v = element.getAttribute(_att) || element[_att];
				if(v != undefined){
					return element;
				}
			}
		};
		return false;
	},
	/** @ignore */
	CSSClassNames:{},
	/** @id compono_hasClassName */
	hasClassName:function(_class,scope){
		if(!compono.CSSClassNames[_class]){	compono.CSSClassNames[_class] = new RegExp("(^|\\s+)"+_class+"(\\s+|$)","i");	}
		return (scope && compono.CSSClassNames[_class].test(scope.className));
	},
	/** @id compono_appendClassName */
	appendClassName:function( _class, scope, index){
		if(this.hasClassName(_class,scope) == false){
			if(typeof(index)=="number"){ 
				var a = scope.className.split(" ");
				a[index] = _class;
				scope.className = a.join(" ")
			}else{
				scope.className += " " + _class;
			};
			return true;
		};
		return false;
	},
	/** @id compono_removeClassName */
	removeClassName:function( _class, scope, index){
		if(this.hasClassName( _class, scope) == true){
			if(typeof(index)=="number"){ 
				var a = scope.className.split(" ");
				delete a[index];
				scope.className = a.join(" ");
			}else{
				scope.className = scope.className.replace(new RegExp("(^|\\s+)"+_class+"(\\s+|$)","gi")," ");
			};
			return true;
		};
		return false;
	},
	/** @id compono_toggleClassName */
	toggleClassName:function(_class, scope, index, forceChoose){
		if(typeof(forceChoose) != "boolean"){
			forceChoose = !this.hasClassName(_class, scope);
		};
		return (forceChoose?this.appendClassName:this.removeClassName).apply(this,[_class, scope, index]);
	},
	/**
	* Acha a posicao real do elemento baseado na posicao dos pais
	* http://www.quirksmode.org/js/findpos.html
	* @param {Node} Escopo que quer "saber" a posicao
	* @return {Object} Objeto com as propriedades TOP, LEFT
	*/
	findElementPosition:function(scope){
		var l = t = 0;
		if(scope.offsetParent) {
			l = scope.offsetLeft;
			t = scope.offsetTop;
			while((scope = scope.offsetParent)) {
				l += scope.offsetLeft;
				t += scope.offsetTop;
			}
		}
		return {left:l,top:t};
	},
	/** @id compono_isDisabled */
	isDisabled:function(n,e){
		if( n.getAttribute("disabled") ){
			this.Event.preventDefault(e||window.event);
			return false;		
		}
		return true;
	},
	/** @id compono_namespaces */
	namespaces:{
		ns:"http://www.tlantic.com.br/2006/compono",
		xhtml:"http://www.w3.org/1999/xhtml",
		svg:"http://www.w3.org/2000/svg",
		xbl:"http://www.mozilla.org/xbl",
		html4:"http://www.w3.org/TR/REC-html40",
		xslt:"http://www.w3.org/1999/XSL/Transform",
		xlink:"http://www.w3.org/1999/xlink"
	},
	/** @id compono_wiki_sintax */
	wiki:{
		/** @id compono_wiki_sintax_list */
		sintax:[
			{get:/!!([^!]+?)!!/gm,tag:"<q>$1</q>"},
			{get:/--([^-]+?)--/gm,tag:"<s>$1</s>"},
			{get:/''([^']+?)''/gm,tag:"<em>$1</em>"},
			{get:/\*\*([^*]+?)\*\*/gm,tag:"<strong>$1</strong>"},
			{get:/__([^_]+?)__/gm,tag:"<u>$1</u>"},
			{get:/\[\[([^|]+?)\|([^\]]+?)\]\]/gm,tag:"<a href=\"$2\">$1</a>"}
		],
		/** @id compono_wiki_sintax_render */
		render:function(c){
			for(var i=0,o;o=this.sintax[i];i++){
				c = c.replace(o.get,o.tag);
			}
			return c;
		}
	},
	/** @id compono_Event */
	Event:{
		toString:function(){return this.name;},
		name:"Event",
		add:function(ev, fu, ob, bu){
			if(this.Key.isEvent(ev)){
				var c=this.Key.cache;
				if(!c[fu.__eventID__]){
					if(!fu.__eventID__){fu.__eventID__=this.GenID();};
					c[fu.__eventID__]=function(e){
						var f=arguments.callee,s=Event.Key.groups[f._event][e.keyCode];if(s){f._function.apply(f._scope,[e,s])}
					};
					c[fu.__eventID__]._event = ev;
					c[fu.__eventID__]._function = fu;
					c[fu.__eventID__]._scope = ob;
					ev=this.Key.defaultEvent;
					fu=c[fu.__eventID__];
				}else{
					return false;
				}
			};
			if(ob.attachEvent){
				if(!fu.__eventID__){fu.__eventID__=this.GenID();};
				if(!ob.__event__){ob.__event__={};};
				if(	ob.__event__[fu.__eventID__]&&ob.__event__[fu.__eventID__]._function===fu&&ob.__event__[fu.__eventID__]._event==ev){return false;};
				ob.__event__[fu.__eventID__]=function(){arguments.callee._function.apply(arguments.callee._scope,arguments);};
				ob.__event__[fu.__eventID__].toString=function(){return this._function.toString();};
				ob.__event__[fu.__eventID__]._function = fu;
				ob.__event__[fu.__eventID__]._scope = ob;
				ob.__event__[fu.__eventID__]._event = ev;
				return ob.attachEvent("on"+ev, ob.__event__[fu.__eventID__]);
			}else if(ob.addEventListener){
				return ob.addEventListener(ev,fu,bu||false);
			}else{
				ob["on"+ev] = fu;
				return true;
			};
			return false;
		},	
		remove:function(ev, fu, ob, bu){
			if(this.Key.isEvent(ev)){
				var c=this.Key.cache;
				if(c[fu.__eventID__]){
					var ofu=fu;
					fu=c[fu.__eventID__];
					ev=this.Key.defaultEvent;
					delete c[ofu.__eventID__];
					delete ofu.__eventID__;
				}
			};
			if(ob.detachEvent){
				if(ob.__event__ && ob.__event__[fu.__eventID__]){
					var ofu=fu;
					fu=ob.__event__[fu.__eventID__];
					delete ofu.__eventID__;
					delete ob.__event__[fu.__eventID__];
				}
				ob.detachEvent("on"+ev, fu);
				return true;
			}else if(ob.removeEventListener){
				ob.removeEventListener(ev,fu,bu||false);
				return true;
			}else{
				ob["on"+ev] = null;
				return true;
			};
			return false;
		},
		stopPropagation:function(e){
			if(e.stopPropagation){e.stopPropagation();}
			else{e.cancelBubble=true;}
		},
		preventDefault:function(e){
			if(e.preventDefault){e.preventDefault();}
			else{e.returnValue=false;}
		},
		fire:function(ev,ob){
			if (ob.fireEvent){
				ob.fireEvent("on"+ev);
			}else{
				var e=document.createEvent("Events")
				e.initEvent(ev,true,true);
				ob.dispatchEvent(e);
			}
		},
		GenID:function(){
			var x=Math.random()*1000.0;
			if(!this.__ids__){this.__ids__={}};
			while(this.__ids__[x]){x=Math.random()*1000.0;};
			this.__ids__[x]=true;
			return x;
		},
		Key:{
			defaultEvent:"keydown",
			cache:{},
			groups:{
				KEY_ARROWS:{37:"LEFT",38:"UP",39:"RIGHT",40:"DOWN"},
				KEY_NUMBERS:{48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9"},
				KEY_CHARACTERS:{65:"A",66:"B",67:"C",68:"D",69:"E",70:"F",71:"G",72:"H",73:"I",74:"J",75:"K",76:"L",77:"M",78:"N",79:"O",80:"Q",81:"P",82:"R",83:"S",84:"T",85:"U",86:"V",87:"W",88:"X",89:"Y",90:"Z"},
				KEY_FUNCTIONS:{112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12"},
				KEY_UP:{38:"UP"},
				KEY_DOWN:{40:"DOWN"},
				KEY_RIGHT:{39:"RIGHT"},
				KEY_LEFT:{37:"LEFT"},
				KEY_SPACE:{32:"SPACE"},
				KEY_INSERT:{45:"INSERT"},
				KEY_DELETE:{46:"DELETE"},
				KEY_HOME:{36:"HOME"},
				KEY_END:{35:"END"},
				KEY_PAGEUP:{33:"PAGEUP"},
				KEY_PAGEDOWN:{34:"PAGEDOWN"},
				KEY_TAB:{9:"TAB"},
				KEY_ENTER:{13:"ENTER"},
				KEY_BACKSPACE:{8:"BACKSPACE"},
				KEY_ESQ:{27:"ESQ"},
				KEY_MATHOPERATORS:{106:"*",107:"+",109:"-",111:"/"},
				help:{112:"F1"}
			},
			isEvent:function(ev){
				return this.groups.hasOwnProperty(ev.toUpperCase());
			}
		}
	}
};

/** @ignore */ compono.Object.prototype = compono.prototype;
/** @ignore */ compono.prototype.removeAllChildNodes = compono.removeAllChildNodes;
/** @ignore */ compono.prototype.findElementPosition = compono.findElementPosition;
/** @ignore */ compono.prototype.getAnyByAttribute = compono.getAnyByAttribute;
/** @ignore */ compono.prototype.getAnyByClassName = compono.getAnyByClassName;
/** @ignore */ compono.prototype.getAnyByTagName = compono.getAnyByTagName;
/** @ignore */ compono.prototype.appendClassName = compono.appendClassName;
/** @ignore */ compono.prototype.removeClassName = compono.removeClassName;
/** @ignore */ compono.prototype.toggleClassName = compono.toggleClassName;
/** @ignore */ compono.prototype.getByClassName = compono.getByClassName; 
/** @ignore */ compono.prototype.getByAttribute = compono.getByAttribute;
/** @ignore */ compono.prototype.hasClassName = compono.hasClassName;
/** @ignore */ compono.prototype.getByTagName = compono.getByTagName;
/** @ignore */ compono.prototype.getPrevious = compono.getPrevious;
/** @ignore */ compono.prototype.getByName = compono.getByName;
/** @ignore */ compono.prototype.getByID = compono.getByID;
/** @ignore */ compono.prototype.getNext = compono.getNext;
/** @ignore */ compono.prototype.Object = compono.Object;
/** @ignore */ compono.prototype.Event = compono.Event;
/** @ignore */ compono.prototype.getFirst = compono.getFirst;
/** @ignore */ compono.prototype.getLast = compono.getLast;
/** @ignore */ compono.prototype.getElements = compono.getElements;


/** ------------------------------------------------------------------------------------------------
 *	Extensoes de objetos
 ------------------------------------------------------------------------------------------------ **/
/** @id compono_extend */
Object.extend = function(destination, source) {
  for (property in source){
	destination[property] = source[property];
  };
  return destination;
};


/** @ignore */
String.prototype.REGEXP_FORMAT_METHOD = /\{(?:([\w_-]+)(?:\:([\w_-]+))?)\}/gim;
/**	@id compono_stringFormat */
String.prototype.format = function(args){
	var a=args||arguments;
	return this.replace(this.REGEXP_FORMAT_METHOD, function(str,parentesis1,parentesis2,index,allstr){
		var x = a[parentesis1];
		switch(parentesis2){
			case "Q":
				var v="",s="";for(var i in x){v+=s+i+"="+x[i];s="&"};x=v;
				break;
		}
		return x||"";
	});
};

/** @ignore */
Array.prototype.REGEXP_FORMAT_METHOD = /\{([^}]+)\}/gim;
/** @id compono_arrayFormat */
Array.prototype.format = function(template){
	var args=this;
	return template.replace(this, function(str,parent1,index,allstr){return args[parent1];});
};




if(!Array.prototype.indexOf){
/** @id compono_arrayIndexOf */
	Array.prototype.indexOf = function(str, startIndex){
		if(!startIndex){ startIndex = 0; };
		for(var i=startIndex, s; s = this[i]; i++){
			if(str === s){ return i; };
		};
		return -1;
	};
};

if(!Array.prototype.lastIndexOf){
/** @id compono_arrayLastIndexOf */
	Array.prototype.lastIndexOf = function(str, startIndex){
		if(!startIndex){ startIndex = this.length; };
		for(var i=startIndex, s; s = this[i]; i--){
			if(str === s) return i;
		};
		return -1;
	};
};

if(!Array.prototype.forEach){
/** @id compono_arrayForEach */
	Array.prototype.forEach = function(callback, thisObject){
		if(typeof(callback) != "function"){ return false; };
		if(!thisObject){ thisObject = window; };
		for(var i=0, s; s = this[i]; i++){
			callback.apply(thisObject,[s,i,this])
		};
		return true;
	};
};

if(!Array.prototype.filter){
/** @id compono_arrayFilter */
	Array.prototype.filter = function(callback, thisObject){
		if(typeof(callback) != "function"){ return false; };
		if(!thisObject){ thisObject = window; };
		var returnArray = [];
		for(var i=0, s; s=this[i]; i++){
			if(callback.apply(thisObject,[s,i,this])){
				returnArray.push(s);
			}
		};
		return returnArray;
	};
};

if(!Array.prototype.every){
/** @id compono_arrayEvery */
	Array.prototype.every = function(callback, thisObject){
		if(typeof(callback) != "function"){ return false; };
		if(!thisObject){ thisObject = window; };
		for(var i=0, s; s=this[i]; i++){
			if(!callback.apply(thisObject,[s,i,this])){
				return false;
			}
		};
		return true;
	};
};

if(!Array.prototype.map){
/** @id compono_arrayMap */
	Array.prototype.map = function(callback, thisObject){
		if(typeof(callback) != "function"){ return false; };
		if(!thisObject){ thisObject = window; };
		var rArray = [];
		for(var i=0, s; s=this[i]; i++){
			rArray.push(	callback.apply(thisObject,[s,i,this]) || s	);
		};
		return rArray;
	};
};

/** @id compono_getMonthDays */
Date.prototype.getMonthDays = function(year, month){
	return 32 - new Date(year, month, 32).getDate();
};

/** @id compono_getByPath */
Object.getByPath = function(path, scope){
	var current, parent, base=[];
	path = path.split(".");
	current = scope || window;
	for(var i=0; current = current[ path[i] ]; i++){
		base.push(current);
		if(i == path.length-1){	break;	}
		parent = current;
	};
	base.current = current;
	base.parent = parent;
	return base;
};

/** @id compono_stringEmpty */
String.Empty = '';