/*
	Last published on : 22-Jan-09 09:26
	Location          : \commercial\destinationguide\cms\destinationguide\static\js
	Filename          : multiControls.js
*/
/* 
	Last published on : 6/9/2008 13:45
	Location          : \commercial\destinationguide\cms\destinationguide\static\js
	Filename          : multiControls.js
*/
var map;
var mm;
var geocoder;
var infoId;
var infoName;
var infoImg;
var infoDescr;
var showBalloon;
var bounds = new google.maps.LatLngBounds();
var my_window;
var new_obj;
var balloonInfo = new Array();
var tempPoint;

var __categories = {
  _list:  new Array(),
  push:   function(obj) {return this._list.push(obj)},
  length: function() {return this._list.length },
  get:    function(i) { return this._list[i]},
  hasCategory: function(category)
  {
    for (var i = this._list.length-1; i>=0; --i) {
      if (this._list[i].category == category) return true;
    }
    return false;
  },
  getCategory: function(category)
  {
    for (var i = this._list.length-1; i>=0; --i) {
      if (this._list[i].category == category) return this._list[i];
    }
  }
}

function getCategoriesFromEvents() {
  for (var i = Events.length-1; i>=0; --i) {
    __event = Events[i];
    if (__event) {
      category = getCategorie(__event['category']);
      if (!__categories.hasCategory(category)) {
        __categories.push({checked: true,category: category});
      }
    }
  }
}

function createCategorieHTML(category) {
  rootdiv = document.createElement("div");
  rootdiv.innerHTML = "<label><input type='checkbox' class='check' id='" + category + "box' onclick=\"boxclick(this,'" + category +"')\" /><span>"+ category +"</span></label>"
  return rootdiv;
}

