function LimPesquisaSimples(objCtrPesquisaSimples) {

	this.setId("CtrPesquisaSimples");
	this.setIdFormulario("formPesquisaSimples");
	this.setLargura(490);
	this.setAltura(400);
	this.setTitulo("Pesquisa");
	this.setHtml("commons/pesquisa_simples.html");
	this.setIdFoco("idCampoNome");

	this.setControlador(objCtrPesquisaSimples);
	
	
	this.pesquisa = function() {
		this.reinicializaAtributos();
		this.getControlador().efetuaPesquisa();
	}
	
	this.reinicializaAtributos = function() {
		var ctr = this.getControlador(); 
		
		ctr.setRegistroInicial(0);
		ctr.setPaginaAtual(0);
		this.setCampoNumeroPagina(0);
		ctr.setInicioPagina(0);
		ctr.setFimPagina(0);
		ctr.setPaginaAtualServidor(0);
		this.verificaBotoesPaginacao();
	}
	
	// LISTAGEM DOS REGISTROS
	this.imprimePagina = function(registros) {
		this.limparMensagem();
		var divPesquisa = $("divPesquisaResp");
		divPesquisa.update();
		var i = 0;
	 	var classDesabilitado = "input80";
	 	var conteudoListagem = "";
		var pos = 0;
		var mouseOver = "#C4FFD7";
		var ctr = this.getControlador();

		var inicioPagina = this.getControlador().getInicioPagina();
		var fimPagina = this.getControlador().getFimPagina();
		
		if (ctr.getInicioPagina() >= ctr.getQtdeRegistros()) {
			inicioPagina = inicioPagina - (ctr.getQtdeRegistros() * ctr.getPaginaAtualServidor());
			fimPagina = fimPagina - (ctr.getQtdeRegistros() * ctr.getPaginaAtualServidor());
		}

		for(var i = inicioPagina; i <= fimPagina; i++) {
			
			if (registros[i] == undefined) {
				break;
			}
			var corTabela = (i % 2 == 0) ? "#FFFFFF" : "#F3F3F3";  
			conteudoListagem += "<table bgcolor=\""+corTabela+"\" width='100%' border='0' cellpadding='2' cellspacing='1' class='fonte'>";
			conteudoListagem += "<tr style='cursor: pointer' height='16' onMouseOver=\"bgColor='" + mouseOver + "'\"; onClick='aplicativo.getLimite(\"LimPesquisaSimples\").retornaRegistro("+registros[i].codigo+",\""+registros[i].descricao+"\");' onMouseOut=\"bgColor='" + corTabela + "'\">"; 
			conteudoListagem += "<td width='70'>&nbsp;" + registros[i].codigo + "</td>";
			conteudoListagem += "<td width='290'>"+ registros[i].descricao +"</td>";
			conteudoListagem += "</tr>";
			conteudoListagem += "</table>";
			pos++;
		}
 	 		var addPesquisa = document.createElement("div");
			addPesquisa.id = "divListagemColaborador";
			divPesquisa.appendChild(addPesquisa);
			addPesquisa.innerHTML = conteudoListagem;
			divPesquisa.style.display = "";
 	 	
 	 	this.trataScroll(divPesquisa);
	 	divPesquisa.innerHTML = conteudoListagem;
	 	this.verificaBotoesPaginacao();
	}
	
	this.retornaRegistro = function(codigo, descricao) {
		this.getControlador().retornaRegistro(codigo, descricao);
		this.prototypeWindow.close();
	}
	
	this.verificaBotoesPaginacao = function() {
		var ctr = this.getControlador();
		$(this.getIdFormulario()).idCampoNumeroPagina.disabled = false;
		$(this.getIdFormulario()).idCampoNumeroPagina.className = "input30";	
		this.setCampoNumeroPagina(ctr.getPaginaAtual());
		var div = $("divPesquisaMaximoDePaginas").innerHTML = " de " + this.getCalculaNumeroTotalPaginas();

		
		if ((ctr.getPaginaAtual() + 1) !=  this.getCalculaNumeroTotalPaginas()) {
			$("divImgPesquisaAvancarHabilitado").style.display = "";
			$("divImgPesquisaAvancarDesabilitado").style.display = "none";
		} else {
			$("divImgPesquisaAvancarHabilitado").style.display = "none";
			$("divImgPesquisaAvancarDesabilitado").style.display = "";
		}
		
		if (ctr.getPaginaAtual() > 0 || ctr.getPaginaAtualServidor() > 0) {
			$("divImgPesquisaRecuarHabilitado").style.display = "";
			$("divImgPesquisaRecuarDesabilitado").style.display = "none";						
		} else {
			$("divImgPesquisaRecuarHabilitado").style.display = "none";
			$("divImgPesquisaRecuarDesabilitado").style.display = "";						
		}
	}

	this.getCalculaNumeroTotalPaginas = function() {
		var numeroTotalPaginas = Math.ceil(this.getControlador().getTotalRegistros() / this.getControlador().getTamanhoPagina());
		return numeroTotalPaginas;
	}	
	
	this.escondeDivPesquisa = function() {
		$("divPesquisaResp").style.display = "none";
	}
	
	this.desabilitaBotoesPaginacao = function() {
		this.escondeDivPesquisa();
		$("divImgPesquisaAvancarHabilitado").style.display = "none";
		$("divImgPesquisaAvancarDesabilitado").style.display = "";
		$("divImgPesquisaRecuarHabilitado").style.display = "none";
		$("divImgPesquisaRecuarDesabilitado").style.display = "";		
	}
	
	this.desabilitaCampoNumeroPagina = function() {
		$(this.getIdFormulario()).idCampoNumeroPagina.disabled = true;
		$(this.getIdFormulario()).idCampoNumeroPagina.className = "input30d";
	}
	
	
	this.proximaPagina = function() {
		this.getControlador().proximaPagina();
	}
	
	this.paginaAnterior = function() {
		this.getControlador().paginaAnterior();
	}

	this.paginaEspecifica = function() {
		var pagina = this.getCampoNumeroPagina();
		
		if (pagina >= 0 && pagina < this.getCalculaNumeroTotalPaginas()) {
			this.getControlador().paginaEspecifica(pagina);	
		} else {
			this.desabilitaBotoesPaginacao();
			this.mostrarMensagem("alerta", PESQUISA_SEM_RESULTADO);
		}
	}
	
	// GETTERS E SETTERS
	this.getRadioSituacao = function() {
		if ($(this.getIdFormulario()).radioSituacao[0].checked == true) {
			return true;
		} else {
			return false;
		} 
	}

	this.setRadioSituacao = function(valor) {
		if (valor) {
			$(this.getIdFormulario()).radioSituacao[0].checked = true;
		} else {
			$(this.getIdFormulario()).radioSituacao[1].checked = true;
		}
	}	
	
	this.getCampoCodigo = function() {
		return $(this.getIdFormulario()).idCampoCodigo.value;
	}

	this.setCampoCodigo = function(valor) {
		$(this.getIdFormulario()).idCampoCodigo.value = valor;
	}

	this.getCampoNome = function() {
		return $(this.getIdFormulario()).idCampoNome.value;
	}

	this.setCampoNome = function(valor) {
		$(this.getIdFormulario()).idCampoNome.value = valor;
	}
	
	this.getCampoNumeroPagina = function() {
		var campo = $(this.getIdFormulario()).idCampoNumeroPagina.value;
		return campo - 1;
	}
	
	this.setCampoNumeroPagina = function(valor) {
		$(this.getIdFormulario()).idCampoNumeroPagina.value = valor + 1;
	}
	
	this.posCarregamento = function() {
		this.colocaFoco();
	}
}
LimPesquisaSimples.prototype = new Limite;