if(typeof CR==="undefined"){CR={}}CR.ReviewsDataConnector=function(){return{data:null,service_url:"/index.php/ConsumerReviews",fetch:function(j,d,b){var e,k,h={},l=[],f={},a=null,c={summary:true,track_record:true,reviews:true,limit:null},g={errorHandler:null,successHandler:null,nocache:false,force_ajax:false,pvt_debugstr:""};b=Com.update(g,b||{});d=Com.update(c,d||{});if(j.push===undefined){j=[j]}for(e=0;e<j.length;e+=1){a=this.getCacheKey(j[e]);if(a!==null){if(b.force_ajax===false&&this.checkDataInCache(a,d)){h[a]=this.data[a]}else{l.push("cars[]="+encodeURIComponent(a))}}}if(!l.length){if(typeof b.successHandler==="function"){b.successHandler.call(this,h)}return}f.onSuccess=function(i){var m=Com.evalJSON(i.responseText);if(m.error!==undefined){if(typeof b.errorHandler==="function"){b.errorHandler.call(this,m)}return}if(b.nocache===false){this.data=Com.update(this.data,m.data)}if(h){m.data=Com.update(m.data,h)}if(typeof b.successHandler==="function"){b.successHandler.call(this,m.data)}};f.onFailure=function(i){var m={};m.error="We apologize for the inconvenience.  We have encountered an internal error and cannot access our car reviews.";if(typeof b.errorHandler==="function"){b.errorHandler.call(this,m)}};f.method="get";f.parameters=l.join("&")+((l.length)?"&":"")+"limit="+((d.limit>0)?parseInt(d.limit,10):-1)+"&summary="+((d.summary===true)?1:0)+"&track_record="+((d.track_record===true)?1:0)+"&reviews="+((d.reviews===true)?1:0)+"&action=get_reviews_data";k=new Com.Ajax.Request(this.service_url,f,this)},checkDataInCache:function(b,d){var c=null,a={summary:false,tr_info:false,tr_reviews:false,reviews:false};if(this.data===null||this.data[b]===undefined){return false}if(d&&(typeof(d)==="object")){for(c in a){if(d[c]===undefined){d[c]=false}}if(d.summary&&this.data[b].summary!==undefined){a.summary=true}if(d.track_record&&this.data[b].track_record_info!==undefined){a.tr_info=true}if(d.reviews&&this.data[b].reviews!==undefined){a.reviews=true}if((d.summary===a.summary)&&(d.track_record===a.tr_info)&&(d.reviews===a.reviews)){return true}}else{if(this.data[b]!==undefined){return true}}return false},clearCache:function(c){var b,a=null;if(c.push===undefined){c=[c]}for(b=0;b<c.length;b+=1){a=this.getCacheKey(c[b]);if(this.data&&this.data[a]!==undefined){delete this.data[a]}}},clearCacheAll:function(){this.data=null},getCacheKey:function(a){if(a!==undefined&&a!==null){return""+a.year+"_"+a.make_name+"_"+a.model_name}return null}}}();
