function isCheck(campo) {
	if (campo.value == "S") {
		campo.value = "N";
	} else {
		campo.value = "S";
	}
}

function loadCadastraContato() {
	var pedido = constroiStringPedido("/Ofm_Imprensa/ServletEmail?acao=cadastrar&",document.form1);
	pedido = pedido + "&interesse=" + stringCheckbox();
	getXMLHttpRequest("post",pedido, true, "cadastraContato");
}

function cadastraContato() {
	if (req.readyState==4) {
		if (req.status==200) {
		    var resposta = req.responseText;
		  	if (resposta == "true") {
		    	erro_ok("Cadastro efetuado com sucesso.","index.jsp");
		    } else {
		    	erro_ok("O cadastro não pode ser efetuado, se o erro persistir informe ao administrador do Sistema.");
		    }
		}	
		carregando(req.readyState);
	} else if (req.readyState==1){
		carregando(req.readyState);
	}
}

function loadInteresse() {
	getXMLHttpRequest("post", "/Ofm_Imprensa/ServletInteresse?acao=consultar", true, "Interesse");
}

function Interesse() {
	if (req.readyState==4) {
		if (req.status==200) {
		    var resposta = req.responseText;
		    arrResposta = resposta.split(';');
			var tcorpo = document.getElementById("tbInteresse");
			
		    for (var i = 0; i < arrResposta[i].length ; i++) {
				var JsonInteresse = eval('(' + arrResposta[i] + ')');
				
				var tr1 = document.createElement("TR"); 
				var td1 = document.createElement("TD");				
				
				td1.appendChild(document.createTextNode(JsonInteresse.desc));
				
				var td2 = document.createElement("TD");
				var check1 = document.createElement("INPUT");
				
				check1.type = "checkbox";
				check1.className = "interesse";
				check1.value = JsonInteresse.cdInteresse;
				td2.appendChild(check1);
				
				tr1.appendChild(td1);
				tr1.appendChild(td2);				
				tcorpo.appendChild(tr1);
	
		    }
		}	
		carregando(req.readyState);
		loadCargo();
	} else if (req.readyState==1){
		carregando(req.readyState);
	}
}


function loadCargo() {
	getXMLHttpRequest("post", "/Ofm_Imprensa/ServletCargo?acao=consultar", true, "populaCargo");	
}

function populaCargo() {
	
	if (req.readyState==4) {
		if (req.status==200) {
		
			var lista = document.getElementById("cargo");
			limpaOption(lista);
			
			resposta = req.responseText;
			var arrResposta = resposta.split(';');
			
			if (lista.options != null && lista != null) {
				for (var i = 0 ; i < arrResposta.length ; i ++) {
					
					if (arrResposta[i] != "") {
						var Json = eval('(' + arrResposta[i] + ')');					
						addOption(lista,Json.desc,Json.cdCargo,false);
					}
				}				
			}
			loadVeiculo();
		}
	}
}

function loadVeiculo() {
	getXMLHttpRequest("post", "/Ofm_Imprensa/ServletVeiculo?acao=consultar", true, "populaVeiculo");	
}

function populaVeiculo() {
	
	if (req.readyState==4) {
		if (req.status==200) {
		
			var lista = document.getElementById("veiculo");
			limpaOption(lista);
			
			resposta = req.responseText;
			var arrResposta = resposta.split(';');
		
			if (lista.options != null && lista != null) {
				for (var i = 0 ; i < arrResposta.length ; i ++) {	
					if (arrResposta[i] != "") {
						var Json = eval('(' + arrResposta[i] + ')');
						addOption(lista,Json.desc,Json.cdVeiculo,false);
					}
				}				
			}
			
		}
	}
}

