//----------------------------------FUNÇÕES MURAL
function trim(str)
{
    return str.replace(/^\s+|\s+$/g,"");
}

function proc_mural()
{
	if (document.form1.titulo.value == "")
		{
		alert("Preencha o Título");
		return false
		}
	else
	  document.form1.action='redigir.asp?processa=S'
      document.form1.submit(); 
}

function proc_sol_mat()
{
	if (document.form1.titulo.value == "")
		{
		alert("Preencha o Título");
		return false
		}
	else
	  document.form1.action='solicitacao_materiais.asp?processa=S'
      document.form1.submit(); 
}

function reload()
{
    document.form1.submit(); 
}

function CheckAll() {
  for (var i=0;i<document.form1.elements.length;i++) {
    var x = document.form1.elements[i];
    if (x.type == 'checkbox') {
      x.checked = document.form1.selall.checked;
      document.form1.submit();
    }
  }
}
//----------------------------------FIM FUNÇÕES MURAL

var v_tab=true;
//------------------------------------------------------
// Para tabulação no campo
//------------------------------------------------------
function f_parar_tab(quem) { v_tab=false; } 
//------------------------------------------------------
// Checa tabulação do campo
//------------------------------------------------------
function f_checar_tab() { v_tab=true; } 
//------------------------------------------------------
// Pula para o proximo campo
//------------------------------------------------------
function f_proximo(quem, tammax) {
	var c = document.layers ? evt.which
            : document.all ? event.keyCode
            : evt.keyCode;
    if (c == 13) {tammax = quem.value.length;}

	if ( (quem.value.length == tammax) && (v_tab) ) { 
		var i=0,j=0, indice=-1;
		for (i=0; i<document.forms.length; i++) { 
		for (j=0; j<document.forms[i].elements.length; j++) { 
			if (document.forms[i].elements[j].name == quem.name) { 
				indice=i;
				break;
			} 
		} 
		if (indice != -1) break; 
     } 
     for (i=0; i<=document.forms[indice].elements.length; i++) { 
		if (document.forms[indice].elements[i].name == quem.name) { 
			while ( (document.forms[indice].elements[(i+1)].type == "hidden") &&
                  (i < document.forms[indice].elements.length) ) { 
				i++;
			} 
			document.forms[indice].elements[(i+1)].focus();
			document.forms[indice].elements[(i+1)].select();
			v_tab=false;
			break;
       } 
     } 
   } 
} 
//---------------um dia de AZ---------Andressa Diniz
function abre_processamento( purl ){

	window.open ( purl , 'newWin', 'resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,width=680,height=450');
}

function Referencias() {
	window.open ('referencia.asp', 'referencia', 'toolbar=no, scrollbars=yes,location=no,directories=no,width=550,height=500');
}


//---------------lista de colaboradores---------Andressa Diniz
function nada_lista()
{
	if (document.form1.area.value == "")
	alert("Selecione uma área");
	else
	  document.form1.action='confirmainclusao.asp';
      document.form1.submit();
}

function alterar(pcrm) {
	window.open ('alterarusu.asp?pcrm=' + pcrm, 'alterar', 'toolbar=no, scrollbars=no,location=no,directories=no,width=400,height=380');
}

//------------------hot_line--------------Andressa Diniz
function testa(){
	if (document.fale.nome.value.length == 0)
		{
		alert("Obrigatório colocar nome")
		return false}
	else{
		return true}
}

