/*
	Last published on : 22-Jan-09 09:26
	Location          : \commercial\destinationguide\cms\destinationguide\static\js
	Filename          : controls.js
*/
    var map; 
	var mm;
    var geocoder;
	var infoId;
	var infoName;
	var infoImg;
	var infoDescr;
	var showBalloon;
	var bounds = new GLatLngBounds();
	var my_window;
	var new_obj;
	var balloonInfo = new Array();
	var tempPoint;
	
	function TextualZoomControl() {
    }
    TextualZoomControl.prototype = new GControl();

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

      var panLeftDiv  = document.createElement("div");
      this.setButtonStyleLeft_(panLeftDiv);
      container.appendChild(panLeftDiv);
      GEvent.addDomListener(panLeftDiv, "click", function() {
      map.panDirection(1,0);
      });

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

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

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

		map.setZoom(beginZoom);
		centerMap(beginLatLng);
		
		show_custom_info_window(activeMarker, active);
		window.setTimeout(
		function(){
			hide();
		},1);	
      });

      var zoomOutDiv  = document.createElement("div");
      zoomOutDiv.className = "zoom-out";
	  container.appendChild(zoomOutDiv);
	  zoomOutDiv.appendChild(document.createTextNode("-"))
      GEvent.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("+"));
	  GEvent.addDomListener(zoomInDiv, "click", function() {
      	if (map.getZoom() == MAXZOOM){
			
		}else{
			map.zoomIn();
			var tempcoord = map.fromDivPixelToLatLng(map_point[active]);
			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;
      GEvent.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;
      GEvent.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;
      GEvent.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 GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(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";
	} 
