/* GOOGLE MAP 
  v.20
  v.21 re-design, on the basis of v.20 (site version 19)
  images fix
  v.21j 'NO result' airport/city/custom specific
  v.21o8 - geocoding - fix with addressLocationCache
  v.21s7 - address text fix for the Custom (Widget)
*/

var defaultPointZoom = 16;    // Default zoom level when viewing a point (i.e. address/cross-street/attraction)
var minZoom = 15;        // Minimum zoom level
var maxZoom = 17;

var gMap = null;
var gGeocoder = null;
var currAddress = "";  // currently searched address
var currAddress2 = ""; 
var currZoom = defaultPointZoom;

var addressLabel = null;   // blue dot with address popup, TLabel object
var currAddrLblLoc = null; // data for addressLabel, Location oblect

var controlZoom = null;
var controlNorth = null;
var controlSouth = null;

var addressLocationCache = Array();


function Location(address, latLng)
{
  this.address = address;
  this.latLng = latLng;
}


///      initMap
function initMap(showFriendlyControls)
{ // the main MAP initialization function

  // , G_SATELLITE_MAP, G_HYBRID_MAP
    try
    { 
    gMap = new GMap2(document.getElementById("google_map"), {mapTypes:[G_NORMAL_MAP]});
    }
    catch(e)
    { // error creating map
    var message = "The Google map was unable to display correctly\n\n" +
    "This could be due to any one of the following:\n" + 
    "1) You are using a browser other than IE 6+ or Firefox 1.5+\n" + 
    "2) Your internet connection speed is too slow\n" +
    "3) The latest IE patches are not installed on your computer\n" +
    "4) Windows XP Service Pack 2 is not installed on your computer\n";
    
    alert(message);
    return;
    }

    
  if(showFriendlyControls)
  { // custom Zoom and Arrow controls
    gMap.addControl(new TextualZoomControl());
    gMap.addControl(new PanArrowsControl());
  }
                                                   
  // now the map is not loaded on initialization
  //gMap.setCenter(new GLatLng(40.757655,-73.982792), minZoom, G_NORMAL_MAP);
  
  var mt = gMap.getMapTypes();
  
  for (var i=0; i<mt.length; i++)
    mt[i].getMinimumResolution = function() {return minZoom;}
  
  /*
   The map move end event ('moveend') calls updateGarages function and therefore 
   checking garages and request data via XML if needed
  */
  GEvent.addListener(gMap, 'moveend', function()
  {CreateAddressLabel();updateGarages();} );
  
   /* GEvent.addListener(gMap, 'zoomend', function()
  {CreateAddressLabel();updateGarages();} );  */
  /*
  GEvent.addListener(gMap, 'onmousemove', function()
  {Shrink();window.status = "onmousemove"});
  */
  
  gMap.disableDoubleClickZoom();
 
  gGeocoder = new GClientGeocoder();
  
  if(!gGeocoder){alert("Geocode google: can't create gGeocoder (map21e.js)"); jserror(3, "");}
  
  ///  Gradient feature
  var ratesGradient = document.createElement('div');
  ratesGradient.id = 'rates_gradient';
  ratesGradient.style.visibility = 'hidden';
  ratesGradient.style.position = 'absolute';
  ratesGradient.style.right = '5px'; 
  ratesGradient.style.top = '35px'; // 10px
  ratesGradient.style.zIndex = 3000;
  ratesGradient.innerHTML = '<img src="' + PATH_IMG + 'images/rates.gif">';
  document.getElementById("google_map").appendChild(ratesGradient);
  setOpacityCompat(ratesGradient, 0.9);
  
  /*
  /// Gradient feature : Highlight by [Partners] or [Rates]
  var coloredRatesSwitch = document.createElement('div');
  coloredRatesSwitch.id = 'color_switch';
  coloredRatesSwitch.style.visibility = 'hidden';
  coloredRatesSwitch.innerHTML = 
   '<table border="0" cellspacing="0" cellpadding="0"><tr><td>' +
   '&nbsp;Highlight by&nbsp;</td><td>' +
   '<div id="colorSwitchfalse" class="dis" onClick="HighlightByRates(false);"><center style="padding-top:3px;">Partners</center></div>' +
   '</td><td>&nbsp;or&nbsp;</td><td>' +
   '<div id="colorSwitchtrue" class="en" onClick="HighlightByRates(true);"><center style="padding-top:3px;" ' +
   '>Rates</center></div>' +
   '</td></tr></table>';

  document.getElementById("google_map").appendChild(coloredRatesSwitch);
  
  var btnEn = document.getElementById("colorSwitchtrue");
  btnEn.onmouseover = function() {setBackgrnd(this, 'color_switch_over.gif');};
  btnEn.onmouseout = function() {setBackgrnd(this, 'color_switch_btn.gif')};
  
 */ 
 /* 'search_results' contains 'google_map'. The Google map can't be created 
    for not-displayed DIV, only invisible. So it invisible by creating. However then 
    display property used.
 */
 
 if(NO_RESULT)
 {
 if(CUSTOM) var imgNoResult = 'images/no_result.gif';
 else if (AIRPORT) var imgNoResult = 'images/no_result_airports.gif';
 else  var imgNoResult = 'images/no_result_cities.gif';
 
 
  /// No Parking Facilities  notice
  var txtNoResult = document.createElement('div');
  txtNoResult.id = 'no_result';
  txtNoResult.className = "do_not_print";
  txtNoResult.innerHTML =
  '<center><img src="' + PATH_IMG + imgNoResult + '"></center>';
  gMap.getContainer().appendChild(txtNoResult);
  
  setOpacityCompat(txtNoResult, 0.9); 
 }
 
 DisplayElem("search_results", "visible");
 DisplayElem("search_results", "none"); 
}

