dealerInfo={DEBUG:false,INFO:this.DEBUG?this.DEBUG:false,_cname_pd:"dealerpf",_cname_pddtails:"dealerpf_details",_cexpire:730,_cexpire_0:0,_cpath:"/",preferredDealerXml:null,dealerSet:false,dealerID:null,hrefLocation:location.href.toLowerCase(),id:null,name:null,address:null,city:null,state:null,zipcode:null,phone:null,email:null,principal:null,fivestar:null,webtools:null,latitude:null,longitude:null,distance:null,URL:null,gaqURL:null,ttdURL:null,invURL:null,sapURL:null,partsURL:null,servicesURL:null,mapURL:null,hoursURL:null,contactusURL:null,servicesOffered:null,dma:null,domainName:null,hotdealsOBJ:null,inventoryOBJ:null,zip5:null,dealerSitePointer:null,init:function(){this.getPreferredDealerCookie();this.loadDealerDetails();},loadDealerDetails:function(){if(this.dealerID){var pdc=this.getPreferredDealerDetailsCookie();if((pdc.toString()).contains(",}]")){this.clearPreferredDealerCookie();pdc=false;}if(pdc){this.DEBUG?(console.log("load detail from cookie:\n\n "+pdc)):null;var pdcA=eval(pdc);this.fromArray(pdcA[0]);this.DEBUG?(console.log("got it?:\n\n "+this.toString())):null;if(this.dealerID!=this.id){this.getDealerXML(this.dealerID);}}else{this.DEBUG?(console.log("go load xml for:\n\n "+this.dealerID)):null;this.getDealerXML(this.dealerID);}this.dealerSet=true;}},setPreferredDealer:function(b){this.dealerID=b;this.setPreferredDealerCookie();this.getDealerXML(this.dealerID);this.INFO?(alert("Set Preferred Dealer:\n\n "+this.toString())):null;if((this.hrefLocation.search("hostc")!=-1)||(this.hrefLocation.search("hostd")!=-1)){ASC.Chrysler.setPreferredDealer(b);}},getPreferredDealerCookie:function(){var b=Cookie.get(this._cname_pd);if(b){this.dealerID=b;}this.DEBUG?(console.log("cookie value:\n\n "+this.dealerID)):null;},setPreferredDealerCookie:function(){if(this.dealerID){this.DEBUG?console.log("setPreferredDealerCookie\nduration: "+this._cexpire+"\ndomain: "+this.getDomain()+"\npath: "+this._cpath):null;Cookie.set(this._cname_pd,this.dealerID,{duration:this._cexpire,domain:this.getDomain(),path:this._cpath});if((this.hrefLocation.search("hostc")==-1)&&(this.hrefLocation.search("hostd")==-1)){Cookie.set(this._cname_pd,this.dealerID,{duration:this._cexpire,path:this._cpath});}}},clearPreferredDealerCookie:function(){Cookie.set(this._cname_pd,"",{duration:-1,domain:this.getDomain(),path:this._cpath});Cookie.set(this._cname_pddtails,"",{duration:this._cexpire_0,path:this._cpath});if((this.hrefLocation.search("hostc")==-1)&&(this.hrefLocation.search("hostd")==-1)){Cookie.set(this._cname_pd,"",{duration:-1,path:this._cpath});}if((this.hrefLocation.search("hostc")!=-1)||(this.hrefLocation.search("hostd")!=-1)){ASC.Chrysler.removePreferredDealer();}},getPreferredDealerDetailsCookie:function(){return Cookie.get(this._cname_pddtails);},setPreferredDealerDetailsCookie:function(){Cookie.set(this._cname_pddtails,this.toArray(),{duration:this._cexpire_0,path:this._cpath});},getDomain:function(){domainRX=/\w*.com/;domain=domainRX.exec(window.location.hostname);domain=domain?window.location.hostname.substring(domain.index):window.location.hostname;this.DEBUG?console.log("getDomain\nhostname: "+window.location.hostname+"\ndomain: "+domain):null;return domain;},getDealerXML:function(i,k){var g="/hostd/getlocatedealersbasic.xml";var h="&dealerCode="+i;var l="dealerInfo.parseDealer(http_request[i])";var j=new Ajax(g,{method:"post",data:h,onComplete:function(a,b){dealerInfo.parseDealer(b);}.bind(this)});j.request();if((this.hrefLocation.search("hostc")!=-1)||(this.hrefLocation.search("hostd")!=-1)&&!k){ASC.Chrysler.getPreferredDealer();}},getMapURL:function(){return this.mapURL;},setMapURL:function(){},getHoursURL:function(){return this.hoursURL;},setHoursURL:function(){},getContactUsURL:function(){return this.contactusURL;},setContactUsURL:function(){},isFiveStar:function(){return this.fivestar=="Y";},parseDealer:function(b){this.preferredDealerXml=b;pDealer=this.preferredDealerXml.getElementsByTagName("dealer");if(pDealer.length>0){this.loadDealerObj(pDealer[0]);this.setPreferredDealerDetailsCookie();populate_dealerInfo();}},loadDealerObj:function(b){this.id=b.getAttribute("id");this.name=b.getAttribute("name");this.name=this.name.replace(/'/,"&apos;");this.address=b.getAttribute("address");this.city=b.getAttribute("city");this.state=b.getAttribute("state");this.zipcode=formatXMLValue(b.getAttribute("zipcode"));this.phone=formatXMLValue(b.getAttribute("phone"));this.email=b.getAttribute("email");this.principal=b.getAttribute("principal");this.fivestar=b.getAttribute("fivestar");this.webtools=b.getAttribute("webtools");this.latitude=b.getAttribute("latitude");this.longitude=b.getAttribute("longitude");this.distance=b.getAttribute("distance");this.URL=b.getAttribute("URL");this.gaqURL=b.getAttribute("gaqURL");this.ttdURL=b.getAttribute("ttdURL");this.invURL=b.getAttribute("invURL");this.sapURL=b.getAttribute("sapURL");this.partsURL=b.getAttribute("partsURL");this.servicesURL=b.getAttribute("servicesURL");this.servicesOffered=b.getAttribute("servicesOffered");this.dma=b.getAttribute("dma");this.domainName=b.getAttribute("domainName");this.setMapURL();this.setHoursURL();this.setContactUsURL();this.zip5=(this.zipcode!=""?this.zipcode.substring(0,5):"");this.dealerSitePointer=b.getAttribute("dealerSitePointer");this.DEBUG?(console.log("dealer loaded:\n\n "+this.toArray())):null;},toArray:function(){if(this.dealerSitePointer=="4"){return;}return"[{'id':'"+this.id+"','name':'"+this.name+"','address':'"+this.address+"','city':'"+this.city+"','state':'"+this.state+"','zipcode':'"+this.zipcode+"','phone':'"+this.phone+"','email':'"+this.email+"','principal':'"+this.principal+"','fivestar':'"+this.fivestar+"','webtools':'"+this.webtools+"','latitude':'"+this.latitude+"','longitude':'"+this.longitude+"','distance':'"+this.distance+"','URL':'"+this.URL+"','gaqURL':'"+this.gaqURL+"','ttdURL':'"+this.ttdURL+"','invURL':'"+this.invURL+"','sapURL':'"+this.sapURL+"','partsURL':'"+this.partsURL+"','servicesURL':'"+this.servicesURL+"','servicesOffered':'"+this.servicesOffered+"','dma':'"+this.dma+"','domainName':'"+this.domainName+"','mapURL':'"+this.mapURL+"','dealerSitePointer':'"+this.dealerSitePointer+"'}]";},fromArray:function(b){this.id=b.id;this.name=b.name;this.address=b.address;this.city=b.city;this.state=b.state;this.zipcode=b.zipcode;this.phone=b.phone;this.email=b.email;this.principal=b.principal;this.fivestar=b.fivestar;this.webtools=b.webtools;this.latitude=b.latitude;this.longitude=b.longitude;this.distance=b.distance;this.URL=b.URL;this.gaqURL=b.gaqURL;this.ttdURL=b.ttdURL;this.invURL=b.invURL;this.sapURL=b.sapURL;this.partsURL=b.partsURL;this.servicesURL=b.servicesURL;this.servicesOffered=b.servicesOffered;this.dma=b.dma;this.domainName=b.domainName;this.dealerSitePointer=b.dealerSitePointer;if(b.mapURL=="undefined"){this.setMapURL();}else{this.mapURL=b.mapURL;}this.setHoursURL();this.setContactUsURL();this.zip5=(this.zipcode!=""?this.zipcode.substring(0,5):"");},toString:function(){return"Preferred Dealer\n----------------\nid: "+this.id+"\nname: "+this.name+"\naddress: "+this.address+"\ncity: "+this.city+"\nstate: "+this.state+"\nzipcode: "+this.zipcode+"\nphone: "+this.phone+"\nemail: "+this.email+"\nprincipal: "+this.principal+"\nfivestar: "+this.fivestar+"\nwebtools: "+this.webtools+"\nlatitude: "+this.latitude+"\nlongitude: "+this.longitude+"\ndistance: "+this.distance+"\nURL: "+this.URL+"\ngaqURL: "+this.gaqURL+"\nttdURL: "+this.ttdURL+"\ninvURL: "+this.invURL+"\nsapURL: "+this.sapURL+"\npartsURL: "+this.partsURL+"\nservicesURL: "+this.servicesURL+"\nservicesOffered: "+this.servicesOffered+"\ndma: "+this.dma+"\ndomainName: "+this.domainName+"\nmapURL: "+this.mapURL+"\nhoursURL: "+this.hoursURL+"\ndealerSitePointer: "+this.dealerSitePointer+"\ncontactusURL: "+this.contactusURL;}};
