
if (typeof YAHOO.Edmunds == 'undefined') {
    YAHOO.Edmunds = {};
}

// creates a namespace for this "YAHOO.Edmunds.Inventory"
YAHOO.namespace("YAHOO.Edmunds.Inventory");

/**
 * Overview Handles all the AutoTrader Pidget integration with the Edmunds site.
 * All interation is set to be localized within a global functionas this code is only used for the
 * new car inventory integration.
 *
 */
YAHOO.Edmunds.Inventory.SRLLitePidget = function(containerID, pidget_loader){
    this.containerID = containerID;
    this.pidget_loader = pidget_loader;
    this.pidget_type = "SRL";
    this.pidget_config = new YAHOO.Edmunds.Inventory.PidgetConfig();
    this.display_error = false;
    this.default_tab_value = null;
};

YAHOO.Edmunds.Inventory.SRLLitePidget.prototype = {

    setParameters: function(parameters){
        if (parameters) {
            this.pidget_config._make = parameters['make'];

            if(!YAHOO.Edmunds.Inventory.IsNullOrEmpty(parameters['year'])) {
                this.pidget_config._yearFrom = parameters['year'];
            }
            
            if(!YAHOO.Edmunds.Inventory.IsNullOrEmpty(parameters['yearTo'])) {
                this.pidget_config._yearTo = parameters['yearTo'];
            }

            this.pidget_config._model = parameters['model'];
            this.pidget_config._styleId = parameters['styleid'];
            this.pidget_config._modelId = parameters['modelid'];
            this.pidget_config._only_special = parameters['only_special'];
            this.pidget_config._per_page = parameters['count_per_page'];
            this.pidget_config._radius = parameters['radius'];
            this.display_error = parameters['display_error'];
            this.default_tab_value = parameters['default_tab_value'];
        }
    },
    
    createViewInventoryLink: function(pidget_config){
        var newSpanTop = null;
        var newSpanBottom = null;
        var newAnchorTop = null;
        var newAnchorBottom = null;
        var newDivTop = null;
        var newDivBottom = null;
        var requestStr = '/inventory/srp.html';
        
        /*********************************************************************
         *   Please uncomment the next line to pass the year into the inventory URL.
         *   NOTE:  Make sure to replace the "?" with an "&" for the make parameter (currently it is using "?")
         *          Once the year is set back into the URL, please verify with business to see if they want to
         *          restrict the vehicles returned by the SRLLitePidget and STATPidget by adding the fromYear and toYear
         *          (currently it set to pass in all new years by default)
         *
         *********************************************************************/
        //if(pidget_config._yearFrom) requestStr = requestStr + "?year=" + pidget_config._yearFrom;
        if (pidget_config._make != null) {
            requestStr = requestStr + "?make=" + pidget_config._make;
        }
        if (pidget_config._model != null) {
            requestStr = requestStr + "&model=" + pidget_config._model;
        }
        
        YAHOO.Edmunds.Inventory.removeCookie("edmunds3");
        if (pidget_config._yearFrom) {
            YAHOO.Edmunds.Inventory.setCookieSub("nci_transYear", pidget_config._yearFrom);
        }
        if (pidget_config._make) {
            YAHOO.Edmunds.Inventory.setCookieSub("make", pidget_config._make);
        }
        if (pidget_config._model) {
            YAHOO.Edmunds.Inventory.setCookieSub("model", pidget_config._model);
        }
        if (pidget_config._atc_make) {
            YAHOO.Edmunds.Inventory.setCookieSub("atc_make", pidget_config._atc_make);
        }
        if (pidget_config._atc_model) {
            YAHOO.Edmunds.Inventory.setCookieSub("atc_model", pidget_config._atc_model);
        }
        if (pidget_config._atc_body) {
            YAHOO.Edmunds.Inventory.setCookieSub("atc_body", pidget_config._atc_body);
        }
        
        var inventory_listings = document.getElementById("edmui-pidgetSRL-listings-top");
        
        if (inventory_listings) {
            var inventory_listings_all = document.getElementById("nci_inventorylinktop");
            if (!inventory_listings_all) {
                newSpanTop = document.createElement("span");
                newSpanTop.id = "nci_inventorylinktop";
                
                inventory_listings.appendChild(newSpanTop);
                
                newAnchorTop = document.createElement("a");
                newAnchorTop.id = "nci_inventorylinkanchortop";
                newAnchorTop.href = requestStr;
                newAnchorTop.innerHTML = "See All Listings";
                
                inventory_listings.appendChild(newAnchorTop);
                YAHOO.Edmunds.Inventory.showElement("edmui-pidgetSRL-top");
            }
        }
        
        var inventory_listings_bottom = document.getElementById("edmui-pidgetSRL-listings-bottom");
        if (inventory_listings_bottom) {
            newSpanBottom = document.createElement("span");
            newSpanBottom.id = "nci_inventorylinkbottom";
            
            newAnchorBottom = document.createElement("a");
            newAnchorBottom.id = "nci_inventorylinkanchorbottom";
            newAnchorBottom.href = requestStr;
            newAnchorBottom.innerHTML = "See All Listings";
            
            inventory_listings_bottom.appendChild(newSpanBottom);
            inventory_listings_bottom.appendChild(newAnchorBottom);
            YAHOO.Edmunds.Inventory.showElement("edmui-pidgetSRL-bottom");
        }
    },
    
    load_pidget: function(){
    
        /** Variables initialized for loading **/
        var current_object = this;
        var pidget_config = this.pidget_config;
        var display_error = this.display_error;
        
        if (!pidget_config._make) {
            YAHOO.Edmunds.Inventory.logDebug("'make' must be defined!");
        }
        
        if (!pidget_config._yearFrom) {
            YAHOO.Edmunds.Inventory.logDebug("'year' must be defined!");
        }

        if (!pidget_config._yearTo) {
            YAHOO.Edmunds.Inventory.logDebug("'yearTo' must be defined!");
        }
        
        if (!pidget_config._model) {
            YAHOO.Edmunds.Inventory.logDebug("'model' must be defined!");
        }
        
        if (!pidget_config._styleId) {
            YAHOO.Edmunds.Inventory.logDebug("'styleid' must be defined!");
        }
        
        if (!pidget_config._modelId) {
            YAHOO.Edmunds.Inventory.logDebug("'modelid' must be defined!");
        }
        
        if (!pidget_config._only_special) {
            YAHOO.Edmunds.Inventory.logDebug("'only_special' must be defined!");
        }
        
        if (!pidget_config._per_page) {
            YAHOO.Edmunds.Inventory.logDebug("'count_per_page' must be defined!");
        }
        
        if (!pidget_config._radius) {
            YAHOO.Edmunds.Inventory.logDebug("'radius' must be defined!");
        }
        
        if (!this.default_tab_value) {
            YAHOO.Edmunds.Inventory.logDebug("'default_tab_value' must be defined!");
        }
        
        YAHOO.Edmunds.Inventory.logDebug("displaying error messages on pidget error - " + display_error);
        
        try {
        
            /** Translation callback functions **/
            var vehicle_translation_init_callback = function(){
                YAHOO.Edmunds.Inventory.startGomezTracking(pidget_config, ['SRLLite Edmunds Translation']);
            };
            
            var vehicle_translation_destroy_callback = function(){
                YAHOO.Edmunds.Inventory.stopGomezTracking(pidget_config, ['SRLLite Edmunds Translation']);
            };
            
            var vehicle_translation_found_callback = function(o, partnerdata){
                if (partnerdata && partnerdata.length > 0) {
                    get_srl_lite_pidget(partnerdata[0].key, partnerdata.bodyType, o.argument[0]);
                }
            };
            
            var get_srl_lite_pidget = function(partnerKey, partnerBody, scope){
                if (partnerKey) {
                    var makeModel = partnerKey.split('|');
                    
                    if (makeModel && makeModel.length > 1) {
                        var atc_make = makeModel[0];
                        var atc_model = makeModel[1];
                        var atc_bodyType = partnerBody || '';
                        
                        pidget_config._atc_make = atc_make;
                        pidget_config._atc_model = atc_model;
                        pidget_config._atc_body = atc_bodyType;
                        
                        var start_year_date = new Date().getFullYear() - 1;
                        var end_year_date = '';
                        
                        if(!YAHOO.Edmunds.Inventory.IsNullOrEmpty(pidget_config._yearFrom)) {
                            start_year_date = pidget_config._yearFrom;
                        }
                        
                        if(!YAHOO.Edmunds.Inventory.IsNullOrEmpty(pidget_config._yearTo)) {
                            end_year_date = pidget_config._yearTo;
                        }
                        
                        var _rad = YAHOO.Edmunds.Inventory.IsNullOrEmpty(pidget_config._radius) ? "50" : pidget_config._radius;
                        var atc_tab_value = YAHOO.Edmunds.Inventory.getATCTabValue("SRLLite", scope.default_tab_value);                

                        var myData = {
                            service: 'listings',
                            callback: 'SRL',
                            parameters: {
                                make: pidget_config._atc_make,
                                model: pidget_config._atc_model,
                                distance: _rad,
                                address: pidget_config._zip,
                                start_year: start_year_date,
                                end_year: end_year_date,
                                search_type: 'new',
                                num_records: pidget_config._per_page,
                                partner: 'edmunds',
                                body_style: pidget_config._atc_body,
                                feature: "",
                                only_special: pidget_config._only_special
                            }
                        };
                        
                        if (!YAHOO.Edmunds.Inventory.IsNullOrEmpty(pidget_config._zip)) {
                            YAHOO.Edmunds.Inventory.startGomezTracking(pidget_config, ['SRLLite-Pidget']);
                            Pidget.SRL.loadData(myData);
                        } else {
                            if (!display_error) {
                                YAHOO.Edmunds.Inventory.SRLLitePidget.prototype.hide();
                            } else {
                                YAHOO.Edmunds.Inventory.SRLLitePidget.prototype.hideLoadingGraphic();
                                YAHOO.Edmunds.Inventory.showPidget("vdp_inventory_no_results", "SRL", pidget_config);
                            }
                        }
                    }
                }
            };
            
            var no_vehicle_translation_found_callback = function(o){
                YAHOO.Edmunds.Inventory.resetGomezTracking(pidget_config);
                YAHOO.Edmunds.Inventory.resetGlobalPidgetTimeout();
                var values = [];
                values.loadState = "error";
                values.errorCode = "002;Translation Error;Unable to retrieve the requested translated value";
                YAHOO.Edmunds.Inventory.setInventorySummaryVars(values, pidget_config, 'SRLLite');
                YAHOO.Edmunds.Inventory.writeOmni2Pixel(values);
                if (!display_error) {
                    YAHOO.Edmunds.Inventory.SRLLitePidget.prototype.hide();
                } else {
                    YAHOO.Edmunds.Inventory.SRLLitePidget.prototype.hideLoadingGraphic();
                    YAHOO.Edmunds.Inventory.showPidget("vdp_inventory_no_results", "SRL", pidget_config, values);
                }
            };
            
            var vehicle_translation_error_callback = function(o){
                YAHOO.Edmunds.Inventory.resetGomezTracking(pidget_config);
                YAHOO.Edmunds.Inventory.resetGlobalPidgetTimeout();
                var values = [];
                values.loadState = "error";
                values.errorCode = "002;Translation Error;Unable to retrieve the requested translated value";
                YAHOO.Edmunds.Inventory.setInventorySummaryVars(values, pidget_config, 'SRLLite');
                YAHOO.Edmunds.Inventory.writeOmni2Pixel(values);
                if (!display_error) {
                    YAHOO.Edmunds.Inventory.SRLLitePidget.prototype.hide();
                } else {
                    YAHOO.Edmunds.Inventory.SRLLitePidget.prototype.hideLoadingGraphic();
                    YAHOO.Edmunds.Inventory.showPidget("error", "SRL", pidget_config, values);
                }
            };
            
            var vehicle_translation_failure_callback = function(o){
                YAHOO.Edmunds.Inventory.resetGomezTracking(pidget_config);
                YAHOO.Edmunds.Inventory.resetGlobalPidgetTimeout();
                var values = [];
                values.loadState = "error";
                values.errorCode = "002;Translation Error;Unable to retrieve the requested translated value";
                YAHOO.Edmunds.Inventory.setInventorySummaryVars(values, pidget_config, 'SRLLite');
                YAHOO.Edmunds.Inventory.writeOmni2Pixel(values);
                if (!display_error) {
                    YAHOO.Edmunds.Inventory.SRLLitePidget.prototype.hide();
                } else {
                    YAHOO.Edmunds.Inventory.SRLLitePidget.prototype.hideLoadingGraphic();
                    YAHOO.Edmunds.Inventory.showPidget("error", "SRL", pidget_config, values);
                }
            };
            
            var init_pidget = function(){
                YAHOO.Edmunds.Inventory.startGomezTracking(pidget_config, ['SRLLite-Pidget Overall']);
                if (mboxATCKey) {
                    get_srl_lite_pidget(mboxATCKey, mboxATCBodyType, current_object);
                } else {
                    var vehicle_translation = new YAHOO.Edmunds.Inventory.VehicleTranslation(current_object);
                    vehicle_translation.addCallback('translation_init', vehicle_translation_init_callback);
                    vehicle_translation.addCallback('translation_destroy', vehicle_translation_destroy_callback);
                    vehicle_translation.addCallback('translation_found', vehicle_translation_found_callback);
                    vehicle_translation.addCallback('no_translation_found', no_vehicle_translation_found_callback);
                    vehicle_translation.addCallback('translation_error', vehicle_translation_error_callback);
                    vehicle_translation.addCallback('translation_failure', vehicle_translation_failure_callback);
                    vehicle_translation.run(pidget_config._yearFrom, pidget_config._make, pidget_config._model, pidget_config._modelId, pidget_config._styleId);
                }
            };
            
            /*******************************************************************
             * BEGIN -- SRL
             *******************************************************************/
            Pidget.info("Available SRL Notifications: " + Object.toJSON(Pidget.SRL.listNotifications()));
            pidget_config.subscribe(pidget_config, "SRL", Pidget.SRL, "init", init_pidget, null, true);
            
            // Pidget ERROR event
            // Error events include 'no results' as an error.
            pidget_config.subscribe(pidget_config, "SRL", Pidget.SRL, "error", function(data){
                YAHOO.Edmunds.Inventory.stopGomezTracking(pidget_config, ['SRLLite-Pidget', 'SRLLite-Pidget Overall']);
                
                var values = [];
                values.loadState = "error";
                values.errorCode = data.errorCode + ";" + data.errorCause + ";" + data.errorDetails;
                YAHOO.Edmunds.Inventory.setInventorySummaryVars(values, pidget_config, 'SRLLite');
                YAHOO.Edmunds.Inventory.writeOmni2Pixel(values);
                
                if (!display_error) {
                    YAHOO.Edmunds.Inventory.SRLLitePidget.prototype.hide();
                } else {
                    YAHOO.Edmunds.Inventory.SRLLitePidget.prototype.hideLoadingGraphic();
                    YAHOO.Edmunds.Inventory.showPidget("error", "SRL", pidget_config, data);
                }
                YAHOO.Edmunds.Inventory.logDebug(values.errorCode);
            }, null, true);
            
            // Pidget DATA_LOADED event
            //
            pidget_config.subscribe(pidget_config, "SRL", Pidget.SRL, "data_loaded", function(data){
                YAHOO.Edmunds.Inventory.stopGomezTracking(pidget_config, ['SRLLite-Pidget', 'SRLLite-Pidget Overall']);
                YAHOO.Edmunds.Inventory.SRLLitePidget.prototype.hideLoadingGraphic();
                if (data && !YAHOO.Edmunds.Inventory.IsPidgetError(data)) {
                    var values = [];
                    values.loadState = "data_loaded";
                    values.totalVehicles = data.total_hits;
                    values.totalListings = data.displayable_hits;
                    values.standardListings = data.displayable_hits - data.with_premiums;
                    values.premiumListings = data.with_premiums;
                    values.listingsPhotos = data.with_photos;
                    values.listingsSpecials = data.with_specials;
                    values.pageNum = pidget_config._pgNum;
                    values.exactMatches = data.total_exact_matches;
                    values.closeMatches = data.total_close_matches;
                    
                    YAHOO.Edmunds.Inventory.setInventorySummaryVars(values, pidget_config, 'SRLLite');
                    YAHOO.Edmunds.Inventory.writeOmni2Pixel(values);
                    
                    if (data['total_hits'] != null) {
                        if (data['total_hits'] == 0) {
                            if (!display_error) {
                                YAHOO.Edmunds.Inventory.SRLLitePidget.prototype.hide();
                            } else {
                                var titleDivCount = document.getElementById("inventory-title-count");
                                var notFoundText = document.getElementById("vehicle-text");
                                if (titleDivCount) {
                                    YAHOO.Edmunds.Inventory.hideElement(titleDivCount);
                                }
                                if (notFoundText) {
                                    var _miles = YAHOO.Edmunds.Inventory.IsNullOrEmpty(pidget_config._radius) ? 50 : pidget_config._radius;
                                    notFoundText.innerHTML = "Sorry, No Matching Vehicles Found Within " + _miles + " Miles";
                                }
                                
                                YAHOO.Edmunds.Inventory.showPidget("vdp_inventory_no_results", "SRL", pidget_config);
                            }
                        } else {
                            YAHOO.Edmunds.Inventory.showPidget("valid", "SRL", pidget_config);
                            
                            var titleDiv = document.getElementById("inventory-title-count");
                            
                            if (titleDiv) {
                                titleDiv.innerHTML = data['total_hits'];
                            }
                            YAHOO.Edmunds.Inventory.showElement("inventory-title");
                            YAHOO.Edmunds.Inventory.SRLLitePidget.prototype.createViewInventoryLink(pidget_config);
                        }
                    } else {
                        if (!display_error) {
                            YAHOO.Edmunds.Inventory.SRLLitePidget.prototype.hide();
                        } else {
                            YAHOO.Edmunds.Inventory.showPidget("error", "SRL", pidget_config, { errorCode : '000;Pidget loading timeout;exceeded the set global timeout' });
                        }
                    }
                }
            }, null, true);
            
            pidget_config.subscribe(pidget_config, "SRL", Pidget.SRL, "ncal_click", function(data){
                var last_year_date = new Date().getFullYear() - 1;
                YAHOO.Edmunds.Inventory.setUserActionVars(data, pidget_config, 'SRLLite');
                YAHOO.Edmunds.Inventory.setCookieSub("nci_dealer_id", data.dealer_id);
                YAHOO.Edmunds.Inventory.setCookieSub("nci_is_edmunds", data.is_edmunds);
                YAHOO.Edmunds.Inventory.setCookieSub("ddp_active_search", "NCAL");
                YAHOO.Edmunds.Inventory.setCookieSub("yearFrom", last_year_date);
                YAHOO.Edmunds.Inventory.setCookieSub("ncalId", data.ncal_id);
                YAHOO.Edmunds.Inventory.setCookieSub("ncalId", data.ncal_id);				
                pidget_config._ddp_tab = "tab_inventory";
                window.location = YAHOO.Edmunds.Inventory.generateURL("ddp", pidget_config);
            }, null, true);
            
            pidget_config.subscribe(pidget_config, "SRL", Pidget.SRL, "car_click", function(data){
                // Forward to VIN
                YAHOO.Edmunds.Inventory.setUserActionVars(data, pidget_config, 'SRLLite');
                YAHOO.Edmunds.Inventory.setCookieSub("nci_dealer_id", data.dealer_id);
                YAHOO.Edmunds.Inventory.setCookieSub("nci_is_edmunds", data.is_edmunds);
                YAHOO.Edmunds.Inventory.setCookieSub("carId", data.car_id);
                window.location = YAHOO.Edmunds.Inventory.generateURL("vin", pidget_config);
            }, null, true);
            
            pidget_config.subscribe(pidget_config, "SRL", Pidget.SRL, "view_all_specials_click", function(data){
                YAHOO.Edmunds.Inventory.setCookieSub("ddp_tab", "tab_specials");
                YAHOO.Edmunds.Inventory.setCookieSub("nci_dealer_id", data.dealer_id);
                YAHOO.Edmunds.Inventory.setCookieSub("ncalId", data.ncal_id);
                YAHOO.Edmunds.Inventory.setCookieSub("nci_is_edmunds", data.is_edmunds);
                YAHOO.Edmunds.Inventory.setUserActionVars(data, pidget_config, 'SRLLite');
                pidget_config._ddp_tab = "tab_specials";
                window.location = YAHOO.Edmunds.Inventory.generateURL("ddp", pidget_config);
            }, null, true);
            
            pidget_config.subscribe(pidget_config, "SRL", Pidget.SRL, "view_specials_click", function(data){
                YAHOO.Edmunds.Inventory.setUserActionVars(data, pidget_config, 'SRLLite');
                pidget_config._ncalId = data.ncal_id;
                pidget_config._isEdmunds = data.is_edmunds;
                YAHOO.Edmunds.Inventory.setCookieSub("nci_dealer_id", data.dealer_id);
                YAHOO.Edmunds.Inventory.setCookieSub("nci_is_edmunds", data.is_edmunds);
                YAHOO.Edmunds.Inventory.setCookieSub("url", data.url);
                YAHOO.Edmunds.Inventory.popupWindow("srp.popup.html?page=specials");
            }, null, true);
            pidget_config.subscribe(pidget_config, "SRL", Pidget.SRL, "sort_begin", function(data){
                YAHOO.Edmunds.Inventory.startGomezTracking(pidget_config, ['SRL-Pidget Sort']);
                YAHOO.Edmunds.Inventory.setUserActionVars(data, pidget_config, 'SRLLite');
                pidget_config._sortOrd = data.newValue;
            }, 5000, false);
            
            pidget_config.subscribe(pidget_config, "SRL", Pidget.SRL, "sort_end", function(data){
                YAHOO.Edmunds.Inventory.stopGomezTracking(pidget_config, ['SRL-Pidget Sort']);
                YAHOO.Edmunds.Inventory.setUserActionVars(data, pidget_config, 'SRLLite');
                YAHOO.Edmunds.Inventory.refreshAds();
            }, null, false);
            
            pidget_config.subscribe(pidget_config, "SRL", Pidget.SRL, "per_page_change_begin", function(data){
                YAHOO.Edmunds.Inventory.startGomezTracking(pidget_config, ['SRL-Pidget Num_Listings per page']);
                YAHOO.Edmunds.Inventory.setUserActionVars(data, pidget_config, 'SRLLite');
                pidget_config._perPage = data.newValue;
                YAHOO.Edmunds.Inventory.setCookieSub("perPage", data.newValue);
            }, 5000, false);
            
            pidget_config.subscribe(pidget_config, "SRL", Pidget.SRL, "per_page_change_end", function(data){
                YAHOO.Edmunds.Inventory.stopGomezTracking(pidget_config, ['SRL-Pidget Num_Listings per page']);
                YAHOO.Edmunds.Inventory.setUserActionVars(data, pidget_config, 'SRLLite');
                YAHOO.Edmunds.Inventory.refreshAds();
                pidget_config._pgNum = 1;
            }, null, false);
            
            pidget_config.subscribe(pidget_config, "SRL", Pidget.SRL, "pagination_begin", function(data){
                YAHOO.Edmunds.Inventory.startGomezTracking(pidget_config, ['SRL-Pidget Paginate']);
                YAHOO.Edmunds.Inventory.setUserActionVars(data, pidget_config, 'SRLLite');
            }, 5000, false);
            
            pidget_config.subscribe(pidget_config, "SRL", Pidget.SRL, "pagination_end", function(data){
                YAHOO.Edmunds.Inventory.stopGomezTracking(pidget_config, ['SRL-Pidget Paginate']);
                YAHOO.Edmunds.Inventory.setUserActionVars(data, pidget_config, 'SRLLite');
                YAHOO.Edmunds.Inventory.refreshAds();
                pidget_config._pgNum = data.new_page;
            }, null, false);
            
            pidget_config.subscribe(pidget_config, "SRL", Pidget.SRL, "phone_click", function(data){
                YAHOO.Edmunds.Inventory.setUserActionVars(data, pidget_config, 'SRLLite');
            }, null, true);
            
            pidget_config.subscribe(pidget_config, "SRL", Pidget.SRL, "contact_dealer", function(data){
                YAHOO.Edmunds.Inventory.setUserActionVars(data, pidget_config);
                YAHOO.Edmunds.Inventory.setCookieSub("url", data.url);
                YAHOO.Edmunds.Inventory.popupLightbox("srp.popup.html?page=contact", true, {
                    width: 820
                });
            }, null, false);

            pidget_config.subscribe(pidget_config, "SRP", Pidget.SRL, "dealer_info_click", function(data){
                YAHOO.Edmunds.Inventory.setUserActionVars(data, pidget_config, 'SRL');
                YAHOO.Edmunds.Inventory.setCookieSub("nci_dealer_id", data.dealer_id);
                YAHOO.Edmunds.Inventory.setCookieSub("nci_is_edmunds", data.is_edmunds);
                YAHOO.Edmunds.Inventory.setCookieSub("ddp_active_search", "NCAL");
                YAHOO.Edmunds.Inventory.setCookieSub("ncalId", data.ncal_id);
                pidget_config._ddp_tab = "tab_details";
                window.location = YAHOO.Edmunds.Inventory.generateURL("ddp", pidget_config);
            }, null, false);

            /*******************************************************************
             * END -- SRL
             *******************************************************************/
        } 
        catch (e) {
            YAHOO.Edmunds.Inventory.resetGomezTracking(pidget_config);
            if (!display_error) {
                YAHOO.Edmunds.Inventory.SRLLitePidget.prototype.hide();
            } else {
                YAHOO.Edmunds.Inventory.SRLLitePidget.prototype.hideLoadingGraphic();
                YAHOO.Edmunds.Inventory.showPidget("error", "SRL", pidget_config);
            }
        }
    },
    
    hide: function(){
        YAHOO.Edmunds.Inventory.hideElement('inventory-title');
        YAHOO.Edmunds.Inventory.hideElement('edmui-pidgetSRL-top');
        YAHOO.Edmunds.Inventory.hideElement('edmui-pidgetSRL-listings-bottom');
        YAHOO.Edmunds.Inventory.SRLLitePidget.prototype.hideLoadingGraphic();
    },
    
    hideLoadingGraphic: function(){
        var loading_graphic = document.getElementById('loading-graphic');
        if (loading_graphic) {
            loading_graphic.innerHTML = '';
            loading_graphic.style.visibility = 'hidden';
        }
    },
    
    show: function(component_version, lazy_load, parameters){
        this.setParameters(parameters);

        var atc_tab_value = YAHOO.Edmunds.Inventory.getATCTabValue("SRLLite", this.default_tab_value);
        var extra_config_parameters = {
            tab: atc_tab_value,
            pidgetTextConfig: {
                contact_dealer_text: 'E-mail Dealer',
                dealer_specials_text: 'View Dealer Specials'
            }
        };

        this.pidget_loader.addPidget(component_version, this.containerID, this.load_pidget, this.pidget_type, null, extra_config_parameters, this);
    }
};




