// JavaScript Document

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

function particular_login_onLoad(resultado) {
	resultado = new Function("return "+resultado)();
	if (resultado.status != 0) {
		//alert("Seja bem vindo!");
		//ajaxHTML('box_conteudo','particular.inc.php');
		//Aqui vai a Categoria e o ID do conteudo QUERO VENDER -> PARTICULARES
		ajaxHTML('conteudo','conteudo_interno.inc.php?cat=23&id=115');
	} else {
		document.getElementById("fmLoginPart").reset();
		document.getElementById("statuspart").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=161&enviado=ok");
		}
		if (document.getElementById("bemail")) { document.getElementById("bemail").value = ""; }
	} else {
		//alert(resultado.msg);
		if (document.getElementById("box_conteudo")) {
			ajaxHTML("box_conteudo","conteudo.inc.php?id=161&enviado=erro");
		}
	}
}

function enviar_pedido_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=161&enviado=ok");
		}
		if (document.getElementById("bemail")) { document.getElementById("bemail").value = ""; }*/
		alert("CORRETO");
	} else {
		//alert(resultado.msg);
		/*if (document.getElementById("box_conteudo")) {
			ajaxHTML("box_conteudo","conteudo.inc.php?id=161&enviado=erro");
		}//*/
		alert("erro");
	}
}

function boletim_onLoad(resultado) {
	resultado = new Function("return "+resultado)();
	if (resultado.status == "SUCCESS") {
		alert(resultado.msg);
		ajaxHTML("box_boletim","boletim.inc.php");
		//ajaxHTML("box_conteudo","boletim.inc.php?status=success&opcao="+resultado.opcao);
	} 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('conteudo','conteudo_interno.inc.php?cat=23&id=108');
	} 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('conteudo','conteudo_interno.inc.php?cat=23&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.boleto.submit();
		ajaxHTML('box_conteudo','particular.veiculo.inc.php');
	} else {
		alert(resultado.msg);
	}
}
function pedido_add_onLoad(resultado) {
	if (resultado == "SUCCESS") {
		alert('Pedido enviado com sucesso!');
		document.getElementById('form_bpedido').reset();
	} else {
		alert('ERRO AO ENVIAR!\n'+resultado);
	}
}

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);
	}
}

function pergunte_add_onLoad(resultado) {

	if (resultado == "SUCCESS") {
		alert('Cadastro efetuado com sucesso!');
		document.getElementById('form_pergunte').reset();
	} else {
		alert('Desculpe falha ao cadastrar!\n'+resultado);
	}
}
