var geocoder;
var gables;
var homestead;
// var ocean;
var tavernier;
var marathon;
var pine;
var keywest;

function initialize() {
	var latlng = new google.maps.LatLng(25.157159,-81.005846);
	var myOptions = {
		zoom: 7,
		center: latlng,
		mapTypeControl: false,
		panControl: false,
		zoomControl: true,
		zoomControlOptions: {
			style: google.maps.ZoomControlStyle.SMALL
		},
		scaleControl: false,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	};
	var map = new google.maps.Map(document.getElementById("contact_map"),myOptions);

	//	For multiple pins on contact page map
	var nyLayer = new google.maps.KmlLayer('http://maps.google.com/maps/ms?ftid=0x88d1b14afd25385f:0x279a4e9c71fb0b03&hl=en&vps=16&ie=UTF8&authuser=0&msa=0&output=kml&msid=215379405434382606254.0004b04c04c9ac0c73900',{
		suppressInfoWindows: false,
		map: map
	});
}

function initializeLocations() {
	geocoder = new google.maps.Geocoder();
	var latlng = new google.maps.LatLng(25.750612, -80.23509);
	var myOptions = {
		zoom: 11,
		center: latlng,
		mapTypeControl: false,
		panControl: false,
		zoomControl: true,
		zoomControlOptions: {
			style: google.maps.ZoomControlStyle.SMALL
		},
		scaleControl: false,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	}
	gables = new google.maps.Map(document.getElementById("gables_map"), myOptions);
	homestead = new google.maps.Map(document.getElementById("homestead_map"), myOptions);
//	ocean = new google.maps.Map(document.getElementById("ocean_map"), myOptions);
	tavernier = new google.maps.Map(document.getElementById("tavernier_map"), myOptions);
	marathon = new google.maps.Map(document.getElementById("marathon_map"), myOptions);
	pine = new google.maps.Map(document.getElementById("pine_map"), myOptions);
	keywest = new google.maps.Map(document.getElementById("keywest_map"), myOptions);
}

function codeAddress() {
	var gablesAddress = '2441 Coral Way, 33145';
	var homesteadAddress = '975 Baptist Way #101, 33030';
//	var oceanAddress = '30 Ocean Reef Drive, 33037';
	var tavernierAddress = '91461 Overseas Hwy, 33070';
	var marathonAddress = '5701 Overseas Hwy #17, 33050';
	var pineAddress = '29755 Overseas Hwy, 33043';
	var keywestAddress = '2407 N Roosevelt Blvd, 33040';
	geocoder.geocode( { 'address': gablesAddress}, function(results, status) {
		if (status == google.maps.GeocoderStatus.OK) {
			gables.setCenter(results[0].geometry.location);
			var marker = new google.maps.Marker({
				map: gables,
				position: results[0].geometry.location
			});
		}
	});
	geocoder.geocode( { 'address': homesteadAddress}, function(results, status) {
		if (status == google.maps.GeocoderStatus.OK) {
			homestead.setCenter(results[0].geometry.location);
			var marker = new google.maps.Marker({
				map: homestead,
				position: results[0].geometry.location
			});
		}
	});
//	geocoder.geocode( { 'address': oceanAddress}, function(results, status) {
//		if (status == google.maps.GeocoderStatus.OK) {
//			ocean.setCenter(results[0].geometry.location);
//			var marker = new google.maps.Marker({
//				map: ocean,
//				position: results[0].geometry.location
//			});
//		}
//	});
	geocoder.geocode( { 'address': tavernierAddress}, function(results, status) {
		if (status == google.maps.GeocoderStatus.OK) {
			tavernier.setCenter(results[0].geometry.location);
			var marker = new google.maps.Marker({
				map: tavernier,
				position: results[0].geometry.location
			});
		}
	});
	geocoder.geocode( { 'address': marathonAddress}, function(results, status) {
		if (status == google.maps.GeocoderStatus.OK) {
			marathon.setCenter(results[0].geometry.location);
			var marker = new google.maps.Marker({
				map: marathon,
				position: results[0].geometry.location
			});
		}
	});
	geocoder.geocode( { 'address': pineAddress}, function(results, status) {
		if (status == google.maps.GeocoderStatus.OK) {
			pine.setCenter(results[0].geometry.location);
			var marker = new google.maps.Marker({
				map: pine,
				position: results[0].geometry.location
			});
		}
	});
	geocoder.geocode( { 'address': keywestAddress}, function(results, status) {
		if (status == google.maps.GeocoderStatus.OK) {
			keywest.setCenter(results[0].geometry.location);
			var marker = new google.maps.Marker({
				map: keywest,
				position: results[0].geometry.location
			});
		}
	});
}

initializeLocations();
codeAddress();

var $j = jQuery.noConflict();
$j(document).ready(function() {
	$j('.tabs-area').bind('tabsshow', function(event, ui) {
		if (ui.panel.id == 'tab-' || ui.panel.id == 'tab-1' || ui.panel.id == 'tab-2' || ui.panel.id == 'tab-3' || ui.panel.id == 'tab-4' || ui.panel.id == 'tab-5' || ui.panel.id == 'tab-6') {
			initializeLocations();
			codeAddress();
		}
	});
});
