var map; var curState;
var mapSize = 12; var mgr; var icons = {};
var gmarkersSite = [];      
var gmarkersRegion = [];
var gmarkersFind = [];
var findAddressBnd = new GLatLngBounds();
var findAddLat; var findAddLong;
var findAddPoint = new GLatLng();
var findMarker;
var curIdx = 0; 
var findNoCentres = 4;
var findDistance = 1000;
var polyline = new Array();
var CentreMarkers = [];
var RegionMarkers = [];
//######################################
var myCentres = new Array();
function CentreDetails(CName, CState, CPoint, CID, CDist) 
{
    this.CName		= CName;
    this.CState	= CState;
    this.CPoint	= CPoint; 
    this.CID		= parseFloat(CID);
    this.CDist		= parseFloat(CDist);
}

function sortByCDist(a, b)
{
	var x = parseFloat(a.CDist);
   var y = parseFloat(b.CDist);
   return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}
//######################################

// ====== Geocoding ======
	var geoClient = new GClientGeocoder(); 
	var localSearch = new GlocalSearch();
	var geocoder = new GClientGeocoder(); //Not sure if this required
	
//###########################
// ====== Array for decoding the failure codes ======
      var reasons=[];
      reasons[G_GEO_SUCCESS]            = "Success";
      reasons[G_GEO_MISSING_ADDRESS]    = "Missing Address: The address was either missing or had no value.";
      reasons[G_GEO_UNKNOWN_ADDRESS]    = "Unknown Address:  No corresponding geographic location could be found for the specified address.";
      reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";
      reasons[G_GEO_BAD_KEY]            = "Bad Key: The API key is either invalid or does not match the domain for which it was given";
      reasons[G_GEO_TOO_MANY_QUERIES]   = "Too Many Queries: The daily geocoding quota for this site has been exceeded.";
      reasons[G_GEO_SERVER_ERROR]       = "Server error: The geocoding request could not be successfully processed.";
      reasons[403]                      = "Error 403: Probably an incorrect error caused by a bug in the handling of invalid JSON.";
//###########################
//LocalHost
//<script src="http://maps.google.com.au/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAfuSRCzKdq1oyNcAWMpL8sBT2yXp_ZAY8_ufC3CFXhHIE1NvwkxT3Emu_o1sMk-xIucko3Qe7M2IwYw" type="text/javascript">
//<script src="http://www.google.com/uds/api?file=uds.js&v=1.0&key=ABQIAAAAfuSRCzKdq1oyNcAWMpL8sBT2yXp_ZAY8_ufC3CFXhHIE1NvwkxT3Emu_o1sMk-xIucko3Qe7M2IwYw" type="text/javascript" />

//kennards.co.nz
//ABQIAAAAfuSRCzKdq1oyNcAWMpL8sBR1tIhHryfnET6x1sEUFKsU5JEP2xSGpT2DF_2NVibanNfroZnaUIppmA

//kss.com.au
//<script src="http://maps.google.com.au/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAfuSRCzKdq1oyNcAWMpL8sBQLFx4ckMIbG4OtYmifx8-qu66mrxRl00YMFE_e2NzsGfDKAdKLcE8cDg" type="text/javascript">
//<script src="http://www.google.com/uds/api?file=uds.js&v=1.0&key=ABQIAAAAfuSRCzKdq1oyNcAWMpL8sBQLFx4ckMIbG4OtYmifx8-qu66mrxRl00YMFE_e2NzsGfDKAdKLcE8cDg" type="text/javascript" />


//localhost //ABQIAAAAfuSRCzKdq1oyNcAWMpL8sBT2yXp_ZAY8_ufC3CFXhHIE1NvwkxT3Emu_o1sMk-xIucko3Qe7M2IwYw
//kss.com.au //ABQIAAAAfuSRCzKdq1oyNcAWMpL8sBQLFx4ckMIbG4OtYmifx8-qu66mrxRl00YMFE_e2NzsGfDKAdKLcE8cDg

//###########################

function initMap()
{
	map = new GMap2(document.getElementById("divGoogleMap"));
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
	map.enableDoubleClickZoom();
	//map.enableScrollWheelZoom();
	map.setCenter(new GLatLng(0,0),0,G_HYBRID_MAP);
}