//       setOpacityCompat
function setOpacityCompat(lyr, c)
{ // used to set opacity to Zoom and Arrow controls
  if(typeof(lyr.style.filter)=='string'){lyr.style.filter='alpha(opacity:'+c*100+')';}
  if(typeof(lyr.style.KHTMLOpacity)=='string'){lyr.style.KHTMLOpacity=c;}
  if(typeof(lyr.style.MozOpacity)=='string'){lyr.style.MozOpacity=c;}
  if(typeof(lyr.style.opacity)=='string'){lyr.style.opacity=c;}
}

///      clearMap
function clearMap()
{
// hide all icons in map
  if(addressLabel != null)
  {
    gMap.removeTLabel(addressLabel);
    addressLabel = null;
    currAddrLblLoc = null;

  }
  // hide garages icons
  for(var id in garages)
  {
    var g = garages[id];
    for(var n=0; n<g.entrances.length; n++)
      g.entrances[n].requireDisplay(false);
  }
}


function rotateLatLng(p, theta)
{
  return new GLatLng(Math.sin(theta)*p.lng() + Math.cos(theta)*p.lat(), Math.cos(theta)*p.lng() - Math.sin(theta)*p.lat());
}

///      unionLatLngBounds
function unionLatLngBounds(b1, b2)
{ // is not in use
  var sw1 = b1.getSouthWest();
  var sw2 = b2.getNorthEast();
  var ne1 = b1.getSouthWest();
  var ne2 = b2.getNorthEast();
  var swNew = new GLatLng( Math.min(sw1.lat(), sw2.lat()), Math.min(sw1.lng(), sw2.lng()) );
  var neNew = new GLatLng( Math.max(ne1.lat(), ne2.lat()), Math.max(ne1.lng(), ne2.lng()) );
  return new GLatLngBounds( swNew, neNew );
} 
 
