 TECLA_TAB           = 9;
 TECLA_BACKSPACE     = 8;
 TECLA_ENTER         = 13;
 TECLA_END           = 35;
 TECLA_HOME          = 36;
 TECLA_SETA_ESQUERDA = 37;
 TECLA_SETA_DIREITA  = 39;
 TECLA_DELETE        = 46;
function verificaEmail(email)
	{    
		if (!email) return false;   
		var  BadChars = "*|,\":<>[]{}`\'!;Ç+?%()&$#% ";
		var  GoodChars = "@.";   
	
		for (var i = 0; i < email.length; i++) 
		{
			if (BadChars.indexOf(email.charAt(i)) != -1) 
			{
				return false;   
			}
		}
	
		for (var i = 0; i < GoodChars.length; i++) 
		{
			if (email.indexOf(GoodChars.charAt(i)) == -1) 
			{
				return false;
			}
		}   
	
		if (email.indexOf ('@.',0) != -1) 
		{
			return false;
		}   
	   return true;  
	}

function somente_numero(campo)
    {
	  var digits="0123456789"
	  var campo_temp
			for (var i=0;i<campo.value.length;i++)
			{
			campo_temp=campo.value.substring(i,i+1)
				if (digits.indexOf(campo_temp)==-1)
				{
				campo.value = campo.value.substring(0,i);
				break;
		       }
		    }
		}

function contadorCaracteres(campo)
{
	//document.getElementById("Qtd").innerText = 8-campo.value.length
		if((8-campo.value.length)==0)
			alert('Atenção! Sua senha atingiu o limite máximo de 8 caracteres.');
}


//*************** FUNCOES DO AMPLIAR IMAGEM *****************************************

var tam = 13;

function mudaFonte(tipo,elemento){
	if (tipo=="mais") {
		if(tam<16) tam+=1;
		createCookie('fonte',tam,365);
	} else {
		if(tam>10) tam-=1;
		createCookie('fonte',tam,365);
	}
	document.getElementById('mudaFonte').style.fontSize = tam+'px';
	// document.getElementById('mudaFoto').style.fontSize = tam+'px';
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	} else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

var undefined;
function isUndefined(property) {
	return (typeof property == 'undefined');
}


// float do box de publicidadec 
		function resizePublicidade(){
				var d=document;
				if (!d.getElementById('publicidadeMateria')) d.getElementById('boxesMateria').style.width='99.5%';
				if (d.getElementById('pub')!= null) {
					if (!d.getElementById('publicidadeMateria')) d.getElementById('pub').style.width='460px';
				}
			}			
			
// Popup 
function popup(lnk,pop,w,h,s) { 
	window.open(lnk,pop,'width='+w+',height='+h+',top=100,left=100,resizable=0,status=0,menubar=0,scrollbars='+s); 
}


// Largura do box descri??o do Zoom

function larguraBoxZoom(){
	if (document.getElementById('imgZoom') != null) {
		var largura = document.getElementById('imgZoom').width;	
	}	
	if (document.getElementById('fotoZoom')) document.getElementById('descricao').style.width=largura;
}
window.onload = larguraBoxZoom;