function setCurZoom(tmpBounds, minZoom)
{
	map.setZoom(map.getBoundsZoomLevel(tmpBounds));	
	if (minZoom > 0 && map.getBoundsZoomLevel(tmpBounds) > 9) {map.setZoom(9)};
	if (map.getBoundsZoomLevel(tmpBounds) > 15){map.setZoom(15); }
	map.setCenter(tmpBounds.getCenter());

	//DivError.innerHTML = 'tmpBounds: ' + tmpBounds ; //map.getZoom()
	//DivError.innerHTML += '<BR>Min: ' + (minZoom > 0) + ' - ' + minZoom
	//DivError.innerHTML += '<BR> Center: ' + tmpBounds.getCenter()
}
function CentreOver(myID){GEvent.trigger(CentreMarkers[myID], "mouseover"); }
function CentreOut(myID){GEvent.trigger(CentreMarkers[myID], "mouseout"); }

function RegionOver(myID){GEvent.trigger(RegionMarkers[myID], "mouseover"); }
function RegionOut(myID){GEvent.trigger(RegionMarkers[myID], "mouseout"); }

//###########################
//Current using Lat and long
//###########################
function loadCentre(tmpState, tmpName, tmpID, tmpLat, tmpLong, tmpAdd, tmpPhone, tmpFax, tmpEmail, tmpBound, tmpRegionBnd, tmpHtml)
{
	var point = new GLatLng(tmpLat, tmpLong);
	var marker = createMarker(point, tmpName, tmpID, tmpState, tmpHtml);
   CentreMarkers[tmpID] = marker;
	
	gmarkersSite.push(marker);
	myCentres[curIdx] = new CentreDetails(tmpName, tmpState, new GLatLng(tmpLat,tmpLong), tmpID, 0) ;
	curIdx++ 
	if (curIdx < 4) {findNoCentres = curIdx}
	
	// ==== Each time a point is found, extent the bounds to include it =====
	tmpBound.extend(point);
	if (tmpRegionBnd != '') { tmpRegionBnd.extend(point);}
	
}

function loadRegion(tmpState, tmpName, tmpRegionBnd, tmpID, tmpHtml)
{
	var point = tmpRegionBnd.getCenter(); //new GLatLng(tmpRegionBnd.getCenter());
	var marker = createMarkerRegion(point, tmpName,  tmpState, tmpHtml, tmpRegionBnd);
	RegionMarkers[tmpID] = marker;
	gmarkersRegion.push(marker);
}
	
function createMarker(point, name, thisID, State, html) {
	var myIcon = getIcon(); 
	var marker = new GMarker(point,{icon:myIcon});
	if (thisID != 0 ){ GEvent.addListener(marker, 'click', function() { window.location = "/brouchre.php?locationId=" + thisID } );}
	//var opts = {maxWidth :100};
	//,{suppressMapPan:true}
	GEvent.addListener(marker, 'mouseover', function() { marker.openInfoWindowHtml(html );} );
	GEvent.addListener(marker, 'mouseout', function() {marker.closeInfoWindow()} );
	//closeInfoWindow
	return marker;
}

function createMarkerRegion(point, name, State, html, tmpRegionBnd) {
	//var myTitle = (name + " Region " + State)
	var myIcon = getIconRegion(); 
	//var marker = new GMarker(point, {icon:myIcon, title:myTitle});
	var marker = new GMarker(point, {icon:myIcon});
	GEvent.addListener(marker, 'click', function() {  changeRegion(State, name, tmpRegionBnd)} );
	GEvent.addListener(marker, 'mouseover', function() { marker.openInfoWindowHtml(html );} );
	GEvent.addListener(marker, 'mouseout', function() {marker.closeInfoWindow()} );
	return marker;
}

function createMarkerFind(point, name) {
	//var myTitle = (name + " Region " + State)
	var myIcon = getIconFind(); 
	var html = "Your requested Address:<BR> " + name
	//var marker = new GMarker(point, {icon:myIcon, title:thisTitle});
	var marker = new GMarker(point, {icon:myIcon});
	
	GEvent.addListener(marker, 'mouseover', function() { marker.openInfoWindowHtml(html);} );
	//GEvent.addListener(marker, 'mouseout', function() {marker.closeInfoWindow()} );
	return marker;
}

