if(typeof google=="undefined"){alert("This feature requires the Google maps API")
}google.load("maps","2");var DealerLocator=function(B,A){this.init(B,A)};DealerLocator.prototype.init=function(C,A){var B=this;
this.Container=$("#"+C);this.Settings=$.extend({scope:1,name:"Dealer",phone:"",appPath:"/",serviceUrl:"/InterActRV/Supplement/DealerLocator/DealerLocator.asmx",formUrl:"/ContactUs.aspx"},A||{});
this.Data=null;this.FormBox=this.Container.find(".LocatorForm");this.ResultBox=this.Container.find(".LocatorResults").hide();
this.Loader=this.Container.find(".LocatorLoader").hide();this.Map=this.Container.find(".LocatorMap").hide();
this.ZipText=this.Container.find(":text").val(" Enter zip code");this.ZipText.bind("keydown",function(D){if(B.IsEnter(D)){B.Locate();
return false}});this.ZipText.bind("focus",function(D){if(this.value==" Enter zip code"){this.value=""
}});this.ZipText.bind("blur",function(D){if(this.value==""){this.value=" Enter zip code"
}});this.MakeList=(this.Settings.make==null||this.Settings.make.length==0)?this.Container.find(".dropdown"):null;
this.Submit=this.Container.find(".ButtonLocate");this.Submit.bind("click",function(){B.Locate();
return false})};DealerLocator.prototype.ClearForm=function(){this.ZipText.val("");
if(this.MakeList!=null&&this.MakeList.length!=0){this.MakeList[0].selectedIndex=0
}};DealerLocator.prototype.HideResults=function(){this.ResultBox.hide()};DealerLocator.prototype.ShowResults=function(){this.ResultBox.show()
};DealerLocator.prototype.Loading=function(){this.ResultBox.hide();this.Map.hide();
this.Submit.hide();this.Loader.show()};DealerLocator.prototype.Complete=function(){this.Loader.hide();
this.Submit.show()};DealerLocator.prototype.Locate=function(){this.Loading();var B=escape(this.ZipText.val());
var H=this.Settings.manufacturerID;var A=this.MakeList==null||this.MakeList.length==0?this.Settings.make:this.MakeList.val();
if(A==undefined){A=""}var F=this.Settings.requiresMake;var E=this.Settings.formUrl;
var C=this.Settings.enforceCountryBoundaries;var G={zipCode:B,manufacturerID:H,make:A,scope:this.Settings.scope,formUrl:E,enforceCountryBoundaries:C,requiresMake:F};
var D=this;$.ajax({global:true,url:D.Settings.serviceUrl,type:"POST",timeout:0,contentType:"application/x-www-form-urlencoded",processData:true,async:true,data:G,dataType:"xml",beforeSend:function(I){I.setRequestHeader("Content-Length",0)
},success:function(J,I){D.Success(J,I)},error:function(J,I){D.Error(J,I)}})};DealerLocator.prototype.Success=function(data,status){var base=this;
try{this.Data=eval("("+data.documentElement.firstChild.nodeValue+")");this.ResultBox.html(this.Data.responseHtml);
var mapButton=this.ResultBox.find(".MapButton");if(mapButton.size()>0){mapButton.bind("click",function(){base.ViewMap(this)
})}}catch(ex){this.ResultBox.html("<p>There was an error fetching the dealers. Please try again.</p><!--"+ex.message+"\n"+data.documentElement.firstChild.nodeValue+" -->")
}this.ShowResults();this.Complete()};DealerLocator.prototype.Error=function(B,A){this.ShowResults();
this.Complete();this.ResultBox.html(B.responseText)};DealerLocator.prototype.ViewMap=function(E){var B=this;
var F=parseInt($(E).attr("rel"));this.Map.show();if(GBrowserIsCompatible()){var D=new GMap2(this.Map[0]);
D.addControl(new GSmallMapControl());var C=new GClientGeocoder();var A=this.Data.dealers[F].qry;
C.getLatLng(A,function(G){if(!G){B.Map.hide();alert(A+"\ncould not be found.")}else{var H=new GMarker(G);
D.setCenter(G,13);D.setZoom(5);D.addOverlay(H)}})}};DealerLocator.prototype.IsEnter=function(A){A=A||window.event;
if(A.keyCode==13||A.which==13){return true}return false}