/* ----- zoom ---- */

	function getPageSize() {
		var xScroll, yScroll;
		if (window.innerHeight && window.scrollMaxY){
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else {
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		var windowWidth, windowHeight;
		if (self.innerHeight) {
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) {
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) {
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		if(yScroll < windowHeight) pageHeight = windowHeight;
		else pageHeight = yScroll;
		if(xScroll < windowWidth) pageWidth = windowWidth;
		else pageWidth = xScroll;
		arrayPageSize = {pageWidth:pageWidth,pageHeight:pageHeight,windowWidth:windowWidth,windowHeight:windowHeight}
		return arrayPageSize;
	}
	
	function getPageScroll(){
		var yScroll;
		if (self.pageYOffset) yScroll = self.pageYOffset;
		else if (document.documentElement && document.documentElement.scrollTop) yScroll = document.documentElement.scrollTop;
		else if (document.body) yScroll = document.body.scrollTop;
		arrayPageScroll = {yScroll:yScroll};
		return arrayPageScroll;
	}

 	function initZoom(div) {
		var container = document.getElementById(div);	
		var lnks = container.getElementsByTagName('a');
		for(var i=0,len=lnks.length;i<len;i++) {
			if(lnks[i].className.indexOf('linkZoom') > -1) {
				lnks[i].onclick = function() {
					openZoom(this);
					return false;
				}
			}
		}
	}
	
	function closeZoom(obj) {
		document.body.removeChild(document.getElementById('zoom'));
		document.body.removeChild(document.getElementById('sombra'));
		obj.parentNode.parentNode.parentNode.removeChild(obj.parentNode.parentNode);
	}
	
	function resizeZoom(obj) {
		var largura = obj.width;
		var altura = obj.height;
		var box = obj.parentNode.parentNode;
		var pageSize = getPageSize();
		var pageScroll = getPageScroll();
		var boxTop = pageScroll.yScroll + ((pageSize.windowHeight - altura - 26) / 2);
		var boxLeft = ((pageSize.pageWidth - largura - 40) / 2);
		box.style.top = (boxTop < 0) ? "0px" : boxTop + "px";
		box.style.left = (boxLeft < 0) ? "0px" : boxLeft + "px";
		box.style.visibility = 'visible';
		try {
			var divZoom = document.getElementById('zoom_'+obj.className);
			var divDescricao = document.getElementById('desc_'+obj.className);
			if(divZoom) divZoom.style.width = largura;
			if(divDescricao) divDescricao.style.width = largura;
		} catch(erro) {}
	}
	
	function openZoom(obj) {

		var pageSize = getPageSize();
		var fonte = '';
		var descricao = '';
		var classe = 'abc';
		var divs = obj.parentNode.getElementsByTagName('div');
		for(var i=0,len=divs.length;i<len;i++) {
			if(divs[i].className.indexOf('fonte') > -1) fonte = divs[i].innerHTML;
			if(divs[i].className.indexOf('descricao') > -1) descricao = divs[i].innerHTML;
		}
		var divContainer = document.createElement('div');
		divContainer.id = 'zoom';
		divContainer.className = 'zoom';
		divContainer.style.height = (pageSize.pageHeight + 'px');
		var divSombra = document.createElement('div');
		divSombra.id = 'sombra';
		divSombra.className = 'sombra';
		divSombra.style.height = (pageSize.pageHeight + 'px');
		document.body.appendChild(divSombra);
		var divZoom = document.createElement('div');
		divZoom.id = 'zoom_' +  classe;
		divZoom.className = 'fotoZoom';
		var spanFonte = document.createElement('span');
		spanFonte.className = 'fonte';
		spanFonte.innerHTML = fonte;
		var imgZoom = document.createElement('img');
		imgZoom.id = 'img_' +  classe;
		imgZoom.className = classe;
		imgZoom.src = obj.href;
		imgZoom.alt = 'Bio Ritmo Academia - Manaus';
		var divDescricao = document.createElement('div');
		divDescricao.id = 'desc_' +  classe;
		divDescricao.className = 'descricao';
		var p = document.createElement('p');
		p.innerHTML = descricao;
		var divFechar = document.createElement('div');
		divFechar.className = 'fechar';
		var aFechar = document.createElement('a');
		aFechar.title = '';
		aFechar.innerHTML = 'Fechar';
		aFechar.href = '#';
		aFechar.onclick = function() {
			closeZoom(this);
			return false;
		}
		divDescricao.appendChild(imgZoom);
		divFechar.appendChild(aFechar);
		divDescricao.appendChild(p);
		divZoom.appendChild(divFechar);
		divZoom.appendChild(spanFonte);
		divZoom.appendChild(divDescricao);
		divContainer.appendChild(divZoom);		
		document.body.appendChild(divContainer);
		if(imgZoom.width && imgZoom.width > 56) {
		 resizeZoom(imgZoom);
		}
		imgZoom.onload = function() {
		  resizeZoom(this);
		  return false;
		}	
	}						

	function verifica_form() {
			var msg = '';
			var erro = false;
			var bg = '#FFFF99';
			
			/* Nome */
			if (document.getElementById("nome").value == '') {
				erro = true;
				msg = msg + 'O campo Nome é obrigatório. \n';
				document.getElementById("nome").style.backgroundColor = bg;
			}
			/* Sexo */
			if (document.getElementById("sexo").options[document.getElementById("sexo").selectedIndex].value == '-') {
				erro = true;
				msg = msg + 'O campo Sexo é obrigatório. \n';
				document.getElementById("sexo").style.backgroundColor = bg;
			}
			/* Nascimento */
			if (document.getElementById("nascimento").value == '') {
				erro = true;
				msg = msg + 'O campo Nascimento é obrigatório. \n';
				document.getElementById("nascimento").style.backgroundColor = bg;
			}
			/* Email */
			if (document.getElementById("email").value == '') {
				erro = true;
				msg = msg + 'O campo Email é obrigatório. \n';
				document.getElementById("email").style.backgroundColor = bg;
			}
			/* DDD Residencial */
			if (document.getElementById("dddResidencial").value == '') {
				erro = true;
				msg = msg + 'O campo DDD do Telefone Residencial é obrigatório. \n';
				document.getElementById("dddResidencial").style.backgroundColor = bg;
			}
			/* Telefone Residencial */
			if (document.getElementById("telResidencial").value == '') {
				erro = true;
				msg = msg + 'O campo Telefone Residencial é obrigatório. \n';
				document.getElementById("telResidencial").style.backgroundColor = bg;
			}
			/* Rua */
			if (document.getElementById("rua").value == '') {
				erro = true;
				msg = msg + 'O campo Endereço é obrigatório. \n';
				document.getElementById("rua").style.backgroundColor = bg;
			}
			/* Numero */
			if (document.getElementById("numero").value == '') {
				erro = true;
				msg = msg + 'O campo Número é obrigatório. \n';
				document.getElementById("numero").style.backgroundColor = bg;
			}
			/* Bairro */
			if (document.getElementById("bairro").value == '') {
				erro = true;
				msg = msg + 'O campo Bairro é obrigatório. \n';
				document.getElementById("bairro").style.backgroundColor = bg;
			}
			/* Cidade */
			if (document.getElementById("cidade").value == '') {
				erro = true;
				msg = msg + 'O campo Cidade é obrigatório. \n';
				document.getElementById("cidade").style.backgroundColor = bg;
			}
			/* Estado */
			if (document.getElementById("estado").options[document.getElementById("estado").selectedIndex].value == '-') {
				erro = true;
				msg = msg + 'O campo Estado é obrigatório. \n';
				document.getElementById("estado").style.backgroundColor = bg;
			}
			/* CEP */
			if (document.getElementById("cep").value == '') {
				erro = true;
				msg = msg + 'O campo CEP é obrigatório. \n';
				document.getElementById("cep").style.backgroundColor = bg;
			}
			/* Area */
			if (document.getElementById("area").options[document.getElementById("area").selectedIndex].value == '-') {
				erro = true;
				msg = msg + 'O campo Área é obrigatório. \n';
				document.getElementById("area").style.backgroundColor = bg;
			}
			/* Curriculum */
			if (document.getElementById("anexar").value == '') {
				erro = true;
				msg = msg + 'O Currículo é obrigatório. \n';
				document.getElementById("anexar").style.backgroundColor = bg;
			}
			if (erro) {
				alert(msg);
			} else {
				document.form_oportunidade.submit();
			}
		}

function formataData(val)
{
   	var pass = val.value;
	var expr = /[0123456789]/;
		
	for(i=0; i<pass.length; i++){
		// charAt -> retorna o caractere posicionado no índice especificado
		var lchar = val.value.charAt(i);
		var nchar = val.value.charAt(i+1);
	
		if(i==0){
		   // search -> retorna um valor inteiro, indicando a posição do inicio da primeira
		   // ocorrência de expReg dentro de instStr. Se nenhuma ocorrencia for encontrada o método retornara -1
		   // instStr.search(expReg);
		   if ((lchar.search(expr) != 0) || (lchar>3)){
			  val.value = "";
		   }
		   
		}else if(i==1){
			   
			   if(lchar.search(expr) != 0){
				  // substring(indice1,indice2)
				  // indice1, indice2 -> será usado para delimitar a string
				  var tst1 = val.value.substring(0,(i));
				  val.value = tst1;				
 				  continue;			
			   }
			   
			   if ((nchar != '/') && (nchar != '')){
				 	var tst1 = val.value.substring(0, (i)+1);
				
					if(nchar.search(expr) != 0) 
						var tst2 = val.value.substring(i+2, pass.length);
					else
						var tst2 = val.value.substring(i+1, pass.length);
	
					val.value = tst1 + '/' + tst2;
			   }

		 }else if(i==4){
			
				if(lchar.search(expr) != 0){
					var tst1 = val.value.substring(0, (i));
					val.value = tst1;
					continue;			
				}
		
				if	((nchar != '/') && (nchar != '')){
					var tst1 = val.value.substring(0, (i)+1);

					if(nchar.search(expr) != 0) 
						var tst2 = val.value.substring(i+2, pass.length);
					else
						var tst2 = val.value.substring(i+1, pass.length);
	
					val.value = tst1 + '/' + tst2;
				}
   		  }
		
		  if(i>=6){
			  if(lchar.search(expr) != 0) {
					var tst1 = val.value.substring(0, (i));
					val.value = tst1;			
			  }
		  }
	 }
	
     if(pass.length>10)
		val.value = val.value.substring(0, 10);
	 	return true;
}

