var qtd = null;
function def_qtd_registros(qtd_registros) {
	this.qtd = qtd_registros + 4;	
}

function block(e) {

	if (window.event) { // for IE, e.keyCode or window.event.keyCode can be used
		key = e.keyCode;
	}
	else if(e.which) { // netscape
		key = e.which;
	}
	if (key == 32) {
		return true;
	}
	if (key!=8 || key < 48 || key > 57) return (((key > 47) && (key < 58)) || (key==8)); {
		return true;
	}
}

var def_categoria_ativo = 0;

function get_categoria_ativo() {
	return(this.def_categoria_ativo);	
}
function set_categoria_ativo(valor) {
	this.def_categoria_ativo = valor;
}

function LTrim(value) {
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

function RTrim(value) {
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}

function trim(value) {
	return LTrim(RTrim(value));
}

function manipular_texto(texto) {
	var caracteres		= new Array(2);
	caracteres[0]		= 10;
	caracteres[1]		= 1310;	
	
	var lista 			= new Array();
	var indices			= new Array();
	var texto_atual		= new String(texto);
	var novo_texto 		= new String('');

	for (var i = 0; i < texto_atual.length; i++) {
		for (var x = 0; x < caracteres.length; x++) {
			if (texto_atual.charCodeAt(i) == caracteres[x]) {
				indices.push(i);
			}
		}
	}
	
	var ini = 0;
	var fim = 0;
	
	for (var i = 0; i <= indices.length; i++) {
		
		if ((i + 1) > indices.length) {
			fim = texto.length;
			novo_texto += (texto_atual.substring(ini, fim));
			
		}
		else {
			fim = indices[i];
			novo_texto += (texto_atual.substring(ini, fim) + '<br />');
		}
		
		ini = fim + 1;	
				
	}
	
	return(novo_texto);
	
}

function validar_contato_rapido() {
	var cor_erro 	= '#FFFFCC';
	
	var nome 		= document.getElementById('fast_cont_nome');
	var email 		= document.getElementById('fast_cont_email');
	var mensagem 	= document.getElementById('fast_cont_mensagem');
	
	if (trim(nome.value) == '') {
		alert('Atenção: Informe seu "NOME"!');
		nome.focus();
		nome.style.background 		= cor_erro;
		return(false);
	}
	if (trim(email.value) == '') {
		alert('Atenção: Informe seu "E-MAIL"!');
		email.style.background 		= cor_erro;
		return(false);
	}
	if (!trim(email.value).match(/^[A-Za-z0-9]+([_.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_.-][A-Za-z0-9]+)*.[A-Za-z0-9]{2,4}$/)){
		alert('Atenção: Você deve infomar um endereço de "E-MAIL" válido!');
		email.style.background 		= cor_erro;
		return(false);
	}	
	if (trim(mensagem.value) == '') {
		alert('Atenção: Informe sua "MENSAGEM"!');
		mensagem.style.background 	= cor_erro;		
		return(false);
	}
	return(true);
}

function status_menu(cod) {
	if (cod == 3) {
		document.getElementById('sub_menu').style.display = 'block';				
		for (var i = 0; i < qtd; i++) {
			if ((i == 3) || (i == 4)) {
				document.getElementById('menu_' + i.toString()).className = 'menu_ativo';
			}
			else {
				document.getElementById('menu_' + i.toString()).className = 'menu_inativo';
			}
		}
	}
	else if (cod >= 4) {
		document.getElementById('sub_menu').style.display = 'block';		
		for (var i = 0; i < qtd; i++) {
			if ((i == 3) || (i == cod)) {
				document.getElementById('menu_' + i.toString()).className = 'menu_ativo';
			}
			else {
				document.getElementById('menu_' + i.toString()).className = 'menu_inativo';
			}
		}
	}
	else {
		document.getElementById('sub_menu').style.display = 'none';
		for (var i = 0; i < qtd; i++) {
			if (i == cod) {
				document.getElementById('menu_' + i.toString()).className = 'menu_ativo';
			}
			else {
				document.getElementById('menu_' + i.toString()).className = 'menu_inativo';
			}
		}
	}
}


function status_sub_menu(obj, elementos) {
	for (var i = 0; i <= elementos; i++) {
		if (('menu_sub_categoria_' + i.toString()) == (obj)) {
			document.getElementById('menu_sub_categoria_' + i.toString()).className = 'sub_link_on';						
		}
		else {
			document.getElementById('menu_sub_categoria_' + i.toString()).className = 'sub_link_off';			
		}
	}
}

function setCSS(obj, classe) {
	obj.className = classe;
}
