
function Validar_Fale_Conosco()
{
	with(document.form)
	{
		if(nome.value=="")
		{
			alert("Preenchimento obrigatório!");
			nome.focus();
			return false;
		}
		if (!isEmail(email.value))
		{
			alert("Preencha corretamente o seu e-mail!");
			email.focus();
			return false;
		}
		if(mensagem.value=="")
		{
			alert("Preenchimento obrigatório!");
			mensagem.focus();
			return false;
		}
		return true;
	}
}




function Validar_Publicidade()
{
	with(document.form)
	{
		if(empresa.value=="")
		{
			alert("Preenchimento obrigatório!");
			empresa.focus();
			return false;
		}
		if(nome.value=="")
		{
			alert("Preenchimento obrigatório!");
			nome.focus();
			return false;
		}
		if (!isEmail(email.value))
		{
			alert("Preencha corretamente o seu e-mail!");
			email.focus();
			return false;
		}
		if(mensagem.value=="")
		{
			alert("Preenchimento obrigatório!");
			mensagem.focus();
			return false;
		}
		if(ddd.value=="")
		{
			alert("Por favor, incluir DDD.");
			ddd.focus();
			return false;
		}
		if(telefone.value=="")
		{
			alert("Por favor, não deixe de incluir um telefone para contato.");
			telefone.focus();
			return false;
		}
		if(cidade.value=="")
		{
			alert("Preenchimento obrigatório.");
			cidade.focus();
			return false;
		}
		return true;
	}
}



function Validar_Material(oForm)
{
	with(oForm)
	{
		if(nome.value == "")
		{
			alert("Preenchimento obrigatório!")
			nome.focus();
			return false;
		}
		if(faculdade.value == "")
		{
			alert("Preenchimento obrigatório!")
			faculdade.focus();
			return false;
		}
		if(periodo.value == "")
		{
			alert("Preenchimento obrigatório!")
			periodo.focus();
			return false;
		}
		if (!isEmail(email.value))
		{
			alert("Preencha corretamente o seu e-mail!");
			email.focus();
			return false;
		}
		if(titulo.value == "")
		{
			alert("Preenchimento obrigatório!")
			titulo.focus();
			return false;
		}
		if(area.value == "")
		{
			alert("Preenchimento obrigatório!")
			area.focus();
			return false;
		}
		if(arquivo.value == "")
		{
			alert("Preenchimento obrigatório!")
			arquivo.focus();
			return false;
		}
		return true;
	}
}

function valida()
{
	if ((document.form.nm_usuario_login.value != "")||(document.form.nm_usuario_email.value != ""))
	{
		return true;
	}
	else
	{
		alert("Preencha o campo Login ou o E-mail.");
		return false;
	}
}

function validar_contatenos()
{
	with(document.contatenos)
	{
		if (cont_nome.value == "")
		{
			alert("Digite seu nome!")
			cont_nome.focus();
			return;
		}
		if (cont_email.value == "")
		{
			alert("Digite seu e-mail!");
			cont_email.focus();
			return;
		}
		else
		{
			if (!isEmail(cont_email.value))
			{
				alert("Preencha corretamente o seu e-mail!");
				cont_email.focus();
				return;
			}
		}
		if (cont_area.value == "")
		{
			alert("Selecione a área de envio do e-mail!")
			cont_area.focus();
			return;
		}
		if (cont_msg.value == "")
		{
			alert("Digite sua mensagem!")
			cont_msg.focus();
			return;
		}
		submit();
	}
}

function validarBusca() {

	with(document.busca) {
		if(busca.value == "") {
			alert("Preechimento obrigatório!");
			busca.focus();
			return false;
		}
		else {
			if(busca.value.length < 2) {
				alert("O termo procurado deve ter no mínimo dois carateres");
				busca.focus();
				return false;
			}	
			else {
				return true;
			}
		}
	}
}

function Validar_Login()
{
	with(document.login)
	{
		if(username.value == "")
		{
			alert("Preechimento obrigatório!");
			username.focus();
			return false;
		}
		if(password.value == "")
		{
			alert("Preechimento obrigatório!");
			password.focus();
			return false;
		}

		return true;

	}
}

/*********************************************************************************
*	FUNCTION:		isEmail
*	PARAMETER:		String (Email Address)
*	RETURNS:		TRUE if the String is a valid Email address
*					FALSE if the passed string is not a valid Email Address
*	EMAIL FORMAT:	AnyName@EmailServer e.g; webmaster@hotmail.com
*					@ sign can appear only once in the email address.
**********************************************************************************/
function isEmail (theStr) {
	var atIndex = theStr.indexOf('@');
	var dotIndex = theStr.indexOf('.', atIndex);
	var flag = true;
	theSub = theStr.substring(0, dotIndex+1)

	if ((atIndex < 1)||(atIndex != theStr.lastIndexOf('@'))||(dotIndex < atIndex + 2)||(theStr.length <= theSub.length)) 
	{	flag = false; }
	else { flag = true; }
	
	return(flag);
}