///      moveDetailLabelToLatLng
function moveDetailLabelToLatLng(subjectLabel, oEntrance, yPos)
{ // move floating DIV (subjectLabel) to coordinates position (targetLatLng) on the Map
  // used for garage detail popups on the map

  // yPos - compulsive  y direction ; 0 - upward; 1 - downward

  var targetLatLng = oEntrance.latLng;


  var targetDivPos = gMap.fromLatLngToDivPixel(targetLatLng);
  // center concerning targetDivPos center
  
  //// horizontal position
  var labelLeft = targetDivPos.x + gMap.getPane(G_MAP_MAP_PANE).parentNode.offsetLeft - Math.floor(subjectLabel.offsetWidth / 2);
  
  //overspillMargin is how much pixels subjectLabel can go beyond map bound
  
  var overspillMargin = 0; // if beyond the map left bound move it to bound (minus overspillMargin)
  if(labelLeft < -overspillMargin)
    labelLeft = -overspillMargin;
  
  // if subjectLabel goes beyond right bound, move its right to the map rigth bound (minus overspillMargin)
  if(labelLeft + subjectLabel.offsetWidth > gMap.getContainer().offsetWidth + overspillMargin)
    labelLeft = gMap.getContainer().offsetWidth + overspillMargin - subjectLabel.offsetWidth;
 
  //// vertical position
  
  var ver_pos = 0;
  
  // first, the labelTop set upward 
  var labelTop = targetDivPos.y + gMap.getPane(G_MAP_MAP_PANE).parentNode.offsetTop - subjectLabel.offsetHeight - 8;
  
  // if beyond top bound, set direction to downward
  if(labelTop < -overspillMargin) ver_pos = 1;
  
  if(yPos != undefined)ver_pos = yPos; // compulsive
  
  if(ver_pos)// if position set finally to downward, set labelTop downward position
  {
  var iconHeight = oEntrance.garageLabel.layer.offsetHeight;
 
  if(parseInt(iconHeight) == 25)iconHeight = 13;
  else if(parseInt(iconHeight) == 31)iconHeight = 19;
  else iconHeight = iconHeight/2;
  
  labelTop = targetDivPos.y + gMap.getPane(G_MAP_MAP_PANE).parentNode.offsetTop + iconHeight;
  }
  else
  labelTop -= 3;
  
  // map position
  var absPos = getAbsolutePositionOf(gMap.getContainer());
  subjectLabel.style.left = absPos[0] + labelLeft;
  subjectLabel.style.top = absPos[1] + labelTop;
  
  return ver_pos; // return what position finally set
}


var neighbourhoodZoom = 16;

///      focusOnNeighbourhood
function focusOnNeighbourhood(lng, lat, zoom)
{
// on clicking Neighbourhood area ('By Neighbourhood')
  
  // TIMER
  PerformTimer = new Date();
  
  // remove address label
  if(addressLabel != null){ gMap.removeTLabel(addressLabel);addressLabel = null;}
  currAddrLblLoc = null;
  
  showResultOptions(); // hide Neighbourhood map
  
  // create Location
  var loc = new Location(null, new GLatLng(lat,lng));
 
  if(!zoom)zoom = neighbourhoodZoom;
  
  focusOnLocation(loc, zoom);  
}


///      focusOnAddress
function focusOnAddress(addr, zoom, geocoder, text)
{
//clicking 'Search' button, on entering adrress on 'By Address', 'By Cross Street' page
  
  //alert('focusOnAddress2 ' + text);
  
  if(!gMap) return false;
  // TIMER
  PerformTimer = new Date();
  
  if(geocoder==null || typeof geocoder=='undefined')geocoder = MAP_GEOCODE;
  
  //alert("addressLocationCache: \n" + addressLocationCache[addr]);
  
  if(addressLocationCache[addr] != null)
  {
  loc = addressLocationCache[addr];
  }
  else
  {  
  if(MAP_GEOCODE == "google" && geocoder=='google')
  {

  // get Google geocode
  currAddress = addr;
  currAddress2 = '';
  if(text)if(text != '')currAddress2 = text;
   
  if(addr.indexOf(" " + CITY_NAME) == -1) 
  {
  if(CITY_NAME == "New York")addr += ", Manhattan";
  addr +=   ", " + CITY_NAME;  
  }
  if(addr.indexOf(" " + CITY_STATE) == -1)addr +=   ", " + CITY_STATE;   
  
  currZoom = zoom; 
 
  //alert(addr);
 
  if(gGeocoder) gGeocoder.getLocations(addr, doneGoogleGeocode); 
  return true;
    
  }
  else
  {
  // geocode entered address to get coordinates
  loc = getLocationFromAddress(addr); // returns Location object
  if(loc == null)
  {
    alert("Could not find " + CITY_NAME + " City location:\n" + addr /*+ "\n(old)"*/);
    jserror(2, addr);
    return false;
  }
  if(text)if(text != '')loc.address = text;
  addressLocationCache[addr] = loc;
   
  } 
  }
  showResultOptions(); // hide address input
  
  focusOnLocation(loc, zoom);
  return true;
}

