
var root = "http://www.decsant.com.br/";

$(document).ready(function() {
	var newsoption1 = {
		firstname: "depoimentos",
		secondname: "showhere",
		fourthname: "news_button",
		mouseover: false,
		newsspeed: '15000',
		effectspeed: '500',
		newscountname: "depoimento_contador",
		imagedir: root +"_imagem/"
	}

	$.init_news(newsoption1);
});

function abrir_contato(tipo) {
	var a = "fale_conosco/"+ tipo +"/?keepThis=true&TB_iframe=true&height=250&width=450";
	tb_show(null, a, false);
}

function abrir_imprensa(codigo) {
	var a = "imprensa_detalhes/"+ codigo +"/?keepThis=true&TB_iframe=true&height=450&width=700";
	tb_show(null, a, false);
}

var map;
var gdir;
var markerOrigem;

function load() {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("mapa"));
		gdir = new GDirections(map, document.getElementById("direcao"));
		GEvent.addListener(gdir, "load", onGDirectionsLoad);
		GEvent.addListener(gdir, "error", handleErrors);

		map.setCenter(new GLatLng('-25.091642624051374', '-50.16684724258423'), 16);

		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());

		map.setMapType(G_HYBRID_MAP);

		var locationOrigem = new GLatLng('-25.091526027640644', '-50.167222023010254');
		markerOrigem = new GMarker(locationOrigem);
		
		new GEvent.addListener(markerOrigem, "click", function() {
   			this.openInfoWindow("<p>Decsant IT Solutions</p>");
  		});

		map.addOverlay(markerOrigem);
	}
}

function handleErrors() {
	if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
		alert("O endereço informado não foi encontrado.\n\nUtilize o seguinte formato:\nRua, número, Cidade, UF");
	else
		alert("Ocorreu um erro ao tentar realizar a pesquisa.\nTente novamente.");
	
	$("#direcao").hide();
	$("#mapa").css("width", "735px");
	$("#mapa").css("float", "none");
}

function onGDirectionsLoad() {
	markerOrigem.hide();
	$("#direcao").show();
	$("#mapa").css("width", "485px");
	$("#mapa").css("float", "right");
}

function setDirections() {
	gdir.load("from: "+ $("#endereco").val() +" to: Frederico Bahls, 309, Ponta Grossa, PR", { "locale": "pt_BR" });
}