//###########################
//get The ICON
//###########################
function getIcon() 
{
	var icon = new GIcon();
//   icon.image = "images/Pin_Orange1.png";
//   icon.shadow = "images/Pin_shadow.png";
//   icon.iconSize = new GSize(13 , 22);
//   icon.shadowSize = new GSize(22, 20);
//   icon.iconAnchor = new GPoint(6, 20);
//   icon.infoWindowAnchor = new GPoint(5, 1);   
   
   //icon.centerIcon = new GIcon(this.selectedIcon);
  icon.image = "/images/arrowSmallOrange.gif";
  icon.shadow = "/images/arrowshadow.png";;
  icon.iconSize = new GSize(31, 27);
  icon.shadowSize = new GSize(31, 27);
  icon.iconAnchor = new GPoint(8, 27);
  icon.infoWindowAnchor = new GPoint(5, 1);
	return icon;
}	

function getIconRegion() 
{
	var icon = new GIcon();
   icon.image = "/images/arrowLargeOrange.gif";
   icon.shadow = "/images/arrowshadow.png";
   icon.iconSize = new GSize(40, 35);
   icon.shadowSize = new GSize(40, 35);
   icon.iconAnchor = new GPoint(6, 20);
   icon.infoWindowAnchor = new GPoint(5, 1);      
	return icon;
}	

function getIconFind() 
{
	var icon = new GIcon();
   icon.image = "/images/arrowLargeBlue.gif"; //
   icon.shadow = "/images/arrowshadow.png";
  icon.iconSize = new GSize(40, 35);
  icon.shadowSize = new GSize(40, 35);
  icon.iconAnchor = new GPoint(8, 27);
  icon.infoWindowAnchor = new GPoint(5, 1);     
	return icon;
}
//#################################
//Find for Online Quote and Box Shop
//#################################
function findAddress2(theAddress, tmpDivErr, tmpResults) 
{
	if (document.getElementById(tmpResults) != null) { document.getElementById(tmpResults).innerHTML = '';}
	if (theAddress != '')
	{
		var uri = window.location.hostname;
		if (uri == "www.kennards.co.nz") { theAddress = theAddress + ' New Zealand'}
		else										{ theAddress = theAddress + ' Australia' }
		document.getElementById(tmpDivErr).innerHTML  = '';	
		geoClient.getLocations(theAddress, function (result)
		{ 
			// If that was successful
			if (result.Status.code == G_GEO_SUCCESS) 
			{
				// Lets assume that the first marker is the one we want
				var p = result.Placemark[0].Point.coordinates;
				findAddLat	= p[1];
				findAddLong	= p[0];
				findAddPoint = new GLatLng(findAddLat,findAddLong);
				getFind(findAddPoint, result.Placemark[0].address, tmpResults);
			}else{
				// ====== Decode the error status ======
				var reason= result.Status.code;
				if (reasons[result.Status.code]) { reason = reasons[result.Status.code] }
				if (document.getElementById(tmpDivErr) != null) {document.getElementById(tmpDivErr).innerHTML  = "<U>ERROR:</U> " +  reason;}
				alert(reason);
			}
		});
	}
}

function getFind(thisPoint, tmpName, tmpResults)
{
	//Clear the findAddress Bound before adding the Centres and the search location
	findAddressBnd =  new GLatLngBounds(); 
	findAddressBnd.extend(thisPoint);
	findMarker = createMarkerFind(thisPoint, tmpName);
	loadDistances();
	myCentres.sort(sortByCDist); // Sort the Centres by Distance to entered Search Suburb
	searchResults(tmpResults);
}

