var slider, bg="vertBGDiv", thumb="vertHandleDiv";


    // The slider can move 0 pixels up
    var topConstraint = 0;

    // The slider can move 200 pixels down
    var bottomConstraint = 154;
	//Scale Factor is a calculation of (MaxMapZoomLevel-MinMapZoomLevel)/(bottomConstraint-topConstraint)
	var MaxMapZoomLevel = 14;
	var MinMapZoomLevel = 7;
    // Custom scale factor for converting the pixel offset into a real value
    var scaleFactor = (MaxMapZoomLevel-MinMapZoomLevel)/(bottomConstraint-topConstraint);
    
    //var scaleFactor = 9.5;

    // The amount the slider moves when the value is changed with the arrow
    // keys

    var keyIncrement = (bottomConstraint-topConstraint)/(MaxMapZoomLevel-MinMapZoomLevel);
    
    
YAHOO.example.SliderApp = function() {
    var Event = YAHOO.util.Event;
    var Dom   = YAHOO.util.Dom;
    var Key   = YAHOO.util.Key;

    return {

        init: function() {

//            Event.on("formV", "submit", this.updateVert);
//            Event.on("vertButton", "click", this.updateVert);

            slider = YAHOO.widget.Slider.getVertSlider(bg, 
                             thumb, topConstraint, bottomConstraint, keyIncrement);

            slider.subscribe("change", this.updateUI);

            slider.subscribe("slideStart", function() {
                    YAHOO.log("slideStart fired", "warn");
                });

            slider.subscribe("slideEnd", function() {
                    YAHOO.log("slideEnd fired", "warn");
                });
                
            slider.setValue(parseInt(Math.round((MaxMapZoomLevel - map.GetZoomLevel()) * keyIncrement)),10);
            
        },

        updateUI: function(offsetFromStart) {
                // use the scale factor to convert the pixel offset into a
                // real value
                var actualValue = parseInt(Math.round(((bottomConstraint - offsetFromStart) * scaleFactor)+MinMapZoomLevel),10);
				
                // update the text box with the actual value
                //Dom.get("vertVal").value = actualValue;
                map.SetZoomLevel(actualValue)

                // update the title attribute on the background
                Dom.get(bg).title = "Zoom Level = " + Math.round(actualValue);
                

        },

//        updateVert: function() {
//            var v = parseFloat(document.forms['formV']['vertVal'].value, 10);
//            if ( isNaN(v) ) v = 0;

//            // convert the real value into a pixel offset
//            slider.setValue(Math.round(v/scaleFactor));
//            
//            
//            return false;
//        },

        clearConstraints: function() {
            slider.getThumb().clearConstraints();
        },

        clearTicks: function() {
            slider.getThumb().clearTicks();
        }
        
    };
} ();

//YAHOO.example.SliderApp.init();
YAHOO.util.Event.addListener(window, "load", YAHOO.example.SliderApp.init, 
                             YAHOO.example.SliderApp, true);
YAHOO.util.Event.addListener("re2", "click", YAHOO.example.SliderApp.clearTicks);

