
      // == Some global variables ==
      var YSLIDERLENGTH = 231;       // maximum length that the knob can move (slide height minus knob height)
      var MAXZOOM = 19
      var MINZOOM = 13

      // == Create a Custom GControl ==
      function YSliderControl() { }
      YSliderControl.prototype = new GControl();

      // == This function positions the slider to match the specified zoom level ==
      YSliderControl.prototype.setSlider = function(zoom) {
		  //console.log('zoom is '+MAXZOOM);
        //var top = Math.round((YSLIDERLENGTH/MAXZOOM*zoom)+(YSLIDERLENGTH/MINZOOM*zoom));
        var left = Math.round((YSLIDERLENGTH/(MAXZOOM-MINZOOM)*(zoom-MINZOOM)));
		left = (left>=0)?left:0;
		this.slide.left = left;
		this.knob.style.left = (left+5)+"px";
        //GLog.write("Map was zoomed to:"+zoom+" new Knob position:"+top);
		//console.log("Map was zoomed to:"+zoom+" new Knob position:"+left);
		//console.log(left);
		if(this.map.getZoom()<MINZOOM){
			this.map.setZoom(MINZOOM);
			alert("You cannot zoom out any further!");
		}
      }

      // == This function reads the slider and sets the zoom level ==
      YSliderControl.prototype.setZoom = function() {
        var z=Math.round(MINZOOM+((this.slide.left*(MAXZOOM-MINZOOM))/YSLIDERLENGTH));
        this.map.setZoom(z);
        //GLog.write("New knob position:"+this.slide.top+" new zoom: "+z);
		//console.log("New knob position:"+this.slide.top+" new zoom: "+z);
      }

      YSliderControl.prototype.setRanges = function(maptype) {
       if(maptype == 'Map'){
		  MAXZOOM = 17
		  MINZOOM = 13
	   }else{
		  MAXZOOM = 19
		  MINZOOM = 13
	   }
		  //console.log('to '+MAXZOOM);
		this.setSlider(this.map.getZoom())
	   
      }

      // == This gets called bu the API when addControl(new YSlider()) is used ==
      YSliderControl.prototype.initialize = function(map) {
        // obtain Function Closure on a reference to "this"
        var that=this;
        // store a reference to the map so that we can call setZoom() on it
        this.map = map;

        // Is this MSIE, if so we need to use AlphaImageLoader
        var agent = navigator.userAgent.toLowerCase();
        if ((agent.indexOf("msie") > -1) && (agent.indexOf("opera") < 1)){this.ie = true} else {this.ie = false}

        // create the background graphic as a <div> containing an image
        var container = document.createElement("div");
        container.style.width="250px";
        container.style.height="19px";

        // Handle transparent PNG files in MSIE
        if (this.ie) {
          var loader = "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='xslide.png', sizingMethod='scale');";
          container.innerHTML = '<div style="height:19px; width:250px; ' +loader+ '" ></div>';
        } else {
          container.innerHTML = '<img src="xslide.png"  width=250 height=19 >';
        }

        // create the knob as a GDraggableObject
        // Handle transparent PNG files in MSIE
        if (this.ie) {
          var loader = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='xknob.png', sizingMethod='scale');";
          this.knob = document.createElement("div"); 
          this.knob.style.height="26px";
          this.knob.style.width="8px";
          this.knob.style.filter=loader;
        } else {
          this.knob = document.createElement("img"); 
          this.knob.src = "xknob.png";
          this.knob.height = "26";
          this.knob.width = "8";
        }
	    this.knob.style.marginTop="-4px";
        container.appendChild(this.knob);
        this.slide=new GDraggableObject(this.knob, {container:container});

        // attach the control to the map
        map.getContainer().appendChild(container);

        // Listen for other things changing the zoom level and move the slider
        GEvent.addListener(map, "maptypechanged", function(a,b) {that.setRanges(map.getCurrentMapType().Hz)});
        GEvent.addListener(map, "zoomend", function(a,b) {that.setSlider(b)});
     
        // Listen for the slider being moved and set the zoom level
        GEvent.addListener(this.slide, "dragend", function() {that.setZoom()});

		this.setSlider(this.map.getZoom())

        return container;
      }

      // == Set the default position for the control ==
      YSliderControl.prototype.getDefaultPosition = function() {
        return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(212, 7));
      }