function searchResults(tmpResults)
{
	var tmpDsp = "<BR><div class='centreResultsHdr1'>Search Results"
	tmpDsp = tmpDsp  + "</div>"
	if (myCentres[0].CDist <= findDistance)
	{
		tmpDsp = tmpDsp + "<Table width='100%' border=0 ><TR class='centreResultsHdr'><TD width=35% >Centre</td><TD width=15%>Distance</td> <TD width=40%></td></tr>";
		for (var j = 0; j < findNoCentres ; j++)
		{
			if (myCentres[j].CDist <= findDistance)
			{
				tmpDsp = tmpDsp + "<TR class='centresList' >"
				tmpDsp = tmpDsp + "<TD title='Click to select centre'  ><A HREF='javascript:selectCentre(" + myCentres[j].CID + ");'>" 
				tmpDsp = tmpDsp + myCentres[j].CName +  ", " + myCentres[j].CState + '</A></td>' 
				tmpDsp = tmpDsp + "<TD style='cursor: auto;'>" + myCentres[j].CDist + ' kms </td>';
				tmpDsp = tmpDsp + "<td>&nbsp; <A HREF='javascript:OpenCentre(" + myCentres[j].CID + ");'>Tell me more about this centre.</A></td></tr>"
				findAddressBnd.extend(myCentres[j].CPoint);
			}
		}
		tmpDsp = tmpDsp +  "</Table>"
	}
	else 
	{ 
		tmpDsp = tmpDsp + "<div class='divError'><BR>Sorry there are no Centres within " + findDistance + " km's of your selection.<BR><BR></div>";
	}
	var tmpThis = document.getElementById(tmpResults);
	if (tmpThis != null) { tmpThis.innerHTML = tmpDsp}
}

//#################################
//Find Entered Address 
//#################################
function findAddress(theAddress, tmpDivErr, tmpResults) 
{
	if (findMarker != null) { map.removeOverlay(findMarker); }; 
	if (document.getElementById(tmpResults) != null) { document.getElementById(tmpResults).innerHTML = '';}
	if (theAddress != '')
	{
		var uri = window.location.hostname;
		if (uri == "www.kennards.co.nz") { theAddress = theAddress + ' New Zealand';}
		else										{ theAddress = theAddress + ' Australia'; }
		//alert(theAddress);
		document.getElementById(tmpDivErr).innerHTML  = '';	
		geoClient.getLocations(theAddress, function (result)
		{ 
			// If that was successful
			if (result.Status.code == G_GEO_SUCCESS) 
			{
				// Lets assume that the first marker is the one we want
				var p = result.Placemark[0].Point.coordinates;
				findAddLat	= p[1];
				findAddLong	= p[0];
				findAddPoint = new GLatLng(findAddLat,findAddLong);
				addFind(findAddPoint, result.Placemark[0].address, tmpResults);
			}else{
				// ====== Decode the error status ======
				var reason= result.Status.code;
				if (reasons[result.Status.code]) { reason = reasons[result.Status.code] }
				if (document.getElementById(tmpDivErr) != null) {document.getElementById(tmpDivErr).innerHTML  = "<U>ERROR:</U> " +  reason;}
				alert(reason);
			}
		});
	}
}

function addFind(thisPoint, tmpName, tmpResults)
{
	//Clear the findAddress Bound before adding the Centres and the search location
	findAddressBnd =  new GLatLngBounds(); 
	findAddressBnd.extend(thisPoint);
	//var tmpHtml = tmpName 
	var html = "Your requested Address:<BR><B> " + tmpName
	findMarker = createMarkerFind(thisPoint, tmpName);
	map.addOverlay(findMarker);
	findMarker.openInfoWindowHtml(html);
	loadDistances();
	myCentres.sort(sortByCDist); // Sort the Centres by Distance to entered Search Suburb
	//dspCentres();// Test Function to display 
	getClosest(tmpResults);
	setCurZoom(findAddressBnd, 0);
	if (map.getBoundsZoomLevel(findAddressBnd) < 10) {map.setZoom(10)}
}

