﻿Type.registerNamespace('DDTI.Web.Map.Spotlight');

DDTI.Web.Map.Spotlight.DTSpotlightControl = function(element) { 
    DDTI.Web.Map.Spotlight.DTSpotlightControl.initializeBase(this, [element]);
    this._layer = null;
    this._attribute = null;
}

DDTI.Web.Map.Spotlight.DTSpotlightControl.prototype = {
    initialize : function() {
        DDTI.Web.Map.Spotlight.DTSpotlightControl.callBaseMethod(this, 'initialize');
        this._onchangeHandler = Function.createDelegate(this, this._onChange);
        $addHandlers ( this.get_element(), { 'change' : this._onChange }, this );
    },

    dispose : function() {
        $clearHandlers(this.get_element());
        DDTI.Web.Map.Spotlight.DTSpotlightControl.callBaseMethod(this, 'dispose');
    },

    _onChange : function(e) {
        var i = this.get_element().selectedIndex;
        var w = DDTI.Web.Map.Viewer.DTViewerComponent.prototype.get_width();
        var h = DDTI.Web.Map.Viewer.DTViewerComponent.prototype.get_height();
        DDTI.Web.Map.Viewer.DTViewerComponent.prototype.set_imageUrl('Default.mapx?Todo=Find&Layer=' + this._layer + '&Column=' + this._attribute + '&SearchString=' + this.get_element().options[i].value + '&Width=' + w + '&Height=' + h + '&Random=' + Math.floor(Math.random() * 1000000));
    },
    
    get_layer : function() {
        return this._layer;
    },
    
    set_layer : function(value) {
        if (this._layer !== value) {
            this._layer = value;
            this.raisePropertyChanged('layer');
        }
    },
    
    get_attribute : function() {
        return this._attribute;
    },
    
    set_attribute : function(value) {
        if (this._attribute !== value) {
            this._attribute = value;
            this.raisePropertyChanged('attribute');
        }
    }
}

DDTI.Web.Map.Spotlight.DTSpotlightControl.registerClass('DDTI.Web.Map.Spotlight.DTSpotlightControl', Sys.UI.Control);

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();