﻿// Register the control
Type.registerNamespace(NAMESPACE_STARBUCKS);

// Define properties
Starbucks.MiniLocatorControl = function(element) {

    Starbucks.MiniLocatorControl.initializeBase(this, [element]);
}

// Create prototype
Starbucks.MiniLocatorControl.prototype = {

    initialize : function(){

    Starbucks.MiniLocatorControl.callBaseMethod(this, 'initialize'); 
        
        // Initializes map based on developer set properties
        GetMap(this._mapID, this._mapType, this._navControlType, this._zoomLevel, this._centerLatitude, this._centerLongitude, this._showFindControl, this._findNearby, this._sizeWidth, this._sizeHeight, this._pagingDivID);
        SetLocation(this._pinlatitude, this._pinlongitude, this._pintitle, this._pindescription, this._iconPath);
               
    },

    dispose : function(){
        Starbucks.MiniLocatorControl.callBaseMethod(this, 'dispose');
    },

    // Pulling property values to front-end
 
    /**
    * Gets or sets the mapID place holder for map on the page
    * @type (string) 
    */ 
    
    get_targetScriptManager : function(){
        return this._targetScriptManager;
    },
    
    set_targetScriptManager : function(value) {
        if (this._targetScriptManager  !== value){
            this._targetScriptManager  = value;
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_TARGET_SCRIPT_MANAGER);
        }
    },
    
    get_mapID : function(){
        return this._mapID;
    },

    set_mapID : function(value){
        if (this._mapID  !== value){
            this._mapID  = value;
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_MAP_ID);
        }
    },
    
    /**
    * Gets or sets the relative Icon Path for the push pin image
    * @type (string) 
    */ 
    get_iconPath : function(){
        return this._iconPath;
    },

    set_iconPath : function(value){
        if (this._iconPath  !== value){
            this._iconPath  = value;
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_ICON_PATH);
        }
    },
 
    /**
    * Gets or sets the Size height of the map
    * @type (int) 
    */ 
    get_sizeHeight : function(){
        return this._sizeHeight;
    },

    set_sizeHeight : function(value){
        if (this._sizeHeight  !== value){
            this._sizeHeight  = value;
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_SIZE_HEIGHT);
        }
    },
    
    /**
    * Gets or sets the size width of the map
    * @type (int) 
    */ 
    get_sizeWidth : function(){
        return this._sizeWidth;
    },

    set_sizeWidth : function(value){
        if (this._sizeWidth !== value){
            this._sizeWidth = value;
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_SIZE_WIDTH);
        }
    },
    
    /**
    * Gets or sets the latitude coordinate in which the map is to be centered on load
    * @type (double) 
    */ 
    get_centerLatitude : function(){
        return this._centerLatitude;
    },

    set_centerLatitude : function(value){
        if (this._centerLatitude !== value){
            this._centerLatitude = value;
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_CENTER_LATITUDE);
        }
    },

    /**
    * Gets or sets the longitude coordinate in which the map is to be centered on load
    * @type (double) 
    */     
    get_centerLongitude : function(){
        return this._centerLongitude;
    },

    set_centerLongitude : function(value){
        if (this._centerLongitude !== value){
            this._centerLongitude = value;
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_CENTER_LONGITUDE);
        }
    },
    
    /**
    * Gets or sets the zoom level in which the map is to be set on load
    * @type (int) 
    */ 
    get_zoomLevel : function(){
        return this._zoomLevel;
    },

    set_zoomLevel : function(value){
        if (this._zoomLevel !== value){
            this._zoomLevel = value;
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_ZOOM_LEVEL);
        }
    },
    
    /**
    * Gets or sets the map view (road, aerial, hybrid, or birdseye)
    * @type (enum) 
    */ 
    get_mapType : function(){
        return this._mapType;
    },

    set_mapType : function(value){
        if (this._mapType !== value){
            this._mapType = value;
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_MAP_TYPE);
        }
    },
 
    /**
    * Gets or sets the navigation control size (normal, small, tiny)
    * @type (enum) 
    */    
    get_navControlType : function(){
        return this._navControlType;
    },

    set_navControlType : function(value){
        if (this._navControlType !== value){
            this._navControlType = value;
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_NAV_CONTROL_TYPE);
        }
    },
 
    /**
    * Gets or sets the enable variable showFindControl which determines whether not to show the find control
    * @type (bool) 
    */    
    get_showFindControl : function(){
        return this._showFindControl;
    },

    set_showFindControl : function(value){
        if (this._showFindControl !== value){
            this._showFindControl = value;
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_SHOW_FIND_CONTROL);
        }
    },

    /**
    * Gets or sets the enable variable FindNearby which determines whether not a find nearby search is performed
    * @type (bool) 
    */  
    get_findNearby : function(){
        return this._findNearby;
    },

    set_findNearby : function(value){
        if (this._findNearby !== value){
            this._findNearby = value;
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_FIND_NEARBY);
        }
    },
    
    /**
    * Gets or sets the latitude coordinate of the push pin to be placed on the map on load
    * @type (double) 
    */  
    get_pinlatitude : function(){
        return this._pinlatitude;
    },

    set_pinlatitude : function(value){
        if (this._pinlatitude !== value){
            this._pinlatitude = value;
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_PIN_LATITUDE);
        }
    },

    /**
    * Gets or sets the longitude coordinate of the push pin to be placed on the map on load
    * @type (double) 
    */          
    get_pinlongitude : function(){
        return this._pinlongitude;
    },

    set_pinlongitude : function(value){
        if (this._pinlongitude !== value){
            this._pinlongitude = value;  
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_PIN_LONGITUDE);
        }
    },
  
    /**
    * Gets or sets the title of the push pin to be placed on the map on load
    * @type (string) 
    */    
    get_pintitle : function(){
        return this._pintitle;
    },

    set_pintitle : function(value){
        if (this._pintitle !== value){
            this._pintitle = value;
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_PIN_TITLE);
        }
    },
     
    /**
    * Gets or sets the description of the push pin to be placed on the map on load
    * @type (string) 
    */    
    get_pindescription : function(){
        return this._pindescription;
    },

    set_pindescription : function(value){
        if (this._pindescription !== value){
            this._pindescription = value;
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_PIN_DESCRIPTION);
        }
    },
 
    /**
    * Gets or sets the data source user id for MWS credentials
    * @type (string) 
    */    
    get_dataSourceUserID : function(){
        return this._dataSourceUserID;
    },

    set_dataSourceUserID : function(value){
        if (this._dataSourceUserID !== value){
            this._dataSourceUserID = value;
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_DATASOURCE_USERID);
        }
    },
    
    /**
    * Gets or sets the data source password for MWS credentials
    * @type (string) 
    */ 
    get_dataSourcePassword : function(){
        return this._dataSourcePassword;
    },

    set_dataSourcePassword : function(value){
        if (this._dataSourcePassword !== value){
            this._dataSourcePassword = value;
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_DATASOURCE_PASSWORD);
        }
    },    
    
    /**
    * Gets or sets the data source URL for MWS
    * @type (string) 
    */     
    get_dataSourceURL : function(){
        return this._dataSourceURL;
    },

    set_dataSourceURL : function(value){
        if (this._dataSourceURL !== value){
            this._dataSourceURL = value;
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_DATASOURCE_URL);
        }
    },  
 
    /**
    * Gets or sets the data source filter for a MWS find specification
    * @type (string) 
    */     
    get_dataSourceFilter : function(){
        return this._dataSourceFilter;
    },

    set_dataSourceFilter : function(value){
        if (this._dataSourceFilter !== value){
            this._dataSourceFilter = value;
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_DATASOURCE_FILTER);
        }
    }, 
 
    /**
    * Gets or sets the data source radius for a MWS find specification
    * @type (string) 
    */     
    get_dataSourceRadius : function(){
        return this._dataSourceRadius;
    },

    set_dataSourceRadius : function(value){
        if (this._dataSourceRadius !== value){
            this._dataSourceRadius = value;
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_DATASOURCE_RADIUS);
        }
    },
 
    /**
    * Gets or sets the popup infobox description for the Find Nearby result push pins
    * @type (string) 
    */       
    get_findNearbyResultDescription : function(){
        return this._findNearbyResultDescription;
    },

    set_findNearbyResultDescription : function(value){
        if (this._findNearbyResultDescription !== value){
            this._findNearbyResultDescription = value;
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_FIND_NEARBY_RESULT_DESCRIPTION);
        }
    },
    
    /**
    * Gets or sets the array which holds a list of names correspond to valid property values
    * in the specified datasource URL
    * @type (string[]) 
    */ 
    get_findNearbyPropValues : function(){
        return this._findNearbyPropValues;
    },

    set_findNearbyPropValues : function(value){
        if (this._findNearbyPropValues !== value){
            this._findNearbyPropValues = value;
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_FIND_NEARBY_PROP_VALUES);
        }
    },
    
    /**
    * Gets or sets the id of the paging DIV
    * @type (string) 
    */ 
    get_pagingDivID : function(){
        return this._pagingDivID;
     },
    
    set_pagingDivID : function(value){
        if (this._pagingDivID != value){
            this._pagingDivID = value;
            this.raisePropertyChanged(RAISE_PROPERTY_CHANGED_PAGING_DIV_ID);
        }
    }
}

// Register the class as a type that inherits from Sys.UI.Control.
Starbucks.MiniLocatorControl.registerClass(REGISTER_CLASS, Sys.UI.Behavior);
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();