function doneGoogleGeocode(response)
{
//alert("doneGoogleGeocode ");

if (!response || response.Status.code != 200) 
{ 
    focusOnAddress(currAddress, null, 'yahoo', currAddress2)
    //alert("Could not find " + CITY_NAME + " City location:\n" + currAddress /*+ "\n(new)"*/);
    jserror(4, currAddress + "(redirected)");
}
else
{ 
  place = response.Placemark[0]; 
  
  var arrAddr = place.address.split(",");
  var locAddress = arrAddr[0];
                             /*place.address + "<br><br>"  + */
  var loc = new Location(locAddress, 
                         new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0])
                         );
  
  showResultOptions(); // hide address input
  
  if(currAddress2 != '')loc.address  = currAddress2;
  focusOnLocation(loc, currZoom);
  
  addressLocationCache[currAddress] = loc;  
 
}

}



///      focusOnSelectedAttraction
function focusOnSelectedAttraction()
{ // called from 'By Attraction' page when attraction selected and 'Search' clicked
  //  or attraction double clicked
  
  // selectedAttractionOpt keeps selected SELECT object, designated on change
  if(selectedAttractionOpt == null)
  {
    alert('Please select an attraction.');
    return false;
  }
  
  // TIMER
  PerformTimer = new Date();

  // get data from selected SELECT
  var name = selectedAttractionOpt.value.split("@")[0];
  var addr = selectedAttractionOpt.value.split("@")[1];
  if(addr != "")
    name += "<br>" + addr + "";
  var coords = selectedAttractionOpt.value.split("@")[2].split(",");
  // create Location
  var loc = new Location(name, new GLatLng(coords[0], coords[1]));
 
  showResultOptions(); // hide attractions tables
  // call 
  focusOnLocation(loc);
  
  return true;  
}

///      focusOnLocation
function focusOnLocation(loc, zoom, iconImage)
{ // (1) from focusOnNeighbourhood
  // (2) from focusOnAddress
  // (3) from focusOnSelectedAttraction

   if(!gMap) return false;

   DisplayElem("search_results", "block");
   DisplayElem("garage_list_div", "none");


if(globJSBrowser != "Safari")
    document.getElementsByName("#level2")[0].scrollIntoView();

  HideAllGarages(); // hide garage icons fron the map
  
  if(loc.address != null) // 'null' for Neighbourhood, as there no address label needed for it
  currAddrLblLoc = loc; // define address label (blue dot)
  
  // move the map to specified coordinates
  gMap.setCenter(loc.latLng, (zoom != null)?zoom:defaultPointZoom);
 
  if(lastSelectedGarage != null)
    lastSelectedGarage.deselect();
    
}



///      ByAllManhattan
function ByAllManhattan(numManh)
{ // called:  'By All Manhattan' clicked
  //          Previous, Next link clicked Thet on the top of 'Manhattan' result list
  // numManh - number of page, required to display

  // TIMER
  PerformTimer = new Date();

DisplayElem("garage_list_div", "none")

showResultOptions();
//HideAllGarages();

if(globJSBrowser != "Safari")
   document.getElementsByName("#level2")[0].scrollIntoView();


num_currAllManh = numManh; // set to global current Manh page (garagesX.js)

   // check whether specified page exists in array
   if(parking_vehicle == VEHICLE_MOTORCYCLE)  // motorcycle
   var loc_exists = arrAllManhattanMC[num_currAllManh];
   else                                    // regular
   var loc_exists = arrAllManhattan[num_currAllManh];
    
if(!loc_exists)
{ // download data
sort_results = SORT_RATE; // default
InitPopMap(); // init 'All Manh' poup map if is not yet done (index.php)
fetchGaragesAroundBounds(0, numManh); // garagesX.js
}
else
{
listGarages(numManh);  // display result list (garagesX.js)
}


};



