﻿window.PAGE_FIND_EMPLOYEE_LIST = 34784;
window.PAGE_FIND_EMPLOYEE_DETAILS = 35173;

window.MAP = null;
window.GEOCODER = null;

function findEmployee(keyword) {
  window.location.href = '/Default.aspx?ID='+ window.PAGE_FIND_EMPLOYEE_LIST +'&search='+ keyword;
}

function showEmployeeDetails(employeeId) {
  window.location.href = '/Default.aspx?ID='+ window.PAGE_FIND_EMPLOYEE_DETAILS +'&employeeRefID='+ employeeId;
}

function isMobileDevice() {
  return (screen.width <= 700) 
        || (navigator.userAgent.match(/Android/i)) 
        || (navigator.userAgent.match(/iPhone/i)) 
        || (navigator.userAgent.match(/iPad/i)) 
        || (navigator.userAgent.match(/iPod/i));
}

function redirectToMobileSite() {
  window.location.href = "/Default.aspx?ID=35208";
}

function gMap_Initialize(mapId, address, markerType) {
  if (GBrowserIsCompatible()) {
  window.MAP = new GMap2(document.getElementById(mapId));
  window.MAP.addControl(new GSmallMapControl());
  window.GEOCODER  = new GClientGeocoder();
  window.MAP.setMapType(G_HYBRID_MAP);
  window.MAP.addControl(new GSmallMapControl());
  window.MAP.addControl(new GMapTypeControl());
  if (address != '') {
    gMap_ShowAddress(address, markerType);
  }  
  }
}
  
function gMap_ShowAddress(address, markerType) {
  if (window.GEOCODER) {
  window.GEOCODER.getLatLng(
    address,
    function(point) {
    if (!point) {
      alert(address + " not found");
    } else {
      var myIcon = new GIcon(G_DEFAULT_ICON);
      myIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
      myIcon.infoWindowAnchor = new GPoint(9, 2)

      if (markerType == '1') {
        myIcon.image = '/Files/Templates/Designs/skanderborg/images/skanderborg-map-icon.png';
        myIcon.iconSize = new GSize(52, 46);    
      }

      var markerOptions = { icon: myIcon };
      var marker = new GMarker(point, markerOptions);

      window.MAP.setCenter(point, 16);      
      window.MAP.addOverlay(marker);
    }
    }
  );
  }
}
