var urlBase = location.protocol + '//' + location.host + '/';
if(location.host == 'www'){
	var pos = location.pathname.indexOf('/', 1);
	urlBase += location.pathname.substr(1, pos);
}else{
//	urlBase += 'novo/';
}

String.prototype.trim = function(c, t){
    return c = "[" + (c == undefined ? " " : c.replace(/([\^\]\\-])/g, "\\\$1")) + "]+",
    this.replace(new RegExp((t != 2 ? "^" : "") + c + (t != 1 ? "|" + c + "$" : ""), "g"), "");
};

isDate = function(y, m, d){
		if(!m){
			m = /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/;
		}
		if(!d){
			d = {d: 3, m: 2, y: 1};
		}
        if(typeof y == "string" && m instanceof RegExp && d){
            if(!m.test(y)) return 1;
            y = RegExp["$" + d.y], m = RegExp["$" + d.m], d = RegExp["$" + d.d];
        }
        d = Math.abs(d) || 0, m = Math.abs(m) || 0, y = Math.abs(y) || 0;
        return d < 1 || d > 31 ? 2 : m < 1 || m > 12 ? 3 : /4|6|9|11/.test(m) && d == 31 ? 4
        : m == 2 && (d > ((y = !(y % 4) && (y % 1e2) || !(y % 4e2)) ? 29 : 28)) ? 5 + !!y : 0;
};

String.prototype.isCPF = function(){
    var c = this;
    if((c = c.replace(/[^\d]/g,"").split("")).length != 11) return false;
    if(new RegExp("^" + c[0] + "{11}$").test(c.join(""))) return false;
    for(var s = 10, n = 0, i = 0; s >= 2; n += c[i++] * s--);
    if(c[9] != (((n %= 11) < 2) ? 0 : 11 - n)) return false;
    for(var s = 11, n = 0, i = 0; s >= 2; n += c[i++] * s--);
    if(c[10] != (((n %= 11) < 2) ? 0 : 11 - n)) return false;
    return true;
};

String.prototype.isCNPJ = function(){
    var b = [6,5,4,3,2,9,8,7,6,5,4,3,2], c = this;
    if((c = c.replace(/[^\d]/g,"").split("")).length != 14) return false;
    for(var i = 0, n = 0; i < 12; n += c[i] * b[++i]);
    if(c[12] != (((n %= 11) < 2) ? 0 : 11 - n)) return false;
    for(var i = 0, n = 0; i <= 12; n += c[i] * b[i++]);
    if(c[13] != (((n %= 11) < 2) ? 0 : 11 - n)) return false;
    return true;
};

String.prototype.isEmail = function(){
	return /^[A-Z0-9._%-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,6}$/i.test(this);
}

String.prototype.pad = function(l, s, t){
    return s || (s = " "), (l -= this.length) > 0 ? (s = new Array(Math.ceil(l / s.length)
        + 1).join(s)).substr(0, t = !t ? l : t == 1 ? 0 : Math.ceil(l / 2))
        + this + s.substr(0, l - t) : this;
};

// FUNÇÃO PARA MOSTRAR DIV
var varAtivado = false
			
function mostraConteudo(id){
	if ( id == varAtivado) {
		return
		}
	if (document.getElementById(id).style.display == '') {
		document.getElementById(id).style.display = 'none';
		varAtivado = false;
	} else {
		document.getElementById(id).style.display = '';
		varAtivado ? document.getElementById(varAtivado).style.display = 'none' : null;
		varAtivado = id;
	}
}

Number.prototype.toMoney = function(c, d, t){
	var n = this;
	var negative = parseFloat(n) < 0;
    var m = (
		c = Math.abs(c) + 1 ? 
			c 
		: 
			2, 
		d = d || ",", 
		t = t || ".",
        /(\d+)(?:(\.\d+)|)/.exec(n + "")
	), 
	x = m[1].length > 3 ? 
		m[1].length % 3 
	: 
		0;
    return (
		negative ?
			'-'
		:
			'') 
		+ (x ? 
			m[1].substr(0, x) + t 
		: 
			"") 
		+ m[1].substr(x).replace(/(\d{3})(?=\d)/g, "$1" + t) 
		+ (c ? d + (+m[2] || 0).toFixed(c).substr(2) : "");
};

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}