
!function(){var hasStorage=Modernizr.sessionstorage;var storage=hasStorage?window.sessionStorage:{};var nativeStorageMethods={init:function(key){storage[this.sessionKey]=storage[this.sessionKey]||'{}';},set:function(data){storage[this.sessionKey]=JSON.stringify(data);},get:function(){return JSON.parse(storage[this.sessionKey]);},drop:function(){delete storage[this.sessionKey];}};var fallbackStorageMethods={init:function(){storage[this.sessionKey]={};},set:function(data){storage[this.sessionKey]=data;},get:function(){return storage[this.sessionKey];},drop:function(){storage[this.sessionKey]={};}};var JSONSessionStore=function(sessionStorageKey){this.sessionKey=sessionStorageKey;this.init();};JSONSessionStore.prototype=fallbackStorageMethods;var root=this;var VehicleDataCache=function(bootstrapData,mediator){this.baseData=bootstrapData;this.vehicleDataCache=new JSONSessionStore('vehicleDataCache');this.mediator=mediator;this.init();};VehicleDataCache.prototype={init:function(){this.mediator.subscribe('vehicleChange',this.fetchSelectorData,this);},fetchSelectorData:function(payload){var vehicleData=this.baseData.vehicles[payload.vehicleIndex];var vehicleCode=vehicleData.uscCode;var seriesCode=vehicleData.seriesCode;var vehicletype=vehicleData.vehicleType;var catalogid=vehicleData.catalogId;var gforcemode=EP2.getGforceMode();this.addToDataSet(vehicleCode,vehicleData,this.baseData.vehicles[0].selector);if(this.fromStorage(vehicleCode))
return;},addToDataSet:function(vehicleCode,vehicleData,selectorData){this.currentVehicle=vehicleCode;var aggregatedData=$.extend({},vehicleData,selectorData);var dataSet=this.vehicleDataCache.get();dataSet[vehicleCode]=aggregatedData;this.vehicleDataCache.set(dataSet);this.notify(aggregatedData);},updateStoredConfiguration:function(payload){var dataSet=this.vehicleDataCache.get();dataSet[this.currentVehicle].configuration=payload;this.vehicleDataCache.set(dataSet);},fromStorage:function(vehicleCode){var value=this.vehicleDataCache.get()[vehicleCode];if(value&&(typeof value!='undefined')){this.notify(value);return true;}
return false;},notify:function(data){var data=data;this.mediator.notify('vehicleDataRequested',data)}};root.VehicleDataCache=function(data,mediator){return new VehicleDataCache(data,mediator);};}.call(EP2);