///      CreateAddressLabel
function CreateAddressLabel()
{  // create address label  - blue dot with address popup
  
  if(currAddrLblLoc == null)return;
  
  try {
  
  if(addressLabel != null){ gMap.removeTLabel(addressLabel);addressLabel = null;}
  
  // CREATE 
  addressLabel = new TLabel();
  
  addressLabel.id = "label_address";
  addressLabel.anchorLatLng = currAddrLblLoc.latLng;
  gMap.addTLabel(addressLabel);
  
  addressLabel.layer.style.zIndex = 2;
  addressLabel.setImage(PATH_IMG + "images/marker_address.gif");
  
  // as mouse moving over addressLabel, popup with address text appears
  addressLabel.layer.onmouseover =
    function()
    { 
      var addressDetailLabel = document.getElementById("address_detail_label");
      moveDetailLabelToLatLng(addressDetailLabel, currAddrLblLoc);
      DisplayElem("address_detail_label", "visible");
    };
  
  //  hide address text popup when mouse gone
  addressLabel.layer.onmouseout =
    function()
    {
      DisplayElem("address_detail_label", "hidden");
    };

  // set text to address popup
  var addressDetailLabel = document.getElementById("address_detail_label");
  DisplayElem("address_detail_label", "hidden");

  GetElement('address_detail_label_cont').innerHTML = currAddrLblLoc.address; 
   
  //"<strong style='font-size:11px; font-weight:normal;'>" + currAddrLblLoc.address + "</strong>";
  
  //addressLabel.setPosition();
  
  }catch(e) {/*alert("error in CreateAddressLabel func");*/ } //  + e.description 


}



/* **** CUSTOM GOOGLE MAP CONTROLS **** */

///      TextualZoomControl
function TextualZoomControl()
{
}

TextualZoomControl.prototype = new GControl();

///               .prototype.initialize
TextualZoomControl.prototype.initialize = function(map)
{
  var container = document.createElement("div");
  controlZoom = container;

 /// ZOOM
 
  var zoomZoom = document.createElement("div");
  
  //this.setButtonStyle_(zoomZoom);
  zoomZoom.className = "zoomButton";
  setOpacityCompat(zoomZoom, 0.9);
   
  container.appendChild(zoomZoom);
  zoomZoom.appendChild(document.createTextNode("Zoom:"));
  zoomZoom.style.marginRight = "4px"; 
  zoomZoom.style.cursor = "default";
  zoomZoom.style.width = "58px"; 
  
  //// ZOOM IN
  var zoomInDiv = document.createElement("div");
  
  //this.setButtonStyle_(zoomInDiv);
  zoomInDiv.id = "zoomInDiv";
  zoomInDiv.className = "zoomButton";
  setOpacityCompat(zoomInDiv, 0.9);  
  
  container.appendChild(zoomInDiv);
  zoomInDiv.appendChild(document.createTextNode("+"));
  zoomInDiv.style.marginRight = "4px";
  zoomInDiv.style.width = "25px"; 
  
  // function for 'Zoom In'
  GEvent.addDomListener(zoomInDiv, "click", function() {
    if(gMap.getZoom() == maxZoom)return false; //can't be more than 17
    EnableZoom(1);
    HideAllGarages();
    gMap.zoomIn();
  });


  //// ZOOM OUT
  var zoomOutDiv = document.createElement("div");
  //this.setButtonStyle_(zoomOutDiv);
  zoomOutDiv.id = "zoomOutDiv";
  zoomOutDiv.className = "zoomButton";
  setOpacityCompat(zoomOutDiv, 0.9);  
  container.appendChild(zoomOutDiv);
  zoomOutDiv.appendChild(document.createTextNode(String.fromCharCode(8722))); 
  zoomOutDiv.style.width = "25px";
  zoomOutDiv.style.fontWeight = "900";
  
  //zoomOutDiv.style.marginLeft = "50px";
  
  GEvent.addDomListener(zoomOutDiv, "click", function() {
    if(gMap.getZoom() == minZoom){return false;} //can't be less than 15
    EnableZoom(-1);
    HideAllGarages();
    gMap.zoomOut();
    
   });

  
  gMap.getContainer().appendChild(container);
  
   
  return container;
}
///               .prototype.getDefaultPosition
TextualZoomControl.prototype.getDefaultPosition = function() {

  return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(3, 3)); // 160, 7
}
/*
///               .prototype.setButtonStyle_ 
TextualZoomControl.prototype.setButtonStyle_ = function(button) {
 
  button.className = "zoomButton";
  
  
  button.style.color = "000096";
  button.style.fontSize = "20px"; //155%
  button.style.fontWeight = "bold";
  button.style.textAlign = "center"; // left
  button.style.backgroundColor = "white";
  button.style.padding = "2px"; // 3px
 // button.style.marginBottom = "3px";
  //button.style.marginRight = "3px";
  //button.style.width = "130px"; // 145px
  button.style.cursor = "pointer";
  button.style.display = "inline";
  //button.style.width = "125px";
  
  setOpacityCompat(button, 0.9);
}
*/
//       EnableZooms
function EnableZoom(addVal)
{ // enable/dosable Zoom [+] [-]

var currZoom = parseInt(gMap.getZoom()) + addVal;

if(currZoom==minZoom)
GetElement("zoomOutDiv").className = "zoomButton zoomButtonDis";
else
GetElement("zoomOutDiv").className = "zoomButton";

if(currZoom==maxZoom)
GetElement("zoomInDiv").className = "zoomButton zoomButtonDis";
else
GetElement("zoomInDiv").className = "zoomButton";

}

