window.jBr = function(id,loc){
	if(!loc)loc = window;
	if(typeof id=='string')return loc.document.getElementById(id);
	return id;
}
window.$ = jBr;
jBr.extend = function(){
	var alvo=this, t=alvo, fonte, p, i=0;
	if(arguments.length>1){
		i++;
		alvo = t = arguments[0];
	}
	for(; fonte=arguments[i]; i++){
		for(var pp in fonte){
			p = fonte[pp];
			if(pp.charAt(0)!='@'){
				if(p&&p.splice){
					var tp = t[pp];
					t[pp] = tp&&tp.splice?tp.concat(p):[].concat(p);
				}else if(p&&(typeof p=='object')){
					t[pp] = jBr.extend(t[pp]||{},p);
				}else t[pp] = p;
				continue;
			}
			if(pp=='@init')p.call(t);
		}
	}
	return alvo;
}
// *********************** //
//Number
jBr.extend(Number.prototype,{
abs:function(){return Math.abs(this);},
round:function(){return Math.round(this);},
floor:function(){return Math.floor(this);},
ceil:function(){return Math.ceil(this);},
pow:function(ex){return Math.pow(this,ex);},
sqrt:function(){return Math.sqrt(this);}
});
//String
jBr.extend(String.prototype,{
trim:function(s,n){
	var r = this.replace(/^\s*|\s*$/g,'');
	if(s)r = r.replace(/[ \t]{2,}/g,' ');
	if(n){
		r = r.replace(/\r?\n/g,'\n').split('\n');
		for(var i=0; i<r.length; i++)r[i] = r[i].trim();
		r = r.join('\n');
	}
	return r;
},
ltrim:function(){return this.replace(/^\s+\s/g,'');},
rtrim:function(){return this.replace(/\s+\s$/g,'');},
explode:function(){return this.split(' ');},
reverse:function(){return this.split('').reverse().join('');},
sort:function(){return this.split('').sort().join('');},
low:function(){return this.toLowerCase();},
upp:function(){return this.toUpperCase();},
tag:function(c){
	var a = ['À|Á|Â|Ã|Ä|Å','à|á|â|ã|ä|å|ª|@','ß','Ç|¢','ç','È|É|Ê|Ë|€','è|é|ê|ë|&','Ì|Í|Î|Ï','ì|í|î|ï','£','Ñ','ñ','Ò|Ó|Ô|Õ|Ö','ò|ó|ô|õ|ö|º','\\$','†','Ù|Ú|Û|Ü','ù|ú|û|ü','Ý','ý|ÿ','¹','²','³','"|\'|\\?|!|\\.|:|,|;','\\s+','[^\\w-]'];
	var a2 = ['A','a','B','C','c','E','e','I','i','L','N','n','O','o','S','t','U','u','Y','y','1','2','3','','-','_'];
	var r = this;
	for(var i=0; i<a.length; i++)r = r.replace(new RegExp(a[i],'g'),a2[i]);
	if(c===1)return r.low();
	if(c===2)return r.upp();
	return r;
},
ucf:function(){
	var c = this.ltrim().charAt(0);
	return this.replace(c,c.upp());
},
ucw:function(s,n,l){
	if(l==null)l = 3;
	var w = this.trim(!s,!n).explode();
	for(var i=0,v; v=w[i]; i++){
		if(v.length>=l)w[i] = v.ucf();
	}
	return w.join(' ');
},
lpad:function(c,q){
	var v = this;
	for(var i=v.length; i<q; i++)v = c+v;
	return v;
},
rpad:function(c,q){
	var v = this;
	for(var i=v.length; i<q; i++)v += c;
	return v;
},
subs:function(i,f){
	if(i<0)i += this.length;
	if(f<0)f += this.length;
	return this.substring(i,f);
}});
// *********************** //
jBr.extend({
agent:navigator.userAgent.low(),
platform:navigator.platform.low(),
XHTMLNS:'http://www.w3.org/1999/xhtml',
isOpera:function(){
	return(jBr.agent.indexOf('opera')!=-1);
},
isIE:function(b){
	var a='msie';
	if(jBr.isNum(b))var a=a+' '+b;
	return(jBr.agent.indexOf(a)!=-1&&!jBr.isOpera());
},
isNum:function(a){
	return(typeof a=='number');
},
id:function(){
	var c=[];
	for(var b=0;b<arguments.length;b++){
		var a=arguments[b];
		if(typeof a=="string"){
			if(document.getElementById)a=document.getElementById(a);
			else if(document.all)a=document.all[a];
			else if(document.layers)a=document.layers[a];
			else if(document[a])a=document[a];
		}
		if(arguments.length==1)return a;
		c.push(a);
	}
	return c;
},
on:function(e){
	if(!jBr.isFn(this.e[e]))return this;
	var ag=[];
	for(var i=0,v; v=arguments[++i];)ag[i] = v;
	this.e[e].apply(this,ag);
	return this;
},
isFn:function(o){
	return typeof o=='function'&&(!Function.prototype.call||typeof o.call=='function')?true:false;
},
encode:function(o,r){
	o = o||{};
	r = r||null;
	var v='';
	for(var k in o){
		if(!/string|number|boolean/.test(typeof o[k]))continue;
		v += escape(k)+'='+escape(o[k])+'&';
	}
	return v?v.replace(/&$/,''):r;
},
XMLHttpRequest:function(){
	if(typeof XMLHttpRequest!='undefined')return new XMLHttpRequest();
	var a = ['Microsoft.XMLHTTP','Msxml2.XMLHTTP','Msxml2.XMLHTTP.6.0','Msxml2.XMLHTTP.4.0','Msxml2.XMLHTTP.3.0'];
	for(var i=0,v; v=a[i]; i++){
		try{
			return new ActiveXObject(v);
		}catch(e){}
	}
	return null;
},
opacity:function(o,a,v){
	if(a==100)a = 99.99999;
	o.style.opacity = (a/100)+'';
	o.style.filter = 'alpha(opacity='+a+')';
	if(v===0);
	else if(v===1)o.style.visibility = a?'':'hidden';
	else o.style.display = a?'':'none';
},
before:function(el,ref){
	if(!el.splice)el = [el];
	for(var i=0,o;o=el[i++];)ref.parentNode.insertBefore(o,ref);
},
after:function(el,ref){
	if(!el.splice)el = [el];
	for(var i=el.length,o;o=el[--i];)ref.parentNode.insertAfter(o,ref);
},
append:function(pai,el){
	if(!el.splice)el = [el];
	for(var i=0,o;o=el[i++];)pai.appendChild(o);
},
prepend:function(pai,el){
	if(!pai.firstChild)jBr.append(pai,el);
	else jBr.before(el,pai.firstChild);
},
removeAll:function(el){
	if(!(el&&el.NodeType==1))return;
	while(el.hasChildNodes())el.removeChild(el.lastChild);
},
filho:function(o,el){
	if(!el)el = '';
	var r = [];
	if(!o)return r;
	if(o&&o.nodeType!==1)return r;
	for(var i=0,j=0,v; v=o.childNodes[i]; i++){
		if(v.nodeType!=1)continue;
		if(el&&(','+el+',').indexOf(v.nodeName.low())<0)continue;
		r[j++] = v;
	}
	return r;
},
each:function(a,fn,ref){
	if(!a)return;
	if(!fn)return;
	if(!a.slice)a = [a];
	for(var i=0,v; v=a[i]; i++)fn.call((ref?ref:v),i,v);
}
});
// *********************** //
// jBr.ajax		v 1.0
jBr.ajax = function(){
	this.a = jBr.XMLHttpRequest();
}
jBr.ajax.prototype = {e:{},
on:jBr.on,
r:function(n,v){
	this.a.setRequestHeader(n,v);
	return this;
},
o:function(url,m,a,s,r){
	a = a?true:false;
	if(!this.a){
		alert('Esse navegador não suporta Ajax.');
		return this;
	}
	this.a.open(m,url,a);
	for(var k in r)this.r(k,r[k]);
	this._fn();
	this.a.send(jBr.encode(s));
	return this;
},
_fn:function(){
	this.on('ini');
	var t = this;
	this.a.onreadystatechange = function(){
		t._onr();
	}
	return this;
},
_onr:function(){
	this.rst = this.a.readyState;
	if(this.rst==4){
		this.stt = this.a.status;
		this.txt = this.a.responseText;
		this.xml = this.a.responseXML;
	}
	this.on('st'+this.rst);
	return this;
},
t:function(){
	return this.a?true:false;
},
c:function(){
	this.e = {};
	return this;
}
};
// *********************** //
jBr.animar = {st:'width',ep:'[a]px',a:100,to:0,min:.2,v:2,t:33,id:null,e:{},
on:jBr.on,
set:function(v,t){
	if(v!=null)this.a = v;
	if(t!=null)this.to = t;
	return this.onset().on('set');
},
onset:function(){
	this.o.style[this.st] = this.ep.replace(/(\[a\])/,this.a);
	return this;
},
time:function(s){
	var _ = this;
	if(!_.id||s)_.id = setTimeout(function(){_.stop().go();},_.t);
	return _;
},
stop:function(){
	clearTimeout(this.id);
	this.id = null;
	return this.on('stop');
},
go:function(t){
	if(t!=null){
		this.stop().to = t;
		this.on('ini');
	}else{
		if(this.id)return this;
		t = this.to;
	}
	if(t!=this.a){
		if(Math.abs((this.a-t)/this.v)<=this.min)this.a = t;
		else this.a += (t-this.a)/this.v;
		this.set().on('run').time();
	}else this.on('fim');
	return this;
}};
// *********************** //
jBr.fade = function(o,e){
	jBr.extend(this,jBr.animar,{onset:function(){jBr.opacity(this.o,this.a);return this;}},o);
	this.o = e;
}
// *********************** //
jBr.anime = function(o,e){
	jBr.extend(this,jBr.animar,o);
	this.o = e;
}
// *********************** //
jBr.mask = function(){
	this.divobj;
	this.show = function(){
		if(!$('xdivmasking')){
			var divEle = document.createElement('div');
			divEle.setAttribute('id','xdivmasking');
			document.body.appendChild(divEle);
			var divSty = jBr('xdivmasking').style;
			divSty.position = 'absolute';
			divSty.top = '0px';
			divSty.left = '0px';
			divSty.zIndex = '46';
			divSty.opacity = '.50';
			divSty.backgroundColor = '#000';
			divSty.filter = 'alpha(opacity=50)';

			var divFram = document.createElement('iframe');
			divFram.setAttribute('id','xmaskframe');
			document.body.appendChild(divFram);
			divSty = jBr('xmaskframe').style;
			divSty.position = 'absolute';
			divSty.top = '0px';
			divSty.left = '0px'; 
			divSty.zIndex = '1';
			divSty.border = 'none';
			divSty.filter = 'alpha(opacity=0)';
		}
		this.divobj = jBr('xdivmasking');
		this.waitifrm = jBr('xmaskframe');

		var dsh = document.documentElement.scrollHeight;
		var dch = document.documentElement.clientHeight;
		var dsw = document.documentElement.scrollWidth;
		var dcw = document.documentElement.clientWidth;

		var bdh = (dsh>dch)?dsh:dch;
		var bdw = (dsw>dcw)?dsw:dcw;

		this.waitifrm.style.height = this.divobj.style.height = bdh+'px';
		this.waitifrm.style.width = this.divobj.style.width = bdw+'px';	
		this.waitifrm.style.display = this.divobj.style.display = 'block';
	}
	this.hide = function(){
		this.waitifrm.style.display = this.divobj.style.display = 'none';
	}
}
// *********************** //
jBr.center = function(o,p,a){
	if(!p)p = document.documentElement;
	var t = ((p.clientHeight*0.5)+p.scrollTop)-(o.offsetHeight/2);
	var l = ((p.clientWidth*0.5)+p.scrollLeft)-(o.offsetWidth/2);
	if(!a){
		if(t<p.scrollTop+15)t = p.scrollTop+15;
		if(l<p.scrollLeft+15)l = p.scrollLeft+15;
	}
	o.style.top = t+'px';
	o.style.left = l+'px';
}
// *********************** //
jBr.org = function(o,p,a){
	var t = 0;
	var l = 0;
	if(!p)p = document.documentElement;
	else{
		t = p.style.marginTop;
		l = p.style.marginLeft;
		}
	if(!a){
		if(t<(p.style.marginTop)+30)t = parseInt(t)+30;
		if(l<(p.style.marginLeft)+15)l = parseInt(t)+15;
	}
	o.style.top = t+'px';
	o.style.left = l+'px';
}
// *********************** //
function mnvMouse(o,t,nmn){
	var p = o.parentNode;
	if(!nmn){
		var f = $.filho(o);
		var a = f[0];
		var ul = f[1];
	}
	var n = p.getAttribute('mnn');
	if(!n){
		n = mnvMouse.n.length;
		mnvMouse.n[n] = {};
		p.setAttribute('mnn',''+n);
	}else n = parseInt(n,10);
	var nv = mnvMouse.n[n];
	if(t==1){
		clearTimeout(nv.i);
		if(o==nv.o)return;
		if(nv.f)nv.f();
		if(nmn)return;
		o.className = 'liover';
		a.className = 'submn hover';
		ul.className = 'over';
	}
	if(t==2){
		nv.o = o;
		nv.f = function(){
			o.className = '';
			a.className = 'submn';
			ul.className = 'out';
			nv.o = null;
			nv.f = null;
			nv.i = null;
		}
		nv.i = setTimeout(function(){nv.f();},1000);
	}
}
mnvMouse.n = [];
// *********************** //