// JavaScript Document

function mudastatus() {
	window.status = "Jornal Brasileiro de Pneumologia";
}

var loginacess = 0;
var senhaacess = 0;

function limpalogin() {
	if(loginacess == 0) {
		document.getElementById("login").value = "";
		loginacess = 1;
	}
}

function limpasenha() {
	if(senhaacess == 0) {
		document.getElementById("senha").value = "";
		senhaacess = 1;
	}
}

function restituicampo(campo) {
	if(!document.getElementById(campo).value && campo == "login") {
		document.getElementById(campo).value = "Login"
		loginacess = 0;
	}
	if(!document.getElementById(campo).value && campo == "senha") {
		document.getElementById(campo).value = "Senha"
		//document.getElementById("senha").type = "text";
		senhaacess = 0;
	}
}
//Mensagem do botão direitp
var message="® Copyright Jornal Brasileiro de Pneumologia - All rights reserved"; // Message for the alert box
function click(e) {
if (document.all) {
if (event.button == 2) {
//alert(message);
return false;
}
}
if (document.layers) {
if (e.which == 3) {
alert(message);
return false;
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
//Funcões para Troca de fundo da tabela
function mover(local){
	//local.style.backgroundImage = "../images/back_menu_over.gif";
	local.bgColor = "#D80A0A";
	//local.background = "../images/back_menu_over.gif";
}
function mout(local){
	local.bgColor = "";
	//local.background = "";
	//local.style.backgroundImage = "";
}
function valida_email(campoform)
{
	email = campoform.value;
    if (email)
		{
		p=email.indexOf('@');
		pont=email.indexOf('.');
		if (p<1 || p==(email.length-1) || pont<1 || pont==(email.length-1))
			{
				alert ('Invalid e-mail.');
	    		campoform.value = '';
	    		campoform.focus();
				return false;
			}
		} else {
			alert ('Invalid e-mail.');
  		campoform.value = '';
	    campoform.focus();
		return false;
		}
}
function valida_tel(campo) {
   var valor='';
   var digito = false;
   a = campo.value;
   if (a) {
   num = a.length;
   for (f=0;f<num;f++)
     {
     if (parseInt(a.substr(f,1)) || a.substr(f,1)=='0') 
        if ((a.substr(f,1) != '0') || digito) valor = valor + '' + a.substr(f,1);
        if (parseInt(a.substr(f,1)) && a.substr(f,1) != '0') digito = true;
     };
   num = valor.length;
   if (num < 9 || num > 10)
      {
      alert ('- Invalid phone number. \nEnter code area and phone.\nEx: (11) 1234-5678');
      campo.value = '';
      campo.focus();
      }
	  else
	  {
	  if (num == 9) valor = '(' + valor.substr(0, 2) + ') ' + valor.substr(num-7, 3) + '-' + valor.substr(num-4, 4);
	  if (num == 10) valor = '(' + valor.substr(0, 2) + ') ' + valor.substr(num-8, 4) + '-' + valor.substr(num-4, 4);
	  campo.value = valor;
	  }
   }
}