﻿
// globally scoped variables
var map = null;

// load the google maps ajax library (version 2.x)
google.load("maps", "2.x");

// set the main initialization function to execute when the page loads
google.setOnLoadCallback(initialize);

function initialize()
{
	// check for compatibility
	if (!GBrowserIsCompatible())
		return false;

    // initialise the map
	var mapDiv = document.getElementById("mapDiv");
	map = new google.maps.Map2(mapDiv);
    
	// add the standard controls
	map.addControl(new google.maps.LargeMapControl());
	map.addControl(new google.maps.MapTypeControl());
	map.addControl(new google.maps.OverviewMapControl());

	// enable zooming features
	map.enableDoubleClickZoom();
	map.enableContinuousZoom();
	map.enableScrollWheelZoom();

	// disable page from scrolling when zooming with scroll wheel
	google.maps.Event.addDomListener(mapDiv, "DOMMouseScroll", disableMapScrollWheel);
	mapDiv.onmousewheel = disableMapScrollWheel; // needed for IE?
	
	// centre on salts mill, bradford
	var centrePoint = new google.maps.LatLng(53.837023, -1.778839);
	
	// set the starting position and zoom level
	map.setCenter(centrePoint, 7);	

	// add a marker to the map
	var marker = new google.maps.Marker(centrePoint);
	map.addOverlay(marker);
	
	// open an info window on the marker
	marker.openInfoWindowHtml("<div style=\"height:20px\"><strong>The Early Music Shop</strong><br /><a href=\"http://www.saltsmill.org.uk/\" target=\"_blank\">Salts Mill</a>, Saltaire</div>");
}

function disableMapScrollWheel(e)
{
	if (!e) e = window.event;
	if (e.preventDefault) e.preventDefault();
	e.returnValue = false;
}

function onPageUnload()
{
	GUnload();
}


// "get directions" textbox functions

var getDirectionsPromptText = 'town or postcode';

function hideInputTextBoxPrompt(inputTextBox)
{
	if (inputTextBox.value == getDirectionsPromptText)
	{
		inputTextBox.value='';
		inputTextBox.className = '';
	}
}

function showInputTextBoxPrompt(inputTextBox)
{
	if (inputTextBox.value == '')
	{
		inputTextBox.value = getDirectionsPromptText;
		inputTextBox.className = 'textboxPrompt'; // make the text gray
	}
}


