messageObj = new DHTML_modalMessage();
messageObj.setShadowOffset(5);

function fecharJanela() {
	messageObj.close();
}

function popupDinamico(url) {
	messageObj.setSource(url);
	messageObj.setCssClassMessageBox(false);
	messageObj.setSize(600, 200);
	messageObj.setShadowDivVisible(true);
	messageObj.display();
}

function popupDinamico2(url, height) {
	messageObj.setSource(url);
	messageObj.setCssClassMessageBox(false);
	messageObj.setSize(640, height);
	messageObj.setShadowDivVisible(true);
	messageObj.display();
}

function popupDinamico3(url, width, height) {
	messageObj.setSource(url);
	messageObj.setCssClassMessageBox(false);
	messageObj.setSize(width, height);
	messageObj.setShadowDivVisible(true);
	messageObj.display();
}

function confirmar(texto, url) {
	if (confirm(texto)) {
		setTimeout("location.href = '" + url + "'", 70);
	}
}

function espacamento(padding) {
         var novoDiv = document.createElement("div");
         novoDiv.style.padding = padding + "px 0px 0px 0px";
         return novoDiv;
}

function linha(padding, largura) {
         var novoDiv = document.createElement("div");
         novoDiv.appendChild(this.espacamento(padding));
         var novoDiv2 = document.createElement("div");
         novoDiv2.id = "linha";
         novoDiv2.style.borderWidth = largura + "px 0px 0px 0px";
         novoDiv.appendChild(novoDiv2);
         novoDiv.appendChild(this.espacamento(padding));
         return novoDiv;
}

function montarA(href, title, objeto, texto, classe) {
         var novoA = document.createElement("a");
         novoA.href = href;
         novoA.title = title;
         if (objeto) { novoA.appendChild(objeto); }
         if (texto) { novoA.innerHTML = texto; }
         novoA.className = classe;
         return novoA;
}

function montarABlank(href, objeto, texto, classe) {
         var novo_a = document.createElement("a");
         novo_a.href = href;
         novo_a.target = "_blank";
         if (objeto) {novo_a.appendChild(objeto);}
         if (texto) {novo_a.innerHTML = texto;}
         novo_a.className = classe;
         return novo_a;
}

function montarDiv(div, objeto, texto) {
         var novoDiv = document.createElement("div");
         novoDiv.id = div;
         if (objeto) { novoDiv.appendChild(objeto); }
         if (texto) { novoDiv.innerHTML = texto; }
         return novoDiv;
}

function montarImg(src, alt, height, width) {
         var novaImg = document.createElement("img");
         novaImg.src = src;
         novaImg.alt = alt;
         if (height) { novaImg.height = height; }
         if (width) { novaImg.width = width; }
         return novaImg;
}

function popup(url, nome, altura, largura) {
	var left = (screen.width - largura) / 2;
	var top = (screen.height - altura) / 2;
	var parametros = "width = " + largura + ", height = " + altura;
	parametros += ", top = " + top + ", left = " + left;
	parametros += ", directories = no";
	parametros += ", location = no";
	parametros += ", menubar = no";
	parametros += ", resizable = no";
	parametros += ", scrollbars = no";
	parametros += ", status = yes";
	parametros += ", toolbar = no";
	newwin = window.open(url, nome, parametros);
	if (window.focus) {
		newwin.focus();
	}
	return false;
}

function popupScroll(url, nome, altura, largura) {
	var left = (screen.width - largura) / 2;
	var top = (screen.height - altura) / 2;
	var parametros = "width = " + largura + ", height = " + altura;
	parametros += ", top = " + top + ", left = " + left;
	parametros += ", directories = no";
	parametros += ", location = no";
	parametros += ", menubar = no";
	parametros += ", resizable = no";
	parametros += ", scrollbars = yes";
	parametros += ", status = yes";
	parametros += ", toolbar = no";
	newwin = window.open(url, nome, parametros);
	if (window.focus) {
		newwin.focus();
	}
	return false;
}

function mascara(o, f) {
	v_obj = o;
	v_fun = f;
	setTimeout("execmascara()", 1);
}

function execmascara() {
	v_obj.value = v_fun(v_obj.value);
}

function mCep(v) {
	v = v.replace(/\D/g, "");
	v = v.replace(/^(\d{5})(\d)/, "$1-$2");
	return v;
}

function mData(v) {
	v = v.replace(/\D/g, "");
	v = v.replace(/(\d{2})(\d)/, "$1/$2");
	v = v.replace(/(\d{2})(\d)/, "$1/$2");
	v = v.replace(/(\d{4})(\d)/, "$1/$2");
	return v;
}

function mTelefone(v) {
	v = v.replace(/\D/g, "");
	v = v.replace(/^(\d\d)(\d)/g, "($1) $2");
	v = v.replace(/(\d{4})(\d)/, "$1-$2");
	return v;
}

