var map = "";
var directionsPanel;
var directions;
    
var localSearch = new GlocalSearch();

	function switchMenu(menuName) {

	    if (document.getElementById(menuName).style.display == 'none' || document.getElementById(menuName).style.display == '') {
	        document.getElementById(menuName).style.display = 'block';
	    } else {
	        document.getElementById(menuName).style.display = 'none';
	    }
	}

var emailAddress1 = '<a href="mailto:&#101;&#110;q&#117;&#105;&#114;&#105;&#101;&#115;&#64;&#97;&#98;&#101;rco&#110;&#119;&#121;&#114;&#101;&#115;&#111;&#114;&#116;.&#99;&#111;&#109;">&#101;&#110;q&#117;&#105;&#114;&#105;e&#115;&#64;&#97;&#98;&#101;&#114;&#99;&#111;&#110;&#119;&#121;&#114;&#101;&#115;o&#114;&#116;&#46;&#99;&#111;&#109;</a>';

    function clearData(thisBox, value)
	{
	    if(thisBox.value ==(value))
	    {
            thisBox.value = ("");	    
	    }

	}
	
	function resetData(thisBox, value)
	{
		if(thisBox.value == (""))
	    {
            thisBox.value = value;
	    }
	}
	
    function usePointFromPostcode(postcode, callbackFunction) {
  
    localSearch.setSearchCompleteCallback(null, 
    function() {
      
      if (localSearch.results[0]) {    
        var resultLat = localSearch.results[0].lat;
        var resultLng = localSearch.results[0].lng;
        var point = new GLatLng(resultLat,resultLng);
        callbackFunction(point);
      }else{
        alert("Postcode not found!");
      }
    });  
    
  localSearch.execute(postcode + ", UK");
}
	
	function getRoute2() {
      if (GBrowserIsCompatible()) {
        
        var map = new GMap2(document.getElementById("map"));
        	       
        usePointFromPostcode(document.getElementById("txtPostcode").value,
    
        function (point) {

    	map.setCenter(point, 17);
		
        map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.setCenter(new GLatLng(53.408827,-2.226869), 15);
        directionsPanel = document.getElementById("directions");
        directionsPanel.innerHTML = "";
        
        directions = new GDirections(map, directionsPanel);

        var point1 = point;
        var point2 = new GLatLng(53.408827,-2.226869);
        directions.loadFromWaypoints([point1,point2],{getPolyline:true,getSteps:true})

        });
        
      }
    }

	function officeMap()
	{
		
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		// map.addControl(new GOverviewMapControl());
		map.enableDoubleClickZoom();
					
		var point = new GLatLng(53.408827,-2.226869);

		map.setCenter(point, 15);
		
		var marker = new GMarker(point);
			
		GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml("<p>NJL Consulting</p>");
		});	
		
		map.addOverlay(marker);
		
		//map.addOverlay(geoXml);
}


	
	