///      PanArrowsControl
function PanArrowsControl()
{
}

PanArrowsControl.prototype = new GControl();

///             .prototype.initialize
PanArrowsControl.prototype.initialize = function(map)
{  // Create Arrow controls

  var container = gMap.getContainer();
  var arrowDiv, arrowImg, arrowTextDiv;

  /// North
   // container DIV
  arrowDiv = document.createElement("div");
  
  controlNorth = arrowDiv;
  
  container.appendChild(arrowDiv);
  this.setButtonStyle_(arrowDiv);
  arrowDiv.style.left = "46%"; // position on the map
  arrowDiv.style.top = "0px";
  arrowDiv.style.margin = "0 auto 0 auto";
  
   // Image DIV
  arrowImg = document.createElement("img");
  arrowDiv.appendChild(arrowImg);
  arrowImg.src = PATH_IMG + "images/pan_up_c.gif";
  
   // 'North' word DIV
  arrowTextDiv = document.createElement("div");
  arrowDiv.appendChild(arrowTextDiv);
  arrowTextDiv.appendChild(document.createTextNode("North"));

  this.setTextStyle_(arrowTextDiv);
  
   // add click event to move the map
  GEvent.addDomListener(arrowDiv, "click", function() {
    gMap.panDirection(-PAN_NUMBER_1,1);
  });

  /// East
   // container DIV
  arrowDiv = document.createElement("div");
  arrowDiv.className = "mapArrE";
  container.appendChild(arrowDiv);
  this.setButtonStyle_(arrowDiv);
  arrowDiv.style.right = "0px"; // position on the map
  arrowDiv.style.top = ((gMap.getSize().height - arrowDiv.offsetHeight) / 2) + "px";

   // 'East' word DIV 
  arrowTextDiv = document.createElement("div");
  arrowDiv.appendChild(arrowTextDiv);
  arrowTextDiv.style.cssFloat = arrowTextDiv.style.styleFloat = "left";
  arrowTextDiv.appendChild(document.createTextNode("East"));

  this.setTextStyle_(arrowTextDiv);

   // Image DIV
  arrowImg = document.createElement("img");
  arrowDiv.appendChild(arrowImg);
  arrowImg.src = PATH_IMG + "images/pan_right_c.gif";
  arrowImg.style.cssFloat = arrowImg.style.styleFloat = "left";
  arrowImg.style.margin = "7px 0 0 0";
  
   // add click event to move the map
  GEvent.addDomListener(arrowDiv, "click", function() {
    gMap.panDirection(-1,-PAN_NUMBER_2);
  });

  /// South
   // container DIV
  arrowDiv = document.createElement("div");
  
  controlSouth = arrowDiv;
  
  container.appendChild(arrowDiv);
  this.setButtonStyle_(arrowDiv);
  arrowDiv.style.left = "46%"; // position on the map
  arrowDiv.style.bottom = "0px";
  arrowDiv.style.margin = "0 auto 0 auto";

   // 'South' word DIV
  arrowTextDiv = document.createElement("div");
  
  
  arrowDiv.appendChild(arrowTextDiv);
  arrowTextDiv.appendChild(document.createTextNode("South"));

  this.setTextStyle_(arrowTextDiv);

  arrowImg = document.createElement("img");
  arrowDiv.appendChild(arrowImg);
  arrowImg.src = PATH_IMG + "images/pan_down_c.gif";
  
   // add click event to move the map
  GEvent.addDomListener(arrowDiv, "click", function() {
    gMap.panDirection(PAN_NUMBER_1,-1);
  });

  /// West
   // container DIV
  arrowDiv = document.createElement("div");
  arrowDiv.className = "mapArrW";
  container.appendChild(arrowDiv);
  this.setButtonStyle_(arrowDiv);
  arrowDiv.style.left = "0px";
  arrowDiv.style.top = ((gMap.getSize().height - arrowDiv.offsetHeight)/2) + "px";

   // Image DIV
  arrowImg = document.createElement("img");
  arrowDiv.appendChild(arrowImg);
  arrowImg.src = PATH_IMG + "images/pan_left_c.gif";
  arrowImg.style.cssFloat = arrowImg.style.styleFloat = "left";
  arrowImg.style.margin = "7px 0 0 0";

  // 'West' word DIV
  arrowTextDiv = document.createElement("div");
  arrowDiv.appendChild(arrowTextDiv);
  arrowTextDiv.style.cssFloat = arrowTextDiv.style.styleFloat = "left";
  arrowTextDiv.appendChild(document.createTextNode("West"));
  
  this.setTextStyle_(arrowTextDiv);

   // add click event to move the map
  GEvent.addDomListener(arrowDiv, "click", function() {
    gMap.panDirection(1,PAN_NUMBER_2);
  });

  return document.createElement("div");
}
///             .prototype.getDefaultPosition
PanArrowsControl.prototype.getDefaultPosition = function() {
  return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(0, 0));
}

