// JavaScript Document


function comprar(destino)
{
	window.location.href= destino;
}

function mostrafoto(id, foto, tipo, legenda)
{
	if(tipo == 1)
	{
		caminho_foto = "galeria_fotos/principal/"+foto;
	}else{
		caminho_foto = "galeria_fotos/"+id+"/"+foto;
	}
	document.getElementById("foto_big").src=caminho_foto;
	document.getElementById("legenda").innerHTML=legenda;
}


function foto_noticia(foto, op, pos)
{
	if (op == "small")
	{
		caminho_foto = "<img src=\"noticias/"+foto+"\" id=\"foto_big_a\" onclick=\"javascript:foto_noticia('"+foto+"','big', '"+pos+"');\" class=\"img_capa_"+pos+"\" />";
	}else{

		caminho_foto = "<img src=\"noticias/thumb_"+foto+"\" id=\"foto_big_a\" onclick=\"javascript:foto_noticia('"+foto+"','small', '"+pos+"');\" class=\"img_capa_"+pos+"\" />";
		
	}
	

	document.getElementById("imagem_"+pos).innerHTML=caminho_foto;
	
}



function foto_vereadores(foto, op, pos)
{
	if (op == "small")
	{
		caminho_foto = "<img src=\"vereadores/"+foto+"\" id=\"foto_big_a\" onclick=\"javascript:foto_vereadores('"+foto+"','big', '"+pos+"');\" class=\"img_capa_"+pos+"\" />";
	}else{

		caminho_foto = "<img src=\"vereadores/thumb_"+foto+"\" id=\"foto_big_a\" onclick=\"javascript:foto_vereadores('"+foto+"','small', '"+pos+"');\" class=\"img_capa_"+pos+"\" />";
		
	}
	

	document.getElementById("imagem_"+pos).innerHTML=caminho_foto;
	
}


function cadastra_cliente()
{

	document.form1.submit();
}

function alerta()
{
	document.getElementById('cadastro').innerHTML="";
}

function finaliza_pedido()
{
	var valor_frete = document.getElementById("total_frete").innerHTML;
	var cep = document.getElementById("cep").value;
	
	if ((valor_frete = "0,00") && (cep == ""))
	{
		alert("Favor preencher o CEP e Clicar em Calcular");
	}else{

	if (confirm('Finalizar o pedido?')== true)
	{
	calcula_frete('ajax_consultas.php?op=calcula_frete', 'total_frete', 'valor_total_frete');		
		destino = "index.php?origem=finalizar&cep="+cep;
		window.location.href = destino;
	}else{
		
	}
	}
}


function conecta_pagseguro()
{

	var valor_frete = document.getElementById("total_frete").innerHTML;
	var cep = document.getElementById("cep").value;


	if ((valor_frete = "0,00") && (cep == ""))
	{
		alert("Favor Preecher o CEP e Clicar em Calcular!");
	}else{

	if (confirm('Seu pedido será gravado, e você direcionado para o pagamento.\nPara finalizar pedido, clique em <OK>\nPara continuar comprando, clique em <Cancelar>?')== true)
	{
		//window.document.pagseguro.submit();
		var valor_frete = document.getElementById("total_frete").innerHTML;
		destino = "index.php?origem=carrinho_listar&op=sim&valor_frete="+valor_frete;
		window.location.href = destino;
	}
	}

}
 

function mostra_avisa()
{
	document.getElementById("avisa").style.visibility="visible";
	document.getElementById("avisa").style.display="block";
	document.getElementById("link_avisa").innerHTML ="";

}


function mostra_texto()
{
	document.getElementById("texto_novidade").style.visibility="visible";
	document.getElementById("texto_novidade").style.display="block";
}

function carrega_menu()
{
	document.getElementById("menu_adicional").style.visibility="visible";
	document.getElementById("menu_adicional").style.display="block";
}

function fecha_menu()
{
	
	document.getElementById("menu_adicional").style.visibility="hidden";  
	document.getElementById("menu_adicional").style.display="none";

	
}




function foco(identificador)
{
	alert('asdfas');
}

function verifica()
{
	var nome = document.getElementById("nome").value;
	var empresa = document.getElementById("empresa").value;
	var ramo = document.getElementById("ramo").value;
	var email = document.getElementById("email").value;
	var telefone = document.getElementById("telefone").value;
	var cidade = document.getElementById("cidade").value;
	var mensagem = document.getElementById("mensagem").value;
	if(nome == "")
	{
		alert('Favor preencher campo nome');
		return false;
	}
	if(empresa == "")
	{
		alert('Favor preencher campo empresa');
		return false;
	}
	if(ramo == "")
	{
		alert('Favor preencher campo ramo');
		return false;
	}
	if(email == "")
	{
		alert('Favor preencher campo email');
		return false;
	}
	if(telefone == "")
	{
		alert('Favor preencher campo telefone');
		return false;
	}
	if(cidade == "")
	{
		alert('Favor preencher campo cidade');
		return false;
	}
	if(mensagem == "")
	{
		alert('Favor preencher campo mensagem');
		return false;
	}
		return true;	
}


function mostra_noticia()
{
		var id_noticia = document.getElementById("noticia").value;

		destino = "index.php?origem=noticias_corpo&id="+id_noticia;
		window.location.href = destino;

}

function confere_dados()
{
	var nome = document.getElementById("nome").value;
	var empresa = document.getElementById("empresa").value;	
	var email = document.getElementById("email").value;
	var telefone = document.getElementById("telefone").value;
	var cidade = document.getElementById("cidade").value;
	var mensagem = document.getElementById("mensagem").value;	
	
	if((nome == "") || (empresa == "") || (email == "") || (telefone == "") || (cidade == "") || (mensagem == ""))// verica se algum destes campos está vazio
	{
		//alert("Existe algum campo que não foi preenchido, por favor verifique");
		alert("Favor verificar se os campos Nome, Empresa, Email , Telefone e Cidade estão preenchidos.");
		//nome = "NOME";
		return false;
	}else{
		//nome = "";
		return true;
	}
	
}
