function FindACar()
{
	this.Init = function(id)
	{
	    this._clientId = id;
	    this._popup = false;
	    this.OnBeforeNavigate = null;
	    this.ZipWM = "Enter ZIP Code";
	    this._txtZip = $get(this._clientId + "_txtZip");
	    	    
	    // 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);
        $addHandlers(this._txtZip, {'focus':this.ZipOnFocus,'blur':this.ZipOnBlur}, this);
        $addHandlers($get(this._clientId + "_checkNew"), {'click':this.LotTypeOnClick}, this);        
        $addHandlers($get(this._clientId + "_checkUsed"), {'click':this.LotTypeOnClick}, this);        
        $addHandlers($get(this._clientId + "_checkCertified"), {'click':this.LotTypeOnClick}, this);        
        $addHandlers($get(this._clientId + "_ddlMake"), {'change':this.MakeOnChange}, this);        
        
        // Handler for key press to map "enter" to the search button.
        $addHandlers($get('carSearch'), {keypress:this.CheckKey}, this);
        
        this._delExecuteSearch = Function.createDelegate(this, this.ExecuteSearch);
        
        // Setup a method to cleanup
        var delDispose = Function.createDelegate(this, this.Dispose);
        Sys.Application.add_unload(delDispose);
        
        // call the zip on blur to get the watermark initialized.
	    this.ZipOnBlur();        
	}
	
    // Clean up after ourself
	this.Dispose = function()
	{
        $clearHandlers($get("ftcShowAdvanced"));
        $clearHandlers($get("ftcSearch"));
        $clearHandlers($get("carSearch"));
        $clearHandlers(this._txtZip);
        $clearHandlers($get(this._clientId + "_checkNew"));
        $clearHandlers($get(this._clientId + "_checkUsed"));
        $clearHandlers($get(this._clientId + "_checkCertified"));
        $clearHandlers($get(this._clientId + "_ddlMake"));
        
        this._delExecuteSearch = null;
	}
	
    this.CheckKey = function(evt)
    {
        // evt is a Sys.UI.DomEvent object
     
        if (mapKeyToAction(evt))
        { 
            setEnterPress();
            this.Search();
            return false;
        }
    }
    
    // On focus for the zip input to do watermark processing.
    this.ZipOnFocus = function()
    {
        if(this.ZipWM == this._txtZip.value)
        {
            this._txtZip.value = "";
        }
    }
	
    // On blur for the zip input to do watermark processing.
    this.ZipOnBlur = function()
    {
        if("" == this._txtZip.value)
        {
            this._txtZip.value = this.ZipWM;
        }
    }

    // The New/Used/Certified checkboxes have been clicked. Repopulate 
    // the Make/Model drop downs.
    this.LotTypeOnClick = function()
    {
        // Call common CL java script function to populate the model list. 
        PopulateMakes(this._clientId + "_ddlMake", this._clientId + "_ddlModel", 
                    $get(this._clientId + "_checkNew").checked, 
                    $get(this._clientId + "_checkUsed").checked,
                    $get(this._clientId + "_checkCertified").checked,
                    true);        
    }
      
    this.MakeOnChange = function()
    {
        // Call common CL java script function to populate the model list. 
        PopulateModels(this._clientId + "_ddlMake", this._clientId + "_ddlModel", 
                    $get(this._clientId + "_checkNew").checked, 
                    $get(this._clientId + "_checkUsed").checked,
                    $get(this._clientId + "_checkCertified").checked, 
                    false);
    }

	// Search for this vehicle. Validate the fields and then search.
	this.Search = function()
	{ 
	    if (typeof(ValidateZip) == "function")
	    {
            if(this.Validate())
            {
                this.ExecuteSearch(this._txtZip.value);
            }
            else
            {
                if(!this._popup)
                {
                    zipPromptVar.Open("Car", this._delExecuteSearch, this._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("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;
        
        if(0 == this._txtZip.value.length)
        {
            removeCssClass($get(this._clientId + "_reqZip"), "hide");
            this._txtZip.focus();
            valid = false;
        }
        else if(!ValidateZip(this._txtZip.value))
        {
            removeCssClass($get(this._clientId + "_reqZip"), "hide");
            this._txtZip.focus();
            valid = false;
        }
        
        return valid;
	}
	
}