///             .prototype.setButtonStyle_
PanArrowsControl.prototype.setButtonStyle_ = function(button) {
  button.style.position = "absolute";
  button.style.cursor = "pointer";
  button.style.textAlign = "center";
}

///              prototype.setTextStyle_
PanArrowsControl.prototype.setTextStyle_ = function(button) {
  button.style.color = "000096";
  button.style.fontSize = "20px"; // 155%"
  button.style.fontWeight = "bold";
  button.style.textAlign = "center";
  button.style.backgroundColor = "white";
  button.style.margin = "0px";
  button.style.padding = "2px 5px 2px 5px";
  setOpacityCompat(button, 0.9);
}


function setZoomPos()
{
return;
var map_w = parseInt(gMap.getContainer().offsetWidth/2);
 
//alert(controlNorth.offsetWidth + " - " + controlSouth.offsetWidth); 
 
controlZoom.style.left = map_w - 175;
controlNorth.style.left = map_w - (controlNorth.offsetWidth/2);
controlSouth.style.left = map_w - (controlSouth.offsetWidth/2);

//window.status = "ZoomPos:  " + controlZoom;

}  

var addrW = '350px';
if(navigator.userAgent.indexOf("MSIE") > -1)addrW = '100%';

document.write(
'<table id="address_detail_label" class="menu_pop_red plain" cellspacing="0" ' +
'style="visibility:hidden;display:block!important;z-index:3015;width:200px;">' +
'<tr><td class="tl_mb_red"><img src="' + PATH_IMG + 'images/blank.gif" width="9"></td>' +
'<td class="bar_mb_red" rowspan="2" width="' + addrW + '"></td><td class="tr_mb_red"><img src="' + PATH_IMG + 'images/blank.gif" width="9"></td></tr>' +
'<tr class="bar_mb_red" style="height:3px;"><td></td><td></td></tr>' +
'<tr><td colspan="3" id="address_detail_label_cont" class="main" style="text-align:center;padding:4px;color:#191919;font-size:13px;">' + 

'</td></tr>' +
'<tr class="bar_mb_red" style="height:3px;"><td></td><td rowspan="2">' +
'</td><td></td></tr>' +
'<tr><td class="bl_mb_red"></td><td class="br_mb_red"></td></tr>' +
'</table>'
);



