// JavaScript Document

$(function() {
	$("#menu").lavaLamp({ 
		speed: 400,
		click: function(event, menuItem) {
			return true;
		}
	});
	
});

$('#banners').cycle({ 
	fx:    'fade', 
	speed:  2500 
});

$('#parceiros').cycle({ 
	fx:    'scrollLeft', 
	speed:  2500 
});

$(document).ready(function() {
	//Carrega elementos do flash
	
	var flashvars = {};
	var params = {
		wmode: "transparent"
	};
	var attributes = {};
	
	swfobject.embedSWF("design/fortcon.swf", "logo", "200", "129", "10", true, flashvars, params, attributes);
	
	//Popup atendimento online
	$("#Atendimento").click(function () {  
		var caracteristicas = "height=558,width=458,scrollTo,resizable=0,scrollbars=0,location=0";  
		nueva=window.open(this.href, 'atendimento', caracteristicas);  
		return false;  
	}); 
	
}); 
 
 
//ANALYTICS 
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28449815-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

// GOOGLE MAPS ::::::::::::::::::::::::::::::::::::::::::	
		var map;
		var geocoder;
		var address;
		
		function initialize($pesquisa,$endereco,$cidade,$cep) {
		  map      = new GMap2(document.getElementById("mapa"));
		  map.addControl(new GLargeMapControl3D);
		  geocoder = new GClientGeocoder();
		  convertAddress($pesquisa,$endereco,$cidade,$cep);
		  
		  GEvent.addListener(map, "click", getAddress);  
		}
		
		function getAddress(overlay, latlng) {
		  if (latlng != null) {
			address = latlng;
			geocoder.getLocations(latlng, showAddress);
		  }
		}
		
		function convertAddress(address,$endereco,$cidadeUf,$cep) {
		  geocoder.getLatLng(address,function(point) {
			  if (!point) {
				alert(address + " não encontrado!");
			  } else {
				map.setCenter(point, 15);
				var marker = new GMarker(point);
				map.addOverlay(marker);
				marker.openInfoWindowHtml(
				'<p><b>Endere&ccedil;o:</b> ' + $endereco + '<br />' +
				'<p><b>Telefone:</b> ' + $cidadeUf + '</p>'
				);
			  }
			});
		}
		
		function showAddress(response) {
		  map.clearOverlays();
		  if (!response || response.Status.code != 200) {
			alert("Status Code:" + response.Status.code);
		  } else {
			place = response.Placemark[0];
			point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
			marker = new GMarker(point);
			map.addOverlay(marker);
			// '<b>Latitude:</b>' + place.Point.coordinates[0] + '<br>' +
			// '<b>Longitude:</b>' + place.Point.coordinates[1] + '<br>' +
			// '<b>Address:</b>' + place.address;
			$array    = place.address.split("-");
			$array_   = $array[3].split(",");
			$array__ = $array[4].split(",");
			marker.openInfoWindowHtml(
			   '<p><b>Endere&ccedil;o:</b> ' + $array[0] + '-' + $array[1] + '<br />' +
			   '<p><b>Cidade:</b> ' + $array[2] + '-' + $array_[0] + '</p>'
				);
		  }
		}	
		
// FIM GOOGLE MAPS :::::::::::::::::::::::::::::::::::::::::
