﻿
var
  MyMap,
  MyLatlng;

function MyMapsInit() 
{
  //InitDivMapSize();
  SetDivMapSize();
  
  MyLatlng = new google.maps.LatLng(FLatitudeInit, FLongitudeInit);
  var myOptions = {
    zoom: OptGoogleMapsInitialZoom,
    center: MyLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    scaleControl:true
  }
  MyMap = new google.maps.Map(document.getElementById(divGoogleMapId), myOptions);
  
  var marker = new google.maps.Marker({
      position: MyLatlng, 
      map: MyMap,
      title: FTitle
  });   
}

function CenterOnHotel()
{
  MyMap.setCenter(MyLatlng);
}

function InitDivMapSize()
{
  var el = document.getElementById(divGoogleMapId);
  el.style.width = OptGoogleMapsDivMapWidth + "px";
  el.style.height = OptGoogleMapsDivMapHeight + "px";
}

function SetDivMapSize()
{
  var newWidth = GetWindowWidth() - 2*OptGoogleMapsDivMapHorzMargin; 
  var newHeght = GetWindowHeight() - 2*OptGoogleMapsDivMapVertMargin;
  
  var el = document.getElementById(divGoogleMapId);
  
  if (newWidth < OptGoogleMapsDivMapMinWidth)
  {
    newWidth = OptGoogleMapsDivMapMinWidth;
  }
  el.style.width = newWidth + "px";
  
  if (newHeght < OptGoogleMapsDivMapMinHeight)
  {
    newHeght = OptGoogleMapsDivMapMinHeight;
  }  
  el.style.height = newHeght + "px";
  
  
}

function MyOnResize(event)
{
  SetDivMapSize();
} 

function GetWindowWidth()
{
  if (window.innerWidth)
  {
    return window.innerWidth;
  }
  else
  {
    return document.body.clientWidth;
  }
}

function GetWindowHeight()
{
  // document.body.clientHeight returns ALWAYS in IE as ZERO, unless we do as 
  // in http://forums.asp.net/t/1058801.aspx
  // see the last answer (on doctype)
  if (window.innerHeight)
  {
    return window.innerHeight;
  }
  else
  {
    return document.body.clientHeight;
  }
}

