// Globally define icons
var icon = new Array();
var iconColor = new Array();
var marker_html1 = new Array();
var marker_html2 = new Array();
var pageURLbox = false;
var gmarkers = [];

// Click sidebar controller
function click_sidebar(idx) {
	GEvent.trigger(gmarkers[idx], "click");
//	marker[idx].openInfoWindowTabsHtml(marker_html1[idx]);
	location.href="#mapbox";
}

iconColor[0] = "blue";
iconColor[1] = "green";
iconColor[2] = "red";
iconColor[3] = "orange";
iconColor[4] = "white";
iconColor[5] = "black";
iconColor[6] = "purple";

function recenter(address) {
	dirtyFlag = true;
	document.getElementById("STREET").value = address;
	loadData();
}

function initializeMap() {
	var map = new google.maps.Map2(document.getElementById("map"));
	for (var i = 0; i < 7; i++) {
		icon[i] = new GIcon();
		icon[i].image = "http://labs.google.com/ridefinder/images/mm_20_" + iconColor[i] + ".png";
		icon[i].shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		icon[i].iconSize = new GSize(12, 20);
		icon[i].shadowSize = new GSize(22, 20);
		icon[i].iconAnchor = new GPoint(6, 20);
		icon[i].infoWindowAnchor = new GPoint(5, 1);	
	}
	map.addControl(new GSmallMapControl());
	map.addControl(new GScaleControl());
	map.addControl(new GMapTypeControl());

	return map;
}

function centerMap(map, centerX, centerY) {
	map.setCenter(new google.maps.LatLng(centerX, centerY));
}

function setZoom(map, minX, maxX, minY, maxY) {
	var bds = new GLatLngBounds(new GLatLng(minX, minY), new GLatLng(maxX, maxY));
	map.setZoom(map.getBoundsZoomLevel(bds));
}

function createMarker(point, tabs, color) {
	var ic = icon[color];
	var marker = new GMarker(point, {icon: ic});
    marker.tabs = tabs;
	return marker;
}

function createTabbedMarker(point,tabs,color) {
	var ic = icon[color];
	var marker = new GMarker(point,ic);
	var marker_num = gmarkers.length;
	marker.marker_num = marker_num;
	marker.tabs = tabs;
	gmarkers[marker_num] = marker;
	GEvent.addListener(gmarkers[marker_num], "click", function() {
		marker.openInfoWindowTabsHtml(gmarkers[marker_num].tabs);
	});
	return marker;
}

function graphicType(i) {
	if (i == 1) {
		jQuery(".taxpersqft").css("display", "none");
		jQuery(".display_persqft").css("display", "none");
		jQuery("#sqftlink").removeClass("selected-option");
		jQuery(".taxpermv").css("display", "inline");
		jQuery(".display_permv").css("display", "inline");
		jQuery("#mvlink").addClass("selected-option");
	}
	if (i == 0) {
		jQuery(".taxpermv").css("display", "none");
		jQuery(".display_permv").css("display", "none");
		jQuery("#mvlink").removeClass("selected-option");
		jQuery(".taxpersqft").css("display", "inline");
		jQuery(".display_persqft").css("display", "inline");
		jQuery("#sqftlink").addClass("selected-option");
	}
}

function mouseOver(thing) {
}