
// This definition is taken from the xsl/macros.xsl.m4 definition file.

//
// This file contains the JavaScript to be able to add any of the "Other" Controls
//  onto a Google Map displayed on TripAdvisor.  The Other Controls are used
//	by LocalMaps.  They are the ReloadHotels control and the Saves Controls
//
//	@author 	mhoule
//  @since     14 March 2007
//

/* ============================================================= */
/*	Saves Control Custom Google Map Control                      */
/*  Display the Saves widget                                     */
/*    */
/*  @param linkOnClick - Function name for an onClick handler */
/* ============================================================= */
function TA_SavesControl( linkOnClick )
{
  this.linkOnClick = linkOnClick;
}

TA_SavesControl.prototype = new GControl();

TA_SavesControl.prototype.initialize = function(map)
{
 	/*	We need a way to create this control and put in the properly
 	    Translated Strings and Images */
  var containerDiv = document.createElement("div");
  containerDiv.style.backgroundColor = "transparent";
  containerDiv.style.backgroundImage = "url(http://cdn.tripadvisor.com/img/saves/saveMapBarRight.gif)";
  containerDiv.style.backgroundRepeat = "no-repeat";
  containerDiv.style.backgroundPosition = "right";
  containerDiv.style.width = "105px";
  containerDiv.style.height = "18px";

  var Img = document.createElement("img");
  Img.id = "TA_SavesImg";
  Img.src = "http://cdn.tripadvisor.com/img/saves/saveThisMap.gif";
  Img.alt = "Save"
  Img.border = 0;
  Img.align = "absmiddle";
  Img.style.cursor = "pointer";

  if (this.linkOnClick != null)
  {
    Img.onclick = this.linkOnClick;
    GEvent.addDomListener(Img, "click", this.linkOnClick);
  }

  containerDiv.appendChild(Img);

  map.getContainer().appendChild(containerDiv);

  return containerDiv;
}

TA_SavesControl.prototype.getDefaultPosition = function()
{
  return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(6, 6));
}

TA_SavesControl.prototype.printable = function()
{
  return false;
}

TA_SavesControl.prototype.selectable = function()
{
  return false;
}

/* ============================================================= */
/*  Reload Hotels Google Map Control  */
/*  Display a control allow the user to reload the hotels */
/*      */
/*  @param onClick - Function name for an onClick handler */
/* ============================================================= */
function TA_ReloadHotelsControl(onClick)
{
  this.onClick = onClick;
}

TA_ReloadHotelsControl.prototype = new GControl();

TA_ReloadHotelsControl.prototype.initialize = function(map)
{
 	/*	We need a way to create this control and put in the properly
 	    Translated Strings and Images */
  var containerDiv = document.createElement("div");
  containerDiv.style.backgroundColor = "transparent";

  var Img = document.createElement("img");
  Img.id = "TA_ReloadHotelsControl";
  Img.src = sImgReloadMap;
  Img.alt = sReloadMap;
  Img.style.cursor = "pointer";
  
  if (this.onClick != null)
  {
    GEvent.addDomListener(Img, "click", this.onClick);
  }

  containerDiv.appendChild(Img);

  map.getContainer().appendChild(containerDiv);

  return containerDiv;
}

TA_ReloadHotelsControl.prototype.getDefaultPosition = function()
{
  return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(6, 32));
}

TA_ReloadHotelsControl.prototype.printable = function()
{
  return false;
}

TA_ReloadHotelsControl.prototype.selectable = function()
{
  return false;
}