function TextualZoomControl() {}
TextualZoomControl.prototype = new google.maps.Control();
TextualZoomControl.prototype.initialize = function(map) {
  getCategoriesFromEvents();
  var container = document.createElement("div");
  var cvmptc_ = this;
  var panLeftDiv  = document.createElement("div");
  this.setButtonStyleLeft_(panLeftDiv);
  container.appendChild(panLeftDiv);
  google.maps.Event.addDomListener(panLeftDiv, "click", function() {
    map.panDirection(1,0);
  });

  var panRightDiv  = document.createElement("div");
  this.setButtonStyleRight_(panRightDiv);
  container.appendChild(panRightDiv);
  google.maps.Event.addDomListener(panRightDiv, "click", function() {
    map.panDirection(-1,0);
  });

  var panUpDiv  = document.createElement("div");
  this.setButtonStyleUp_(panUpDiv);
  container.appendChild(panUpDiv);
  google.maps.Event.addDomListener(panUpDiv, "click", function() {
    map.panDirection(0,1);
  });

  var panDownDiv  = document.createElement("div");
  this.setButtonStyleDown_(panDownDiv);
  container.appendChild(panDownDiv);
  google.maps.Event.addDomListener(panDownDiv, "click", function() {
    map.panDirection(0,-1);
  });

  var panBackDiv  = document.createElement("div");
  this.setButtonStyleBack_(panBackDiv);
  container.appendChild(panBackDiv);
  google.maps.Event.addDomListener(panBackDiv, "click", function() {
    close_all_windows();
    map.setZoom(beginZoom);
    if(tmpLatLng != undefined){
      map.panTo(beginLatLng);
    }
    lastActiveHover = activeHover;
    activeHover = active;
    show_custom_info_window(activeMarker, active);
  });
  
  var zoomOutDiv  = document.createElement("div");
  zoomOutDiv.className = "zoom-out";
  container.appendChild(zoomOutDiv);
  zoomOutDiv.appendChild(document.createTextNode("-"))
  google.maps.Event.addDomListener(zoomOutDiv, "click", function() {
    if (map.getZoom() == 0){
    }else{
      map.zoomOut();
    }
  });
  
  var zoomInDiv  = document.createElement("div");
  zoomInDiv.className = "zoom-in";
  container.appendChild(zoomInDiv);
  zoomInDiv.appendChild(document.createTextNode("+"));
  google.maps.Event.addDomListener(zoomInDiv, "click", function() {
    if (map.getZoom() != MAXZOOM){
	map.zoomIn();
    }
      /* no panning and no bubbles when zooming */
      //map.panTo(activeMarker.getPoint());
      //position_window(my_window[active], activeMarker, active);
  });
  
  var normalDiv  = document.createElement("div");
  this.setMapCtrlSelectStyleMap_(normalDiv);
  container.appendChild(normalDiv);
  normalDiv.appendChild(document.createTextNode("Map"));
  normalDiv.toggle=this;
  google.maps.Event.addDomListener(normalDiv, "click", function() {
    map.setMapType(G_NORMAL_MAP);
    this.toggle.setMapCtrlSelectStyleMap_(normalDiv);
    this.toggle.setMapCtrlUnselectStyleHyb_(hybridDiv);
    this.toggle.setMapCtrlUnselectStyleSat_(satDiv);
  });	  

  var hybridDiv  = document.createElement("div");
  this.setMapCtrlUnselectStyleHyb_(hybridDiv);
  container.appendChild(hybridDiv);
  hybridDiv.appendChild(document.createTextNode("Hyb"));
  hybridDiv.toggle=this;
  google.maps.Event.addDomListener(hybridDiv, "click", function() {
    map.setMapType(G_HYBRID_MAP);
    this.toggle.setMapCtrlSelectStyleHyb_(hybridDiv);
    this.toggle.setMapCtrlUnselectStyleMap_(normalDiv);
    this.toggle.setMapCtrlUnselectStyleSat_(satDiv);		
  });	  
  
  var satDiv  = document.createElement("div");
  this.setMapCtrlUnselectStyleSat_(satDiv);
  container.appendChild(satDiv);
  satDiv.appendChild(document.createTextNode("Sat"));
  satDiv.toggle=this;
  google.maps.Event.addDomListener(satDiv, "click", function() {
    map.setMapType(G_SATELLITE_MAP);
    this.toggle.setMapCtrlSelectStyleSat_(satDiv);
    this.toggle.setMapCtrlUnselectStyleHyb_(hybridDiv);
    this.toggle.setMapCtrlUnselectStyleMap_(normalDiv);		
  });

  var mapCtrlBg  = document.createElement("div");
  this.setMapCtrlBg_(mapCtrlBg);
  container.appendChild(mapCtrlBg);

  var scrollCtrlBg  = document.createElement("div");
  this.setScrollCtrlBg_(scrollCtrlBg);
  container.appendChild(scrollCtrlBg);	  
  
  map.getContainer().appendChild(container);
  return container;
}

  TextualZoomControl.prototype.getDefaultPosition = function() {
  return new google.maps.ControlPosition(G_ANCHOR_TOP_LEFT, new google.maps.Size(7, 7));
  }

  TextualZoomControl.prototype.setButtonStyleLeft_ = function(button) {
  button.className = "bttnLeft";
} 
  TextualZoomControl.prototype.setButtonStyleRight_ = function(button) {
  button.className = "bttnRight";
} 
  TextualZoomControl.prototype.setButtonStyleUp_ = function(button) {
  button.className = "bttnUp";
} 
  TextualZoomControl.prototype.setButtonStyleDown_ = function(button) {
  button.className = "bttnDown";
} 
TextualZoomControl.prototype.setButtonStyleBack_ = function(button) {
  button.className = "bttnBack";
}
TextualZoomControl.prototype.setMapCtrlBg_ = function(button) {
  button.className = "MapCtrlBg";
  } 
TextualZoomControl.prototype.setMapCtrlUnselectStyleMap_ = function(button) {
  button.className = "MapCtrlUnselectStyleMap";
  } 
TextualZoomControl.prototype.setMapCtrlSelectStyleMap_ = function(button) {
  button.className = "MapCtrlSelectStyleMap";
} 
TextualZoomControl.prototype.setMapCtrlUnselectStyleHyb_ = function(button) {
  button.className = "MapCtrlUnselectStyleHyb";
  } 
TextualZoomControl.prototype.setMapCtrlSelectStyleHyb_ = function(button) {
  button.className = "MapCtrlSelectStyleHyb";
} 
TextualZoomControl.prototype.setMapCtrlUnselectStyleSat_ = function(button) {
  button.className = "MapCtrlUnselectStyleSat";
  } 
TextualZoomControl.prototype.setMapCtrlSelectStyleSat_ = function(button) {
  button.className = "MapCtrlSelectStyleSat";
} 
TextualZoomControl.prototype.setScrollCtrlBg_ = function(button) {
  button.className = "ScrollCtrlBg";
} 