function IsIntegerPos(strString)
{
	//  check for valid numeric strings	
	var strValidChars = "0123456789";
	var strChar;
	var blnResult = true;
   
	if (strString.length == 0) return true;
	
	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++)
		{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
			{
			blnResult = false;
			}
		}
	return blnResult;
}
//#################################
//Find Distance 
//#################################
function getClosest(tmpResults)
{
	var tmpDsp = "<BR><div class='centreResultsHdr1'>Search Results"
	tmpDsp = tmpDsp  + "</div>"
	//setCurZoom(findAddressBnd, 0)
	if (myCentres[0].CDist <= findDistance)
	{
		tmpDsp = tmpDsp + "<Table width='100%' border=0 ><TR class='centreResultsHdr'><TD width=35% >Centre</td><TD width=15%>Distance</td><TD width=15%></td><TD width=35%></td></tr>";
		for (var j = 0; j < findNoCentres ; j++)
		{
			if (myCentres[j].CDist <= findDistance)
			{
				//addLine(j,findMarker.getPoint(),myCentres[j].CPoint)
				tmpDsp = tmpDsp + "<TR class='centresList' onmouseover='javascript:CentreOver(" + myCentres[j].CID + ")' onmouseout='javascript:CentreOut(" + myCentres[j].CID + ")'>"
				tmpDsp = tmpDsp + "<TD>" + myCentres[j].CName + ", " + myCentres[j].CState + '</td>' 
				tmpDsp = tmpDsp + '<TD>' + myCentres[j].CDist + ' kms </td>';
				tmpDsp = tmpDsp + "<TD align=center><A HREF='javascript:getQuote(" + myCentres[j].CID + ");'>Get Quote.</A> </td>";
				//"javascript:CentreOver('" & tmpData("ID") & "')"
				//javascript:CentreOut('" & tmpData("ID") & "')
				// />getQuote(" + myCentres[j].CID + ");
				//onclick='OpenCentre(" + myCentres[j].CID + ");'  title='" + "Click to View our " + myCentres[j].CName + " Centre' " + myCentres[j].CName + "
				tmpDsp = tmpDsp + "<td>&nbsp; <A HREF='javascript:OpenCentre(" + myCentres[j].CID + ");'>Tell me more about this centre.</A></td></tr>"
				findAddressBnd.extend(myCentres[j].CPoint);
			}
		}
			tmpDsp = tmpDsp +  "</Table>"
		
	}
	else 
	{ 
		tmpDsp = tmpDsp + "<div class='divError'><BR>Sorry there are no Centres within " + findDistance + " km's of your selection.<BR><BR></div>";
	}
	var tmpThis = document.getElementById(tmpResults);
	if (tmpThis != null) { tmpThis.innerHTML = tmpDsp}
}

function loadDistances()
{
	//alert(myCentres.length);
	for (var i = 0; i < myCentres.length; i++)
	{
		var d = findMarker.getPoint().distanceFrom(myCentres[i].CPoint)/1000;
		myCentres[i].CDist = d.toFixed(2);
	}
}

function dspCentres()
{
	alert('here');
	var tmpMe = document.getElementById("DivError")
	tmpMe.innerHTML = tmpMe.innerHTML + findMarker.getPoint() + ' <BR>';
	for (var i = 0; i < myCentres.length && i < findNoCentres; i++)
	{
		tmpMe.innerHTML = tmpMe.innerHTML + myCentres[i].CName + ' : ' +  myCentres[i].CPoint  + ' : ' +  myCentres[i].CDist  + 'kms <BR>';
	}
}
//#############################
//Add Line
//##############################
function addLine(myCtr, point1, point2)
{
	var tmpPoly = new GPolyline([point1,point2], "#ff0000", 10);
	map.addOverlay(tmpPoly);
	//polyline(myCtr) = tmpPoly;
}

//##################################################
//Other  Test Functions
//##################################################
//###########################
//Used by FindLatLongMap.aspx
//###########################
function findCentre(tmpState, tmpName, tmpLat, tmpLong, tmpAdd, tmpBound)
{
	//alert('here')
	//geocoder.getLatLng(address)
	var point = new GLatLng(tmpLat, tmpLong);
	//alert(point);
	var tmpHtml = tmpName + "<BR>" + tmpState
	var marker = createMarker(point, tmpName, 0, tmpState, tmpHtml);

	gmarkersSite.push(marker);
	//#########

	// ==== Each time a point is found, extent the bounds to include it =====
	//if (curState == tmpState) {curBounds.extend(point); }
	tmpBound.extend(point);
}

