///Funções para formuládios-->
//Destaca o campo do formuláfio quando não foi prenchido
function formBlur(e){
	if(typeof(e)=='undefined')var e=window.event;
	source=e.target?e.target:e.srcElement;
	if(source.nodeType == 3)source = source.parentNode;
	source.style.border = '1px solid #0099CC';
}
function formFocus(camp){
	camp.focus();
	camp.style.border = '1px solid #FF0000';
	addEvent(camp,'change',formBlur);
}
//Somente Numeros
function soNmrs(e){
	var tecla = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
	if (!(tecla > 47 && tecla < 58) && !(tecla >95 && tecla<106) && ((tecla != 8) && (tecla != 46) && (tecla != 9))){ 
		return false;
	}else return true;
}
//Limita o numero de caracteres
function chrLimite(camp,mxlng) {
	if (camp.value.length > mxlng){
		camp.value = camp.value.substring(0,mxlng);
	}else return true; 
} 
//Valida e-mail
function naoEmail(campEmail){
	var srtEmail = campEmail.value;
	if(srtEmail.search(/^[\w-]+(\.[\w-]+)*@(([\w-]{2,63}\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/i) == -1){
		alert ("Endereço de e-mail " + srtEmail+ " inválido");
		formFocus(campEmail);
		return true;
	}else return false; 
}
//Campo preenchido ou selecionado
function naoPreench(camp,msg){
	var campTipo = camp.type;
	var estado = false;
	if(campTipo== 'text' || campTipo == 'textarea' || campTipo == 'password' ){
		if(camp.value=="")estado = true;
	}
	if(campTipo == 'select-one'){
		if(camp.selectedIndex == -1 || camp.value == "" || camp.value == "opcao")estado = true;
	}
	if(campTipo == 'hidden'){
		if(camp.value==""){alert(msg);return true;}
	}
	if(estado){
		alert(msg);
		formFocus(camp);
		return estado;
	}
}
//Campo preenchido ou selecionado
function naoPreench2(camp){
	var campTipo = camp.type;
	var estado = false;
	if(campTipo== 'text' || campTipo == 'textarea' || campTipo == 'password' ){
		if(camp.value=="")estado = true;
	}
	if(campTipo == 'select-one'){
		if(camp.selectedIndex == -1 || camp.value == "" || camp.value == "opcao")estado = true;
	}
	if(campTipo == 'hidden'){
		if(camp.value==""){return true;}
	}
	if(estado){
		formFocus(camp);
		return estado;
	}
}
function ttChk(oC){
	var tt = 0;
	for (i=0; i<oC.length; i++) {
		if(oC[i].checked){
			tt++;
		}
	}
	return tt;
}
//Campo marcado 
function naoChecked(camp,msg){
	var estado = false;
	var marcado = -1;
	for (i=0; i < camp.length; i++) {
		if(camp[i].checked)marcado++;
	}
	if(marcado == -1)estado = true;
	camp = camp[0];
	if(estado){
		alert(msg);
		camp.focus();
		return estado;
	}
}

//Campo marcado 
function naoChecked2(camp){
	var estado = false;
	var marcado = -1;
	for (i=0; i < camp.length; i++) {
		if(camp[i].checked)marcado++;
	}
	if(marcado == -1)estado = true;
	camp = camp[0];
	if(estado){
		camp.focus();
		return estado;
	}
}