function extLinks() {
	var links = document.getElementsByTagName('a');
	for (i=links.length;i!=0;i--) {
		var a = links[i-1];
		if (a.className == 'blank') {
		/*
			if (!a.href.indexOf('http:\/\/') && a.href.indexOf('http://www.ellopuma.com.br/')) a.onclick = function() {
				extPop(this.href);
				return false;
			};
*/
		a.setAttribute("target", "_blank");
		};
	};
};

function extPop(url) {
	newWin = window.open(url,"_blank","top=0,left=0,height="+screen.availHeight+",width="+screen.availWidth+",location,scrollbars,directories,menubar,resizeable,status,toolbar");
};
function mascara(o){
    v_obj=o
    setTimeout("execmascara()",1);
};
function mascaraData(o){
    v_obj=o
    setTimeout("execmascaraData()",1);
};

function execmascara(){
    v_obj.value=telefone(v_obj.value);
};
function execmascaraData(){
    v_obj.value=data(v_obj.value);
};

function execTelefone(v_obj){
	v_obj.value=telefone(v_obj.value);
};

function telefone(v){
    v=v.replace(/\D/g,"");                 //Remove tudo o que não é dígito
    v=v.replace(/^(\d\d)(\d)/g,"($1) $2"); //Coloca parênteses em volta dos dois primeiros dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2");    //Coloca hífen entre o quarto e o quinto dígitos
    return v;
};
function data(v) {
    v=v.replace(/\D/g,"");
    v=v.replace(/^(\d{2})(\d)/g,"$1/$2");
    v=v.replace(/(\d{2})(\d)/,"$1/$2");
    return v;
};

function validaForm(form) {
	var nome = form.remetente_nome.value;
	var email = form.remetente_email.value;
	var destinatario = form.destinatario.value;
	
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	if (!filter.test(destinatario)) {
		alert('E-mail destinatário inválido.');
		form.destinatario.focus();
		return false;
	}
	else {
		return true;
	};
};

function validaForm2(form,i1,i2,i3,i4) {
	/*var nome = form.nome.value;*/
	var telefone = form.telefone.value;
	var email = form.email.value;
	var texto_mensagem = form.texto_mensagem.value;
	/*if (i1 && (nome == "")) {
		alert("Escreva seu nome.");
		form.nome.focus();
		return false;
	};*/
	var filter  = /\(?\d{2}\)?\s?\d{4}-\d{4}/;
	
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	/*if (i3 && (!filter.test(email))) {
		alert('E-mail inválido.');
		form.email.focus();
		return false;
	};*/
	if (i4 && (texto_mensagem == "")) {
		alert('Escreva sua mensagem.');
		form.texto_mensagem.focus();
		return false;
	}
	else {
		return true;
	};
};

function abreCartao(id) {
	var pagina = "includes/rh_cartao_exibir.php?id="+id;
	var largura = 600;
	var altura = 432;
	var direita=(screen.width) ? ((screen.width-largura)/2) : 0;
	var topo=(screen.height) ? ((screen.height-altura)/2) : 0;
	var Open=window.open(pagina,"_blank","top="+topo+",left="+direita+",height="+altura+",width="+largura);
};

function mudaAltura() {
	if (document.getElementById("Container")) {
		alturaConteudo = document.getElementById("Container").offsetHeight;
		if (alturaConteudo > 339) {
			if (document.all&&document.getElementById) {
				ajuste = -5;
			} else {
				ajuste = 37;
			};
			document.getElementById("Menu").style.height = alturaConteudo+ajuste+"px";
		};
	};
};

onload = function() {
	mudaAltura();
	extLinks();
	if (document.getElementById("FormTalentos")) { iniciaTalentos(); }
}
function abrePopup(url,alt,lar) {
	var pagina = url;
	var largura = lar;
	var altura = alt;
	var direita=(screen.width) ? ((screen.width-largura)/2) : 0;
	var topo=(screen.height) ? ((screen.height-altura)/2) : 0;
	window.open(pagina,"janela1","top="+topo+",left="+direita+",height="+altura+",width="+largura+",scrollbars=NO");
	//var Open=window.open(pagina,"_blank","top="+topo+",left="+direita+",height="+altura+",width="+largura);
};
function abrePopup2(url,alt,lar) {
	var pagina = url;
	var largura = lar;
	var altura = alt;
	var direita=(screen.width) ? ((screen.width-largura)/2) : 0;
	var topo=(screen.height) ? ((screen.height-altura)/2) : 0;
	window.open(pagina,"janela1","top="+topo+",left="+direita+",height="+altura+",width="+largura+",scrollbars=yes");
	//var Open=window.open(pagina,"_blank","top="+topo+",left="+direita+",height="+altura+",width="+largura);
};
