function fecha(i){
	jQuery('#fechavel'+i).hide();
}

function SomenteNumero(e){
    var tecla=(window.event)?event.keyCode:e.which;
	if((tecla > 47 && tecla < 58)) return true;
		else{
		if ((tecla != 8)&&(tecla != 0)) return false;
		else return true;
		}
}

function campo_obri(frm,arr_campos,arr_linhas){
	for (c=0; c<arr_campos.length; c++){
		campo	= arr_campos[c];
		linha		= arr_linhas[c];
		if ((!eval('frm.'+campo+'.value'))||(eval('frm.'+campo+'.value')==" ")){
			$('#'+linha).css('backgroundColor','#cccccc');
			eval('frm.'+campo+'.focus()');
			return false;
		}
		else {
			document.getElementById(linha).bgColor="";
		}
	}
}
function formataTelefone(campo, e) {
	t = typeof window.event != "undefined" ? window.event.keyCode : e.which;
	if((isNaN(String.fromCharCode(t)) || (t == 32)) && (t != 8 && t != 0)){
		return false;
	}
	campo = typeof(campo) == "object" ? campo : document.getElementById(campo);
	if(campo.value.charAt(0) != "(" && !isNaN(String.fromCharCode(t)))
		campo.value = "("+campo.value;
	if( typeof window.event != "undefined" ) {
		if(window.event.keyCode != 40) {
			if(campo.value.length == 0) {
				campo.value += '(';
			}
		}
		if(window.event.keyCode != 41) {
			if(campo.value.length == 3) {
				campo.value += ')';
			}
		}
		if(window.event.keyCode != 45) {
			if(campo.value.length == 8) {
				campo.value += '-';
			}
		}
	} else {
		if (e.which != 8) {
			if(e.which != 0) {
				if(e.which != 40) {
					if(campo.value.length == 0) {
						campo.value += '(';
					}
				}
			}
			if(e.which != 41) {
				if(campo.value.length == 3) {
					campo.value += ')';
				}
			}
			if(e.which != 45) {
				if(campo.value.length == 8) {
					campo.value += '-';
				}
			}
		}
	}
}
function retornaHTML(ret){
	$('#'+ret['div']).html(ret['html']);
}

function veremail(obj, email){
	if (email){
		reemail=/^[\w-]+(\.[\w-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
		if (reemail.test(email)) {
			return true;
		}
		else {
			alert(email + " NÃO é um endereço de e-mail válido.");
			obj.focus();
			return false;
		}
	}
}