/*********************************************************************************
*	FUNCTION:		validaForm()
*	PARAMETERS:		nenhum
*	CALLS:			NOTHING
*	RETURNS:		Faz o submit do form quando as condições forem atendidas.
**********************************************************************************/

function validarForm()
{
	if (document.form.nome.value == "") {
	
		alert("Preencha o campo nome.");
		document.form.nome.focus();
		return false;
	}
	if (document.form.faculdade.value == "") {
		
		alert("Preencha o campo faculdade.");
		document.form.faculdade.focus();		
		return false;
	}

	if (document.form.periodo.value == "") {

		alert("Preencha o campo periodo.");
		document.form.periodo.focus();
		return false;
	}
	
	if (document.form.titulo.value == "") {
		
		alert("Preencha o campo titulo.");
		document.form.titulo.focus();		
		return false;
	}
	
	if (document.form.area.value == "") {
		
		alert("Preencha o campo area.");
		document.form.area.focus();
		return false;
	}	

	if (document.form.arquivo.value == "") {
		
		alert("Preencha o campo arquivo.");
		document.form.arquivo.focus();
		return false;
		
	}	
	
	if (!isEmail(document.form.email.value))
			{
				alert("Preencha corretamente o seu e-mail!");
				document.form.email.focus();
				return;
			}
		return true;	
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function Validar_Resposta_Pesquisa(qt_prompt)
{
	with(document.pesquisa)
	{
		i = 0
		status = '0';
		for (i = 0; i <= (qt_prompt-1); i++)
		{
			if (pesq_resp[i].checked == true)
			{
				status = '1';
			}
		}
		if (status == '0')
		{
			alert("Selecione o item correspondente a sua opinião!");
			return;
		}
		submit();
	}
}

function enviaMedline() {
		
		if (((navigator.appName.indexOf("Netscape") > -1) && (navigator.appVersion.indexOf("4.") > -1))
				|| ((navigator.appName.indexOf("Microsoft") > -1) && (navigator.appVersion.indexOf("5.") > -1))) {
				window.open('medlinestudents.asp','_blank');
			}		
		return true;
}

function enviaComunidade() {
		if (((navigator.appName.indexOf("Netscape") > -1) && (navigator.appVersion.indexOf("4.") > -1))
				|| ((navigator.appName.indexOf("Microsoft") > -1) && (navigator.appVersion.indexOf("5.") > -1))) {
				window.open('comunidadestudents.asp');//,'_blank');
			}		
		return true;
}

function sleep(iMs){
	var dtMilliseconds = Date.parse(new Date());
	while (1){
		if (((Date.parse(new Date()) - dtMilliseconds)) > iMs)
			break;
	}
}





function NavegueRapidoTop()
{
	indice = document.Navegacao.menu_rapido.value;	
	
	if (indice == "")
	{
		alert("Selecione o site desejado!");
		return;
	}
	else
	{
		parent.opener.location = indice;
		parent.close();
	}
}
	


function NavegueRapido()
{
	if (document.Navegacao.menu_rapido.value == "")
	{
		alert("Selecione o site desejado!");
		return;
	}
	
	indice = document.Navegacao.menu_rapido.value;
	
	switch (indice)
	{
		case '1':
			window.open('/classilogin.asp', 'Medcenter');
			return;
		case '2':
			window.open('http://www.medcenter.com', 'Medcenter');
			return;
		case '3':
			window.open('/chama_medicina.asp', 'Medcenter');
			return;
		case '4':
			window.open('http://www.medlivros.com.br', 'Medcenter');
			return;
		case '5':
			window.open('http://www.medlivros.com.br/medshopping/index.htm', 'Medcenter');
			return;
		case '6':
			window.open('/chama_medstudents.asp', 'Medcenter');
			return;
		case '7':
			window.open('/chama_odontologia.asp', 'Medcenter');
			return;
	}
}

function validarMensagemDiagnostico()
{
	
	with(document.msg_diag)
	{
		if (ds_autor.value == "" || ds_mensagem.value == "")
		{
			alert("Você deve preencher todos os campos");
			return;
		}
		submit();
	}
}

/*********************************************************************************
*	FUNCTION:		ValidaCadastro
*	PARAMETERS:		nenhum
*	CALLS:			NOTHING
*	RETURNS:		Faz o submit do form quando as condições forem atendidas.
**********************************************************************************/

function ValidaCadastro(form)
{
  var flag=true;

  /* Campo nome */
  if (isEmpty(document.form.nome.value))
  {
    alert("Preencha o campo NOME.");
    document.form.nome.focus();
    return false
  }
    
  /* Campo email */
  if (!isEmail(document.form.email.value))
  {
    alert("Preencha corretamente o campo EMAIL.");
    document.form.email.focus();
    return false
  }
  
  /* Campo sexo */
  optou=0
  for (i=0; i < document.form.sexo.length;i++)
  {
	if (document.form.sexo[i].checked)
	{
		optou=1
	}
  }
  if (optou==0){
    alert("Selecione o sexo")
    return false
  }
  
  /* Campo endereço */
  if (isEmpty(document.form.endereco.value))
  {
    alert("Preencha o campo ENDERECO.");
    document.form.endereco.focus();
    return false
  }

  /* Campo bairro */
  if (isEmpty(document.form.bairro.value))
  {
    alert("Preencha o campo BAIRRO.");
    document.form.bairro.focus();
    return false
  }

  /* Campo Estado */
  //if (isEmpty(document.form.estado.value))
  if (document.form.estado.value == "")
  {
    alert("Preencha o campo ESTADO.");
    document.form.estado.focus();
    return false
  }
    
  /* Campo Cidade */
  if (isEmpty(document.form.cidade.value))
  {
    alert("Preencha o campo CIDADE.");
    document.form.cidade.focus();
    return false
  }

  /* Campo cep */
  if (isEmpty(document.form.cep.value))
  {
    alert("Preencha o campo CEP.");
    document.form.cep.focus();
    return false
  }
 
 /* Campo Usuario*/
 if (isEmpty(document.form.usuario.value))
 {
	alert("Por favor entre com o usuário (login)");
	document.form.usuario.select();
	return false
 }

 /* Campo Senha*/
 if (document.form.senha1.value.length < 4) 
 {
    alert("Por favor sua senha deve ter 4 ou mais dígitos");
	document.form.senha1.select();
	return false
 }

 if (document.form.senha1.value.length > 8) 
 {
	alert("Por favor sua senha deve ter até 8 dígitos");
	document.form.senha1.select();
	return false
 }

 /* --comentado--
 if (isEmpty(document.form.senha1.value) || document.form.senha1.value.length < 4 || document.form.senha1.value.length > 8 ) 
 {
	alert("Por favor entre corretamente com sua senha");
	document.form.senha1.select();
	return false
 }
 */
  
 if (isEmpty(document.form.senha1.value)) 
 {
	alert("Por favor entre com sua senha");
	document.form.senha1.select();
	return false
 }

 /* Campo Senha conferem?*/
 if (document.form.senha2.value != document.form.senha1.value)
 {
	alert("A senha não confere, por favor redigite a senha e a confirmação.");
	document.form.senha2.value=""
	document.form.senha1.select();
	return false
 }  
	return true
}

function goSimples() {

	if (document.form.nome.value == "") {
			alert("Preencha o seu nome.");
			document.form.nome.focus();
			return false;
	}

	if (!isEmail(document.form.email.value)) {
			alert("Preencha o seu email corretamente.");
			document.form.email.focus();
			return false;
	}
	if (document.form.ocup.options[document.form.ocup.selectedIndex].value == "outros")	{
			alert("O Medcenter.com criou um site especialmente para você que não trabalha na área de saúde.");
			window.open("http://www.medcenter.com.br/saude","_self");
			return false;
	}
	if (document.form.ocup.options[document.form.ocup.selectedIndex].value == "")	{
			alert("Selecione a sua profissão.");
			document.form.ocup.focus();
			return false;
	}

	if (document.form.usuario.value == "") {
			alert("Preencha o seu login.");
			document.form.usuario.focus();
			return false;
	}
	
 if (document.form.senha1.value.length < 4) 
 {
    alert("Por favor sua senha deve ter 4 ou mais dígitos");
	document.form.senha1.select();
	return false
 }

 if (document.form.senha1.value.length > 8) 
 {
	alert("Por favor sua senha deve ter até 8 dígitos");
	document.form.senha1.select();
	return false
 }
	
	if (document.form.senha.value == "") {
			alert("Preencha a sua senha.");
			document.form.senha.focus();
			return false;
	}

	if (document.form.senha.value != document.form.senha1.value) {
			alert("As senhas digitadas não conferem.");
			document.form.senha.focus();
			return false;
	}
		return true;
}

function ValidaRegistro(form)
{
  /*Campo registro_profissional*/
  if ( (document.form.ocup.value=="medico") ||(document.form.ocup.value=="dentista") )
  {
	if (isEmpty(document.form.registro_profissional.value))
	{
		alert("Informe seu número de registro profissional");
		document.form.registro_profissional.focus();
		return false
	}
  }
  if (isEmpty(document.form.anoform.value))
  {
	alert("Informe o ano de formatura");
	document.form.anoform.focus();
	return false
  }

}

function validaLogin() {
	with (document.login) {
		if ((nm_usuario_login.value == "") || (ds_senha.value=="")){
			alert ("É requerido o preenchimento de todos os campos !");
			return false;
		}
		submit();
	}
}

function validaPost() {
	with (document.msg){
		if (ds_mensagem.value==""){
			alert ("Escreva sua mensagem !");
			return;
		}
		submit();
	}
}















