// JavaScript Document

function busca_avancada_onLoad(resultado) {
	writeDIV('conteudo', resultado);
}

function send_proposta_onLoad(resultado) {
		alert("Proposta enviada com sucesso!");
		document.getElementById("envia_proposta").reset();
}

function particular_login_onLoad(resultado) {
	resultado = new Function("return "+resultado)();
	if (resultado.status != 0) {
		if(resultado.mostar_avisos){
			$.facebox({div:'#avisos'});
		} else {
			alert("Seja bem vindo!");
		}
		
		//ajaxHTML('box_conteudo','particular.inc.php');
		//Aqui vai a Categoria e o ID do conteudo QUERO VENDER -> PARTICULARES
		document.location='#conteudo';
		ajaxHTML('conteudo','conteudo_interno.inc.php?cat=23&id=108');
		//ajaxHTML('box_conteudo','particular.login.inc.php');
	} else {
		document.getElementById("fmLoginPart").reset();
		alert("Usuário ou Senha não conferem!");
		//document.getElementById("respostaP").innerHTML = "<p>Usuário ou Senha não conferem!</p>";
	}
}
function enviar_contato_onLoad(resultado) {
	resultado = new Function("return "+resultado)();
	if (resultado.status == "SUCCESS") {
		if (document.getElementById("box_conteudo")) {
			//ajaxHTML("box_conteudo","conteudo.inc.php?id="+resultado.conteudo+"&enviado=ok");
			ajaxHTML('box_conteudo',"conteudo.inc.php?id=150&enviado=ok");
		}
		document.getElementById("bemail").value = "";
	} else {
		//alert(resultado.msg);
		if (document.getElementById("box_conteudo")) {
			ajaxHTML("box_conteudo","conteudo.inc.php?id=150&enviado=erro");
		}
	}
}
function boletim_onLoad(resultado) {
	resultado = new Function("return "+resultado)();
	if (resultado.status == "SUCCESS") {
		alert(resultado.msg);
		if (document.getElementById("box_conteudo")) {
			ajaxHTML("box_conteudo","boletim.inc.php?status=success&opcao="+resultado.opcao);
		}
		document.getElementById("bemail").value = "";
	} else {
		alert("Erro: "+resultado.msg);
	}
}

function particular_add_onLoad(resultado) {
	resultado = new Function("return "+resultado)();
	if (resultado.status == "SUCCESS") {
		alert(resultado.msg);
		document.getElementById('fm_particular').reset();
		ajaxHTML("box_conteudo","conteudo.inc.php?id=108");
	} else {
		alert(resultado.msg);
	}
}

function renovar_anuncio_onLoad(resultado) {
	resultado = new Function("return "+resultado)();
	//msg_debug = "";for (var i=0;i<resultado.length;i++) {msg_debug += resultado[i]+"\n";}alert(msg_debug);
	fechar_erro('status');
	if (resultado.status == "SUCCESS") {
		/*Fechando a mensagem de andamento*/
		/*Preenchendo os dados no Formulario que gera o Boleto*/
		
		document.boleto.NossoNumero.value = resultado.NNUMERO;
		document.boleto.NumeroDocumento.value = resultado.NPEDIDO;
		document.boleto.ValorDocumento.value = resultado.nTotalPedido;
		//document.getElementById('popup_bloq').style.visibility = 'visible';
		setTimeout("document.boleto.submit()",4000);
		//ajaxHTML('box_conteudo','particular.veiculo.inc.php');
	} else {
		alert(resultado.msg);
	}
}

function particular_upd_onLoad(resultado) {
	resultado = new Function("return "+resultado)();
	if (resultado.status == "SUCCESS") {
		alert(resultado.msg);
		document.getElementById('fm_particular').reset();
		ajaxHTML("box_conteudo","particular.veiculo.inc.php");
	} else {
		alert(resultado.msg);
	}
}

function pedido_add_onLoad(resultado) {
	if (resultado == "SUCCESS") {
		alert('Pedido enviado com sucesso!');
		ajaxHTML("conteudo","conteudo_interno.inc.php?cat=25");
	} else {
		alert('Desculpe falha ao cadastrar!');
	}
}

function testemunho_add_onLoad(resultado) {
	if (resultado == "SUCCESS") {
		alert('Obrigado por enviar seu testemunho!');
		ajaxHTML("box_conteudo","conteudo.inc.php?id=191");
	} else {
		alert('Desculpe falha ao cadastrar!');
	}
}

function trabalheconosco_add_onLoad(resultado) {
	if (resultado == "SUCCESS") {
		alert('Obrigado por enviar seu currículo!');
		ajaxHTML("box_conteudo","conteudo.inc.php?id=203");
	} else {
		alert('Desculpe falha ao cadastrar!');
	}
}

function deleteImage_onLoad(id) {
	ajaxHTML('box_conteudo','form.particular.enviaimg.php?id='+id);
}
function deleteVeiculo_onLoad(id) {
	ajaxHTML('box_conteudo','particular.veiculo.inc.php');
}

function particular_veiculo_add_onLoad(resultado) {
	resultado = new Function("return "+resultado)();
	//msg_debug = "";for (var i=0;i<resultado.length;i++) {msg_debug += resultado[i]+"\n";}alert(msg_debug);
	if (resultado[0] == "SUCCESS") {
		alert('Veiculo adicionado com sucesso!');
		ajaxHTML("box_conteudo","form.particular.enviaimg.php?id="+resultado[1]);
		//document.getElementById('fm_veiculo').reset();
	} else {
		alert(resultado[0]);
	}
}

function particular_veiculo_upd_onLoad(resultado) {
	resultado = new Function("return "+resultado)();
	//msg_debug = "";for (var i=0;i<resultado.length;i++) {msg_debug += resultado[i]+"\n";}alert(msg_debug);
	if (resultado.status == "SUCCESS") {
		alert(resultado.msg);
		ajaxHTML("box_conteudo","particular.veiculo.inc.php");
	} else {
		alert(resultado.msg);
	}
}