//###########################
//Search Prompt
//###########################
function addSearch()
{
//Require a new Key 
//http://www.google.com/uds/solutions/localsearch/reference.html
//http://code.google.com/apis/ajaxsearch/documentation/reference.html#_class_GSearchForm
// create your map
//var map = new GMap2(document.getElementById("map_canvas"));
// create a local search control and add it to your map
var lsc = new google.maps.LocalSearch(); 
map.addControl(new google.maps.LocalSearch());
}
//#####################################
	//Can't figure it out can't find centre addresses
	//#######################################
	function AddCentre1(tmpState, tmpName, tmpAdd)
	{
		var tmpFullAdd = tmpAdd + ' ' + tmpName + ' ' + tmpState //+ ' Australia' 
		geocoder.getLatLng(tmpFullAdd , function(point) 
											{      
											if (!point) {alert(tmpFullAdd + " not found");} 
											else 
											{        
												var Icon = getIcon();
												// Create a marker
												var marker = new GMarker(point,Icon);
												// Add the marker to map
												map.addOverlay(marker);       
											}    
											}  
								);
	}
	
	function AddCentre(tmpState, tmpName, tmpAdd)
	{
		var tmpFullAdd = tmpAdd + ' ' + tmpName + ' ' + tmpState //+ ' Australia' 
		geocoder.getLocations(tmpFullAdd, function (response) {
			if (!response || response.Status.code != 200) {
			  alert("Sorry, we were unable to geocode that address: " + response.Status.code);
			} else {
				place = response.Placemark[0];
				point = new GLatLng(place.Point.coordinates[1],
										 place.Point.coordinates[0]);
				var Icon = getIcon();
				// Create a marker
				var marker = new GMarker(point,Icon);
				// Add the marker to map
				map.addOverlay(marker);  
			}
		 });
	}
	
	
function showAddress(address) 
{  
	geocoder.getLatLng(address, function(point) 
										{      
										 if (!point) {alert(address + " not found");} 
										 else 
										 {        
											//G_NORMAL_MAP ; G_SATELLITE_MAP ; G_HYBRID_MAP
											  map.setCenter(point, mapSize,G_SATELLITE_MAP);        
											  var marker = new GMarker(point);        
											  map.addOverlay(marker);        
										 }    
										}  
							);
}

	function setupOfficeMarkers() {
		mgr = new GMarkerManager(map);
		for (var i in officeLayer)
		{
		  var layer = officeLayer[i];
		  var markers = [];
		  for (var j in layer["places"]) 
		  {
			 var place = layer["places"][j];
			 var icon = getIcon(place["icon"]);
			 var posn = new GLatLng(place["posn"][0], place["posn"][1]);
			 markers.push(new GMarker(posn, { title: place["name"], icon: icon }));
		  }
		  mgr.addMarkers(markers, layer["zoom"][0], layer["zoom"][1]);
		}
		mgr.refresh();
	}

//	var officeLayer = [{ "zoom"	:[0, 3],    
//								"places"	:[      
//									{"name": "US Offices", "icon": ["us", "flag-shadow"], "posn": [40, -97] },      
//									{"name": "Canadian Offices", "icon": ["ca", "flag-shadow"], "posn": [58, -101] }    
//							]  },  ...};

	
//##################################################
//Current Test Functions
//##################################################

//doLatLong(-33.8094261633,151.17768930);}
function doLatLong(lat, lng)
{
	map = new GMap2(document.getElementById("divGoogleMap"));
   geocoder = new GClientGeocoder();
   
	var point = new GLatLng(lat,lng);
	map.setCenter(point, mapSize,G_SATELLITE_MAP);        
	var marker = new GMarker(point);        
   map.addOverlay(marker);   
	map.addControl(new GLargeMapControl());
   map.enableDoubleClickZoom();
   map.addControl(new GMapTypeControl());
}


//if (document.getElementById("divGoogleMap") != null)  {doGoogleMap();}
function doGoogleMap()
{
		var address1 = document.getElementById("cmbStates").value;
      mapSize = getSize(address1);
        
      if (address1 == '') { address1 ='Australia';}
      else { address1 = address1 + ', Australia';}
      //address1 = "1 Columbia Lane, Homebush NSW, Australia"
      
		map = new GMap2(document.getElementById("divGoogleMap"));
      geocoder = new GClientGeocoder();
      //geocoder.GClientGeocoder.setBaseCountryCode("AU");
      //var trafficInfo = new GTrafficOverlay();
      showAddress(address1);
      map.addControl(new GLargeMapControl());
      map.enableDoubleClickZoom();
      map.addControl(new GMapTypeControl());
      //window.setTimeout(setupOfficeMarkers, 0);
      //var center = map.getCenter();
     // window.setTimeout(setupOfficeMarkers, 0);
}
    
    