function CL_CAD_INC () {
	this.arr_campos_tt = new Array();
	this.arr_campos_id = new Array();
	this.arr_campos_null = new Array();
	this.fCad = '';
	
	this.sub_form = function() {
		var iCampo = CL_CAD_INC.consiste_campos();
		if (iCampo!==false) {
			alert(CL_CAD_INC.msg(0)+CL_CAD_INC.arr_campos_tt[iCampo]);
			return false;
		}
		document.getElementById('INC').value=1;
		document.getElementById(CL_CAD_INC.fCad).submit();
	}

	this.limpar = function() {
		var i;
		for (i=0; i<CL_CAD_INC.arr_campos_id.length; i++) document.getElementById(CL_CAD_INC.arr_campos_id[i]).value='';
		document.getElementById(CL_CAD_INC.arr_campos_id[0]).focus();
	}
	
	this.consiste_campos = function() {
		var i, cont;
		//Publico
		for (i=0; i<CL_CAD_INC.arr_campos_id.length; i++) {
			if (!document.getElementById(CL_CAD_INC.arr_campos_id[i])) continue;
			cont = document.getElementById(CL_CAD_INC.arr_campos_id[i]).value;
			if (cont.replace(' ','')=='' && !CL_CAD_INC.arr_campos_null[i]) return i;
		}
		//Específico Financeiro
		if (this.fCad=='fFinalizar_Comissao') {
			if (document.getElementById('Calculo_Extra').checked) {
				if (document.getElementById('NR_Calculo_Extra').value=='') return 8;
			} else document.getElementById('FL_Tipo_Calculo_Extra').value='NL';
		}
		//Específico Categoria Banner
		switch (CL_CAD_INC.fCad) {
			case 'fCategoria_Banner': { 
				if (document.getElementById('DS_Categoria_Banner').value.length>254) return 2;
				break;
			}
			case 'fProduto_Categoria': { 
				if (document.getElementById('DS_Descricao').value.length>254) return 2;
				break;
			}
		}
		
		
		return false;
	}
	
	this.carrega_campos = function(iForm) {
		CL_CAD_INC.fCad = iForm;
		switch (iForm) {
			case 'fUsuario': {
				CL_CAD_INC.arr_campos_tt = new Array('Login','Senha','E-Mail','Nome','Nick');
				CL_CAD_INC.arr_campos_id = new Array('CD_Login', 'CD_Senha', 'NM_Mail', 'NM_Usuario', 'CD_Nick');
				CL_CAD_INC.arr_campos_null = new Array(false,false,true,false,false);
				break;
			}
			case 'fFinanc_comissao': {
				CL_CAD_INC.arr_campos_tt = new Array('Afiliado', 'Senha', 'Login', 'Endereço', 'Complemento', 'Bairro', 'Cidade', 'UF', 'Pais', 'CEP', 'Fone', 'E-Mail', 'Site', 'Visitação Mensal' ,'Obsercação');
				CL_CAD_INC.arr_campos_id = new Array('NM_Afiliado', 'CD_Senha', 'CD_Login', 'NM_Endereco', 'NM_Complemento', 'NM_Bairro', 'NM_Cidade', 'CD_UF', 'NM_Pais', 'CD_CEP', 'CD_Fone', 'NM_Email', 'NM_Site', 'CD_Visitacao_Site' ,'DS_OBS');
				CL_CAD_INC.arr_campos_null = new Array(false,false,false,false,false,false,false,false,false,false,false,false,false,true,true);
				break;
			}
			case 'fFinalizar_Comissao': {
				CL_CAD_INC.arr_campos_tt = new Array('Afiliado', 'DT. Inicio', 'DT. Fim', 'DT. Pagamento', 'Comissão Direta', 'Comissão Sub Afiliado', 'Valor Cálculo Extra', 'Tipo do Cálculo Extra', 'Valor Pagamento', 'Observação');
				CL_CAD_INC.arr_campos_id = new Array('ID_Affiliate_Tracker', 'DT_Inicio', 'DT_Fim', 'DT_Pagamento', 'NR_Comissao_NV1', 'NR_Comissao_NV2', 'NR_Calculo_Extra', 'FL_Tipo_Calculo_Extra', 'VL_Valor_Pagamento', 'DS_Observacao');
				CL_CAD_INC.arr_campos_null = new Array(false,false,false,false,false,false,true,true,false,true);
				break;
			}
			case 'fBanner': {
				CL_CAD_INC.arr_campos_tt = new Array('Nome/Título','Arquivo','Altura (px)','Atributo ALT da tag IMG','Comprimento (px)','URL Destino','Descrição');
				CL_CAD_INC.arr_campos_id = new Array('NM_Imagem','CD_Imagem','VL_Altura','NM_ALT_Imagem','VL_Comprimento','CD_URL_Destino','DS_Imagem');
				CL_CAD_INC.arr_campos_null = new Array(false,false,true,true,true,false,true);
				break;
			}
			case 'fProduto': {
				CL_CAD_INC.arr_campos_tt = new Array('Código','Identificador','Nome','Título para Anuncios','Descrição','Versão','Peso','Preço em Real','Preço em Dolar','Preço em Euro','Data de Cadastro','Modelo','Marca','Dimensões','Garantia','Composição','Imagem Produto','Quantidade em Estoque');
				CL_CAD_INC.arr_campos_id = new Array('CD_Codigo','ID_Produto','NM_Produto','NM_Titulo','NM_Descricao','CD_Versao','VL_Peso','VL_Preco_Real','VL_Preco_Dolar','VL_Preco_Euro','DT_Cadastro','NM_Modelo','NM_Marca','NM_Dimensoes','CD_Garantia','DS_Composicao','CD_Imagem','NR_Estoque');
				CL_CAD_INC.arr_campos_null = new Array(false,false,false,false,true,false,true,true,true,true,false,true,true,true,true,true,true,true);
				break;
			}
			case 'fCategoria_Banner': {
				CL_CAD_INC.arr_campos_tt = new Array('Nome Categoria','Imagem','Descrição');
				CL_CAD_INC.arr_campos_id = new Array('NM_Categoria_Banner','CD_IMG_Categoria_Banner','DS_Categoria_Banner');
				CL_CAD_INC.arr_campos_null = new Array(false,true,true);
				break;
			}
			case 'fProduto_Categoria': {
				CL_CAD_INC.arr_campos_tt = new Array('Nome Categoria','Imagem','Descrição');
				CL_CAD_INC.arr_campos_id = new Array('NM_Nome_Categoria','CD_Imagem','DS_Descricao');
				CL_CAD_INC.arr_campos_null = new Array(false,true,true);
				break;
			}
			case 'fFormaPagamento': {
				CL_CAD_INC.arr_campos_tt = new Array('Forma de Pagamento','E-Mail de Cadastro','Nome do Banco','Código do Banco','Agência Bancária','Número da Conta Corrente ou Poupança','Nome Completo do Titular da Conta','CPF','Descrição');
				CL_CAD_INC.arr_campos_id = new Array('CD_Tipo_Forma_Pagamento','NM_Email','NM_Banco','CD_Banco','CD_Agencia_Bancaria','CD_Conta_Corrente_Poupanca','NM_Titular_Conta','CD_CPF','DS_Forma_Pagamento');
				CL_CAD_INC.arr_campos_null = new Array(false,true,true,true,true,true,true,true,true);
				break;
			}
			case 'fAfiliadoBanner': {
				CL_CAD_INC.arr_campos_tt = new Array('Nome/Título','Arquivo','Altura (px)','Atributo ALT da tag IMG','Comprimento (px)','URL Destino','Descrição');
				CL_CAD_INC.arr_campos_id = new Array('NM_Imagem','CD_Imagem','VL_Altura','NM_ALT_Imagem','VL_Comprimento','CD_URL_Destino','DS_Imagem');
				CL_CAD_INC.arr_campos_null = new Array(false,false,true,true,true,false,true);
				break;
			}
			case 'fAnunciante': {
				CL_CAD_INC.arr_campos_tt = new Array('ID Afiliado','Nome Anunciante/Empresa/Blog','URL Anuncio Principal','Nome do Responsável','Email do Responsável','Fone','OBS');
				CL_CAD_INC.arr_campos_id = new Array('ID_Afiliado','NM_Anunciante','CD_URL','NM_Responsavel','NM_Email_Responsavel','CD_Fone_Contato','DS_OBS');
				CL_CAD_INC.arr_campos_null = new Array(true,false,false,false,true,true,true);
				break;
			}
			case 'fLista_Icontact': {
				CL_CAD_INC.arr_campos_tt = new Array('Nome/Título','Código','Descrição');
				CL_CAD_INC.arr_campos_id = new Array('NM_Lista_Icontact','CD_Lista_Icontact','DS_Lista_Icontact');
				CL_CAD_INC.arr_campos_null = new Array(false,false,true);
				break;
			}
			case 'fSys_Contato_Email': {
				CL_CAD_INC.arr_campos_tt = new Array('Nome','Email','Status','Lista','Observação');
				CL_CAD_INC.arr_campos_id = new Array('NM_Nome_Contato','NM_Email_Contato','FL_Status','CD_Lista_Icontact','NM_Observacao');
				CL_CAD_INC.arr_campos_null = new Array(false,false,false,false,true);
				break;
			}
		}
	}
	
	this.msg = function(iMsg) {
		var arr_msg = new Array('Preencha Corretamente o Campo: ');
		return arr_msg[iMsg];
	}
}
var CL_CAD_INC = new CL_CAD_INC();
