function ZipCodePrompt()
{
    this._clientId = null;
    this._onSearch = null;
    this._onCancel = null;
    this._txtZipCode = null;
    
	this.Init = function(id)
	{
	    this._clientId = id;
        this._txtZipCode = $get("txtZipCodePrompt");
	    
	    // Add handlers so we can call functions associated with this object.
        $addHandlers($get("zipAlert"), {keypress:this.CheckKey}, this);
        $addHandlers($get("aZipSearch"), {click:this.Search}, this);
        $addHandlers($get("aZipCancel"), {click:this.Close}, this);
        $addHandlers($get("aZipClose"), {click:this.Close}, this);

        // Setup a method to cleanup
        var delDispose = Function.createDelegate(this, this.Dispose);
        Sys.Application.add_unload(delDispose);
	}
    
    // Clean up after ourself
	this.Dispose = function()
	{
        $clearHandlers($get("zipAlert"));
        $clearHandlers($get("aZipSearch"));
        $clearHandlers($get("aZipCancel"));
        $clearHandlers($get("aZipClose"));
	}

    this.Open = function(title, func, sZip, cancelFunc)
    {
        // Remember the function to call when the Search button is selected.
        this._onSearch = func;
        
        // Remember the function to call when the Cancel button is selected.
        if('undefined' != typeof(cancelFunc))
        {
            this._onCancel = cancelFunc;
        }
        else
        {
            this._onCancel = null;
        }

        //hideDropDownVarList();
        $get('titleText').innerHTML = title;
        Sys.UI.DomElement.removeCssClass($get('alertBackground'), 'hide');
        Sys.UI.DomElement.removeCssClass($get('zipAlert'), 'hide');
        this._txtZipCode.focus();
    }

    this.Close = function()
    {
        //showDropDownVarList();
        addCssClass($get('alertBackground'), 'hide');
        addCssClass($get('zipAlert'), 'hide');
        $get('titleText').innerHTML = '';
        
        if(null != this._onCancel)
        {
            this._onCancel();
        }
        
        return false;
    }

    this.Search = function()
    {
       var sZip = this._txtZipCode.value;
       
       if(!ValidateZip(sZip))
       {
          this._txtZipCode.style.backgroundColor = '#FF9E00';
       }
       else
       {
            this.Close();
	        this._onSearch(sZip);
       }
       
       return false;
    }

    this.CheckKey = function(evt)
    {
        // evt is a Sys.UI.DomEvent object
        if (mapKeyToAction(evt))
        { 
            setEnterPress();
            this.Search();
            return false;
        }
    }
}

function addCssClass(elm, classname)
{
    if(elm)
    {Sys.UI.DomElement.addCssClass(elm, classname);}
} 

function removeCssClass(elm, classname)
{
    if(elm)
    {Sys.UI.DomElement.removeCssClass(elm, classname);}
} 