/**
 * Contains definition for class FHP.MapParts
 */
 
FHP.MapParts = function()
{
}

/*
 * Wrapper for the zoom section
 */
FHP.MapParts.Zoom = function()
{
}

/*
 * Wrapper for the map type section
 */
FHP.MapParts.Types = function()
{
}

FHP.MapParts.Types.Init = function()
{
    $( "#icon-satellite" ).click( function() 
    {
        FHP.Map.setMapType( G_SATELLITE_MAP );
    });
    
    $( "#icon-map" ).click( function() 
    {
        FHP.Map.setMapType( G_NORMAL_MAP );
    });
    
    $( "#icon-hybrid" ).click( function() 
    {
        FHP.Map.setMapType( G_HYBRID_MAP );
    }); 
}

FHP.MapParts.Zoom.Init = function()
{
    $( "#icon-zoom-out" ).click( function()
    {
        FHP.Map.zoomOut();
    });
    
    $( "#icon-zoom-in" ).click( function()
    {
        FHP.Map.zoomIn();
    });
    
    $( "#icon-pan-left" ).click( function()
    {
        FHP.Map.panDirection( 1, 0 );
    });
    
    $( "#icon-pan-right" ).click( function()
    {
        FHP.Map.panDirection( -1, 0 );
    });
    
    $( "#icon-pan-top" ).click( function() 
    {
        FHP.Map.panDirection( 0, 1 );
    });
    
    $( "#icon-pan-bottom" ).click( function()
    {
        FHP.Map.panDirection( 0, -1 );
    });
    
    $( "#icon-pan-to-last-result" ).click( function()
    {
        FHP.Map.returnToSavedPosition();
    });
    
    $("#slider-bar").slider({
        steps: 18,
        stepping: 1,
        min: 17,
        max: 0,
        stop: function() {
            // when you have grabbed the handle and set a new value
            FHP.MapParts.Zoom.SliderBarZoom( $( this ) );
        }
    });
    
    // if you just click on the slide bar without interact with the handle
    $("#slider-bar").mouseup( function() {
        FHP.MapParts.Zoom.SliderBarZoom( $( this ) );
    });

    $(".ui-slider-handle").mousedown( function() {
        $(this).addClass( "grabbing" );
        $("#slider-bar").addClass( "grabbing" );
    });
}


FHP.MapParts.Zoom.SliderBarZoom = function( sliderBar )
{
    FHP.Map.setZoom( FHP.MapParts.Zoom.GetLevelFromSlideBar( sliderBar ) );
    $(".ui-slider-handle").removeClass( "grabbing" );
    sliderBar.removeClass( "grabbing" );
}

FHP.MapParts.Zoom.SetSliderBarFromLevel = function( level )
{
    $("#slider-bar").slider( "moveTo", level );
}

FHP.MapParts.Zoom.GetLevelFromSlideBar = function( sliderBar )
{
    return parseInt( sliderBar.slider( "value" ) );
}