//------------------enquete--------------Andressa Diniz
function enquete_mudavalor( pvalor ) {

form_enquete.xresp_enquete.value = pvalor;

//alert('Valor ->' + form_enquete.xresp_enquete.value );

}
function vota_enquete( pCodResp, pCodEnq , pcaminho )
{
if ( document.form_enquete.xresp_enquete.value == '' ) {
	alert('Favor selecionar uma Opção !');
	return false;
} else {
	//alert("Cod Resp --> " + pCodResp );
	//alert("Cod Enq --> " + pCodEnq );
	window.open( pcaminho + 'pop_confirma_voto.asp?cod_enquete=' + pCodEnq + '&resp_enquete=' + pCodResp ,'pop_enquete','menubar=no,scrollbars=yes,width=420,height=240');
	return true;
	}
}
//------------------combo envia p/ pagina--------------Andressa Diniz
/*
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
*/
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval("location.href='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//----
function MM_displayStatusMsg(msgStr) {
	status=msgStr;
	document.MM_returnValue = true;
}

//-------função para formulario (Acessos Hot Topics)--------------Andressa Diniz
function formCheck_acessos(formobj){
	//1) Enter name of mandatory fields
	var fieldRequired = Array("data_inicial", "data_final");
	//2) Enter field description to appear in the dialog box
	var fieldDescription = Array("Data Inicial", "Data Final");
	//3) Enter dialog message
	var alertMsg = "Por favor entre com o(s) campo(s):\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}

//-------função para formulario (fale)--------------Andressa Diniz
function formCheck(formobj){
	//1) Enter name of mandatory fields
	var fieldRequired = Array("nome", "email", "mensagem");
	//2) Enter field description to appear in the dialog box
	var fieldDescription = Array("Nome", "E-mail", "Mensagem");
	//3) Enter dialog message
	var alertMsg = "Por favor complete o(s) campo(s):\n";

	var l_Msg = alertMsg.length;

	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}
//-->
//---------------Enquete ---------------------Andressa Diniz
function nada()
{
  document.form1.action='enquete/confirma_voto.asp';
  document.form1.submit();
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features,newWin,scrollbars=yes,toolbar=no,location=no,directories=no,width=300,height=300);

}
//-->

//-------função para formulario (cadastro médico)--------------Andressa Diniz

function formCheck_2(formobj){
	//1) Enter name of mandatory fields
	var fieldRequired = Array("txtnome", "txtemail", "txtcrm" , "txtestado", "txtespecialidade", "txtendereco", "txtbairro", "txtcidade", "txtcep", "txtfone");
	//2) Enter field description to appear in the dialog box
	var fieldDescription = Array("Nome", "E-mail", "Registro" , "Estado"   , "Especialidade", "Endereço", "Bairro", "Cidade", "CEP", "Telefone");
	//3) Enter dialog message
	var alertMsg = "Por favor complete o(s) campo(s):\n";

	var l_Msg = alertMsg.length;

	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == "" || obj.options[obj.selectedIndex].value == "")
				{
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == null || trim(obj.value) == "")
				{
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
				if (obj.value == null || trim(obj.value) == "" ){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}
//-->
//-------------------------menu da direita -------------------------------Andressa Diniz>
//--Material Cientifico
if (document.getElementById){ 
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("masterdiv").getElementsByTagName("span"); 
		if(el.style.display != "block"){ 
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") 
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}


//------------------------------------------------------
// Formata data
//------------------------------------------------------
function f_data(obj) {
    if (obj.value.length == 9 || obj.value.length == 0 || obj.value.length == 10){f_checar_tab()} else {v_tab=false;}
    var c = document.layers ? evt.which
            : document.all ? event.keyCode
            : evt.keyCode;
	if ((c < 48 || c > 58)) {return false;}
    else {
		if (obj.value.length == 2 || obj.value.length == 5) {obj.value = obj.value + "/"}
	}
}

//------------------------------------------------------
// Formata data - dd/mm
//------------------------------------------------------


function f_data_ddmm(obj) {
    if (obj.value.length == 9 || obj.value.length == 0 || obj.value.length == 10){f_checar_tab()} else {v_tab=false;}
    var c = document.layers ? evt.which
            : document.all ? event.keyCode
            : evt.keyCode;
	if ((c < 48 || c > 58)) {return false;}
    else {
		if (obj.value.length == 2) {obj.value = obj.value + "/"}
	}
}

//------------------------------------------------------
// Consiste Data
//------------------------------------------------------
function f_consiste_data(obj) {
    if (obj.value.length > 0){
		var v_data = obj.value
		var v_dia = v_data.substring(0,2)
		var v_mes = v_data.substring(3,5)
		var v_ano = v_data.substring(6,10)						
		if ( v_mes == "2" || v_mes == "02"  ){
			if (v_dia < 0 || v_dia > 28 || v_dia.substring(0,1) == "/" || v_dia.substring(1,1) == "/") {alert("Data com Dia invalido");obj.focus();obj.select();return}
		}else{
			if (v_dia < 0 || v_dia > 31 || v_dia.substring(0,1) == "/" || v_dia.substring(1,1) == "/") {alert("Data com Dia invalido");obj.focus();obj.select();return}
		}
		
	    //if (v_dia < 0 || v_dia > 31 || v_dia.substring(0,1) == "/" || v_dia.substring(1,1) == "/") {alert("Data com Dia invalido");obj.focus();obj.select();return}
	    if (v_mes == "00" ) {alert("Data com Mês invalido");obj.focus();obj.select();return}	    
	    if (v_mes < 0 || v_mes > 12 || v_mes.substring(0,1) == "/" || v_mes.substring(1,1) == "/") {alert("Data com Mês invalido");obj.focus();obj.select();return}	    
	    if (v_ano < 1900 || v_ano > 2100 || v_ano.substring(0,1) == "/" || v_ano.substring(1,1) == "/" || v_ano.substring(2,1) == "/" || v_ano.substring(3,1) == "/") {alert("Data com Ano invalido");obj.focus();obj.select();return}	    
    }
}
//------------------------------------------------------
// Consiste Data dd/mm
//------------------------------------------------------
function f_consiste_data_ddmm(obj) {
    if (obj.value.length > 0){
		var v_data = obj.value
		var v_dia = v_data.substring(0,2)
		var v_mes = v_data.substring(3,5)
		var v_ano = v_data.substring(6,10)						
	    if (v_dia < 0 || v_dia > 31 || v_dia.substring(0,1) == "/" || v_dia.substring(1,1) == "/") {alert("Data com Dia invalido");obj.focus();obj.select();return}
	    if (v_mes < 0 || v_mes > 12 || v_mes.substring(0,1) == "/" || v_mes.substring(1,1) == "/") {alert("Data com Mês invalido");obj.focus();obj.select();return}	    
    }
}

function resize_pop(pWidth, pHeight, pPop)
{
//window.scroll='no';
window.resizeTo(pWidth,pHeight);
window.moveTo((screen.width-pWidth)/2,(screen.height-pHeight)/2);
window.focus = pPop;
}

function Mascara(formato, objeto)
	{
	campo = eval (objeto);
	keypress = window.event.keyCode
	
	if (formato=='NUN')
	 {
		caracteres = '01234567890';
		conjuntos = 2;
		conjunto1 = 5;
		conjunto2 = 4;
					
			if ((caracteres.search(String.fromCharCode (keypress))!=-1) && campo.value.length < 
			(conjunto1 + conjunto2 + 1))
					{
					if (campo.value.length == conjunto1) 
					campo.value = campo.value;
					}
			else 
				event.returnValue = false;
		}
	
	 else if (formato=='CEP')
	 {
		caracteres = '01234567890';
		separacoes = 1;
		separacao1 = '-';
		conjuntos = 2;
		conjunto1 = 5;
		conjunto2 = 3;
					
			if ((caracteres.search(String.fromCharCode (keypress))!=-1) && campo.value.length < 
			(conjunto1 + conjunto2 + 1))
					{
					if (campo.value.length == conjunto1) 
					campo.value = campo.value + separacao1;
					}
			else 
				event.returnValue = false;
		}
	 
	 else if (formato=='FONE')
	 {
		caracteres = '01234567890';
		separacoes = 1;
		separacao1 = '-';
		conjuntos = 2;
		conjunto1 = 4;
		conjunto2 = 4;
					
			if ((caracteres.search(String.fromCharCode (keypress))!=-1) && campo.value.length < 
			(conjunto1 + conjunto2 + 1))
					{
					if (campo.value.length == conjunto1) 
					campo.value = campo.value + separacao1;
					}
			else 
				event.returnValue = false;
		}
	}

function saida_campo(formato, objeto){
	campo = eval (objeto);
	if (formato == 'DDD')
	{
		if (campo.value.length != '')
		campo.value = '(' + campo.value + ')'
	}
}
