function FindACar()
{
	this.Init = function(id)
	{
	    this._clientId = id;
	    this._popup = false;
	    this.OnBeforeNavigate = null;
	    
	    // Add handlers so we can call functions associated with this object.
        $addHandlers($get("ftcShowAdvanced"), {click:this.ShowAdvanced}, this);
        $addHandlers($get("ftcSearch"), {click:this.Search}, this);
        
        // Handler for key press to map "enter" to the search button.
        $addHandlers($get('carSearch'), {keypress:this.CheckKey}, 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("ftcShowAdvanced"));
        $clearHandlers($get("ftcSearch"));
        $clearHandlers($get("carSearch"));
	}
	
    this.CheckKey = function(evt)
    {
        // evt is a Sys.UI.DomEvent object
     
        if (mapKeyToAction(evt))
        { 
            setEnterPress();
            this.Search();
            return false;
        }
    }
	
	// Search for this vehicle. Validate the fields and then search.
	this.Search = function()
	{ 
	    if (typeof(ValidateZip) == "function")
	    {
            if(this.Validate())
            {
                this.ExecuteSearch($get(this._clientId + "_txtZip").value);
            }
            else
            {
                if(!this._popup)
                {
                    // Create a delegate function for the zip prompt to call to complete the search.
                    var execSearch = Function.createDelegate(this, this.ExecuteSearch);
                    zipPromptVar.Open("Car", execSearch, $get(this._clientId + "_txtZip").value); 
                }   
            }
        }
        
        return false;
	}
	
	// Execute the search for this vehicle. No validation is done. It is assumed that has
	// already been done.
	this.ExecuteSearch = function(sZip)
	{    
    	_searchLF = new LinkFactory();
    	_searchLF._path = this._path
    	_searchLF._qstring = this._qstring;

        if(0 < $get(this._clientId + "_ddlMake").selectedIndex)
        {
            _searchLF.ReplaceToken("xMAKEIDx", $get(this._clientId + "_ddlMake").value);
            _searchLF.ReplaceToken("xMAKEDESCx", $get(this._clientId + "_ddlMake").options[$get(this._clientId + "_ddlMake").selectedIndex].text);
        }
        
        if(0 < $get(this._clientId + "_ddlModel").value.length)
        {
            _searchLF.ReplaceToken("xMODELx", $get(this._clientId + "_ddlModel").value);
        }
            
        // The new/used/certified lot type is a bit mask of the check boxes
        var lotType = 0;
        if ($get(this._clientId + "_checkNew").checked)
        {lotType += 1;}

        if ($get(this._clientId + "_checkUsed").checked)
        {lotType += 2;}

        if ($get(this._clientId + "_checkCertified").checked)
        {lotType += 4;}
        
        if(0 == lotType)
        {lotType = 1;}

        _searchLF.ReplaceToken("xCATx", lotType);

        _searchLF.ReplaceToken("xZIPx", sZip);
        _searchLF.ReplaceToken("xZIPx", sZip);

        _searchLF.ReplaceToken("xDISTANCEx", $get(this._clientId + "_ddlRange").value);
        
        if(null != this.OnBeforeNavigate)
        {
            this.OnBeforeNavigate();
        }
        
        fnNavToSearchResults(_searchLF.FinalizeUrl());
        
        return false;
	}
	
	// Show the advanced search popup.
	this.ShowAdvanced = function()
	{
	    try
	    {
	        // Call the AdvancedSearch.ascx.js function to open the advanced search popup.
	        showAdvancedSearch();
        }
        catch(err)
        {}
	    
	    return false;
	}
	
	this.Validate = function()
	{
	    valid = true;
        Zip = $get(this._clientId + "_txtZip");
        
        if(0 == Zip.value.length)
        {
            removeCssClass($get(this._clientId + "_reqZip"), "hide");
            Zip.focus();
            valid = false;
        }
        else if(!ValidateZip(Zip.value))
        {
            removeCssClass($get(this._clientId + "_reqZip"), "hide");
            Zip.focus();
            valid = false;
        }
        
        return valid;
	}
	
}