
    //<![CDATA[
var map;
var icon0;
var newpoints = new Array();
 
function addLoadEvent(func) { 
	var oldonload = window.onload; 
	if (typeof window.onload != 'function'){ 
		window.onload = func
	} else { 
		window.onload = function() {
			oldonload();
			func();
		}
	}
}
 
addLoadEvent(loadMap);
addLoadEvent(addPoints);
 
function loadMap() {
	map = new GMap(document.getElementById("map"));
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
 
	map.centerAndZoom(new GPoint( -1.1031 , 54.5755), 4);
 
	icon0 = new GIcon();
	icon0.image = "http://www.measurementscience.co.uk/images/maplocation.png";
	icon0.shadow = "http://www.measurementscience.co.uk/images/shade.png";
	icon0.iconSize = new GSize(29, 29);
	icon0.shadowSize = new GSize(29, 29);
	icon0.iconAnchor = new GPoint(9, 34);
	icon0.infoWindowAnchor = new GPoint(9, 2);
	icon0.infoShadowAnchor = new GPoint(18, 25);
}
 
function addPoints() {
 
	newpoints[0] = new Array( -1.1031, 54.5755, icon0, 'Esox', '<div id="popup"><span class="tle">Intertek Measurement Science Group</span></b><br>Wilton Centre, Wilton, Redcar, TS10 4RF, UK<br><br><span class="tle">Driving Directions</span><br>Add your starting point within the box below<br>    <input type="text" id="from" />&nbsp;<input type="button" id="button" onclick="loadDirections();" value="Get route" /></div>'); 
 
	for(var i = 0; i < newpoints.length; i++) {
 
		var point = new GPoint(newpoints[i][0],newpoints[i][1]);
 
		//Add overlay to map 
		var popuphtml = newpoints[i][4] ;
		var marker = createMarker(point,newpoints[i][2],popuphtml);
		map.addOverlay(marker);
	}
}
 
function createMarker(point, icon, popuphtml) {
	var marker = new GMarker(point, icon);
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(popuphtml);
	});
	return marker;
}

		function loadDirections()
		{
			var startPoint=document.getElementById("from").value;
			var theurl = "http://maps.google.co.uk/maps?f=q&hl=en&q=" + startPoint + "+to+Wilton Centre TS10 4RF";
			var pp=window.open(theurl,"mapdirs");
		}

    //]]>