﻿Type.registerNamespace('JetShop.StoreControls.SearchBox'); 

JetShop.StoreControls.SearchBox = function(element)
{
    JetShop.StoreControls.SearchBox.initializeBase(this, [element]); 
    
    this._searchBoxID = null;
    this._isNonFramed = null;
    this._searchPage = null;
    this._onKeyPressHandler = null;
}

JetShop.StoreControls.SearchBox.prototype =
{
    initialize: function() {
        // initialize the base
        JetShop.StoreControls.SearchBox.callBaseMethod(this, 'initialize');

        this._onKeyPressHandler = Function.createDelegate(this, this._keyPressed);


        $addHandler(this.get_element(), 'keypress', this._onKeyPressHandler);
    },

    set_SearchBoxID: function(value) {
        this._searchBoxID = value;
    },

    get_SearchBoxID: function() {
        return this._searchBoxID;
    },

    set_IsNonFramed: function(value) {
        this._isNonFramed = value;
    },

    get_IsNonFramed: function() {
        return this._isNonFramed;
    },

    set_SearchPage: function(value) {
        this._searchPage = value;
    },

    get_SearchPage: function() {
        return this._searchPage;
    },

    _keyPressed: function(e) {
        if (e.charCode == Sys.UI.Key.enter) {
            e.stopPropagation();
            e.preventDefault();

            //this._sendEmail();

            DoSearch(this.get_SearchPage(), this.get_SearchBoxID(), alertText, this.get_IsNonFramed());

            return false;
        }
        else if (e.charCode == Sys.UI.Key.esc) {
            e.stopPropagation();
            e.preventDefault();

            //this._showLink();

            return false;
        }
        else {
            return true;
        }
    },

    dispose: function() {
        $clearHandlers(this.get_element());      
        this._onKeyPressHandler = null;
        JetShop.StoreControls.SearchBox.callBaseMethod(this, 'dispose');
    }
}

// register the class
JetShop.StoreControls.SearchBox.registerClass('JetShop.StoreControls.SearchBox', Sys.UI.Control);


if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();