var map;

function load()
{
  if (GBrowserIsCompatible())
  {
    map = new GMap2(document.getElementById("map"));
    map.setCenter(new GLatLng(61.767580, 16.699219), 4);
    map.addControl(new GSmallMapControl());
    map.enableScrollWheelZoom();

    map.addMapType(G_PHYSICAL_MAP);
    map.setMapType(G_PHYSICAL_MAP);
    var mapControl = new GMapTypeControl();
    map.addControl(mapControl);

    objRouteForecast = new MGRouteForecast(map, {
      symbols: {
        url: "fileadmin/mapapps/weather-to-go/64px/{IMG_NAME}.png",
        dimensions: {
          x: 64,
          y: 64
        }
      },
      route: {
        directionsOptions:
        {
          avoidHighways: false
        }
      },
	  backend: {
		  script: "/fileadmin/mapapps/weather-to-go/getweather_se.php"
	  }
    });
  }
}

function showExtendedInputs()
{
  $(".extendedSet").css("display", "block");
  $(".nonExtended").attr("disabled", "disabled");
  $(".klaus").css("border-bottom", "1px dotted rgb(0, 96, 172)");
  $(".klara").css("border", "1px dotted rgb(0, 96, 172)");
  $(".klara").css("border-bottom", "1px solid rgb(219, 232, 242)");
  $(".klara").css("background-color", "rgb(219, 232, 242)");
  $(".whiteinput").css("background-color", "rgb(255, 255, 255)");
}

function hideExtendedInputs()
{
  $(".extendedSet").css("display", "none");
  $(".nonExtended").removeAttr("disabled");
  $(".klaus").css("border", "none");
  $(".klara").css("border", "none");
  $(".klara").css("background-color", "rgb(255, 255, 255)");
  $(".whiteinput").css("background-color", "rgb(219, 232, 242)");
}

MGRouteForecast.prototype.handleDirectionLoadError = function(intErrorCode)
{
  if (intErrorCode === G_GEO_UNKNOWN_ADDRESS && $(".extendedSet").css("display") === "none")
  {
	showExtendedInputs();
    return;
  }
		
  switch (intErrorCode)
  {
    case G_GEO_BAD_REQUEST: document.getElementById("error").innerHTML = 'A directions request could not be successfully parsed. For example, the request may have been rejected if it contained more than the maximum number of waypoints allowed.'; break;
    case G_GEO_SERVER_ERROR: document.getElementById("error").innerHTML = 'A geocoding, directions or maximum zoom level request could not be successfully processed, yet the exact reason for the failure is not known.'; break;
    case G_GEO_MISSING_QUERY: document.getElementById("error").innerHTML = 'The HTTP q parameter was either missing or had no value. For geocoding requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.'; break;
    case G_GEO_UNKNOWN_ADDRESS: document.getElementById("error").innerHTML = 'No corresponding geographic location could be found for the specified address. This may be due to the fact that the address is relatively new, or it may be incorrect.'; break;
    case G_GEO_UNAVAILABLE_ADDRESS: document.getElementById("error").innerHTML = 'The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.'; break;
    case G_GEO_UNKNOWN_DIRECTIONS: document.getElementById("error").innerHTML = 'The GDirections object could not compute directions between the points mentioned in the query. This is usually because there is no route available between the two points, or because we do not have data for routing in that region.'; break;
    case G_GEO_BAD_KEY: document.getElementById("error").innerHTML = 'The given key is either invalid or does not match the domain for which it was given.'; break;
    case G_GEO_TOO_MANY_QUERIES: document.getElementById("error").innerHTML = 'The given key has gone over the requests limit in the 24 hour period or has submitted too many requests in too short a period of time. If you´re sending multiple requests in parallel or in a tight loop, use a timer or pause in your code to make sure you don´t send the requests too quickly.'; break;
  }
};