function mCpf(v) {
	v = v.replace(/\D/g, "");
	v = v.replace(/(\d{3})(\d)/, "$1.$2");
	v = v.replace(/(\d{3})(\d)/, "$1.$2");
	v = v.replace(/(\d{3})(\d{1,2})$/, "$1-$2");
	return v;
}

function mSoNumeros(v) {
	return v.replace(/\D/g, "");
}

function mCnpj(v) {
	v = v.replace(/\D/g, "");
	v = v.replace(/^(\d{2})(\d)/, "$1.$2");
	v = v.replace(/^(\d{2})\.(\d{3})(\d)/, "$1.$2.$3");
	v = v.replace(/\.(\d{3})(\d)/, ".$1/$2");
	v = v.replace(/(\d{4})(\d)/, "$1-$2");
	return v;
}

function mSite(v) {
	v = v.replace(/^http:\/\/?/, "");
	dominio = v;
	caminho = "";
	if (v.indexOf("/") > -1) {
		dominio = v.split("/")[0];
	}
	caminho = v.replace(/[^\/]*/, "");
	dominio = dominio.replace(/[^\w\.\+-:@]/g, "");
	caminho = caminho.replace(/[^\w\d\+-@:\?&=%\(\)\.]/g, "");
	caminho = caminho.replace(/([\?&])=/, "$1");
	if (caminho != "") {
		dominio = dominio.replace(/\.+$/, "");
	}
	v = "http://" + dominio + caminho;
	return v;
}

function exibirDataHoraAtual(modelo, alvo) {
	var DataAtual = new Date();

	var h_ano = DataAtual.getFullYear();
	var h_mes = DataAtual.getMonth();
	var h_dia = DataAtual.getDate();
	var h_semana = DataAtual.getDay();
	var h_horas = DataAtual.getHours();
	var h_minutos = DataAtual.getMinutes();
	var h_segundos = DataAtual.getSeconds();

	var a_semana = new Array(7);
	var a_mes = new Array(12);

	a_semana[0] = 'Domingo';
	a_semana[1] = 'Segunda-Feira';
	a_semana[2] = 'Ter&ccedil;a-Feira';
	a_semana[3] = 'Quarta-Feira';
	a_semana[4] = 'Quinta-Feira';
	a_semana[5] = 'Sexta-Feira';
	a_semana[6] = 'S&aacute;bado';

	a_semana[0] = 'Domingo';
	a_semana[1] = 'Segunda-Feira';
	a_semana[2] = 'Terça-Feira';
	a_semana[3] = 'Quarta-Feira';
	a_semana[4] = 'Quinta-Feira';
	a_semana[5] = 'Sexta-Feira';
	a_semana[6] = 'Sábado';

	h_semana = a_semana[h_semana];

	a_mes[0]  = 'Janeiro';
	a_mes[1]  = 'Fevereiro';
	a_mes[2]  = 'Março';
	a_mes[3]  = 'Abril';
	a_mes[4]  = 'Maio';
	a_mes[5]  = 'Junho';
	a_mes[6]  = 'Julho';
	a_mes[7]  = 'Agosto';
	a_mes[8]  = 'Setembro';
	a_mes[9]  = 'Outubro';
	a_mes[10] = 'Novembro';
	a_mes[11] = 'Dezembro';

	h_mes = a_mes[h_mes];

	if (h_horas < 10) {
		h_horas = '0' + h_horas;
	}

	if (h_minutos < 10) {
		h_minutos = '0' + h_minutos;
	}

	if (h_segundos < 10) {
		h_segundos = '0' + h_segundos;
	}

	switch (modelo) {
		case 'completo':
		horario_atual = h_semana + ', ' + h_dia + ' de ' + h_mes + ' de ' + h_ano + '. ' + h_horas + ':' + h_minutos + '.' + h_segundos;
		break;
		case 'data_longa':
		horario_atual = h_semana + ', ' + h_dia + ' de ' + h_mes + ' de ' + h_ano;
		break;
		case 'data_curta':
		horario_atual = h_dia + ' de ' + h_mes + ' de ' + h_ano;
		break;
		case 'data_simples':
		horario_atual = h_dia + '.' + h_mes + '.' + h_ano;
		break;
		default:
		horario_atual = h_horas + ':' + h_minutos + '.' + h_segundos;
	}

	document.getElementById(alvo).innerHTML = horario_atual;
}

function exibirDataHoraAtual2(modelo, alvo) {
	exibirDataHoraAtual(modelo, alvo);
	setInterval("exibirDataHoraAtual('" + modelo + "', '" + alvo + "')", 1000);
}

function mouseSobre(what) {
	if (what.className != "selecionado") {
		what.className = "selecionado2";
	}
}

function mouseFora(what) {
	if (what.className != "selecionado") {
		what.className = "naoSelecionado";
	}
}

function mouseSobre2(what, classe) {
	if (what.className != "selecionado") {
		what.className = "selecionado2";
	}
}

function mouseFora2(what, classe) {
	if (what.className != "selecionado") {
		what.className = classe;
	}
}