//  Add an OverviewMapControl, minimized
//
GMap2.prototype.addOverviewMapControl = function() {
	var oControl = new GOverviewMapControl();
	this.addControl(oControl);
	oControl.hide(true);    // true = no animation
}

// Center and zoom to within bounds
//
GMap2.prototype.centerAndZoomOnBounds = function(bounds) {
	var span = new GSize(bounds.maxX - bounds.minX, bounds.maxY - bounds.minY);
	var center = new GPoint(bounds.minX + span.width / 2., bounds.minY + span.height / 2.);
	var newZoom = this.spec.getLowestZoomLevel(center, span, this.viewSize);
	if (this.getZoomLevel() != newZoom) {
		this.centerAndZoom(center, newZoom);
	} else {
		this.recenterOrPanToLatLng(center);
	}
}

// Create an icon based on another, with a new image
//
function createIcon(baseIcon, image) {
	var icon = new GIcon(baseIcon);
	icon.image = image;
	return icon;
}

// Create a marker from a latlng (point), html for the info window, an icon, and the marker's type
//
function createMarker(latlng, html, icon, type, zindex) {
	if (zindex)
		var marker = new GMarker(latlng, {icon:icon, zIndexProcess:zzz});
	else
		var marker = new GMarker(latlng, icon);
	GEvent.addListener(marker, 'click', function() {
		marker.openInfoWindowHtml(html);
	});
	marker.Zindex = zindex;
	marker.Type = type;
	return marker;
}

function zzz(mkr, b) {
	return mkr.Zindex;
}

// Open url in opener window and set focus
//
function linkOpener(url) {
	if (url.substring(0, 5) == 'http:') {
		var w = window.open(url);
		w.focus();
	} else if (window.opener && !window.opener.closed) {
		window.opener.document.location.href = url;
		window.opener.focus();
	} else {
		document.location.href = url;
	}
}

// Change overlay group to selected, switch sidebar
//
function showGroup(group) {
	document.getElementById('mapsidebarlist').innerHTML = sidebar[group];
}

function go(menu) {
	var ref = menu.group.options[menu.group.selectedIndex].value;
	alert(ref);
	window.open('/resortguide/areamap.cfm?a=co40&i=co40&t=1&q=2&p=1');
}

function jump(menu) {
	var ref = menu.choice.options[menu.choice.selectedIndex].value;
	var splitc = ref.lastIndexOf('*');
	var target = '';
	if (splitc != -1) {
		loc = ref.substring(0, splitc);
		target = ref.substring(splitc + 1, 1000);
	} else {
		loc = ref;
		target = '_self';
	}
	if (ref != '') land(loc, target);
}

function land(loc, target) {
	var lowtarget = target.toLowerCase();
	if (lowtarget == "_self")
		window.location = loc;
	else if (lowtarget == "_top")
		top.location = loc;
	else if (lowtarget == "_blank")
		window.open(loc);
	else if (lowtarget == "_parent")
		parent.location = loc;
	else
		parent.frames[target].location = loc;
}

