﻿/*  
Copyright (c) 2010 by 5 Limes Pty Limited. All rights reserved.
This material may not be duplicated for any purpose without the
express written consent of 5 Limes Pty Limited of Sydney, Australia.
http://www.5Limes.com.au
*/

/*   
*/
function CSearchBox(strDummyTextBoxSearchId, strRealTextBoxSearchId, strSearchButtonId, strCloseButtonId, strDivSearchPopupId) {this._initialise(strDummyTextBoxSearchId, strRealTextBoxSearchId, strSearchButtonId, strCloseButtonId, strDivSearchPopupId); }

CSearchBox.prototype =
{
    _jSearchInputBox: null,
    _jDummyInputBox: null,
    _jSearchButton: null,
    _jCloseButton: null,
    _jSearchPopup: null,

    _initialise: function (strDummyTextBoxSearchId, strRealTextBoxSearchId, strSearchButtonId, strCloseButtonId, strDivSearchPopupId)
    {
        this._jDummyInputBox = jQuery("#" + strDummyTextBoxSearchId);
        this._jSearchInputBox = jQuery("#" + strRealTextBoxSearchId);
        this._jSearchButton = jQuery("#" + strSearchButtonId);
        this._jCloseButton = jQuery("#" + strCloseButtonId);
        this._jSearchPopup = jQuery("#" + strDivSearchPopupId);

        this._attachEvents();
    },

    _attachEvents: function ()
    {
        this._jDummyInputBox.click(function (e, f)
        {
            gSearchBox._jSearchPopup.css({ display: "block" });
            gSearchBox._jSearchInputBox.attr("value", "").focus();
        });

        this._jCloseButton.click(function (e, f)
        {
            gSearchBox._jSearchPopup.css({ display: "none" });
        });

        if (this._jSearchPopup.length > 0)
        {
            this._jSearchPopup.css({ display: "none" });
        }

        this._jSearchInputBox.keypress(function (event)
        {
            if (event.keyCode == "13")
            {
                event.preventDefault();
                gSearchBox._jSearchButton.click();
            }
        });
    }
}
