<!--
	var map
	var obj_mapicon
	var var_markercount = 0;
	var center
	var directionsPanel;
    var directions; 
	var arr_markers = new Array(50);
	
    for ( var var_arrayloop=0; var_arrayloop<50; ++var_arrayloop ){
        arr_markers[var_arrayloop] = ''; //to stop stupid undefined errors;
    }
    
	function func_loadmap() {
		if (GBrowserIsCompatible()) {
			map = new GMap2(document.getElementById("id_map"));
			center = new GLatLng(56.350000, -4.178830)
			map.setCenter(center, 8);
			map.addControl(new GSmallMapControl());
			
			//obj_mapicon = new GIcon();
			//obj_mapicon.image = "/_images/map_icon.png";
			//obj_mapicon.iconSize = new GSize(32, 15);
			//obj_mapicon.iconAnchor = new GPoint(16, 7);
			//obj_mapicon.infoWindowAnchor = new GPoint(16, 7);				
		} //if (GBrowserIsCompatible())
	}//window.onload = function()
	
	window.onunload = function() {
		GUnload();
	}
	
	function func_map_createpoint(vararg_point_x, vararg_point_y) {
	    var point   = new GLatLng(vararg_point_x,vararg_point_y);
	    return point;
	}
	
	function func_map_createmarker(vararg_point, vararg_content) {
	    
        if (var_markercount < 50) {
            var marker                      = new GMarker(vararg_point,{ icon: obj_mapicon });
            arr_markers[var_markercount]    = marker;
            marker.var_myid                 = var_markercount;
            marker.var_mycontent            = vararg_content;

		    GEvent.addListener(marker, "click", function() {
		        var content = func_map_html(marker.var_myid, vararg_content);
		        marker.openInfoWindowHtml(content, {maxWidth:'250'} );
	        });
			
		    map.addOverlay(marker);
		    map.setCenter(vararg_point, 8);
		    var_markercount = var_markercount + 1;
		} else {
		    alert ("You have reached the marker limit, if you have removed any markers then please save this page and return here to clear the marker cache.")
		}
	}
	
    function func_map_html(arg_id, arg_content){
        var var_content = "<div style=\"height:60px;\">" + arg_content + "<\/div>"
        return var_content;
    }
    
    function func_map_directions(){
        directionsPanel = document.getElementById("id_map_directions_results");
		directionsPanel.innerHTML = '';
        directions = new GDirections(map, directionsPanel);
        GEvent.addListener(directions, "error", handler_map_directions);
        var var_from    = document.getElementById('id_map_from').value;
        var var_to      = document.getElementById('id_map_to').options[document.getElementById('id_map_to').selectedIndex].value;
        //alert("from:" + var_from + " to:" + var_to);
        //document.getElementById("id_map_directions_results").innerHTML = "from:" + var_from + " to:" + var_to
        directions.load("from:" + var_from + " to:" + var_to);
    }
    
    function handler_map_directions(){
        var var_Ouput
	    if (directions.getStatus().code == G_GEO_UNKNOWN_ADDRESS) {
	        var_Ouput = "No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.";
	    } else if (directions.getStatus().code == G_GEO_SERVER_ERROR) {
	        var_Ouput = "A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.";
	    } else if (directions.getStatus().code == G_GEO_MISSING_QUERY) {
	        var_Ouput = "The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.";
	    } else if (directions.getStatus().code == G_GEO_BAD_KEY) {
	        var_Ouput = "The given key is either invalid or does not match the domain for which it was given.";
	    } else if (directions.getStatus().code == G_GEO_BAD_REQUEST) {
	        var_Ouput = "A directions request could not be successfully parsed.";	    
	    } else {
	        var_Ouput = "An unknown error occurred.";
	    }		
		var_Ouput = "<strong>" + var_Ouput + "</strong>"
		//var_Ouput = var_Ouput + "<br/>Error code: " + directions.getStatus().code
        document.getElementById("id_map_directions_results").innerHTML = var_Ouput
    }
    
//]]>