/*
 * Dealer Locator scripts 0.1
 * Copyright(c) 2008, Conduit IT.
 * 
 */


Ext.namespace("dealerlocator");
dealerlocator.Application=Ext.extend(Ext.Panel,{ctCls:"dealerlocater ws-dlrloc wse-app-dlrloc",isWindow:false,border:false,searchHeaderText:"",url:"json.php?target=dealer_locater&area=C",resultsStoreType:"dealer-locator",fullResultsLimit:100,redirect_url:"",allow_redirect:true,_gDirections:null,_directionsText:"",autoHeight:true,images_dir:DealerLocatorConfig.images_dir,centerLat:DealerLocatorConfig.centerLat,centerLon:DealerLocatorConfig.centerLon,preloadResultsBasedOnIP:DealerLocatorConfig.preloadResultsBasedOnIP,resultsLimit:DealerLocatorConfig.resultsLimit,displayResultsCountAsHeader:DealerLocatorConfig.displayResultsCountAsHeader,hideFormElementsOnSubmit:DealerLocatorConfig.hideFormElementsOnSubmit,searchLocation:DealerLocatorConfig.searchLocation,resultsLocation:DealerLocatorConfig.resultsLocation,showDealerAtTop:DealerLocatorConfig.showDealerAtTop,hideSearchByAddress:DealerLocatorConfig.hideSearchByAddress,hideSearchByCity:DealerLocatorConfig.hideSearchByCity,hideSearchByState:DealerLocatorConfig.hideSearchByState,hideSearchByCountry:DealerLocatorConfig.hideSearchByCountry,addressDisplayOrder:DealerLocatorConfig.addressDisplayOrder,displaySearchAsMultipleFields:DealerLocatorConfig.displaySearchAsMultipleFields,showSearchByZipcode:DealerLocatorConfig.showSearchByZipcode,hideSearchByDealerName:DealerLocatorConfig.hideSearchByDealerName,hideSearchRadius:DealerLocatorConfig.hideSearchRadius,defaultSearchRadius:DealerLocatorConfig.defaultSearchRadius,minimizeNonSelectedItems:DealerLocatorConfig.minimizeNonSelectedItems,combosEditable:DealerLocatorConfig.combosEditable,_noResultsMessagePopup:null,initComponent:function(){if(!(this.resultsStore=Ext.StoreMgr.lookup(this.resultsStoreType))){this.resultsStore=Ext.StoreMgr.add(this.resultsStoreType,new Ext.data.JsonStore({url:this.url+"&method=search",autoLoad:false,root:"markers",id:"row",fields:["row",{name:"dealer_name",mapping:"cit_b_company"},{name:"address",mapping:"b_address"},{name:"city",mapping:"b_city"},{name:"state",mapping:"b_state"},{name:"zipcode",mapping:"b_zipcode"},{name:"phone",mapping:"cit_b_phone"},{name:"tollfree",mapping:"cit_b_toll_free"},{name:"cell",mapping:"cit_b_cell"},{name:"fax",mapping:"cit_b_fax"},{name:"url",mapping:"cit_b_url"},{name:"email",mapping:"cit_b_email"},{name:"dealer_number",mapping:"cit_profile_number"},{name:"latitude",mapping:"cit_b_latitude"},{name:"longitude",mapping:"cit_b_longitude"},{name:"is_preferred",mapping:"cit_is_preferred"},"distance","distance_unit",{name:"dealer_profile_id",mapping:"profile_id"},"resultsLimit","membership_display_message","membership_icon_id"],listeners:{"load":{fn:this.resultsHandler,scope:this}}}));}
var _1=[{xtype:"dealerlocator.MapPanel",id:this.id+"-map-panel",images_dir:this.images_dir,resultsLimit:this.resultsLimit,listeners:{markerselect:this.processMarkerClick.createDelegate(this)}}];var _2=[{xtype:"dealerlocator.SearchPanel",id:this.id+"-search-panel",searchHeaderText:this.searchHeaderText,url:this.url,showDealerAtTop:this.showDealerAtTop,hideSearchByAddress:this.hideSearchByAddress,hideSearchByCity:this.hideSearchByCity,hideSearchByState:this.hideSearchByState,hideSearchByCountry:this.hideSearchByCountry,addressDisplayOrder:this.addressDisplayOrder,displaySearchAsMultipleFields:this.displaySearchAsMultipleFields,showSearchByZipcode:this.showSearchByZipcode,hideSearchByDealerName:this.hideSearchByDealerName,hideSearchRadius:this.hideSearchRadius,combosEditable:this.combosEditable,defaultSearchRadius:this.defaultSearchRadius,listeners:{"searchFormSubmitted":{fn:this.performSearch,scope:this}}}];var _3={xtype:"dealerlocator.ResultsPanel",id:this.id+"-results-panel",autoHeight:true,autoScroll:this.isWindow,images_dir:this.images_dir,resultsLimit:this.resultsLimit,resultsStoreType:this.resultsStoreType,displayResultsCountAsHeader:this.displayResultsCountAsHeader,minimizeNonSelectedItems:this.minimizeNonSelectedItems,listeners:{"mapMarker":{fn:this.focusOnMarker,scope:this},"selectPreferredDealer":{fn:this.setPreferredDealer,scope:this},"getDirections":{fn:this.displayDirections,scope:this},"hideDirections":{fn:this.hideDirections,scope:this},"printDirections":{fn:this.printDirections,scope:this}}};if(this.resultsLocation=="under_search"){_2.push(_3);}else{_1.push(_3);}
var _4={layout:"form",columnWidth:0.72,border:false,items:_1};var _5={layout:"form",columnWidth:0.28,border:false,items:_2};var _6=[];if(this.searchLocation=="left"){_6.push(_5);_6.push(_4);}else{_6.push(_4);_6.push(_5);}
this.items=[{layout:"column",border:false,items:_6}];dealerlocator.Application.superclass.initComponent.call(this);},initEvents:function(){dealerlocator.Application.superclass.initEvents.call(this);},onRender:function(ct,_8){dealerlocator.Application.superclass.onRender.call(this,ct,_8);this.initializeStore.defer(250,this);},initializeStore:function(){if(this.preloadResultsBasedOnIP=="Y"){var _9={"latitude":this.centerLat,"longitude":this.centerLon,"resultsLimit":this.resultsLimit};this.resultsStore.load({params:_9});}else{Ext.getCmp(this.id+"-map-panel").showPlaceholder();}
this.removeListener("afterLayout",this.initializeStore,this);},resultsHandler:function(_a,_b,_c){var _d=_a.reader.jsonData;if(_d.center_point){this.centerLat=_d.center_point.latitude;this.centerLon=_d.center_point.longitude;}
var _e=Ext.getCmp(this.id+"-map-panel");var _f=Ext.getCmp(this.id+"-search-panel");if(_b&&_b.length>0){_e.setCenterPoint(this.centerLat,this.centerLon,true);_e.addMarkers(_b);if(this.hideFormElementsOnSubmit=="Y"){_f.hideFormFields();}
var _10=Ext.getCmp(this.id+"-results-panel");_10.updateHeader();_10.showItem(0);_e.highlightMarker(1);}else{_e.showPlaceholder();if(this.hideFormElementsOnSubmit=="Y"){_f.showFormFields();}
this.showNoResultMessage();}},performSearch:function(_11,_12){this.setResultsLimit(this.fullResultsLimit);_12["resultsLimit"]=this.resultsLimit;this.resultsStore.load({params:_12});},setResultsLimit:function(_13){Ext.getCmp(this.id+"-map-panel").setResultsLimit(_13);Ext.getCmp(this.id+"-results-panel").setResultsLimit(_13);this.resultsLimit=_13;},getResultsLimit:function(){return this.resultsLimit;},processMarkerClick:function(_14,row){var _16=this.resultsStore.getById(row);if(_16){this.focusOnMarker(this,_16);Ext.getCmp(this.id+"-results-panel").showItem(row-1,false,true);}},focusOnMarker:function(_17,_18){Ext.getCmp(this.id+"-map-panel").focusOnMarker(_18);},setPreferredDealer:function(_19,_1a){if(_1a){if(confirm(DealerLocatorLang.message.would_you_like_to_select_x.replace("[1]",_1a.get("dealer_name")))){var _1b={dealer_profile_id:_1a.get("dealer_profile_id")};if(this.redirect_url){_1b["redirect_url"]=this.redirect_url;}
Ext.Ajax.request({url:this.url+"&method=setPreferredDealer",callback:this.setPreferredDealerCallback.createDelegate(this),scope:this,params:_1b});}}},setPreferredDealerCallback:function(_1c,_1d,_1e){var _1f=Ext.util.JSON.decode(_1e.responseText);if(this.allow_redirect){if(_1f.redirect_url){try{var _20=Ext.History.getToken();}
catch(e){var _20=null;}
if(_20!=null&&_1f.redirect_url.indexOf("#")==-1){window.location.reload();}else{window.location=_1f.redirect_url;}}}else{this.fireEvent("dealer_selected",_1f.company);}},_createGDirectionsInstance:function(){if(!this._gDirections){try{var _21=Ext.getCmp(this.id+"-map-panel").getMap();var _22=Ext.getCmp(this.id+"-results-panel").getDirectionsPanel();this._gDirections=new GDirections(_21,_22);}
catch(e){}}},displayDirections:function(_23,_24,_25){if(!this._gDirections){this._createGDirectionsInstance();}
var _26=_25;var _27="";if(_24.get("address")&&_24.get("address")!="NULL"){_27+=_24.get("address");}
if(_24.get("city")&&_24.get("city")!="NULL"){_27+=" "+_24.get("city");}
if(_24.get("state")&&_24.get("state")!="NULL"){_27+=" "+_24.get("state");}
if(_24.get("zipcode")&&_24.get("zipcode")!="NULL"){_27+=" "+_24.get("zipcode");}
if(_27){this._directionsText=_26+" to "+_27;try{Ext.getCmp(this.id+"-map-panel").clearMarkers();Ext.getCmp(this.id+"-results-panel").showDirections();this._gDirections.load(this._directionsText);}
catch(e){this._directionsText="";}}},printDirections:function(){if(this._directionsText){window.open("http://maps.google.com/maps?f=q&hl=en&pw=2&q="+this._directionsText.replace(/ /gi,"+"));}},hideDirections:function(){var _28=this.resultsStore.getRange();if(_28){var _29=Ext.getCmp(this.id+"-map-panel");_29.setCenterPoint(this.centerLat,this.centerLon,true);_29.addMarkers(_28);}
this._directionsText="";},showNoResultMessage:function(){if(!this._noResultsMessagePopup){this._noResultsMessagePopup=new Ext.Window({title:DealerLocatorLang.title.dealer_locater,closeAction:"hide",html:DealerLocatorLang.message.no_dealer_locator_results,width:500,height:300});}
this._noResultsMessagePopup.show();},setRedirectUrl:function(_2a){this.redirect_url=_2a;}});Ext.reg("dealerlocator.Application",dealerlocator.Application);
dealerlocator.MapPanel=Ext.extend(Ext.Panel,{autoHeight:true,border:false,images_dir:"",cls:"showMapHolder dealerlocater-map-us ws-map ws-map-us",markerForCenter:false,_markers:{},_centerPoint:{},_markerIcon:null,_markerHiliteIcon:null,customMarkerConfig:DealerLocatorConfig.customMarkerConfig,customMarkerNum:DealerLocatorConfig.customMarkerNum,markerImgTxtCng:DealerLocatorConfig.markerImgTxtCng,markerHiliteImgTxtCng:DealerLocatorConfig.markerHiliteImgTxtCng,initComponent:function(){this._dealerAddressTpl=new Ext.XTemplate("<p>{dealer_name}<br/>{address}<br />{city} {state} {zipcode}","<tpl if=\"this.isValidString(phone)\">","<br/>"+DealerLocatorLang.label.phone+": {phone}","</tpl>","<tpl if=\"this.isValidString(tollfree)\">","<br/>"+DealerLocatorLang.label.toll_free+": {tollfree}","</tpl>","<tpl if=\"this.isValidString(cell)\">","<br/>"+DealerLocatorLang.label.cell+": {cell}","</tpl>","<tpl if=\"this.isValidString(fax)\">","<br/>"+DealerLocatorLang.label.fax+": {fax}","</tpl>","<tpl if=\"this.isValidString(url)\">","<br/>"+DealerLocatorLang.label.website+": <a href=\"{url}\" target=\"_blank\">{url}</a>","</tpl>","</p>",{isValidString:function(_1){return(_1&&_1!="");}});this.items=[{xtype:"gmappanel",id:this.id+"-gmap",images_dir:this.images_dir,region:"center",zoomLevel:14,gmapType:"map",mapConfOpts:["enableScrollWheelZoom","enableDoubleClickZoom","enableDragging"],mapControls:["GSmallMapControl","GMapTypeControl","NonExistantControl"],listeners:{markerselect:this.selectMarker.createDelegate(this)}},{xtype:"panel",id:this.id+"-mapplaceholder",hidden:true,height:"100%",html:DealerLocatorLang.message.dealer_locator_description_text}];dealerlocator.MapPanel.superclass.initComponent.call(this);},initEvents:function(){dealerlocator.MapPanel.superclass.initEvents.call(this);},setResultsLimit:function(_2){this.resultsLimit=_2;},setCenterPoint:function(_3,_4,_5){if(_3!=""&&_4!=""){var _6=this.getMapContainer();this._centerPoint=_6.fixLatLng(new GLatLng(_3,_4));if(this.markerForCenter){var _7={lat:_3,lon:_4};var _8=this.genCustomMarkerHighlight(this.customMarkerConfig);if(!_8){_8=this.genCustomMarker(this.customMarkerConfig);}
if(_8){_7.icon=_8;}
_6.addMarker(this._centerPoint,_7,_5,true);}else{_6.getMap().setCenter(this._centerPoint);}}},getMapContainer:function(){return Ext.getCmp(this.id+"-gmap");},getMap:function(){var _9=this.getMapContainer();return _9.getMap();},addMarkers:function(_a){this.hidePlaceholder();if(_a){var _b=this.getMapContainer();var _c=this.getMap();var _d=new GLatLngBounds;var _e,_f,_10,lat,lon,_13,row;var _15;for(var i=0;i<this.resultsLimit&&i<_a.length;i++){try{lat=_a[i].get("latitude");lon=_a[i].get("longitude");_13=_a[i].get("dealer_name");row=_a[i].get("row");_15=this.genCustomMarker(this.customMarkerConfig,row);if(lat&&lon){_10=_b.fixLatLng(new GLatLng(lat,lon));_d.extend(_10);if(_13){_e=_b.addMarker(_10,{lat:lat,lon:lon,row:row,title:_13,index:row,icon:_15},false,false);_f=new Tooltip(_e,_13,4);_e.tooltip=_f;_c.addOverlay(_f);GEvent.addListener(_e,"mouseover",function(){this.tooltip.show();});GEvent.addListener(_e,"mouseout",function(){this.tooltip.hide();});}else{_e=_b.addMarker(_10,{lat:lat,lon:lon,row:row},false,false);}
this._markers[row]=_e;}}
catch(e){}}
if(this._centerPoint){try{_d.extend(this._centerPoint);}
catch(e){}}
_c.setZoom(_c.getBoundsZoomLevel(_d));}},clearMarkers:function(){if(Ext.num(this._markers.length,0)>0){this._markers={};try{this.getMapContainer().clearMarkers();}
catch(e){}}},hidePlaceholder:function(){Ext.getCmp(this.id+"-mapplaceholder").hide();Ext.getCmp(this.id+"-gmap").show();},showPlaceholder:function(){this.clearMarkers();try{Ext.getCmp(this.id+"-gmap").hide();}
catch(e){}
Ext.getCmp(this.id+"-mapplaceholder").show();},focusOnMarker:function(_17){if(_17){this.highlightMarker(_17.get("row"));var map=this.getMap();map.setCenter(new GLatLng(_17.get("latitude"),_17.get("longitude")),13);this._markers[_17.get("row")].openInfoWindowHtml(this._dealerAddressTpl.applyTemplate(_17.data));}},selectMarker:function(obj,lat,lng,row){this.fireEvent("markerselect",this,row);},genCustomMarker:function(_1d,num){if(this._markerIcon&&!this.customMarkerNum){return this._markerIcon;}
if(Ext.type(_1d)=="object"&&_1d["icon_url"]){var _1f=new GIcon();num=num?num:"";_1f.image=_1d["icon_url"]+(this.customMarkerNum?"&img_txt="+num+"&img_txt_cfg="+this.markerImgTxtCng:"");_1f.iconSize=new GSize(_1d["icon_x"],_1d["icon_y"]);if(Ext.isArray(_1d["image_anchor"])){_1f.iconAnchor=new GPoint(Number(_1d["image_anchor"][0]),Number(_1d["image_anchor"][1]));}else{_1f.iconAnchor=new GPoint(0,0);}
if(Ext.isArray(_1d["image_window_anchor"])){_1f.infoWindowAnchor=new GPoint(Number(_1d["image_window_anchor"][0]),Number(_1d["image_window_anchor"][1]));}else{_1f.infoWindowAnchor=new GPoint(0,0);}
if(_1d["shadow_url"]){_1f.shadow=_1d["shadow_url"];_1f.shadowSize=new GSize(_1d["shadow_x"],_1d["shadow_y"]);}
if(!this.customMarkerNum){this._markerIcon=_1f;}
return _1f;}
return null;},genCustomMarkerHighlight:function(_20,num){if(this._markerHiliteIcon&&!this.customMarkerNum){return this._markerHiliteIcon;}
if(Ext.type(_20)=="object"&&_20["highlight_url"]){var _22=new GIcon();num=num?num:"";_22.image=_20["highlight_url"]+(this.customMarkerNum?"&img_txt="+num+"&img_txt_cfg="+this.markerHiliteImgTxtCng:"");_22.iconSize=new GSize(_20["highlight_x"],_20["highlight_y"]);if(Ext.isArray(_20["image_anchor"])){_22.iconAnchor=new GPoint(Number(_20["image_anchor"][0]),Number(_20["image_anchor"][1]));}else{_22.iconAnchor=new GPoint(0,0);}
if(Ext.isArray(_20["image_window_anchor"])){_22.infoWindowAnchor=new GPoint(Number(_20["image_window_anchor"][0]),Number(_20["image_window_anchor"][1]));}else{_22.infoWindowAnchor=new GPoint(0,0);}
if(_20["shadow_url"]){_22.shadow=_20["shadow_url"];_22.shadowSize=new GSize(_20["shadow_x"],_20["shadow_y"]);}
if(!this.customMarkerNum){this._markerHiliteIcon=_22;}
return _22;}
return null;},highlightMarker:function(row){var _24=this.genCustomMarkerHighlight(this.customMarkerConfig,row);if(_24){this.getMapContainer().highlightMarker(row,_24["image"]);}}});Ext.reg("dealerlocator.MapPanel",dealerlocator.MapPanel);
dealerlocator.ResultsPanel=Ext.extend(Ext.Panel,{border:false,displayResultsCountAsHeader:"Y",minimizeNonSelectedItems:"N",resultsStoreType:"",cls:"ws-results-hld",initComponent:function(){this.resultsStore=Ext.StoreMgr.lookup(this.resultsStoreType);this.tpl=new Ext.XTemplate("<div class=\"resultsTitleBlock wse-hd-hld\">","<h3 class=\"resultsTitle wse-hd\" id=\""+this.id+"-dealerCount\"></h3>","</div>","<div class=\"wse-boxes\">","<tpl for=\".\">","<tpl if=\"this.includeResult(resultsLimit, [xindex])\">","<tpl if=\"[xindex - 1] % 2 == 0\">","<div id=\"mapRow_{[xindex - 1]}\" class=\"itemBox wse-box even wse-even\">","</tpl>","<tpl if=\"[xindex - 1] % 2 != 0\">","<div id=\"mapRow_{[xindex - 1]}\" class=\"itemBox wse-box odd wse-odd\">","</tpl>","<tpl if=\"this.minimizeItems('"+this.minimizeNonSelectedItems+"')\">","<h4><table><tr><td><span class=\"rowNumber wse-num\">{#}</span></td><td class=\"dealerlocater-dealerlabel wse-lbl\"><a href=\"#\" onclick=\"Ext.getCmp('"+this.id+"').showItem({[xindex - 1]}, true); return false;\">{dealer_name}</a></td></tr></table></h4>","<div id=\"item_box_{[xindex - 1]}\" class=\"itemBox-details wse-box-dtls wse-cont\">","</tpl>","<tpl if=\"!this.minimizeItems('"+this.minimizeNonSelectedItems+"')\">","<h4><table><tr><td><span class=\"rowNumber wse-num\">{#}</span></td><td class=\"dealerlocater-dealerlabel wse-lbl\"><a href=\"#\" onclick=\"Ext.getCmp('"+this.id+"').viewProfile({[xindex - 1]}); return false;\">{dealer_name}</a></td></tr></table></h4>","<div id=\"item_box_{[xindex - 1]}\" class=\"wse-box-dtls\">","</tpl>","<ul>","<li>{address}</li><li>{city} {state} {zipcode}</li>","<tpl if=\"this.isValidString(phone)\">","<li>"+DealerLocatorLang.label.phone+": {phone}</li>","</tpl>","<tpl if=\"this.isValidString(tollfree)\">","<li>"+DealerLocatorLang.label.toll_free+": {tollfree}</li>","</tpl>","<tpl if=\"this.isValidString(cell)\">","<li>"+DealerLocatorLang.label.cell+": {cell}</li>","</tpl>","<tpl if=\"this.isValidString(fax)\">","<li>"+DealerLocatorLang.label.fax+": {fax}</li>","</tpl>","<tpl if=\"this.isValidString(distance)\">","<li class=\"dealerlocater-results-distance wse-dist\">"+DealerLocatorLang.label.distance+": {distance} {distance_unit:lowercase}</li>","</tpl>","</ul>","<ul class=\"linkList wse-lnks\">","<tpl if=\"is_preferred < 1\">","<li class=\"dealerlocater-choosedealer wse-choosedlr\"><a href=\"#\" onclick=\"Ext.getCmp('"+this.id+"').selectPreferredDealer({[xindex - 1]}); return false;\"><span>"+DealerLocatorLang.button.select_this_dealer+"</span></a></li>","</tpl>","<li class=\"dealerlocater-viewprofile wse-lnk wse-lnk-profile\"><a href=\"#\" onclick=\"Ext.getCmp('"+this.id+"').viewProfile({[xindex - 1]}); return false;\"><span>"+DealerLocatorLang.button.view_profile+"</span></a></li>","<tpl if=\"this.isValidString(latitude) && this.isValidString(longitude)\">","<li class=\"dealerlocater-mapit wse-lnk wse-lnk-mapit\"><a href=\"#\" onclick=\"Ext.getCmp('"+this.id+"').showMarker({[xindex - 1]}); return false;\"><span>"+DealerLocatorLang.button.map_it+"</span></a></li>","</tpl>","<tpl if=\"this.isValidString(latitude) && this.isValidString(longitude)\">","<li class=\"dealerlocater-getdirections wse-lnk wse-lnk-dirctns\">","<ul class=\"dealerlocater-startingpointbox wse-startpnt\">","<li><label>"+DealerLocatorLang.message.enter_starting_point+"</label></li>","<li><input type=\"text\" id=\"starting_point_address_string_{[xindex - 1]}\" /></li>","<li class=\"button wse-lnk wse-lnk-go\"><a href=\"#\" onclick=\"Ext.getCmp('"+this.id+"').getDirections({[xindex - 1]}); return false;\">"+DealerLocatorLang.button.go+"</a></li>","</ul>","</li>","</tpl>","</ul>","<div class=\"wse-lnks-bcap\"></div>","</div>","<tpl if=\"membership_icon_id && membership_icon_id &gt; 0\">","<div class=\"wse-dl-membership_icon\" id=\""+this.id+"-membershipIcon\"><img src=\"image.php?object_type=common&image_id={membership_icon_id}\" border=\"0\" /></div>","</tpl>","<tpl if=\"this.isValidString(membership_display_message)\">","<div class=\"wse-dl-membership_message\" id=\""+this.id+"-membershipMessage\">{membership_display_message}</div>","</tpl>","</div>","</tpl>","</tpl></div>",{includeResult:function(_1,_2){if(_1==0||(_1>0&&_2<=_1)){return true;}
return false;},isValidString:function(_3){return(_3&&_3!="");},hideStartingPoint:function(){if(hide_starting_point_link=="Y"){return true;}
return false;},minimizeItems:function(_4){if(_4=="Y"){return true;}
return false;}});this.view=new Ext.DataView({id:this.id+"-dealer-results-list-panel",store:this.resultsStore,border:false,tpl:this.tpl,autoHeight:false,autoWidth:false,loadingText:DealerLocatorLang.message.loading,itemSelector:"div.wse-box",emptyText:"<div id=\"dl_no_results\"></div>"});this.items=[this.view,{xtype:"panel",id:this.id+"-directions-panel",border:false,hidden:true,html:"<div id=\"directions\" class=\"results ws-results\">"+"<ul>"+"<li>"+"<a title=\""+DealerLocatorLang.button.print+"\" href=\"#\" onclick=\"Ext.getCmp('"+this.id+"').printDirections(); return false;\">"+DealerLocatorLang.button.print+"</a>"+"</li>"+"<li>"+"<a title=\""+DealerLocatorLang.button.go_back+"\" href=\"#\" onclick=\"Ext.getCmp('"+this.id+"').hideDirections(); return false;\">"+DealerLocatorLang.button.go_back+"</a>"+"</li>"+"</ul>"+"<div id=\""+this.id+"-directions-content\"></div>"+"<div id=\"directionsStatus\"></div>"+"</div>"}];dealerlocator.ResultsPanel.superclass.initComponent.call(this);},initEvents:function(){dealerlocator.ResultsPanel.superclass.initEvents.call(this);},setResultsLimit:function(_5){this.resultsLimit=_5;},updateHeader:function(){var _6=Ext.get(this.id+"-dealerCount");if(this.displayResultsCountAsHeader=="Y"){var _7=this.resultsLimit;if(this.resultsStore.getCount()<this.resultsLimit){_7=this.resultsStore.getCount();}
_6.update(_7+" "+((_7==1)?DealerLocatorLang.message.dealer_found:DealerLocatorLang.message.dealers_found));}else{_6.update(DealerLocatorLang.button.closest_dealer);}},showMarker:function(_8){var _9=this.resultsStore.getAt(_8);if(_9){this.fireEvent("mapMarker",this,_9);}},viewProfile:function(_a){var _b=this.resultsStore.getAt(_a);var _c=_b.get("dealer_profile_id");if(_c){var _d=window.open("contact-us-"+_c+".html","","top=40, left=100, height=650, width=1050, resizable, scrollbars");if(!_d){alert(DealerLocaterLang.message.dealer_profile_popup_blocked);}}},selectPreferredDealer:function(_e){var _f=this.resultsStore.getAt(_e);if(_f){this.fireEvent("selectPreferredDealer",this,_f);}},getDirectionsPanel:function(){return Ext.get(this.id+"-directions-content").dom;},getDirections:function(row){var _11=this.resultsStore.getAt(row);if(_11){try{var _12=Ext.get("starting_point_address_string_"+row).dom.value;}
catch(e){this._displayDirectionsStartingPointError();}
if(_12){this.fireEvent("getDirections",this,_11,_12);}else{this._displayDirectionsStartingPointError();}}},printDirections:function(){this.fireEvent("printDirections");},showDirections:function(){Ext.getCmp(this.id+"-dealer-results-list-panel").hide();Ext.getCmp(this.id+"-directions-panel").show();},hideDirections:function(){Ext.getCmp(this.id+"-directions-panel").hide();Ext.getCmp(this.id+"-dealer-results-list-panel").show();this.fireEvent("hideDirections");},_displayDirectionsStartingPointError:function(){alert(DealerLocatorLang.message.please_enter_starting_address);},showItem:function(row,_14,_15){var _16=Ext.get("item_box_"+row);var _17=Ext.get("mapRow_"+row);var _18=this.resultsStore.getRange();try{var _19,_1a;for(var i=0;i<_18.length&&i<this.resultsLimit;i++){try{if(this.minimizeNonSelectedItems=="Y"){_1a=Ext.get("item_box_"+i);_1a.dom.style.display="none";}
_19=Ext.get("mapRow_"+i);_19.removeClass(["currentItem","wse-current"]);}
catch(e){}}
try{_16.dom.style.display="block";_17.addClass(["currentItem","wse-current"]);}
catch(e){}}
catch(e){}
if(_15){try{_17.scrollIntoView(_17.up("div.x-panel"),false);}
catch(e){}}
if(_14){this.showMarker(row);}}});Ext.reg("dealerlocator.ResultsPanel",dealerlocator.ResultsPanel);
dealerlocator.SearchPanel=Ext.extend(Ext.form.FormPanel,{border:false,cls:"ws-wrap ws-wrap-frm",labelAlign:"top",showDealerAtTop:"N",hideSearchByAddress:"N",hideSearchByCity:"N",hideSearchByState:"N",hideSearchByCountry:"N",addressDisplayOrder:"address_city_state_country_zip",displaySearchAsMultipleFields:"N",showSearchByZipcode:"N",hideSearchByDealerName:"N",hideSearchRadius:"N",defaultSearchRadius:"50",combosEditable:false,defaults:{labelSeparator:"",anchor:"90%"},buttonAlign:"left",url:"json.php?target=dealer_locater&area=C",initComponent:function(){this.radiusStore=new Ext.data.JsonStore({url:this.url+"&method=getSearchRadius",successProperty:"success",fields:["value","label"],autoLoad:true,listeners:{"load":{fn:this.selectRadiusDefault,scope:this}}});var _1=[{cls:"ws-content-block",xtype:"panel",border:false,html:DealerLocatorLang.message.search_header_text}];if(this.hideSearchByDealerName!="Y"&&this.showDealerAtTop=="Y"){_1.push({xtype:"textfield",id:this.id+"-dealer-name",name:"dealer_name",fieldLabel:DealerLocatorLang.label.dealer,listeners:{"specialkey":{fn:this.checkForEnter,scope:this}}});}
if(this.hideSearchByAddress!="Y"){var _2={xtype:"textfield",id:this.id+"-address",name:"address",fieldLabel:DealerLocatorLang.label.address,listeners:{"specialkey":{fn:this.checkForEnter,scope:this}}};}
if(this.displaySearchAsMultipleFields=="Y"){if(this.hideSearchByCity!="Y"){var _3={xtype:"textfield",id:this.id+"-city",name:"city",fieldLabel:DealerLocatorLang.label.city,listeners:{"specialkey":{fn:this.checkForEnter,scope:this}}};}
if(this.hideSearchByState!="Y"){var _4={xtype:"combo",id:this.id+"-state",fieldLabel:DealerLocatorLang.label.state,labelSeparator:"",hiddenName:"state",store:webStore.stateList,valueField:"code",displayField:"state",mode:"local",lazyInit:false,triggerAction:"all",forceSelection:true,allowBlank:true,typeAhead:true,resizable:false,editable:this.combosEditable,value:"",listeners:{"specialkey":{fn:this.checkForEnter,scope:this}}};webStore.stateList.load();}
if(this.hideSearchByCountry!="Y"){var _5={xtype:"combo",fieldLabel:DealerLocatorLang.label.country,id:this.id+"-country",labelSeparator:"",hiddenName:"country",store:webStore.countryList,valueField:"abbr",displayField:"country",mode:"local",lazyInit:false,triggerAction:"all",forceSelection:true,allowBlank:true,typeAhead:true,resizable:false,editable:this.combosEditable,value:"",listeners:{"select":{fn:this.reloadStates,scope:this},"specialkey":{fn:this.checkForEnter,scope:this}}};webStore.countryList.load();}}
if(this.showSearchByZipcode=="Y"){var _6={xtype:"textfield",id:this.id+"-zip",name:"zipcode",fieldLabel:DealerLocatorLang.label.zip,listeners:{"specialkey":{fn:this.checkForEnter,scope:this}}};}
switch(this.addressDisplayOrder){case"address_city_state_zip_country":if(this.hideSearchByAddress!="Y"){_1.push(_2);}
if(this.displaySearchAsMultipleFields=="Y"){if(this.hideSearchByCity!="Y"){_1.push(_3);}
if(this.hideSearchByState!="Y"){_1.push(_4);}}
if(this.showSearchByZipcode=="Y"){_1.push(_6);}
if(this.displaySearchAsMultipleFields=="Y"){if(this.hideSearchByCountry!="Y"){_1.push(_5);}}
break;case"address_country_state_city_zip":if(this.hideSearchByAddress!="Y"){_1.push(_2);}
if(this.displaySearchAsMultipleFields=="Y"){if(this.hideSearchByCountry!="Y"){_1.push(_5);}
if(this.hideSearchByState!="Y"){_1.push(_4);}
if(this.hideSearchByCity!="Y"){_1.push(_3);}}
if(this.showSearchByZipcode=="Y"){_1.push(_6);}
break;case"country_state_city_address_zip":if(this.displaySearchAsMultipleFields=="Y"){if(this.hideSearchByCountry!="Y"){_1.push(_5);}
if(this.hideSearchByState!="Y"){_1.push(_4);}
if(this.hideSearchByCity!="Y"){_1.push(_3);}}
if(this.hideSearchByAddress!="Y"){_1.push(_2);}
if(this.showSearchByZipcode=="Y"){_1.push(_6);}
break;default:if(this.hideSearchByAddress!="Y"){_1.push(_2);}
if(this.displaySearchAsMultipleFields=="Y"){if(this.hideSearchByCity!="Y"){_1.push(_3);}
if(this.hideSearchByState!="Y"){_1.push(_4);}
if(this.hideSearchByCountry!="Y"){_1.push(_5);}}
if(this.showSearchByZipcode=="Y"){_1.push(_6);}
break;}
if(this.hideSearchByDealerName!="Y"&&this.showDealerAtTop!="Y"){_1.push({xtype:"textfield",id:this.id+"-dealer-name",name:"dealer_name",fieldLabel:DealerLocatorLang.label.dealer,listeners:{"specialkey":{fn:this.checkForEnter,scope:this}}});}
if(this.hideSearchRadius!="Y"){_1.push({xtype:"combo",id:this.id+"-radius",allowBlank:true,fieldLabel:DealerLocatorLang.label.radius,labelSeparator:"",displayField:"label",valueField:"value",lazyInit:false,hiddenName:"distance",store:this.radiusStore,mode:"local",value:this.defaultSearchRadius,selectOnFocus:true,editable:this.combosEditable,triggerAction:"all",forceSelection:true,typeAhead:true,resizable:false,listeners:{"specialkey":{fn:this.checkForEnter,scope:this}}});}
this.items=_1;this.buttons=[{text:DealerLocatorLang.button.search,cls:"wse-xbtn",handler:this.submitForm,scope:this}];dealerlocator.SearchPanel.superclass.initComponent.call(this);},initEvents:function(){dealerlocator.SearchPanel.superclass.initEvents.call(this);},reloadStates:function(_7,_8,_9){if(this.displaySearchAsMultipleFields=="Y"&&this.hideSearchByState!="Y"){var _a=Ext.getCmp(this.id+"-state");if(_8.data&&_8.data.abbr){_a.store.reload({params:{country_code:_8.data.abbr}});}}},selectRadiusDefault:function(){if(this.hideSearchRadius!="Y"){Ext.getCmp(this.id+"-radius").setValue(this.defaultSearchRadius);}},checkForEnter:function(_b,e){if(e.getKey()==e.ENTER){this.submitForm();}},submitForm:function(){var _d=this.getForm();if(_d.isValid()){this.fireEvent("searchFormSubmitted",this,_d.getValues());}else{webStore.displayMessage(DealerLocatorLang.message.no_search_params,"","error");}},showFormFields:function(){if(this.showSearchByZipcode=="Y"){this.showField(this.id+"-zip");}
if(this.hideSearchByAddress!="Y"){this.showField(this.id+"-address");}
if(this.hideSearchByDealerName!="Y"){this.showField(this.id+"-dealer-name");}
if(this.displaySearchAsMultipleFields=="Y"){if(this.hideSearchByCity!="Y"){this.showField(this.id+"-city");}
if(this.hideSearchByState!="Y"){this.showField(this.id+"-state");}
if(this.hideSearchByCountry!="Y"){this.showField(this.id+"-country");}}},showField:function(id){try{var _f=Ext.getCmp(id);_f.enable();_f.show();}
catch(e){}},hideFormFields:function(){if(this.showSearchByZipcode=="Y"){this.showField(this.id+"-zip");if(this.hideSearchByAddress!="Y"){this.hideField(this.id+"-address");}
if(this.hideSearchByDealerName!="Y"){this.hideField(this.id+"-dealer-name");}}else{if(this.hideSearchByAddress!="Y"){this.showField(this.id+"-address");if(this.hideSearchByDealerName!="Y"){this.hideField(this.id+"-dealer-name");}}else{if(this.hideSearchByDealerName!="Y"){this.showField(this.id+"-dealer-name");}}}
if(this.displaySearchAsMultipleFields=="Y"){if(this.hideSearchByCity!="Y"){this.hideField(this.id+"-city");}
if(this.hideSearchByState!="Y"){this.hideField(this.id+"-state");}
if(this.hideSearchByCountry!="Y"){this.hideField(this.id+"-country");}}},hideField:function(id){try{var _11=Ext.getCmp(id);_11.setValue();_11.disable();_11.hide();}
catch(e){}}});Ext.reg("dealerlocator.SearchPanel",dealerlocator.SearchPanel);
dealerlocator.Window=Ext.extend(Ext.Window,{title:"",layout:"fit",closable:true,shim:true,autoHeight:true,width:800,border:false,bodyBorder:false,shadow:false,resizable:false,closeAction:"hide",animateTarget:null,redirect_url:"",forcePopup:"N",allow_redirect:true,replacement_div_id:null,cls:"wse-dlrloc-win",initComponent:function(){if(this.forcePopup=="Y"){this.modal=true;this.closable=false;}
this.items=[{xtype:"dealerlocator.Application",id:this.id+"dealerlocator_app",isWindow:true,redirect_url:this.redirect_url,allow_redirect:this.allow_redirect,listeners:{"dealer_selected":{fn:this.handleDealerSelected,scope:this}}}];dealerlocator.Window.superclass.initComponent.call(this);},initEvents:function(){this.on("show",this.setWindowProperties,this);dealerlocator.Window.superclass.initEvents.call(this);},setWindowProperties:function(){var _1=Ext.get(this.id).getCenterXY();this.setPosition(_1[0],_1[1]);},handleDealerSelected:function(_2){if(this.replacement_div_id.length>0){Ext.get(this.replacement_div_id).update("<h2 class=\"ws-hd\"><span>"+DealerLocatorLang.label.my_dealer+"</span></h2>"+"<div id=\"profile_dealer_info\" class=\"profiles-dealer-profile ws-dlr\">"+"<p><strong>"+_2+"</strong></p>"+"</div>");}
if(this.closeAction=="hide"){this.hide();}else{this.close();}},setRedirectUrl:function(_3){this.redirect_url=_3;Ext.getCmp(this.getId()+"dealerlocator_app").setRedirectUrl(_3);}});Ext.reg("dealerlocator.Window",dealerlocator.Window);
function Tooltip(_1,_2,_3){this.marker_=_1;this.text_=_2;this.padding_=_3;}
Tooltip.prototype.initialize=function(_4){var _5=document.createElement("div");_5.appendChild(document.createTextNode(this.text_));_5.className="tooltip";_5.style.position="absolute";_5.style.visibility="hidden";_4.getPane(G_MAP_FLOAT_PANE).appendChild(_5);this.map_=_4;this.div_=_5;};Tooltip.prototype.remove=function(){this.div_.parentNode.removeChild(this.div_);};Tooltip.prototype.copy=function(){return new Tooltip(this.marker_,this.text_,this.padding_);};Tooltip.prototype.redraw=function(_6){if(!_6){return;}
var _7=this.map_.fromLatLngToDivPixel(this.marker_.getPoint());var _8=this.marker_.getIcon().iconAnchor;var _9=Math.round(_7.x-this.div_.clientWidth/2);var _a=_7.y-_8.y-this.div_.clientHeight-this.padding_;this.div_.style.top=_a+"px";this.div_.style.left=_9+"px";};Tooltip.prototype.show=function(){this.div_.style.visibility="visible";};Tooltip.prototype.hide=function(){this.div_.style.visibility="hidden";};
