/*
Tratamento de Cookies
*/

function OCookies() {
	var v;
	
	function _get(c) {
		var i, f, p;
		c=c.toLowerCase();
		i=0; f=v.length-1; p=Math.floor((i+f)/2);
		while ((i<=f) && (v[p][0]!=c)) {
			if (v[p][0]<c) {i=p+1;} else {f=p;}
			p=Math.floor((i+f)/2);
		}
		return ((v[p][0]==c)?v[p][1]:null);
	}

	function _recarregar() {
		var l, x, i;
		v=new Array();
		l=document.cookie.split(';');
		for (x=0; x<l.length; x++) {
			i=l[x].split('=');
			i[0]=i[0].toLowerCase().replace(' ','');
			v.push(i);
		}
		v.sort(function (a, b) {
			return ((a==b)?0:((a<b)?-1:1));
		});
		this.cookies=v;
	}
	
	this.get=_get;
	this.recarregar=_recarregar;
	_recarregar();
}
