if(typeof HD=="undefined"||!HD){var HD={}
}if(typeof HD.testRide=="undefined"||!HD.testRide){HD.testRide={}
}var HDT=HD.testRide;
HDT.constants={RESTDEALERPATH:"/testride/services/dealerService/findDealerByLocation",RESTDEALERPATHBYID:"/testride/services/dealerService/findNearbyDealers",RESTDWPDEALERPATH:"/testride/services/dealerService/findDWPDealers",RESTFORMPOSTPATH:"/testride/services/dealerService/testRideRequest/",SEARCHFORMVALIDATIONURL:"/testride/services/dealerService/validateBikeSearch/",CONFIRMATIONURL:"/testride/services/dealerService/testRideRequest/",CONFIRMATIONPAGEURL:"/en_US/Content/Pages/Try_a_Bike/Test_Ride_Confirmation.html",CONFIRMATIONIDURLPARAM:"confirmation",FORMPAGEURL:"/en_US/Content/Pages/Try_a_Bike/Schedule_a_Test_Ride.html",SURVEYTHANKYOUPAGEURL:"/en_US/Content/Pages/Try_a_Bike/Thank_You_Survey.html",SURVEYSUBMITPATH:"/testride/services/dealerService/testRideSurveyRequest",DEALERLOADINGID:"dealerLoading",DEALERLOADINGHTML:'<img src="/testride/media/images/img_loader.gif" alt="Loading..."/>',CALENDARDAYSPARAM:"calendarDays",CALENDARDAYSOUT:30,MODELSBASEURL:"/en_US/Content/Pages/2010_Motorcycles/2010_motorcycles.html",PAYMENTESTURLPRE2011:"/en_US/Content/Pages/2010_Motorcycles/2010_motorcycles.html#/tools/tools_EP/",PAYMENTESTURL2011:"/en_US/Motorcycles/estimate-payments.html?modelCode=",BIKEDETAILURLPRE2011:"/en_US/Content/Pages/2010_Motorcycles/2010_motorcycles.html#/model/",BIKEDETAILURL2011:"/en_US/Motorcycles/",BIKEURLPARAMNAME:"bikeModel",ZIPCODEURLPARAMNAME:"zipCode",CITYURLPARAMNAME:"city",STATEURLPARAMNAME:"state",DEALERURLPARAMNAME:"dealerId",DWPDEALERURLPARAMNAME:"dwp_dealerid",DWPRELATEDURLPARAMNAME:"dwp_relatedDealers",DWPRELATEDPARAMNAME:"relatedDealers",SERVICEUNAVAILABLETXT:"The system is currently unavailable. Please try submitting a test ride request at another time. We apologize for any inconvenience.",CONFIRMATIONERRORTXT:"The system could not locate your test ride submission request. Please followup with the dealer you submitted your request with.",DWPBIKEUNAVAILABLETXT:"The dealer you selected does not have the model you wish to test ride. Please select another model from the list of available bikes below.",BIKEERRORTXT:"Select one bike you'd like to test ride",ZIPCODECITYERRORTXT:"Please enter a valid ZIP Code or City and State to Continue",ZIPCODEERRORTXT:"Please Enter a ZIP Code",CITYERRORTXT:"Please Enter a City",STATEERRORTXT:"Please Enter a State",HDONLINEEMAIL:"h-donline@harley-davidson.com",PRE2011BIKES:["xl1200c","fxd","fxstc","vrscaw","fxdfse2","xr1200"]};
if(typeof HD=="undefined"||!HD){var HD={}
}if(typeof HD.testRide=="undefined"||!HD.testRide){HD.testRide={}
}var HDT=HD.testRide;
HDT.rest={sendRequest:function(a,b,c,d){HD.util.REST.request(a,b,c,d)
},handleResponse:function(a,b){HD.util.REST.handleResponse(a,b)
}};
if(typeof HD=="undefined"||!HD){var HD={}
}if(typeof HD.testRide=="undefined"||!HD.testRide){HD.testRide={}
}var HDT=HD.testRide;
var YUD=YAHOO.util.Dom;
var YUE=YAHOO.util.Event;
HDT.global={dealerSelected:null,primaryDealer:null,dealer:new Object(),bikeList:null,currentBikeSearched:null,dwp:false,dwpWithRelatedDealers:false,dwpQueryString:""};
if(typeof HD=="undefined"||!HD){var HD={}
}if(typeof HD.testRide=="undefined"||!HD.testRide){HD.testRide={}
}var HDT=HD.testRide;
var YUD=YAHOO.util.Dom;
var YUE=YAHOO.util.Event;
HDT.landing={toggleParent:"testARideForm_bottom",toggleClick:"toggleSearch",cityStateOn:"cityStateActive",isZipActive:true,bikeModel:"bikeModel",zipcodeId:"zipCode",cityId:"city",stateId:"state",selectedLocationId:"selectedLocation",selectedLocationZip:"zip",selectedLocationCityState:"cityState",modelValue:"",zipValue:"",cityValue:"",stateValue:"",selectedValue:"",formName:"scheduleLandingForm",mainFormErrorId:"error",inputErrorClass:"border-error",formSubmitContainer:"submitContainer",formButtonHTML:null,loadingImageHTML:"<img src='/testride/media/images/img_loader_standard_grey.gif' alt='Form submitting'/> <span class=\"hd_submitting\">Submitting ...</span>",submitButtonId:"btn_find",accordionContainer:"common-questions-content",init:function(){HDT.landing.toggleZipCity();
HDT.landing.initSubmitListener();
var a=new HD.util.Accordion.accordion(HDT.landing.accordionContainer);
a.init();
HDT.global.dwpQueryString=HDT.util.getDWPRequestParams();
if(HDT.global.dwpQueryString&&HDT.global.dwpQueryString!=""){HDT.global.dwp=true
}},initSubmitListener:function(){YUE.addListener(HDT.landing.submitButtonId,"click",function(a){HDT.landing.submit(a)
})
},toggleZipCity:function(){YUD.get(HDT.landing.zipcodeId).value="";
YUD.get(HDT.landing.cityId).value="";
YUD.get(HDT.landing.stateId).selectedIndex=0;
YUD.get(HDT.landing.cityId).disabled=true;
YUD.get(HDT.landing.stateId).disabled=true;
YUE.addListener(YUD.getElementsByClassName(HDT.landing.toggleClick),"click",function(){HDT.landing.isZipActive=YUD.hasClass(HDT.landing.toggleParent,HDT.landing.cityStateOn);
if(HDT.landing.isZipActive){YUD.removeClass(HDT.landing.toggleParent,HDT.landing.cityStateOn);
YUD.get(HDT.landing.cityId).value="";
YUD.get(HDT.landing.stateId).selectedIndex=0;
YUD.get(HDT.landing.zipcodeId).disabled=false;
YUD.get(HDT.landing.cityId).disabled=true;
YUD.get(HDT.landing.stateId).disabled=true;
YUD.get(HDT.landing.selectedLocationId).value=HDT.landing.selectedLocationZip;
YUD.removeClass(HDT.landing.cityId,HDT.landing.inputErrorClass);
YUD.removeClass(HDT.landing.stateId,HDT.landing.inputErrorClass)
}else{YUD.get(HDT.landing.zipcodeId).value="";
YUD.addClass(HDT.landing.toggleParent,HDT.landing.cityStateOn);
YUD.get(HDT.landing.zipcodeId).disabled=true;
YUD.get(HDT.landing.cityId).disabled=false;
YUD.get(HDT.landing.stateId).disabled=false;
YUD.get(HDT.landing.selectedLocationId).value=HDT.landing.selectedLocationCityState;
YUD.removeClass(HDT.landing.zipcodeId,HDT.landing.inputErrorClass)
}})
},submit:function(a){YUE.stopEvent(a);
HDT.landing.submitValidation()
},submitValidation:function(){HDT.landing.formButtonHTML=YUD.get(HDT.landing.formSubmitContainer).innerHTML;
YUD.get(HDT.landing.formSubmitContainer).innerHTML=HDT.landing.loadingImageHTML;
HDT.validationErrorHandling.mainFormErrorId=HDT.landing.mainFormErrorId;
HDT.validationErrorHandling.inputErrorClass=HDT.landing.inputErrorClass;
HDT.landing.modelValue=YUD.get(HDT.landing.bikeModel).value;
HDT.landing.zipValue=YUD.get(HDT.landing.zipcodeId).value;
HDT.landing.cityValue=YUD.get(HDT.landing.cityId).value;
HDT.landing.stateValue=YUD.get(HDT.landing.stateId).value;
HDT.landing.selectedValue=YUD.get(HDT.landing.selectedLocationId).value;
YAHOO.util.Connect.setForm(YUD.get(HDT.landing.formName));
YAHOO.util.Connect.initHeader("Content-Type","application/json");
var a=YAHOO.util.Connect.asyncRequest("GET",HDT.constants.SEARCHFORMVALIDATIONURL,{success:function(b){HDT.rest.handleResponse(b,HDT.landing.handleData)
},failure:function(b){HDT.validationErrorHandling.handleClientError(HDT.constants.SERVICEUNAVAILABLETXT);
YUD.get(HDT.landing.formSubmitContainer).innerHTML=HDT.landing.formButtonHTML;
YUE.onContentReady(HDT.landing.formSubmitContainer,function(){HDT.landing.initSubmitListener()
});
window.scrollTo(0,0)
}},null)
},handleData:function(b){validationResponseObject=new HDT.ValidationResponse.validationResponse(b.dealerResponse);
if(validationResponseObject.wasSuccessful){var a="?";
if(HDT.landing.selectedValue==HDT.landing.selectedLocationZip){a+=HDT.constants.BIKEURLPARAMNAME+"="+HDT.landing.modelValue;
a+="&"+HDT.constants.ZIPCODEURLPARAMNAME+"="+HDT.landing.zipValue
}else{a+=HDT.constants.BIKEURLPARAMNAME+"="+HDT.landing.modelValue;
a+="&"+HDT.constants.CITYURLPARAMNAME+"="+HDT.landing.cityValue;
a+="&"+HDT.constants.STATEURLPARAMNAME+"="+HDT.landing.stateValue
}if(HDT.global.dwp){a+="&"+HDT.global.dwpQueryString
}window.location.href=HDT.constants.FORMPAGEURL+a
}else{HDT.validationErrorHandling.handleFormErrors(validationResponseObject);
YUD.get(HDT.landing.formSubmitContainer).innerHTML=HDT.landing.formButtonHTML;
YUE.onContentReady(HDT.landing.formSubmitContainer,function(){HDT.landing.initSubmitListener()
});
window.scrollTo(0,0)
}},createErrorObject:function(e,d){var c={};
var b=HDT.ValidationResponse.responseObjectErrorMsgKey;
var a=HDT.ValidationResponse.responseObjectErrorFieldNameKey;
c[b]=d;
c[a]=e;
return c
}};
if(typeof HD=="undefined"||!HD){var HD={}
}if(typeof HD.testRide=="undefined"||!HD.testRide){HD.testRide={}
}var HDT=HD.testRide;
HDT.ValidationResponse={responseObjectWasSuccessfulKey:"success",responseObjectErrorsKey:"errors",responseObjectErrorMsgKey:"errorMessage",responseObjectErrorTypeKey:"errorType",responseObjectErrorFieldNameKey:"fieldName",responseSystemErrorsKey:"systemErrors",validationResponse:function(a){this.wasSuccessful=a.success||false;
this.errors=a.errors||null;
this.systemErrors=a.systemErrors||null
}};
HDT.ValidationResponse.validationResponse.prototype={getErrorsHTML:function(){var b="<ul>";
for(var a=0;
a<this.errors.length;
a++){b+="<li>"+this.getErrorMsg(this.errors[a])+"</li>"
}b+="</ul>";
return b
},getSystemErrorsHTML:function(){var b="<ul>";
for(var a=0;
a<this.systemErrors.length;
a++){b+="<li>"+this.getErrorMsg(this.systemErrors[a])+"</li>"
}return b
},getErrorMsg:function(a){return a.errorMessage
},getErrorType:function(a){return a.errorType
},getErrorFieldName:function(a){return a.fieldName
},setErrorFieldName:function(b,a){b.fieldName=a
},getAllErrorsFieldNames:function(){var b=new Array();
for(var a=0;
a<this.errors.length;
a++){b.push(this.getErrorFieldName(this.errors[a]))
}return b
},replaceErrorFieldName:function(d,c){for(var b=0;
b<this.errors.length;
b++){var a=this.getErrorFieldName(this.errors[b]);
if(a==d){this.setErrorFieldName(this.errors[b],c)
}}}};
if(typeof HD=="undefined"||!HD){var HD={}
}if(typeof HD.testRide=="undefined"||!HD.testRide){HD.testRide={}
}var HDT=HD.testRide;
HDT.validationErrorHandling={mainFormErrorId:"mainErrorForm",mainFormErrorClass:"satr-main-error-set",inputErrorClass:"satr-error",dealerLocationErrors:"dealerLocationErrors",handleFormErrors:function(d){HDT.validationErrorHandling.clearInputErrorClass();
if(d.systemErrors){var c=d.getSystemErrorsHTML();
HDT.validationErrorHandling.writeMainError(c)
}else{if(d.errors){var c=d.getErrorsHTML();
HDT.validationErrorHandling.writeMainError(c);
var b=d.getAllErrorsFieldNames();
var e=YUD.getElementsBy(function(){return true
},"input");
for(var a=0;
a<b.length;
a++){if(YUD.get(b[a])){YUD.addClass(b[a],HDT.validationErrorHandling.inputErrorClass)
}else{for(var f=0;
f<e.length;
f++){if(b[a]==e[f].name){YUD.addClass(e[f],HDT.validationErrorHandling.inputErrorClass)
}}}}}}},handleClientError:function(b){var a={};
a[HDT.ValidationResponse.responseObjectWasSuccessfulKey]=false;
a[HDT.ValidationResponse.responseSystemErrorsKey]=new Array(HDT.validationErrorHandling.createErrorNode(null,b,null));
responseObject=new HDT.ValidationResponse.validationResponse(a);
HDT.validationErrorHandling.handleFormErrors(responseObject)
},handleConfirmationRequestErrors:function(c,b){c=c||null;
validationResponseObject=new HDT.ValidationResponse.validationResponse(c);
HDT.validationErrorHandling.mainFormErrorId=b;
if(validationResponseObject.systemErrors){YUD.addClass(HDT.validationErrorHandling.mainFormErrorId,HDT.validationErrorHandling.mainFormErrorClass);
var a=validationResponseObject.getSystemErrorsHTML();
HDT.validationErrorHandling.writeMainError(a)
}else{if(validationResponseObject.errors){YUD.addClass(HDT.validationErrorHandling.mainFormErrorId,HDT.validationErrorHandling.mainFormErrorClass);
var a=validationResponseObject.getErrorsHTML();
HDT.validationErrorHandling.writeMainError(a)
}}},handleConfirmationRequestClientErrors:function(c,a){var b={};
b[HDT.ValidationResponse.responseObjectWasSuccessfulKey]=false;
b[HDT.ValidationResponse.responseObjectErrorsKey]=new Array(HDT.validationErrorHandling.createErrorNode(null,c,null));
HDT.validationErrorHandling.handleConfirmationRequestErrors(b,a)
},writeMainError:function(a){YUE.onAvailable(HDT.validationErrorHandling.mainFormErrorId,function(){YUD.get(HDT.validationErrorHandling.mainFormErrorId).innerHTML=a;
YUD.setStyle(HDT.validationErrorHandling.mainFormErrorId,"display","block")
})
},clearMainError:function(){YUD.get(HDT.validationErrorHandling.mainFormErrorId).innerHTML="";
YUD.setStyle(HDT.validationErrorHandling.mainFormErrorId,"display","none")
},clearInputErrorClass:function(){YUD.getElementsByClassName(HDT.validationErrorHandling.inputErrorClass,null,null,function(){YUD.removeClass(this,HDT.validationErrorHandling.inputErrorClass)
})
},writeDealerLocalError:function(a){YUE.onAvailable(HDT.validationErrorHandling.dealerLocationErrors,function(){YUD.get(HDT.validationErrorHandling.dealerLocationErrors).innerHTML=a;
YUD.setStyle(HDT.validationErrorHandling.dealerLocationErrors,"display","block")
})
},clearDealerLocalError:function(a){YUD.get(HDT.validationErrorHandling.dealerLocationErrors).innerHTML="";
YUD.setStyle(HDT.validationErrorHandling.dealerLocationErrors,"display","none")
},createErrorNode:function(d,c,a){var b={};
b[HDT.ValidationResponse.responseObjectErrorFieldNameKey]=d||"";
b[HDT.ValidationResponse.responseObjectErrorMsgKey]=c||"";
b[HDT.ValidationResponse.responseObjectErrorTypeKey]=a||"";
return b
}};
if(typeof HD=="undefined"||!HD){var HD={}
}if(typeof HD.testRide=="undefined"||!HD.testRide){HD.testRide={}
}var HDT=HD.testRide;
HD.util.Analytics.track=function(a,b){HDT.hbx.hbPageView(a,b)
};
HDT.hbx={hbxSiteName:"TestRide",hbPageView:function(a,b){if(!b){b=this.hbxSiteName
}_hbPageView(b,a)
},track:function(a,b){if("landing"==a){HD.util.Analytics.track(HDT.hbx.landingPageString(),HDT.hbx.hbxSiteName)
}else{if("form"==a){HD.util.Analytics.track(HDT.hbx.formPageString(b),HDT.hbx.hbxSiteName)
}else{if("submit"==a){HD.util.Analytics.track(HDT.hbx.formSubmitString(b),HDT.hbx.formSubmitSiteNameString(b))
}else{if("followUp"==a){HD.util.Analytics.track(HDT.hbx.followUpString(b),HDT.hbx.hbxSiteName)
}else{if("survey"==a){HD.util.Analytics.track(HDT.hbx.surveyString(),HDT.hbx.hbxSiteName)
}}}}}},formPageString:function(b){var a="/Get+On+A+Bike/Try+a+Bike/Schedule+Test+Ride/Form";
if(b){a+="/"+b
}return a
},formSubmitString:function(c){var a="/Get+On+A+Bike/Try+a+Bike/Schedule+Test+Ride/Submit";
var b=(c.date).replace(/\//g,"_");
if(c.bike&&c.dealerId&&c.date){a+="/"+c.bike+"/"+c.dealerId+"/"+b
}return a
},formSubmitSiteNameString:function(b){var a="TestRide";
if(b.timeOfDay&&b.contactType){a+="_"+b.timeOfDay+"_"+b.contactType
}return a
},followUpString:function(b){var a="/Get+On+A+Bike/Try+a+Bike/Schedule+Test+Ride/Dealer+Contact";
if(b){a+="/"+b
}return a
},surveyString:function(){return"/Get+On+A+Bike/Try+a+Bike/Schedule+Test+Ride/Survey+Thank+You"
}};
if(typeof HD=="undefined"||!HD){var HD={}
}if(typeof HD.testRide=="undefined"||!HD.testRide){HD.testRide={}
}var HDT=HD.testRide;
var YUD=YAHOO.util.Dom;
var YUE=YAHOO.util.Event;
HDT.formPage={paramBike:"",paramZipCode:"",paramCity:"",paramState:"",paramDealer:"",paramDWPDealer:"",paramDWPRelatedDealers:"",selectBikeMainContainer:"bikeModelContainer",selectBikeMain:"bikeModel",searchFormContainer:"standardSearchForm",searchForm:"searchForm",searchZip:"zipCode",searchCity:"city",searchState:"state",dealerLocationContainer:"dealerLocationContainer",allDealerResults:["selectedBikeAvailable","selectedBikeUnavailable","selectedBikeLocationUnavailable","standardSearchForm","selectDealer"],selectedBikeAvailable:"selectedBikeAvailable",selectedBikeAvailableSearch:"selectedBikeAvailableSearch",selectedBikeAvailableSeeMore:"selectedBikeAvailableSeeMore",selectedBikeNotAvailable:"selectedBikeUnavailable",selectBikeUnavailableContainer:"selectBikeUnavailableContainer",selectBikeUnavailable:"selectBikeUnavailable",selectedBikeUnavailableDealerError:"selectedBikeUnavailableDealerError",btnBikeUnavailable:"btnBikeUnavailable",selectAnotherDealer:"selectDealer",selectDealerClose:"selectDealerClose",selectAnotherDealerDealers:"selectDealerDealers",selectAnotherDealerPagNav:"selectDealerPagNav",hiddenBikeInput:"selectedBikeModel",hiddenCalendarInput:"calendarDate",hiddenDealerInput:"dealerId",primaryDealerContainer:"primaryDealerContainer",primaryDealerAdditional:"primaryDealerAdditional",selectDealerContainer:"selectedBikeUnavailableDealers",selectDealerPagNav:"selectedBikeUnavailablePagNav",selectedBikeUnavailablePrimary:"selectedBikeUnavailablePrimary",standardSearchSubmit:"standardSearchSubmit",standardSearchFormError:"standardSearchFormError",standardSearchActive:false,bikeImageContainer:"satr-imagery",calendarContainer:"calendarContainer",defaultCalendarHTML:'<div id="calendarDefault"><p>Select a Test Ride Location<br>above in order to pick your<br>Test Ride Date</p></div>',pager:null,noAdditionalDealersAvailable:"No additional dealers are available for online test ride reservations near you.",dwpSeeRelatedDealersAnchor:'<a href="javascript:void(0)" id="selectedBikeAvailableSeeMore">See More Dealerships Nearby</a>',init:function(){HDT.formPage.handleParams();
HDT.formSchedule.init();
HDT.util.stopKeyClicks([13])
},handleParams:function(){HDT.formPage.paramBike=HDT.util.getRequestParam(HDT.constants.BIKEURLPARAMNAME)||"";
HDT.formPage.paramZipCode=HDT.util.getRequestParam(HDT.constants.ZIPCODEURLPARAMNAME)||"";
HDT.formPage.paramCity=HDT.util.getRequestParam(HDT.constants.CITYURLPARAMNAME)||"";
HDT.formPage.paramState=HDT.util.getRequestParam(HDT.constants.STATEURLPARAMNAME)||"";
HDT.formPage.paramDealer=(HDT.util.getRequestParam(HDT.constants.DEALERURLPARAMNAME)/29)||"";
HDT.formPage.paramDWPDealer=(HDT.util.getRequestParam(HDT.constants.DWPDEALERURLPARAMNAME)/29)||"";
HDT.formPage.paramDWPRelatedDealers=HDT.util.getRequestParam(HDT.constants.DWPRELATEDURLPARAMNAME)||"";
HDT.global.dwpQueryString=HDT.util.getDWPRequestParams();
HDT.formPage.paramDealer=HDT.util.formatDealerId(HDT.formPage.paramDealer);
HDT.formPage.paramDWPDealer=HDT.util.formatDealerId(HDT.formPage.paramDWPDealer);
HDT.formPage.setBike(HDT.formPage.paramBike);
if(HDT.formPage.paramDWPDealer){YUD.addClass(document.body,"yui-skin-sam");
YUD.get("satr-header").innerHTML="<div class='satr-back-btn'><a href='javascript:history.back()'><img width='49' height='22' alt='Back' src='/en_US/Media/images/Content/Pictorial/Test_Ride_a_Bike/btn_back.png'></a></div>";
HDT.formPage.handleDWP();
return
}YUE.addListener(HDT.formPage.selectBikeMain,"change",function(){HDT.formPage.mainBikeSelectorChanged()
});
var a=new HDT.DealerRequest.dealerRequest(HDT.formPage.paramBike,HDT.formPage.paramZipCode,HDT.formPage.paramCity,HDT.formPage.paramState,HDT.formPage.paramDealer);
if(HDT.formPage.paramDealer||(HDT.global.currentBikeSearched&&HDT.formPage.paramZipCode)||(HDT.global.currentBikeSearched&&HDT.formPage.paramCity&&HDT.formPage.paramState)){HDT.dealerSearch.sendRequest(a)
}else{HDT.formPage.displaySearch()
}if(HDT.formPage.paramDealer){HDT.hbx.track("form","Dealer+Locator")
}else{if(HDT.formPage.paramBike&&!HDT.formPage.paramZipCode&&!HDT.formPage.paramCity&&!HDT.formPage.paramState){HDT.hbx.track("form","New+Models")
}else{if(HDT.formPage.paramBike&&(HDT.formPage.paramZipCode||(HDT.formPage.paramCity&&HDT.formPage.paramState))){HDT.hbx.track("form","Landing")
}else{HDT.hbx.track("form","Other")
}}}},handleDWP:function(){HDT.global.dwp=true;
var d="";
if(typeof HD.dwp=="undefined"||!HD.dwp){HD.dwp={}
}if(HD.dwp.relatedDealers&&typeof HD.dwp.relatedDealers=="object"&&HD.dwp.relatedDealers.length>0){HDT.global.dwpWithRelatedDealers=true;
for(var a=0;
a<HD.dwp.relatedDealers.length;
a++){if(a>0){d+=","
}d+=HDT.util.formatDealerId((HD.dwp.relatedDealers[a]/29))
}}else{if(HDT.formPage.paramDWPRelatedDealers&&HDT.formPage.paramDWPRelatedDealers!=""){HDT.global.dwpWithRelatedDealers=true;
var c=HDT.formPage.paramDWPRelatedDealers.split(",");
for(var a=0;
a<c.length;
a++){if(a>0){d+=","
}d+=HDT.util.formatDealerId((c[a]/29))
}}}var b=new HDT.DealerRequest.dealerRequest(null,HDT.formPage.paramZipCode,HDT.formPage.paramCity,HDT.formPage.paramState,HDT.formPage.paramDWPDealer,d);
HDT.dealerSearch.sendRequest(b)
},displaySearch:function(a,c,b){HDT.formPage.standardSearchActive=true;
if(b){YUD.get(HDT.formPage.searchZip).value="";
YUD.get(HDT.formPage.searchCity).value="";
YUD.get(HDT.formPage.searchState).value=""
}HDT.formPage.setDealer("");
if(YUD.get(c)){YUD.setStyle(c,"display","none")
}HDT.formPage.resetCalendarDate();
YUE.removeListener(HDT.formPage.standardSearchSubmit,"click");
YUE.addListener(HDT.formPage.standardSearchSubmit,"click",function(){HDT.validationErrorHandling.clearMainError();
HDT.validationErrorHandling.clearInputErrorClass();
var e=YUD.get(HDT.formPage.searchZip).value;
var g=YUD.get(HDT.formPage.searchCity).value;
var f=YUD.get(HDT.formPage.searchState).value;
var d=new HDT.DealerRequest.dealerRequest(HDT.global.currentBikeSearched,e,g,f);
HDT.dealerSearch.sendRequest(d,HDT.formPage.searchFormContainer);
HDT.formPage.standardSearchActive=false
});
if(a){YUD.setStyle(HDT.formPage.standardSearchFormError,"display","block")
}else{YUD.setStyle(HDT.formPage.standardSearchFormError,"display","none")
}YUE.onAvailable(HDT.formPage.searchFormContainer,function(){YUD.setStyle(HDT.formPage.searchFormContainer,"display","block")
})
},displayDealer:function(b){if(YUD.get(b)){YUD.setStyle(b,"display","none")
}var a=HDT.global.dealer[HDT.global.dealerSelected];
YUE.onAvailable(HDT.formPage.primaryDealerContainer,function(){YUD.get(HDT.formPage.primaryDealerContainer).innerHTML=a.getPrimaryDealerHTML()
});
HDT.calendar.draw(HDT.global.dealerSelected,HDT.formPage.calendarContainer);
YUE.addListener(HDT.formPage.selectedBikeAvailableSearch,"click",function(){HDT.formPage.displaySearch(false,[HDT.formPage.selectedBikeAvailable,HDT.formPage.selectAnotherDealer],true);
HDT.validationErrorHandling.clearDealerLocalError();
YUE.removeListener(HDT.formPage.selectedBikeAvailableSearch,"click")
});
YUE.addListener(HDT.formPage.selectedBikeAvailableSeeMore,"click",function(){HDT.formPage.displayMoreDealers(HDT.formPage.selectedBikeAvailable);
YUE.removeListener(HDT.formPage.selectedBikeAvailableSeeMore,"click")
});
YUE.onAvailable(HDT.formPage.selectedBikeAvailable,function(){YUD.setStyle(HDT.formPage.selectedBikeAvailable,"display","block")
})
},displayDWPDealer:function(b){if(YUD.get(b)){YUD.setStyle(b,"display","none")
}var a=HDT.global.dealer[HDT.global.dealerSelected];
YUE.onAvailable(HDT.formPage.primaryDealerContainer,function(){YUD.get(HDT.formPage.primaryDealerContainer).innerHTML=a.getPrimaryDealerHTML()
});
HDT.calendar.draw(HDT.global.dealerSelected,HDT.formPage.calendarContainer);
if(HDT.global.dwpWithRelatedDealers){YUD.get(HDT.formPage.primaryDealerAdditional).innerHTML=HDT.formPage.dwpSeeRelatedDealersAnchor;
YUE.addListener(HDT.formPage.selectedBikeAvailableSeeMore,"click",function(){HDT.formPage.displayDWPRelatedDealers("",true);
YUE.removeListener(HDT.formPage.selectedBikeAvailableSeeMore,"click")
})
}else{YUD.get(HDT.formPage.primaryDealerAdditional).innerHTML="";
YUD.setStyle(HDT.formPage.primaryDealerAdditional,"display","none")
}YUE.onAvailable(HDT.formPage.selectedBikeAvailable,function(){YUD.setStyle(HDT.formPage.selectedBikeAvailable,"display","block")
})
},displayBikeNotFound:function(){YUD.get(HDT.formPage.selectDealerContainer).innerHTML="";
YUD.get(HDT.formPage.selectDealerPagNav).innerHTML="";
YUE.onAvailable(HDT.formPage.selectedBikeUnavailableDealerError,function(){YUD.setStyle(HDT.formPage.selectedBikeUnavailableDealerError,"display","none")
});
var c=HDT.global.dealer[HDT.global.primaryDealer];
YUE.onAvailable(HDT.formPage.selectedBikeUnavailablePrimary,function(){YUD.get(HDT.formPage.selectedBikeUnavailablePrimary).innerHTML=c.getPrimaryDealerHTML()
});
YUE.onAvailable(HDT.formPage.selectBikeUnavailableContainer,function(){YUD.get(HDT.formPage.selectBikeUnavailableContainer).innerHTML=c.getAvailableBikesHTML(HDT.formPage.selectBikeUnavailable,"Select an Available Model")
});
var d=new Array();
for(var a in HDT.global.dealer){if(HDT.global.primaryDealer!=HDT.global.dealer[a].id){d.push(HDT.global.dealer[a].getOtherDealerHTML())
}}if(d.length>0){var b=new HDT.Paging.paging(d,3,0,HDT.formPage.selectDealerContainer,HDT.formPage.selectDealerPagNav);
b.init(b);
b.render();
if(!YAHOO.util.Config.alreadySubscribed(HDT.Paging.pageRendered,HDT.formPage.displayBikeNotFoundDealerListeners)){HDT.Paging.pageRendered.subscribe(HDT.formPage.displayBikeNotFoundDealerListeners)
}}else{YUE.onAvailable(HDT.formPage.selectedBikeUnavailableDealerError,function(){YUD.setStyle(HDT.formPage.selectedBikeUnavailableDealerError,"display","block")
})
}YUE.addListener(HDT.formPage.btnBikeUnavailable,"click",function(){HDT.formPage.changeSelectedBike(HDT.formPage.selectBikeUnavailable,HDT.formPage.selectedBikeNotAvailable);
HDT.Paging.pageRendered.unsubscribe(HDT.formPage.displayBikeNotFoundDealerListeners)
});
YUE.onAvailable(HDT.formPage.selectedBikeNotAvailable,function(){YUD.setStyle(HDT.formPage.selectedBikeNotAvailable,"display","block")
})
},displayBikeNotFoundDealerListeners:function(){YUE.removeListener(YUD.getElementsBy(function(){return true
},"a",HDT.formPage.selectDealerContainer),"click");
if("none"!=YUD.getStyle(HDT.formPage.selectedBikeNotAvailable,"display")){YUE.addListener(YUD.getElementsBy(function(){return true
},"a",HDT.formPage.selectDealerContainer),"click",function(){HDT.formPage.changeSelectedDealer(this.id,HDT.formPage.selectedBikeNotAvailable);
YUE.removeListener(YUD.getElementsBy(function(){return true
},"a",HDT.formPage.selectDealerContainer),"click")
})
}},displayMoreDealers:function(d){if(YUD.get(d)){YUD.setStyle(d,"display","none")
}var c=new Array();
for(var a in HDT.global.dealer){if(HDT.global.dealerSelected!=HDT.global.dealer[a].id){c.push(HDT.global.dealer[a].getOtherDealerHTML())
}}if(c.length>0){HDT.formPage.displayDealer();
YUD.get(HDT.formPage.selectAnotherDealerDealers).innerHTML="";
YUD.get(HDT.formPage.selectAnotherDealerPagNav).innerHTML="";
var b=new HDT.Paging.paging(c,3,0,HDT.formPage.selectAnotherDealerDealers,HDT.formPage.selectAnotherDealerPagNav);
b.init(b);
b.render();
if(!YAHOO.util.Config.alreadySubscribed(HDT.Paging.pageRendered,HDT.formPage.displayMoreDealersListeners)){HDT.Paging.pageRendered.subscribe(HDT.formPage.displayMoreDealersListeners)
}YUE.removeListener(HDT.formPage.selectDealerClose,"click");
YUE.addListener(HDT.formPage.selectDealerClose,"click",function(){HDT.formPage.displayDealer(HDT.formPage.selectAnotherDealer)
});
YUD.setStyle(HDT.formPage.selectAnotherDealer,"display","block")
}else{HDT.validationErrorHandling.writeDealerLocalError(HDT.formPage.noAdditionalDealersAvailable);
HDT.formPage.displayDealer()
}},displayMoreDealersListeners:function(){YUE.removeListener(YUD.getElementsBy(function(){return true
},"a",HDT.formPage.selectAnotherDealerDealers),"click");
if("none"!=YUD.getStyle(HDT.formPage.selectAnotherDealer,"display")){YUE.addListener(YUD.getElementsBy(function(){return true
},"a",HDT.formPage.selectAnotherDealerDealers),"click",function(){HDT.formPage.changeSelectedDealer(this.id,[HDT.formPage.selectAnotherDealer,HDT.formPage.selectedBikeAvailable]);
YUE.removeListener(YUD.getElementsBy(function(){return true
},"a",HDT.formPage.selectAnotherDealerDealers),"click")
})
}},displayDWPRelatedDealers:function(e,d){if(YUD.get(e)){YUD.setStyle(e,"display","none")
}YUE.addListener(HDT.formPage.selectBikeMain,"change",function(){HDT.formPage.mainBikeSelectorChanged()
});
var c=new Array();
for(var a in HDT.global.dealer){if(HDT.global.dealerSelected!=HDT.global.dealer[a].id){c.push(HDT.global.dealer[a].getOtherDealerHTML())
}}if(c.length>0){YUD.get(HDT.formPage.selectAnotherDealerDealers).innerHTML="";
YUD.get(HDT.formPage.selectAnotherDealerPagNav).innerHTML="";
var b=new HDT.Paging.paging(c,3,0,HDT.formPage.selectAnotherDealerDealers,HDT.formPage.selectAnotherDealerPagNav);
b.init(b);
b.render();
if(!YAHOO.util.Config.alreadySubscribed(HDT.Paging.pageRendered,HDT.formPage.displayDWPRelatedDealersListeners)){HDT.Paging.pageRendered.subscribe(HDT.formPage.displayDWPRelatedDealersListeners)
}if(d){YUD.setStyle(HDT.formPage.selectDealerClose,"display","block");
YUE.removeListener(HDT.formPage.selectDealerClose,"click");
YUE.addListener(HDT.formPage.selectDealerClose,"click",function(){HDT.formPage.displayDWPDealer(HDT.formPage.selectAnotherDealer)
})
}else{YUE.removeListener(HDT.formPage.selectDealerClose,"click");
YUD.setStyle(HDT.formPage.selectDealerClose,"display","none")
}YUD.setStyle(HDT.formPage.selectAnotherDealer,"display","block")
}},displayDWPRelatedDealersListeners:function(){YUE.removeListener(YUD.getElementsBy(function(){return true
},"a",HDT.formPage.selectAnotherDealerDealers),"click");
if("none"!=YUD.getStyle(HDT.formPage.selectAnotherDealer,"display")){YUE.addListener(YUD.getElementsBy(function(){return true
},"a",HDT.formPage.selectAnotherDealerDealers),"click",function(){HDT.formPage.selectDWPDealer(this.id,[HDT.formPage.selectAnotherDealer,HDT.formPage.selectedBikeAvailable]);
YUE.removeListener(YUD.getElementsBy(function(){return true
},"a",HDT.formPage.selectAnotherDealerDealers),"click")
})
}},selectDWPDealer:function(a){HDT.formPage.setDealer(a);
HDT.formPage.drawMainSelectBox();
YUE.removeListener(YUD.getElementsBy(function(){return true
},"a",HDT.formPage.selectDealerContainer),"click");
HDT.formPage.displayDWPDealer(HDT.formPage.selectAnotherDealer);
window.scrollTo(0,0)
},changeSelectedBike:function(a,b){var c=YUD.get(a).value;
if(""==c||c==null){return
}HDT.formPage.setBike(c);
HDT.formPage.displayDealer(b);
YUE.removeListener(HDT.formPage.btnBikeUnavailable,"click");
window.scrollTo(0,0)
},changeSelectedDealer:function(f,d){HDT.formPage.setDealer(f);
if(HDT.global.currentBikeSearched){var b=true;
var c=HDT.global.dealer[HDT.global.dealerSelected];
var e=c.isBikeAvailable(HDT.global.currentBikeSearched);
if(e){b=false
}if(b){var a=new HDT.DealerRequest.dealerRequest(HDT.global.currentBikeSearched,null,null,null,HDT.global.dealer[HDT.global.dealerSelected].id);
HDT.dealerSearch.sendRequest(a,d)
}else{HDT.formPage.displayDealer(d)
}}else{HDT.formPage.displayDealer(d)
}YUE.removeListener(YUD.getElementsBy(function(){return true
},"a",HDT.formPage.selectDealerContainer),"click");
YUE.removeListener(HDT.formPage.btnBikeUnavailable,"click");
window.scrollTo(0,0)
},mainBikeSelectorChanged:function(){HDT.formPage.setBike(YUD.get(HDT.formPage.selectBikeMain).value);
if(!HDT.formPage.standardSearchActive&&(""!=HDT.global.dealerSelected)&&(""!=HDT.global.currentBikeSearched)){var b=true;
var c=HDT.global.dealer[HDT.global.dealerSelected];
var d=c.isBikeAvailable(HDT.global.currentBikeSearched);
if(d){b=false
}if(b){var a=new HDT.DealerRequest.dealerRequest(HDT.global.currentBikeSearched,null,null,null,HDT.global.dealer[HDT.global.dealerSelected].id);
HDT.dealerSearch.sendRequest(a,HDT.formPage.allDealerResults)
}}},setDealer:function(a){HDT.global.dealerSelected=a;
HDT.util.formFieldSet(HDT.formPage.hiddenDealerInput,a);
HDT.util.formFieldSet(HDT.formPage.hiddenCalendarInput,"")
},setBike:function(b){var a=HDT.formPage.isValidBike(b);
if(a){HDT.global.currentBikeSearched=b
}else{HDT.global.currentBikeSearched=""
}HDT.util.selectInputOption(HDT.formPage.selectBikeMain,HDT.global.currentBikeSearched);
HDT.util.formFieldSet(HDT.formPage.hiddenBikeInput,HDT.global.currentBikeSearched);
HDT.formPage.setBikeImage(HDT.global.currentBikeSearched)
},setBikeImage:function(a){YUE.onAvailable(HDT.formPage.bikeImageContainer,function(){var f=YUD.get(HDT.formPage.bikeImageContainer);
if(a!=""&&a!=null){var c='<div class="preferred-bike"><img src="/en_US/Media/images/Content/Pictorial/Test_Ride_a_Bike/gallery_images/321x182_'+a+'_dom.jpg" width="321" height="182" alt="preferred bike" /></div>';
f.innerHTML=c
}else{if(((HDT.global&&!HDT.global.dwp))||(!HDT.formPage.proImageHideForDealer&&(HDT.global&&HDT.global.dwp))){var b="";
var d=false;
var e=false;
if(HDT.formPage.proImageLink&&HDT.formPage.proImageLink!=""){d=true
}if(HDT.formPage.proImageOpenNewWindow){e=true
}if(d){b+='<a href="'+HDT.formPage.proImageLink+'"';
if(e){b+=' target="_blank"'
}else{b+=">"
}}b+='<img src="'+HDT.formPage.proImage+'" alt="" width="'+HDT.formPage.proImageWidth+'" height="'+HDT.formPage.proImageHeight+'"/>';
if(d){b+="</a>"
}f.innerHTML=b
}}})
},setFormDate:function(b){var a=(b.getMonth()+1)+"/"+b.getDate()+"/"+b.getFullYear();
HDT.util.formFieldSet(HDT.formPage.hiddenCalendarInput,a)
},resetCalendarDate:function(){YUD.get(HDT.formPage.calendarContainer).innerHTML=HDT.formPage.defaultCalendarHTML;
YUD.removeClass(HDT.formPage.calendarContainer,"yui-calcontainer");
YUD.removeClass(HDT.formPage.calendarContainer,"single");
HDT.util.formFieldSet(HDT.formPage.hiddenCalendarInput,"")
},isValidBike:function(c){if(c==""||c==null){return false
}var b=YUD.get(HDT.formPage.selectBikeMain);
for(var a=0;
a<b.options.length;
a++){if(b.options[a].value==c){return true
}}return false
},drawMainSelectBox:function(){var a=HDT.global.dealer[HDT.global.dealerSelected];
YUD.get(HDT.formPage.selectBikeMainContainer).innerHTML=a.getAvailableBikesHTML(HDT.formPage.selectBikeMain,"Select a Model");
YUE.removeListener(HDT.formPage.selectBikeMain,"change");
YUE.addListener(HDT.formPage.selectBikeMain,"change",function(){HDT.formPage.mainBikeSelectorChanged()
});
YUE.onContentReady(HDT.formPage.selectBikeMainContainer,function(){HDT.formPage.setBike(HDT.global.currentBikeSearched)
});
var b=false;
if(""!=HDT.global.currentBikeSearched){b=a.isBikeAvailable(HDT.global.currentBikeSearched)
}else{b=true
}if(!b){HDT.validationErrorHandling.clearMainError();
HDT.validationErrorHandling.clearInputErrorClass();
HDT.validationErrorHandling.handleClientError(HDT.constants.DWPBIKEUNAVAILABLETXT)
}}};
if(typeof HD=="undefined"||!HD){var HD={}
}if(typeof HD.testRide=="undefined"||!HD.testRide){HD.testRide={}
}var HDT=HD.testRide;
var YUD=YAHOO.util.Dom;
var YUE=YAHOO.util.Event;
HDT.util={selectInputOption:function(d,c){if(!YUD.get(d)||c==null){return
}var b=YUD.get(d);
for(var a=0;
a<b.options.length;
a++){if(b.options[a].value==c){b.options[a].selected=true
}}},getInputRadioValue:function(c){var b="";
for(var a=0;
a<c.length;
a++){if(c[a].checked){b=c[a].value
}}return b
},getRequestParam:function(b){if(!b){return
}zname=b.replace(/\[/g,"[").replace(/\]/g,"]");
var a="[\\?&]"+b+"=([^&#]*)";
var e=new RegExp(a);
var d=e.exec(window.location.href);
var c=d==null?null:d[1];
return !!c&&c.match(/^(true|1)$/)?true:(!!c&&c.match(/^(false|0)$/)?false:(!!c&&c.match(/^(null|undefined)$/)?null:c))
},getDWPRequestParams:function(c){var h=unescape(location.search.substring(1));
var b=h.split("&");
var a="";
var g=true;
for(var f in b){var e=b[f].split("=");
var d=e[0].substring(0,4);
if("dwp_"==d){if(!g){a+="&"
}a+=e[0]+"="+e[1];
g=false
}}return a
},formFieldSet:function(b,a){if(YUD.get(b)){YUD.get(b).value=a
}},maxLength:function(e,c,a){if(c.value){var b=e.which;
if(b>=33||b==13){var d=c.value.length;
if(d>=a){e.preventDefault()
}}}},stopKeyClicks:function(a){var b=new YAHOO.util.KeyListener(document,{keys:a},function(c){YUE.preventDefault(c)
});
b.enable()
},formatDealerId:function(b){if(!b||(""==b)||isNaN(b)){return""
}var a=parseInt(b);
if(a<1000&&a>99){return"0"+a
}else{if(a<100&&a>9){return"00"+a
}else{if(a<10&&a>0){return"000"+a
}}}return a
},stripTrademarks:function(a){a=a.replace(/\&reg;/g,"");
a=a.replace(/\&trade;/g,"");
return a
},isPre2011Bike:function(b){var d=false;
var c=HDT.constants.PRE2011BIKES;
for(var a=0;
a<c.length;
a++){if(c[a]==b.toLowerCase()){d=true;
break
}}return d
}};
if(typeof HD=="undefined"||!HD){var HD={}
}if(typeof HD.testRide=="undefined"||!HD.testRide){HD.testRide={}
}var HDT=HD.testRide;
HDT.calendar={calendar:null,year:null,month:null,daysInMonth:null,dayOfMonth:null,weekDay:null,hourOfDay:null,calendarDate:null,dealer:null,dealerCalendar:null,cutoffTime:0,leadDays:null,minDate:null,maxDate:null,restrictedOverlay:null,restrictedOverlayId:"restrictedOverlay",today:null,draw:function(c,a){HDT.calendar.dealer=HDT.global.dealer[c];
HDT.calendar.leadDays=HDT.calendar.dealer.leadDays;
HDT.calendar.dealerCalendar=HDT.calendar.dealer.getCalendar();
var b=new Date(HDT.calendar.dealerCalendar[0].formattedDate);
b.setDate(b.getDate()-1);
HDT.calendar.today=b;
HDT.calendar.calendar=new YAHOO.widget.Calendar(null,a,{pagedate:b},b);
HDT.calendar.calendarDate=new Date(HDT.calendar.today);
HDT.calendar.calendarDate.setDate(1);
HDT.calendar.calendarDate.setHours(0,0,0,0);
HDT.calendar.getRestrictedDates(HDT.calendar.dealerCalendar);
HDT.calendar.calendar.render();
HDT.calendar.attachPrevNextEvents();
HDT.calendar.attachRestictedEvents();
HDT.calendar.calendar.renderEvent.subscribe(function(){HDT.calendar.attachPrevNextEvents();
HDT.calendar.attachRestictedEvents()
});
HDT.calendar.calendar.selectEvent.subscribe(function(){var d=HDT.calendar.calendar.getSelectedDates();
HDT.formPage.setFormDate(d[0])
})
},attachPrevNextEvents:function(){if(HDT.calendar.calendarDate.getMonth()-1<HDT.calendar.minDate.getMonth()){YAHOO.util.Event.removeListener(HDT.calendar.calendar.linkLeft,"click");
YUD.setStyle(YUD.getElementsByClassName("calnavleft"),"display","none")
}else{YAHOO.util.Event.addListener(HDT.calendar.calendar.linkLeft,"click");
YUD.setStyle(YUD.getElementsByClassName("calnavleft"),"display","block");
YUE.addListener(YUD.getElementsByClassName("calnavleft"),"click",function(){HDT.calendar.calendarDate.setMonth(HDT.calendar.calendarDate.getMonth()-1);
HDT.calendar.getRestrictedDates(HDT.calendar.dealerCalendar)
})
}if(HDT.calendar.calendarDate.getMonth()+1>HDT.calendar.maxDate.getMonth()){YAHOO.util.Event.removeListener(HDT.calendar.calendar.linkRight,"click");
YUD.setStyle(YUD.getElementsByClassName("calnavright"),"display","none")
}else{YAHOO.util.Event.addListener(HDT.calendar.calendar.linkLeft,"click");
YUD.setStyle(YUD.getElementsByClassName("calnavright"),"display","block");
YUE.addListener(YUD.getElementsByClassName("calnavright"),"click",function(){HDT.calendar.calendarDate.setMonth(HDT.calendar.calendarDate.getMonth()+1);
HDT.calendar.getRestrictedDates(HDT.calendar.dealerCalendar)
})
}},getRestrictedDates:function(b){var g=new Array();
var d=new Date(HDT.calendar.today);
HDT.calendar.year=d.getFullYear();
HDT.calendar.month=d.getMonth();
HDT.calendar.daysInMonth=HDT.calendar.findDaysInMonth(HDT.calendar.month,HDT.calendar.year);
HDT.calendar.dayOfMonth=d.getDate();
HDT.calendar.weekDay=d.getDay();
HDT.calendar.hourOfDay=d.getHours();
tempDateObject=new Date(HDT.calendar.calendar.today);
var c=HDT.calendar.leadDays;
if(0>=c||isNaN(c)){c=0
}if(HDT.calendar.cutoffTime>HDT.calendar.hourOfDay){c--
}g.push((tempDateObject.getMonth()+1)+"/"+tempDateObject.getDate());
for(var a=0;
a<b.length;
a++){if(!b[a].open||c>0){var d=new Date(b[a].formattedDate);
g.push((d.getMonth()+1)+"/"+d.getDate())
}c--
}tempDateObject=new Date(b[b.length-1].formattedDate);
var f=(tempDateObject.getMonth()+1)+"/"+tempDateObject.getDate()+"/"+tempDateObject.getFullYear();
tempDateObject=new Date(HDT.calendar.calendar.today);
var e=(tempDateObject.getMonth()+1)+"/"+tempDateObject.getDate()+"/"+tempDateObject.getFullYear();
HDT.calendar.calendar.cfg.setProperty("mindate",e);
HDT.calendar.calendar.cfg.setProperty("maxdate",f);
HDT.calendar.minDate=HDT.calendar.calendar.cfg.getProperty("mindate");
HDT.calendar.maxDate=HDT.calendar.calendar.cfg.getProperty("maxdate");
for(var a=0;
a<g.length;
a++){HDT.calendar.calendar.addRenderer(g[a],HDT.calendar.calendar.renderBodyCellRestricted)
}},attachRestictedEvents:function(){YUD.getElementsBy(function(a){if(YUD.hasClass(a,"restricted")||YUD.hasClass(a,"previous")){return true
}return false
},"td","calendarContainer",function(a){YUE.addListener(a,"click",function(){HDT.calendar.displayUnavailableOverlay()
})
})
},displayUnavailableOverlay:function(){var b="<div id='closeButtonContainer'><a href='javascript:void(0)' class='closeButton xButtonType'></a></div><div class='restrictedOverlayContent'><h2>Online test ride reservation is not available for this date. Please select another valid date or contact your dealer for more information.</h2><p><a href='javascript:void(0)' class='closeButton'>OK</a></p></div>";
var a=new HD.util.Overlay.OverlayConfig(HDT.calendar.restrictedOverlayId,b);
HDT.calendar.restrictedOverlay=new HD.util.Overlay.Overlay(a);
HDT.calendar.restrictedOverlay.showOverlay(function(){var c=YUD.getElementsByClassName("closeButton");
YUE.addListener(c,"click",function(){HDT.calendar.restrictedOverlay.destroyOverlay()
})
})
},findDaysInMonth:function(b,a){return 32-new Date(a,b,32).getDate()
}};
if(typeof HD=="undefined"||!HD){var HD={}
}if(typeof HD.testRide=="undefined"||!HD.testRide){HD.testRide={}
}var HDT=HD.testRide;
var YUD=YAHOO.util.Dom;
var YUE=YAHOO.util.Event;
HDT.formSchedule={formSchedule:"formSchedule",formScheduleSubmitId:"submitForm",formScheduleSubmitContainer:"submitFormContainer",formSubmitButtonHTML:null,hbxObject:{bike:"",dealerId:"",date:"",timeOfDay:"",contactType:""},formDealer:"dealerId",formModel:"selectedBikeModel",formValidLicense:"validLicense",formContact:"contact.preferredContactMethod",formDate:"calendarDate",formTime:"preferredTime",formAdditional:"additionalRequests",formOpenLogin:"openLoginOverlay",formAdditionalTxt:"Have any specific requests or questions? What if it's raining? Interested in test riding other bikes?",preferredContactPhoneLabel:"preferredContactPhoneLabel",preferredContactPhoneTxt:"Phone Number",loadingImageHTML:"<img src='/testride/media/images/img_loader.gif' alt='Form submitting'/> <span class=\"hd_submitting\">Submitting ...</span>",validLicenseOverlay:null,jsonObjectName:"testRideForm",registerWait:null,init:function(){HDT.formSchedule.initSubmitListener();
YUD.getElementsBy(function(a){if(HDT.formSchedule.formContact==a.name){YUE.addListener(a,"click",function(){HDT.formSchedule.formContactClicked(this)
})
}else{if(HDT.formSchedule.formValidLicense==a.name){YUE.addListener(a,"click",function(){HDT.formSchedule.formValidLicenseClicked(this)
})
}}},"input",HDT.formSchedule.formSchedule);
YUE.addListener(HDT.formSchedule.formAdditional,"focus",function(){HDT.formSchedule.setFormAdditionalTxt()
});
YUE.onAvailable(HDT.formSchedule.formAdditional,function(){YUD.get(HDT.formSchedule.formAdditional).value=HDT.formSchedule.formAdditionalTxt
});
YUE.addListener(HDT.formSchedule.formAdditional,"keypress",function(a){HDT.util.maxLength(a,this,255)
});
YUE.addListener(HDT.formSchedule.formOpenLogin,"click",function(){HD.Profile.profile.view.chooseLogin()
});
HD.Config.profile={showSoftProfile:true,initCallback:function(){HDT.formSchedule.getUserAndPopulate();
var a={update:function(b,c){if(b==HD.Profile.profile.model.getEventName("LOGIN_SUCCESSFUL")||b==HD.Profile.profile.model.getEventName("REGISTER_SUCCESSFUL")){HDT.formSchedule.getUserAndPopulate()
}}};
HD.util.Common.getObservable().addObserver(a);
HD.Profile.profile.model.addObserver(a)
}};
if(HDT.global.dwp){HD.get("sourceType").value="DWP"
}else{HD.get("sourceType").value="TEST_RIDE"
}},initSubmitListener:function(){YUE.addListener(HDT.formSchedule.formScheduleSubmitId,"click",HDT.formSchedule.submit)
},showSpinner:function(){},hideSpinner:function(){},hide:function(a){HD.get(a).style.display="none"
},show:function(a){HD.get(a).style.display="block"
},getUserAndPopulate:function(){var a=this;
this.showSpinner();
HD.Profile.profile.model.getUser(function(b){if((null!=b)&&b.success&&(null!=b.user)){if(HDT.global.dwp){a.hide("satr-loggedin");
a.hide("satr-not-loggedin")
}else{a.show("satr-loggedin");
a.hide("satr-not-loggedin");
a.populateForm(b.user);
HD.get("token").value=b.token
}}else{if(HDT.global.dwp){a.hide("satr-loggedin");
a.hide("satr-not-loggedin")
}else{a.hide("satr-loggedin");
a.show("satr-not-loggedin")
}}a.hideSpinner()
})
},populateFormField:function(e,b,f){if(null!=e){var d=(null!=e[f]?e[f]:"");
var c=YUD.get(HDT.formSchedule.formSchedule);
var a=c[b];
if(a!=null){a.value=d
}}},populateForm:function(a){this.populateFormField(a,"firstName","firstName");
this.populateFormField(a,"lastName","lastName");
this.populateFormField(a,"birthdate","birthday");
this.populateFormField(a,"email","userName");
this.populateFormField(a,"phoneNumber","phone");
this.populateFormField(a.address,"address1","addressLine1");
this.populateFormField(a.address,"address2","addressLine2");
this.populateFormField(a.address,"city","city");
this.populateFormField(a.address,"state","state");
this.populateFormField(a.address,"zip","zip");
if("Male"==a.gender){HD.get("genderMale").click()
}else{if("Female"==a.gender){HD.get("genderFemale").click()
}}},submit:function(b){HDT.formSchedule.formSubmitButtonHTML=YUD.get(HDT.formSchedule.formScheduleSubmitContainer).innerHTML;
YUD.get(HDT.formSchedule.formScheduleSubmitContainer).innerHTML=HDT.formSchedule.loadingImageHTML;
HDT.formSchedule.setFormAdditionalTxt();
HD.util.form.jsonSubmit(HDT.formSchedule.formSchedule,HDT.formSchedule.jsonObjectName,HDT.constants.RESTFORMPOSTPATH,HDT.formSchedule.handleData);
var a=YUD.get(HDT.formSchedule.formSchedule);
HDT.formSchedule.hbxObject.bike=a[HDT.formSchedule.formModel].value;
HDT.formSchedule.hbxObject.dealerId=a[HDT.formSchedule.formDealer].value;
HDT.formSchedule.hbxObject.date=a[HDT.formSchedule.formDate].value;
HDT.formSchedule.hbxObject.timeOfDay=HDT.util.getInputRadioValue(a[HDT.formSchedule.formTime]);
HDT.formSchedule.hbxObject.contactType=HDT.util.getInputRadioValue(a[HDT.formSchedule.formContact]);
return false
},setFormAdditionalTxt:function(){if(HDT.formSchedule.formAdditionalTxt==YUD.get(HDT.formSchedule.formAdditional).value){YUD.get(HDT.formSchedule.formAdditional).value=""
}},formContactClicked:function(b){var a=HDT.formSchedule.preferredContactPhoneTxt;
if("phone"==b.value){a+="*"
}YUD.get(HDT.formSchedule.preferredContactPhoneLabel).innerHTML=a
},formValidLicenseClicked:function(d){if("false"==d.value){var c="validLicenseOverlay";
var b="<div id='closeButtonContainer'><a href='javascript:void(0)' class='closeButton xButtonType'></a></div></div><div class='validLicenseOverlayContent'><h2>You will need a motorcycle endorsement on your driver's license in order to test ride a bike at your Harley-Davidson dealership.</h2><p>Never ridden before? Don't sweat it. Search for <a href='/wcm/Content/Pages/Get_On_A_Bike/Learn_To_Ride/new_rider_course.jsp'>New Rider Courses</a> at a dealership near you.</p><p><a href='javascript:void(0)' class='closeButton'>OK</a></p></div>";
var a=new HD.util.Overlay.OverlayConfig(c,b);
HDT.formSchedule.validLicenseOverlay=new HD.util.Overlay.Overlay(a);
HDT.formSchedule.validLicenseOverlay.showOverlay(function(){var e=YUD.getElementsByClassName("closeButton");
YUE.addListener(e,"click",function(){HDT.formSchedule.validLicenseOverlay.destroyOverlay()
})
})
}},handleData:function(a){if(false==a.success){HDT.validationErrorHandling.handleClientError(HDT.constants.SERVICEUNAVAILABLETXT);
HDT.formSchedule.resetFormButton();
window.scrollTo(0,0);
return
}validationResponseObject=new HDT.ValidationResponse.validationResponse(a.scheduleResponse);
if(validationResponseObject.wasSuccessful){var b=HDT.constants.CONFIRMATIONPAGEURL+"?"+HDT.constants.CONFIRMATIONIDURLPARAM+"="+a.scheduleResponse.encryptedTestRideId;
if(HDT.global.dwp){b+="&"+HDT.global.dwpQueryString
}window.location.href=b;
HDT.hbx.track("submit",HDT.formSchedule.hbxObject)
}else{validationResponseObject.replaceErrorFieldName(HDT.formPage.hiddenCalendarInput,HDT.formPage.calendarContainer);
HDT.validationErrorHandling.handleFormErrors(validationResponseObject);
HDT.formSchedule.resetFormButton();
window.scrollTo(0,0)
}},resetFormButton:function(){YUD.get(HDT.formSchedule.formScheduleSubmitContainer).innerHTML=HDT.formSchedule.formSubmitButtonHTML;
YUE.onContentReady(HDT.formSchedule.formScheduleSubmitContainer,function(){HDT.formSchedule.initSubmitListener()
})
}};
if(typeof HD=="undefined"||!HD){var HD={}
}if(typeof HD.testRide=="undefined"||!HD.testRide){HD.testRide={}
}var HDT=HD.testRide;
HDT.Dealer={dealer:function(h,c,b,g,e,f,a,d){this.id=h||"";
this.name=c||"";
this.contact=b||new Object();
this.schedule=g||"";
this.calendar=e||new Array();
this.availableBikes=f||new Array();
this.bikeFound=a||false;
this.leadDays=d||0
}};
HDT.Dealer.dealer.prototype={getCalendar:function(){return this.calendar
},getAvailableBikesHTML:function(e,d){var c='<select id="'+e+'" name="'+e+'"><option value="" selected="selected">'+d+"</option>";
for(var a=0;
a<this.availableBikes.length;
a++){c+='<optgroup label="'+this.availableBikes[a].displayName+'">';
for(var b=0;
b<this.availableBikes[a].models.length;
b++){c+='<option value="'+this.availableBikes[a].models[b].modelCode+'">'+this.availableBikes[a].models[b].displayName+"</option>"
}c+="</optgroup>"
}c+="</select>";
return c
},getPrimaryDealerHTML:function(){var a="<strong>"+this.name+"</strong><br/>"+this.contact.address1+"<br/>"+this.contact.city+", "+this.contact.state+" "+this.contact.zip;
return a
},getOtherDealerHTML:function(){var a="<li><p><strong>"+this.name+"</strong><br/>"+this.contact.address1+"<br/>"+this.contact.city+", "+this.contact.state+" "+this.contact.zip+'</p><a href="javascript:void(0)" id='+this.id+'><img src="/en_US/Media/images/Content/Pictorial/Test_Ride_a_Bike/btn_select.png" width="52" height="22" alt="Select"/></a></li>';
return a
},isBikeAvailable:function(c){for(var a=0;
a<this.availableBikes.length;
a++){for(var b=0;
b<this.availableBikes[a].models.length;
b++){if(this.availableBikes[a].models[b].modelCode==c){return true
}}}return false
}};
if(typeof HD=="undefined"||!HD){var HD={}
}if(typeof HD.testRide=="undefined"||!HD.testRide){HD.testRide={}
}var HDT=HD.testRide;
var YUD=YAHOO.util.Dom;
var YUE=YAHOO.util.Event;
HDT.dealerSearch={hideEl:null,sendRequest:function(a,c){var b;
var d;
paramObject=new Object();
if(HDT.global.dwp&&HDT.global.dwpWithRelatedDealers&&a.dealerId&&a.relatedDealerIds){b=HDT.constants.RESTDWPDEALERPATH;
paramObject[HDT.constants.DEALERURLPARAMNAME]=encodeURIComponent(a.dealerId);
paramObject[HDT.constants.DWPRELATEDPARAMNAME]=encodeURIComponent(a.relatedDealerIds);
d=HDT.dealerSearch.handleDWPWithRelatedDealersData
}else{if(HDT.global.dwp&&a.dealerId){b=HDT.constants.RESTDWPDEALERPATH;
paramObject[HDT.constants.DEALERURLPARAMNAME]=encodeURIComponent(a.dealerId);
d=HDT.dealerSearch.handleDWPDealerData
}else{if(a.dealerId&&!a.bikeId){b=HDT.constants.RESTDEALERPATHBYID;
paramObject[HDT.constants.DEALERURLPARAMNAME]=encodeURIComponent(a.dealerId);
d=HDT.dealerSearch.handleDealerDataId
}else{if(a.bikeId&&a.dealerId){b=HDT.constants.RESTDEALERPATHBYID;
paramObject[HDT.constants.DEALERURLPARAMNAME]=encodeURIComponent(a.dealerId);
paramObject[HDT.constants.BIKEURLPARAMNAME]=encodeURIComponent(a.bikeId);
d=HDT.dealerSearch.handleDealerData
}else{b=HDT.constants.RESTDEALERPATH;
paramObject[HDT.constants.BIKEURLPARAMNAME]=(a.bikeId)?encodeURIComponent(a.bikeId):"";
paramObject[HDT.constants.ZIPCODEURLPARAMNAME]=(a.zipCode)?encodeURIComponent(a.zipCode):"";
paramObject[HDT.constants.CITYURLPARAMNAME]=(a.city)?encodeURIComponent(a.city):"";
paramObject[HDT.constants.STATEURLPARAMNAME]=(a.state)?encodeURIComponent(a.state):"";
d=HDT.dealerSearch.handleDealerData
}}}}if(YUD.get(c)){YUD.setStyle(c,"display","none")
}HDT.dealerSearch.writeLoader();
b+=".json";
paramObject[HDT.constants.CALENDARDAYSPARAM]=HDT.constants.CALENDARDAYSOUT;
HDT.rest.sendRequest("GET",b,paramObject,d)
},handleDealerData:function(a){a=a||null;
if(!HDT.dealerSearch.isValidData(a)){return false
}HDT.dealerSearch.createDealers(a);
var b=HDT.global.dealer[HDT.global.primaryDealer].bikeFound;
HDT.dealerSearch.removeLoader();
if(b){HDT.formPage.displayDealer()
}else{HDT.formPage.displayBikeNotFound()
}},handleDealerDataId:function(c){var b;
var a;
c=c||null;
if(!HDT.dealerSearch.isValidData(c)){return false
}HDT.dealerSearch.createDealers(c);
HDT.dealerSearch.removeLoader();
HDT.formPage.displayDealer()
},handleDWPDealerData:function(a){a=a||null;
if(!HDT.dealerSearch.isValidData(a)){return false
}HDT.dealerSearch.createDealers(a);
HDT.formPage.drawMainSelectBox();
HDT.dealerSearch.removeLoader();
HDT.formPage.displayDWPDealer()
},handleDWPWithRelatedDealersData:function(a){a=a||null;
if(!HDT.dealerSearch.isValidData(a)){return false
}HDT.dealerSearch.createDealers(a);
HDT.global.primaryDealer="";
HDT.global.dealerSelected="";
HDT.formPage.setDealer(HDT.global.dealerSelected);
HDT.dealerSearch.removeLoader();
HDT.formPage.displayDWPRelatedDealers()
},createDealers:function(d){var c;
var b;
HDT.global.dealer=new Object();
c=d.dealerResponse.primaryDealer;
b=new HDT.Dealer.dealer(c.id,c.name,c.contact,c.schedule,c.calendar,c.availableBikes,c.bikeFound,c.leadDays);
HDT.global.dealer[b.id]=b;
HDT.global.primaryDealer=b.id;
HDT.formPage.setDealer(b.id);
if(d.dealerResponse.otherDealers){for(var a=0;
a<d.dealerResponse.otherDealers.length;
a++){c=d.dealerResponse.otherDealers[a];
b=new HDT.Dealer.dealer(c.id,c.name,c.contact,c.schedule,c.calendar,c.availableBikes,c.bikeFound,c.leadDays);
HDT.global.dealer[b.id]=b
}}},isValidData:function(a){if(!a.success&&!HDT.global.dwp){HDT.dealerSearch.removeLoader();
HDT.formPage.displaySearch();
HDT.validationErrorHandling.handleClientError(HDT.constants.SERVICEUNAVAILABLETXT);
window.scrollTo(0,0);
return false
}else{if(!a.success&&HDT.global.dwp){HDT.dealerSearch.removeLoader();
HDT.validationErrorHandling.handleClientError(HDT.constants.SERVICEUNAVAILABLETXT);
window.scrollTo(0,0);
return false
}else{if(!a.dealerResponse){HDT.dealerSearch.removeLoader();
HDT.formPage.displaySearch(true);
return false
}else{validationResponseObject=new HDT.ValidationResponse.validationResponse(a.dealerResponse);
if(validationResponseObject.wasSuccessful){return true
}else{HDT.validationErrorHandling.handleFormErrors(validationResponseObject);
HDT.dealerSearch.removeLoader();
if(!HDT.global.dwp){HDT.formPage.displaySearch()
}window.scrollTo(0,0);
return false
}}}}},writeLoader:function(){HDT.dealerSearch.lock();
YUE.onAvailable(HDT.formPage.dealerLocationContainer,function(){var b=YUD.get(HDT.formPage.dealerLocationContainer);
var a=document.createElement("div");
a.id=HDT.constants.DEALERLOADINGID;
a.innerHTML=HDT.constants.DEALERLOADINGHTML;
b.appendChild(a)
})
},removeLoader:function(){HDT.dealerSearch.unlock();
if(YUD.get(HDT.constants.DEALERLOADINGID)&&YUD.get(HDT.formPage.dealerLocationContainer)){YUD.get(HDT.formPage.dealerLocationContainer).removeChild(YUD.get(HDT.constants.DEALERLOADINGID))
}},lock:function(){HDT.validationErrorHandling.clearDealerLocalError();
YUD.get(HDT.formPage.selectBikeMain).disabled=true
},unlock:function(){YUD.get(HDT.formPage.selectBikeMain).disabled=false
}};
if(typeof HD=="undefined"||!HD){var HD={}
}if(typeof HD.testRide=="undefined"||!HD.testRide){HD.testRide={}
}var HDT=HD.testRide;
HDT.DealerRequest={dealerRequest:function(d,a,e,c,f,b){this.bikeId=d||null;
this.zipCode=a||null;
this.city=e||null;
this.state=c||null;
this.dealerId=f||null;
this.relatedDealerIds=b||null
}};
if(typeof HD=="undefined"||!HD){var HD={}
}if(typeof HD.testRide=="undefined"||!HD.testRide){HD.testRide={}
}var HDT=HD.testRide;
var YUD=YAHOO.util.Dom;
var YUE=YAHOO.util.Event;
HDT.Paging={pageRendered:new YAHOO.util.CustomEvent("pageRendered"),pager:{},pagingPrevClass:"pagingPrev",pagingNextClass:"pagingNext",pagingActive:"pagingActive",navIdPrefix:"pagingItem_",pagingInactive:"pagingInactive",pagingDisabled:"pagingDisabled",paging:function(f,c,e,b,d){this.pagingData=f||{};
this.numberPerPage=c||3;
this.startPage=e||0;
this.pageLocation=b||window.body;
this.navLocation=d||window.body;
this.currentPage=e;
var g=0;
var a=new Array();
this.setPages=function(){page=new Array();
for(var h=1;
h<=this.pagingData.length;
h++){page.push(this.pagingData[h-1]);
if((h%this.numberPerPage)==0||h==this.pagingData.length){a[g]=page;
page=new Array();
g++
}}};
this.getPages=function(){return a
};
this.getNumberOfPages=function(){return g
}
}};
HDT.Paging.paging.prototype={init:function(a){HDT.Paging.pager=a;
HDT.Paging.pager.setPages()
},render:function(){HDT.Paging.pager.writePage(HDT.Paging.pager.currentPage)
},writePage:function(c){var b=HDT.Paging.pager.getPages();
var d="";
if(!b[c]){c=0
}HDT.Paging.pager.currentPage=c;
HDT.Paging.pager.writeNavigation();
for(var a=0;
a<HDT.Paging.pager.numberPerPage;
a++){if(b[c][a]){d+=b[c][a]
}}YUE.onAvailable(HDT.Paging.pager.pageLocation,function(){YUD.get(HDT.Paging.pager.pageLocation).innerHTML=d
});
YUE.onContentReady(HDT.Paging.pager.pageLocation,function(){HDT.Paging.pageRendered.fire()
})
},writeNavigation:function(){YUE.onAvailable(HDT.Paging.pager.navLocation,function(){var c=HDT.Paging.pager.getNumberOfPages();
var b='<ul><li><a class="'+HDT.Paging.pagingPrevClass+'" href="javascript:void(0)"><img src="/en_US/Media/images/Content/Pictorial/Test_Ride_a_Bike/icn_prev_arrow.gif" width="7" height="8" alt="Previous"/></a></li><li><a class="'+HDT.Paging.pagingPrevClass+'" href="javascript:void(0)">Prev</a></li>';
for(var a=0;
a<c;
a++){b+='<li><a id="'+HDT.Paging.navIdPrefix+a+'" href="javascript:void(0)" class="';
if(a==(HDT.Paging.pager.currentPage)){b+=HDT.Paging.pagingActive
}else{b+=HDT.Paging.pagingInactive
}b+='">'+(a+1)+"</a></li>"
}b+='<li><a class="'+HDT.Paging.pagingNextClass+'" href="javascript:void(0)">Next</a></li><li><a class="'+HDT.Paging.pagingNextClass+'" href="javascript:void(0)"><img src="/en_US/Media/images/Content/Pictorial/Test_Ride_a_Bike/icn_next_arrow.gif" width="6" height="8" alt="Next"/></a></li></ul>';
YUD.get(HDT.Paging.pager.navLocation).innerHTML=b;
YUE.onContentReady(HDT.Paging.pager.navLocation,function(){HDT.Paging.pager.attachPagingClickEvents()
})
})
},attachPagingClickEvents:function(){var b=YUD.getElementsByClassName(HDT.Paging.pagingPrevClass,"a",HDT.Paging.pager.navLocation);
var a=YUD.getElementsByClassName(HDT.Paging.pagingNextClass,"a",HDT.Paging.pager.navLocation);
var c=YUD.getElementsByClassName(HDT.Paging.pagingInactive,"a",HDT.Paging.pager.navLocation);
if(HDT.Paging.pager.currentPage>0){YUE.addListener(b,"click",function(){HDT.Paging.pager.showPrevious()
})
}else{YUD.addClass(b,HDT.Paging.pagingDisabled)
}if((HDT.Paging.pager.getNumberOfPages()-1)!=HDT.Paging.pager.currentPage){YUE.addListener(a,"click",function(){HDT.Paging.pager.showNext()
})
}else{YUD.addClass(a,HDT.Paging.pagingDisabled)
}YUE.addListener(c,"click",HDT.Paging.pager.showSelected)
},showSelected:function(){var a=parseInt(this.id.substring(HDT.Paging.navIdPrefix.length));
if(!isNaN(a)){HDT.Paging.pager.writePage(a)
}},showPrevious:function(){HDT.Paging.pager.writePage(HDT.Paging.pager.currentPage-1)
},showNext:function(){HDT.Paging.pager.writePage(HDT.Paging.pager.currentPage+1)
}};
if(typeof HD=="undefined"||!HD){var HD={}
}if(typeof HD.testRide=="undefined"||!HD.testRide){HD.testRide={}
}var HDT=HD.testRide;
HDT.Confirmation={confirmation:function(b,a){this.isDWP=a||false;
this.dealerId=b.testRideResponse.dealer.id||"";
this.dealerName=b.testRideResponse.dealer.name||"";
this.dealerSchedule=b.testRideResponse.dealer.schedule||"";
this.dealerAddress=b.testRideResponse.dealer.contact.address1||"";
this.dealerCity=b.testRideResponse.dealer.contact.city||"";
this.dealerCountry=b.testRideResponse.dealer.contact.country||"";
this.dealerState=b.testRideResponse.dealer.contact.state||"";
this.dealerZip=b.testRideResponse.dealer.contact.zip||"";
this.dealerEmail=b.testRideResponse.dealer.contact.testrideEmail||b.testRideResponse.dealer.contact.email||HDT.constants.HDONLINEEMAIL;
this.dealerWebsite=b.testRideResponse.dealer.website||"";
this.dealerPhone=b.testRideResponse.dealer.contact.phoneNumber||"";
this.dealerLatitude=b.testRideResponse.dealer.contact.latitude||"";
this.dealerLongitude=b.testRideResponse.dealer.contact.longitude||"";
this.bikeModel=b.testRideResponse.testRideForm.selectedBikeModel||"";
this.bikeDisplayName=b.testRideResponse.testRideForm.bikeDisplayName||"";
this.testRideDate=b.testRideResponse.testRideForm.calendarDate||"";
this.testRideTime=b.testRideResponse.testRideForm.preferredTime||"";
this.testRideFirstName=b.testRideResponse.testRideForm.firstName||"";
this.testRideLastName=b.testRideResponse.testRideForm.lastName||"";
this.testRideAddress1=b.testRideResponse.testRideForm.contact.address1||"";
this.testRideAddress2=b.testRideResponse.testRideForm.contact.address2||"";
this.testRideCity=b.testRideResponse.testRideForm.contact.city||"";
this.testRideState=b.testRideResponse.testRideForm.contact.state||"";
this.testRideZip=b.testRideResponse.testRideForm.contact.zip||"";
this.testRidePhoneNumber=b.testRideResponse.testRideForm.contact.phoneNumber||"";
this.testRideEmail=b.testRideResponse.testRideForm.contact.email||""
}};
HDT.Confirmation.confirmation.prototype={getAllContactInformationHTML:function(){var a="<ul><li><h3>TEST RIDE LOCATION</h3></li>";
a+='<li class="satr-some-loc">';
if(!this.isDWP){a+='<a target="_blank" href="'+this.dealerWebsite+'">'
}a+=this.dealerName;
if(!this.isDWP){a+=' <img src="/en_US/Media/images/Content/Pictorial/Test_Ride_a_Bike/icn_arrow_up.gif" width="9" height="9" alt="Location Name" border="0"/></a>'
}a+="</li>";
a+="<li><p>"+this.dealerAddress+"<br/>"+this.dealerCity+", "+this.dealerState+" "+this.dealerZip+"<br/>"+this.dealerPhone+"</p></li>";
a+="<li><h4>Test Ride Contact Information:</h4></li>";
a+='<li><a href="mailto:'+this.dealerEmail+'">'+this.dealerEmail+"</a></li>";
if(this.dealerWebsite&&this.dealerWebsite!=""){a+='<li class="satr-site"><h4>Website</h4></li>';
a+="<li>";
if(!this.isDWP){a+='<a target="_blank" href="'+this.dealerWebsite+'">'
}a+=this.dealerWebsite;
if(!this.isDWP){a+=' <img src="/en_US/Media/images/Content/Pictorial/Test_Ride_a_Bike/icn_arrow_up.gif" width="9" height="9" alt="Website" border="0"/></a>'
}a+="</li>"
}a+="</ul>";
return a
},getAllCustomerInformtionHTML:function(){var a='<ul class="satr-custInfo"><li><h3>Customer Information</h3></li>';
a+="<li><p>"+this.testRideFirstName+" "+this.testRideLastName;
if(this.testRideAddress1||this.testRideAddress2){a+="<br/>"+this.testRideAddress1+" "+this.testRideAddress2
}if(this.testRideCity&&this.testRideState&&this.testRideZip){a+="<br/>"+this.testRideCity+", "+this.testRideState+" "+this.testRideZip
}else{if(this.testRideCity&&this.testRideZip){a+="<br/>"+this.testRideCity+", "+this.testRideZip
}else{if(this.testRideState&&this.testRideZip){a+="<br/>"+this.testRideState+" "+this.testRideZip
}else{if(this.testRideZip){a+="<br/>"+this.testRideZip
}}}}if(this.testRideEmail){a+="<br/>"+this.testRideEmail
}if(this.testRidePhoneNumber){a+="<br/>"+this.testRidePhoneNumber
}a+="</p></li></ul>";
return a
},getScheduleHTML:function(){var a="<ul><li><h4>Hours of Operation:</h4></li>";
a+="<li>"+this.dealerSchedule+"</li></ul>";
return a
},getBikeImageLargeHTML:function(){var a='<img src="/en_US/Media/images/Content/Pictorial/Test_Ride_a_Bike/gallery_images/321x182_'+this.bikeModel+'_dom.jpg" width="321" height="182" alt="preferred bike" /><p>'+this.bikeDisplayName+"</p>";
return a
},getBikeImageSmallHTML:function(){var a='<h2>Details About Your Test Ride</h2><div><img width="246" height="139" alt="Bike" src="/en_US/Media/images/Content/Pictorial/Test_Ride_a_Bike/gallery_images/246x139_'+this.bikeModel+'_dom.jpg" /></div>';
return a
},getBikeInformationHTML:function(){var e="<ul><li><h3>PREFERRED MOTORCYCLE</h3></li>";
var d=HDT.util.stripTrademarks(this.bikeDisplayName.toLowerCase().replace(/ /g,"-"));
var c=HDT.constants.BIKEDETAILURL2011+d+".html";
var g=HDT.constants.PAYMENTESTURL2011;
if(HDT.util.isPre2011Bike(this.bikeModel)){c=HDT.constants.BIKEDETAILURLPRE2011+this.bikeModel;
g=HDT.constants.PAYMENTESTURLPRE2011
}e+="<li>"+this.bikeDisplayName+"</li>";
if(!this.isDWP){e+='<li><a href="javascript:void(0)" onclick="javascript:window.open(\'http://'+document.location.host+c+'\')">Bike Details <img src="/en_US/Media/images/Content/Pictorial/Test_Ride_a_Bike/icn_arrow_up.gif" width="9" height="9" alt="Bike Detail" border="0"/></a></li>';
e+='<li><a href="javascript:void(0)" onclick="javascript:window.open(\'http://'+document.location.host+g+this.bikeModel.toLowerCase()+'\')">Estimate Payments <img src="/en_US/Media/images/Content/Pictorial/Test_Ride_a_Bike/icn_arrow_up.gif" width="9" height="9" alt="Estimate Payments" border="0"/></a></li>'
}else{e+="<li>&nbsp;</li><li>&nbsp;</li>"
}e+='<li class="satr-test"><h3>TEST RIDE DATE</h3></li>';
var f=new Date(this.testRideDate);
var a=this.testRideTime.charAt(0).toUpperCase();
var b=this.testRideTime.slice(1);
e+="<li>"+HD.util.Date.format(f,"ddd, mmm d, yyyy")+" "+a+b+"</li></ul>";
return e
},getConfirmationHeader:function(){var a="<p>"+(this.testRideFirstName).toUpperCase()+", thank you for your request to schedule a test ride. ";
a+=this.dealerName+" will contact you within 1 business day (see dealer's hours of operation below) to finalize the details. ";
a+="If you don't hear from "+this.dealerName+" by then, please call them at ";
a+=this.dealerPhone+" to confirm your appointment.";
return a
},getDealerMapHTML:function(){var a="";
a+='<p><a target="_blank" href="'+this.dealerWebsite+'">'+this.dealerName+' <img src="/en_US/Media/images/Content/Pictorial/Test_Ride_a_Bike/icn_arrow_up.gif" width="9" height="9" alt="Location Name" border="0"/></a><br/>';
a+=this.dealerAddress+"<br/>"+this.dealerCity+", "+this.dealerState+" "+this.dealerZip+"<br/>"+this.dealerPhone+"</p>";
a+='<p>Email<br/><a href="mailto:'+this.dealerEmail+'">'+this.dealerEmail+"</a></p>";
a+='<p>Website<br/><a target="_blank" href="'+this.dealerWebsite+'">'+this.dealerWebsite+' <img src="/en_US/Media/images/Content/Pictorial/Test_Ride_a_Bike/icn_arrow_up.gif" width="9" height="9" alt="Website" border="0"/></a></p>';
return a
},getDealerId:function(){return this.dealerId
},getDealerName:function(){return this.dealerName
},getDealerSchedule:function(){return this.dealerSchedule
},getDealerAddress:function(){return this.dealerAddress
},getDealerCity:function(){return this.dealerCity
},getDealerCountry:function(){return this.dealerCountry
},getDealerState:function(){return this.dealerState
},getDealerZip:function(){return this.dealerZip
},getDealerEmail:function(){return this.dealerEmail
},getDealerWebsite:function(){return this.dealerWebsite
},getDealerPhone:function(){return this.dealerPhone
},getDealerLatitude:function(){return this.dealerLatitude
},getDealerLongitude:function(){return this.dealerLongitude
},getBikeModel:function(){return this.bikeModel
},getBikeDisplayName:function(){return this.bikeDisplayName
},getTestRideDate:function(){return this.testRideDate
},getTestRideTime:function(){return this.testRideTime
},getTestRideFirstName:function(){return this.testRideFirstName
},getTestRideLastName:function(){return this.testRideLastName
},getTestRideAddress1:function(){return this.testRideAddress1
},getTestRideAddress2:function(){return this.testRideAddress2
},getTestRideCity:function(){return this.testRideCity
},getTestRideState:function(){return this.testRideState
},getTestRideZip:function(){return this.testRideZip
},getTestRidePhoneNumber:function(){return this.testRidePhoneNumber
},getTestRideEmail:function(){return this.testRideEmail
}};
if(typeof HD=="undefined"||!HD){var HD={}
}if(typeof HD.testRide=="undefined"||!HD.testRide){HD.testRide={}
}var HDT=HD.testRide;
HDT.confirmationPage={confirmationId:null,pageContainer:"satr-body-content",confirmationHeader:"confirmationHeader",bikeImage:"bikeImage",bikeInfo:"bikeInfo",testRideLocation:"testRideLocation",testRideSchedule:"testRideSchedule",testRideCancel:"testRideCancel",init:function(){HDT.confirmationPage.handleParams()
},handleParams:function(){HDT.confirmationPage.confirmationId=HDT.util.getRequestParam(HDT.constants.CONFIRMATIONIDURLPARAM);
if(""!=HDT.confirmationPage.confirmationId&&HDT.confirmationPage.confirmationId!=null){HDT.confirmationPage.writeLoader();
var a=HDT.constants.CONFIRMATIONURL+encodeURIComponent(HDT.confirmationPage.confirmationId);
HDT.rest.sendRequest("GET",a,null,HDT.confirmationPage.handleConfirmationData)
}else{HDT.confirmationPage.writeConfirmationNotFound()
}},handleConfirmationData:function(b){b=b||null;
if(b.testRideResponse.success){var a=HDT.util.getRequestParam(HDT.constants.DWPDEALERURLPARAMNAME)!=null;
confirmationObject=new HDT.Confirmation.confirmation(b,a);
HDT.confirmationPage.writePage(confirmationObject)
}else{HDT.confirmationPage.writeConfirmationNotFound(b.testRideResponse)
}},writePage:function(a){YUE.onAvailable(HDT.confirmationPage.confirmationHeader,function(){YUD.get(HDT.confirmationPage.confirmationHeader).innerHTML=a.getConfirmationHeader()
});
YUE.onAvailable(HDT.confirmationPage.bikeImage,function(){YUD.get(HDT.confirmationPage.bikeImage).innerHTML=a.getBikeImageSmallHTML()
});
YUE.onAvailable(HDT.confirmationPage.bikeInfo,function(){YUD.get(HDT.confirmationPage.bikeInfo).innerHTML=a.getBikeInformationHTML()
});
YUE.onAvailable(HDT.confirmationPage.testRideLocation,function(){YUD.get(HDT.confirmationPage.testRideLocation).innerHTML=a.getAllContactInformationHTML()+a.getAllCustomerInformtionHTML()
});
YUE.onAvailable(HDT.confirmationPage.testRideSchedule,function(){YUD.get(HDT.confirmationPage.testRideSchedule).innerHTML=a.getScheduleHTML()
});
YUE.onAvailable(HDT.confirmationPage.testRideCancel,function(){YUD.setStyle(HDT.confirmationPage.testRideCancel,"display","block")
});
HDT.map.init(a)
},writeConfirmationNotFound:function(a){a=a||null;
if(a){HDT.validationErrorHandling.handleConfirmationRequestErrors(a,HDT.confirmationPage.confirmationHeader)
}else{HDT.validationErrorHandling.handleConfirmationRequestClientErrors(HDT.constants.CONFIRMATIONERRORTXT,HDT.confirmationPage.confirmationHeader)
}},writeLoader:function(){YUE.onAvailable(HDT.confirmationPage.confirmationHeader,function(){var b=YUD.get(HDT.confirmationPage.confirmationHeader);
var a=document.createElement("div");
a.id=HDT.constants.DEALERLOADINGID;
a.innerHTML=HDT.constants.DEALERLOADINGHTML;
b.appendChild(a)
})
}};
if(typeof HD=="undefined"||!HD){var HD={}
}if(typeof HD.testRide=="undefined"||!HD.testRide){HD.testRide={}
}var HDT=HD.testRide;
var YUD=YAHOO.util.Dom;
var YUE=YAHOO.util.Event;
HDT.map={confirmationObject:null,dealerData:null,dealerLocation:null,map:null,mapContainer:"hdMapContainer",mapLocation:"hdMap",routeContainer:"hdMapRouteContainer",routeLocation:"hdRoute",newDirectionsLink:"hdMapNewDirections",mapLoadingDiv:"mapLoadingDiv",mapSearchContainer:"hdMapSearchAddress",hdMapSearchAddressError:"hdMapSearchAddressError",hdMapSearchAddressErrorTxt:"We're sorry but we could not location your starting address. Please enter a new starting address.",dealerLocationImage:"/testride/media/images/ico_testRide_map.gif",init:function(a){HD.util.Map.LOGGING=true;
if(!a||!YUD.get(HDT.map.mapLocation)||!YUD.get(HDT.map.routeContainer)||!YUD.get(HDT.map.routeLocation)){HDT.map.drawClientError();
return
}YUE.addListener(HDT.map.newDirectionsLink,"click",function(){HDT.map.displayAddressSearch()
});
YUE.addListener("searchAddressForm","submit",function(b){YUE.stopEvent(b);
HDT.map.handleSearchSubmit()
});
HD.util.Map.mapLoadedError.subscribe(function(){HDT.map.drawMapLoadError()
});
HD.util.Map.createLocationLoaded.subscribe(function(){HDT.map.removeLocationLoading()
});
HD.util.Map.createLocationError.subscribe(function(){HDT.map.drawClientLocationError()
});
HD.util.Map.directionsLoaded.subscribe(function(){HDT.map.removeDirectionLoading()
});
HD.util.Map.directionsLoadedError.subscribe(function(){HDT.map.createLocation(HDT.map.dealerLocation,HDT.map.dealerData);
HDT.map.drawClientLocationError()
});
HDT.map.initMap(a)
},initMap:function(a){HDT.map.confirmationObject=a;
HDT.map.map=new HD.util.Map.map(HDT.map.mapLocation);
if(!HDT.map.map.getMap()){return
}var i=HDT.map.confirmationObject.getDealerName();
var b=HDT.map.confirmationObject.getDealerMapHTML();
var g=HDT.map.confirmationObject.getDealerLatitude();
var d=HDT.map.confirmationObject.getDealerLongitude();
var c=HDT.map.confirmationObject.getDealerAddress();
var h=HDT.map.confirmationObject.getDealerCity();
var f=HDT.map.confirmationObject.getDealerState();
var e=HDT.map.confirmationObject.getDealerZip();
HDT.map.dealerLocation=new HD.util.Map.location(g,d,c,h,f,e);
HDT.map.dealerData=new HD.util.Map.displayData(i,b,null,HDT.map.dealerLocationImage);
HDT.map.map.isLocation(HDT.map.dealerLocation,function(o){if(o){var l=HDT.map.confirmationObject.getTestRideAddress1()+" "+HDT.map.confirmationObject.getTestRideAddress2();
var k=HDT.map.confirmationObject.getTestRideCity();
var j=HDT.map.confirmationObject.getTestRideState();
var m=HDT.map.confirmationObject.getTestRideZip();
var n=new HD.util.Map.location(null,null,l,k,j,m);
HDT.map.drawConfirmationMap(n)
}else{HDT.map.drawMapLoadError()
}})
},drawConfirmationMap:function(a){HDT.map.displayLoading();
HDT.map.map.isLocation(a,function(b){if(b){HDT.map.createDirections(a,HDT.map.dealerLocation,HDT.map.dealerData)
}else{HDT.map.createLocation(HDT.map.dealerLocation,HDT.map.dealerData);
HDT.map.drawClientLocationError()
}})
},createLocation:function(b,a){HDT.map.map.createLocation(b,a)
},createDirections:function(c,b,a){HDT.map.map.createDirections(HDT.map.routeLocation,c,b,a)
},drawMapLoadError:function(){if(!YUD.get(HDT.map.mapContainer)){return
}YUD.get(HDT.map.mapContainer).innerHTML=""
},drawClientLocationError:function(){if(!YUD.get(HDT.map.mapContainer)){return
}HDT.validationErrorHandling.mainFormErrorId=HDT.map.hdMapSearchAddressError;
HDT.validationErrorHandling.handleClientError(HDT.map.hdMapSearchAddressErrorTxt);
HDT.map.displayAddressSearch()
},displayAddressSearch:function(){YUD.setStyle(HDT.map.routeContainer,"display","none");
YUD.setStyle(HDT.map.mapSearchContainer,"display","block")
},hideDisplayAddressSearch:function(){YUD.setStyle([HDT.map.mapSearchContainer,HDT.map.hdMapSearchAddressError],"display","none");
YUD.get(HDT.map.hdMapSearchAddressError).innerHTML=""
},handleSearchSubmit:function(){var c=YUD.get("address").value;
var b=YUD.get("city").value;
var a=YUD.get("state").value;
var d=YUD.get("zip").value;
var e=new HD.util.Map.location(null,null,c,b,a,d);
HDT.map.hideDisplayAddressSearch();
HDT.map.drawConfirmationMap(e);
HDT.map.map.clearDirections()
},displayLoading:function(){YUD.setStyle(HDT.map.mapLocation,"visibility","hidden");
YUD.setStyle(HDT.map.routeContainer,"display","none");
var b=YUD.get(HDT.map.mapContainer);
var a=document.createElement("div");
a.id=HDT.map.mapLoadingDiv;
a.innerHTML=HDT.constants.DEALERLOADINGHTML+"<br/><p>Loading Map...</p>";
b.appendChild(a)
},removeLocationLoading:function(){HDT.map.removeLoader();
YUD.setStyle(HDT.map.mapLocation,"visibility","visible")
},removeDirectionLoading:function(){HDT.map.removeLoader();
YUD.setStyle(HDT.map.mapLocation,"visibility","visible");
YUD.setStyle(HDT.map.routeContainer,"display","block")
},removeLoader:function(){YUD.get(HDT.map.mapContainer).removeChild(YUD.get(HDT.map.mapLoadingDiv))
}};
if(typeof HD=="undefined"||!HD){var HD={}
}if(typeof HD.testRide=="undefined"||!HD.testRide){HD.testRide={}
}var HDT=HD.testRide;
var YUD=YAHOO.util.Dom;
var YUE=YAHOO.util.Event;
HDT.dealerFollowUp={dealerFollowUpParam:"followUp",dealerFollowUp:null,confirmationCodeParam:"confirmation",confirmationCode:null,followUpMsgContainer:"dealerFollowup",followUpYesScheduled:"yesScheduled",followUpYesNotScheduled:"yesNotScheduled",followUpNo:"no",confirmationDetailsContainer:"confirmationDetails",bikeImageContainer:"bikeImagecontainer",paymentEstimatorLink:"paymentEstimator",followUpYesHTML:"enjoy your Harley-Davidson<sup>&reg;</sup> test ride experience.<br/> We look forward to seeing you out there.",followUpNoHTML:"we apologize for any inconvenience. We'll follow up with your test ride dealer immediately. But please call the dealer directly to confirm the details of your test ride appointment.",init:function(){HDT.dealerFollowUp.handleParams()
},handleParams:function(){HDT.dealerFollowUp.dealerFollowUp=HDT.util.getRequestParam(HDT.dealerFollowUp.dealerFollowUpParam);
HDT.dealerFollowUp.confirmationCode=HDT.util.getRequestParam(HDT.dealerFollowUp.confirmationCodeParam);
if(""!=HDT.dealerFollowUp.confirmationCode&&HDT.dealerFollowUp.confirmationCode!=null){var a=HDT.constants.CONFIRMATIONURL+encodeURIComponent(HDT.dealerFollowUp.confirmationCode);
HDT.rest.sendRequest("GET",a,null,HDT.dealerFollowUp.handleConfirmationResponse);
HDT.dealerFollowUp.sendFollowUp()
}else{HDT.dealerFollowUp.writeConfirmationNotFound()
}},displayFollowUpMsg:function(b){var a=b.getTestRideFirstName();
a.toUpperCase();
if((HDT.dealerFollowUp.followUpYesScheduled==HDT.dealerFollowUp.dealerFollowUp)||(HDT.dealerFollowUp.followUpYesNotScheduled==HDT.dealerFollowUp.dealerFollowUp)){YUE.onAvailable(HDT.dealerFollowUp.followUpMsgContainer,function(){YUD.get(HDT.dealerFollowUp.followUpMsgContainer).innerHTML="<h2>"+a+", "+HDT.dealerFollowUp.followUpYesHTML+"</h2>"
});
HDT.hbx.track("followUp","Yes")
}else{YUE.onAvailable(HDT.dealerFollowUp.followUpMsgContainer,function(){YUD.get(HDT.dealerFollowUp.followUpMsgContainer).innerHTML="<h2>"+a+", "+HDT.dealerFollowUp.followUpNoHTML+"</h2>"
});
HDT.hbx.track("followUp","No")
}},sendFollowUp:function(){var c=HDT.dealerFollowUp.followUpNo;
if(HDT.dealerFollowUp.followUpYesScheduled==HDT.dealerFollowUp.dealerFollowUp){c=HDT.dealerFollowUp.followUpYesScheduled
}else{if(HDT.dealerFollowUp.followUpYesNotScheduled==HDT.dealerFollowUp.dealerFollowUp){c=HDT.dealerFollowUp.followUpYesNotScheduled
}}postData=HDT.dealerFollowUp.dealerFollowUpParam+"="+c;
var a=HDT.constants.CONFIRMATIONURL+encodeURIComponent(HDT.dealerFollowUp.confirmationCode)+"/followUp";
var b=YAHOO.util.Connect.asyncRequest("POST",a,null,postData)
},handleConfirmationResponse:function(a){a=a||null;
if(a.testRideResponse.success){confirmationObject=new HDT.Confirmation.confirmation(a);
HDT.dealerFollowUp.displayFollowUpMsg(confirmationObject);
YUE.addListener(HDT.dealerFollowUp.paymentEstimatorLink,"click",function(){window.location.href=HDT.constants.PAYMENTESTURL+confirmationObject.bikeModel
});
YUE.onAvailable(HDT.dealerFollowUp.bikeImageContainer,function(){YUD.get(HDT.dealerFollowUp.bikeImageContainer).innerHTML=confirmationObject.getBikeImageLargeHTML()
});
YUE.onAvailable(HDT.dealerFollowUp.confirmationDetailsContainer,function(){YUD.get(HDT.dealerFollowUp.confirmationDetailsContainer).innerHTML=confirmationObject.getAllContactInformationHTML()
})
}else{HDT.dealerFollowUp.writeConfirmationNotFound(a.testRideResponse)
}},writeConfirmationNotFound:function(a){a=a||null;
if(a){HDT.validationErrorHandling.handleConfirmationRequestErrors(a,HDT.dealerFollowUp.followUpMsgContainer)
}else{HDT.validationErrorHandling.handleConfirmationRequestClientErrors(HDT.constants.CONFIRMATIONERRORTXT,HDT.dealerFollowUp.followUpMsgContainer)
}}};
if(typeof HD=="undefined"||!HD){var HD={}
}if(typeof HD.testRide=="undefined"||!HD.testRide){HD.testRide={}
}var HDT=HD.testRide;
var YUD=YAHOO.util.Dom;
var YUE=YAHOO.util.Event;
HDT.dealerSurvey={confirmationCodeParam:"confirmation",confirmationCode:null,bikeImageContainer:"bikeImagecontainer",paymentEstimatorLink:"paymentEstimator",errorMsgContainer:"surveyRequestError",init:function(){HDT.dealerSurvey.handleParams();
HDT.hbx.track("survey")
},handleParams:function(){HDT.dealerSurvey.confirmationCode=HDT.util.getRequestParam(HDT.dealerSurvey.confirmationCodeParam);
if(""!=HDT.dealerSurvey.confirmationCode&&HDT.dealerSurvey.confirmationCode!=null){var a=HDT.constants.CONFIRMATIONURL+encodeURIComponent(HDT.dealerSurvey.confirmationCode);
HDT.rest.sendRequest("GET",a,null,HDT.dealerSurvey.handleConfirmationResponse)
}else{HDT.dealerSurvey.writeConfirmationNotFound()
}},handleConfirmationResponse:function(a){a=a||null;
if(a.testRideResponse.success){confirmationObject=new HDT.Confirmation.confirmation(a);
YUE.addListener(HDT.dealerSurvey.paymentEstimatorLink,"click",function(){window.location.href=HDT.constants.PAYMENTESTURL+confirmationObject.bikeModel
});
YUE.onAvailable(HDT.dealerSurvey.bikeImageContainer,function(){YUD.get(HDT.dealerSurvey.bikeImageContainer).innerHTML=confirmationObject.getBikeImageLargeHTML()
})
}else{HDT.dealerSurvey.writeConfirmationNotFound(a.testRideResponse)
}},writeConfirmationNotFound:function(a){a=a||null;
if(a){HDT.validationErrorHandling.handleConfirmationRequestErrors(a,HDT.dealerSurvey.errorMsgContainer)
}else{HDT.validationErrorHandling.handleConfirmationRequestClientErrors(HDT.constants.CONFIRMATIONERRORTXT,HDT.dealerSurvey.errorMsgContainer)
}}};
if(typeof HD=="undefined"||!HD){var HD={}
}if(typeof HD.testRide=="undefined"||!HD.testRide){HD.testRide={}
}var HDT=HD.testRide;
var YUD=YAHOO.util.Dom;
var YUE=YAHOO.util.Event;
HDT.clientSurvey={question:function(b,g,d,f,c,h){var b=b||"";
var g=g||"";
var d=d||"";
var f=f||"";
var c=c||"";
var h=(typeof(h)=="function")?h:function(){return true
};
var e="";
var a=" is a required field";
this.getVersion=function(){return b
};
this.setVersion=function(i){b=i||""
};
this.getQuestionFormName=function(){return g
};
this.setQuestionFormName=function(i){g=i||""
};
this.getType=function(){return d
};
this.setType=function(i){d=i||""
};
this.getQuestionText=function(){return f
};
this.setQuestionText=function(i){f=i||""
};
this.getKey=function(){return c
};
this.setKey=function(i){c=i||""
};
this.getIsValid=function(){return h()
};
this.setIsValid=function(i){h=(typeof(i)=="function")?i:function(){return true
}
};
this.getAnswer=function(){return e||""
};
this.setAnswer=function(i){e=i||""
};
this.getErrorText=function(){var i=this.getKey();
if("4.4"==i){i="4.1"
}else{if("4.4.a"==i){i="4.1.a"
}}return"Question "+i+a
};
this.setErrorText=function(i){a=i||""
}
},questionsVersion:"",questions:new Array(),questionsArray:new Array(),submitButton:"submitSurvey",clientSurveyForm:"clientSurveyForm",clientSurveySubmitContainer:"clientSurveySubmitContainer",clientSurveySubmitHTML:"",didTakeTestRideFormName:"csuvDidTakeTestRide",didTakeOnDateFormName:"csuvDidTakeOnDate",whyDidntTakeFormName:"csuvTestRideWhyDidnt",textAreaWhyNot:"csuvWhyNot",textAreaSuggest:"csuvSuggest",textAreaOtherReason:"csuvDidntTakeOther",requiredErrorMsg:"Please complete all the required question before submitting your survey.",confirmationID:"",accordion:null,exitFormOverlay:null,accordionOpened:false,loadingImageHTML:"<img src='/testride/media/images/img_loader.gif' alt='survey submitting'/> <span class=\"hd_submitting\">Submitting ...</span>",init:function(){HDT.clientSurvey.confirmationID=HDT.util.getRequestParam(HDT.constants.CONFIRMATIONIDURLPARAM)||"";
HDT.clientSurvey.accordion=new HD.util.Accordion.accordion();
HDT.clientSurvey.createQuestions();
HDT.clientSurvey.questionHandling();
HDT.clientSurvey.initSubmit();
YUE.addListener(HDT.clientSurvey.textAreaWhyNot,"keypress",function(a){HDT.util.maxLength(a,this,255)
});
YUE.addListener(HDT.clientSurvey.textAreaOtherReason,"keypress",function(a){HDT.util.maxLength(a,this,255)
});
YUE.addListener(HDT.clientSurvey.textAreaSuggest,"keypress",function(a){HDT.util.maxLength(a,this,255)
})
},initSubmit:function(){YUE.addListener(HDT.clientSurvey.submitButton,"click",function(){HDT.clientSurvey.handleSubmit()
})
},questionHandling:function(){var b=YUD.getElementsBy(function(){return true
},"input");
for(var a=0;
a<b.length;
a++){if(HDT.clientSurvey.didTakeTestRideFormName==b[a].name){HDT.clientSurvey.didTakeTestRideFormNameListener(b[a])
}else{if(HDT.clientSurvey.didTakeOnDateFormName==b[a].name){HDT.clientSurvey.didTakeOnDateFormNameListener(b[a])
}else{if(HDT.clientSurvey.whyDidntTakeFormName==b[a].name){HDT.clientSurvey.whyDidntTakeFormNameListener(b[a])
}}}}},didTakeTestRideFormNameListener:function(a){YUE.addListener(a,"click",function(g){a=YUE.getTarget(g);
var h="tookTestRideFollowups";
var c="tookTestRide";
var d="didntTakeTestRide";
var b=YUD.getAncestorBy(a);
var f=YUD.getNextSibling(b);
HD.util.Accordion.accordionClosed.subscribe(function(){HDT.clientSurvey.didTakeTestRideFollowup(a,b,h,c,d)
});
if(HDT.clientSurvey.accordionOpened){HDT.clientSurvey.accordion.close(b);
YUD.setStyle(h,"overflow","hidden");
return
}HDT.clientSurvey.didTakeTestRideFollowup(a,b,h,c,d)
})
},didTakeTestRideFollowup:function(d,a,e,b,c){YUD.setStyle([b,c],"display","none");
if("Yes"==d.value){YUD.setStyle(b,"display","block")
}else{YUD.setStyle(c,"display","block")
}HDT.clientSurvey.accordionOpenedSubscribe(e);
HDT.clientSurvey.accordion.open(a);
HDT.clientSurvey.accordionOpened=false;
HD.util.Accordion.accordionClosed.unsubscribe()
},whyDidntTakeFormNameListener:function(a){YUE.addListener(a,"click",function(d){a=YUE.getTarget(d);
var b=YUD.getAncestorBy(a);
var c=YUD.getNextSibling(b);
if("Other"==a.value){HDT.clientSurvey.accordion.open(b)
}else{HDT.clientSurvey.accordion.close(b)
}})
},didTakeOnDateFormNameListener:function(a){YUE.addListener(a,"click",function(d){a=YUE.getTarget(d);
var b=YUD.getAncestorBy(a);
var c=YUD.getNextSibling(b);
if("No"==a.value){HDT.clientSurvey.accordion.open(b)
}else{HDT.clientSurvey.accordion.close(b)
}})
},accordionOpenedSubscribe:function(a){HD.util.Accordion.accordionOpened.subscribe(function(){YUD.setStyle(a,"height","auto");
YUD.setStyle(a,"overflow","visible");
HD.util.Accordion.accordionOpened.unsubscribe();
HDT.clientSurvey.accordionOpened=true
})
},handleSubmit:function(){HDT.clientSurvey.clientSurveySubmitHTML=YUD.get(HDT.clientSurvey.clientSurveySubmitContainer).innerHTML;
YUD.get(HDT.clientSurvey.clientSurveySubmitContainer).innerHTML=HDT.clientSurvey.loadingImageHTML;
var j=YUD.get("clientSurveyForm");
for(var i=0;
i<HDT.clientSurvey.questionsArray.length;
i++){var h=HDT.clientSurvey.questionsArray[i].getType();
var l="";
var a="";
if("radio"==h){a=HDT.clientSurvey.questionsArray[i].getQuestionFormName();
l=HDT.util.getInputRadioValue(j[a]);
HDT.clientSurvey.questionsArray[i].setAnswer(l)
}else{if("text"==h){a=HDT.clientSurvey.questionsArray[i].getQuestionFormName();
l=j[a].value;
HDT.clientSurvey.questionsArray[i].setAnswer(l)
}else{if("textarea"==h){a=HDT.clientSurvey.questionsArray[i].getQuestionFormName();
l=j[a].value;
HDT.clientSurvey.questionsArray[i].setAnswer(l)
}}}}var e=new Object();
var f=new Array();
for(var i=0;
i<HDT.clientSurvey.questionsArray.length;
i++){var k=HDT.clientSurvey.questionsArray[i].getIsValid();
if(!k){f.push(HDT.validationErrorHandling.createErrorNode(HDT.clientSurvey.questionsArray[i].getQuestionFormName(),HDT.clientSurvey.questionsArray[i].getErrorText(),null))
}}if(f.length>0){e[HDT.ValidationResponse.responseObjectWasSuccessfulKey]=false;
e[HDT.ValidationResponse.responseObjectErrorsKey]=f;
responseObject=new HDT.ValidationResponse.validationResponse(e);
HDT.validationErrorHandling.handleFormErrors(responseObject);
window.scrollTo(0,0);
YUD.get(HDT.clientSurvey.clientSurveySubmitContainer).innerHTML=HDT.clientSurvey.clientSurveySubmitHTML;
HDT.clientSurvey.initSubmit();
return
}var b=new Array();
for(var i=0;
i<HDT.clientSurvey.questionsArray.length;
i++){var c={};
c.questionText=HDT.clientSurvey.questionsArray[i].getQuestionText();
c.questionKey=HDT.clientSurvey.questionsArray[i].getKey();
c.questionAnswer=HDT.clientSurvey.questionsArray[i].getAnswer();
b.push(c)
}var g=new Object();
g.testrideSurveyForm={version:HDT.clientSurvey.questionsVersion,encryptedTestrideId:HDT.clientSurvey.confirmationID,answers:b};
YAHOO.util.Connect.setDefaultPostHeader(false);
YAHOO.util.Connect.initHeader("Content-Type","application/json; charset=utf-8");
var d=YAHOO.util.Connect.asyncRequest("POST",HDT.constants.SURVEYSUBMITPATH,{success:function(m){HDT.rest.handleResponse(m,HDT.clientSurvey.handleData)
},failure:function(m){HDT.validationErrorHandling.handleClientError(HDT.constants.SERVICEUNAVAILABLETXT);
window.scrollTo(0,0)
}},YAHOO.lang.JSON.stringify(g))
},handleData:function(a){validationResponseObject=new HDT.ValidationResponse.validationResponse(a.surveyResponse);
if(validationResponseObject.wasSuccessful){window.location.href=HDT.constants.SURVEYTHANKYOUPAGEURL+"?"+HDT.constants.CONFIRMATIONIDURLPARAM+"="+HDT.clientSurvey.confirmationID
}else{HDT.validationErrorHandling.handleFormErrors(validationResponseObject);
window.scrollTo(0,0);
YUD.get(HDT.clientSurvey.clientSurveySubmitContainer).innerHTML=HDT.clientSurvey.clientSurveySubmitHTML;
HDT.clientSurvey.initSubmit()
}},createQuestions:function(){var d=HDT.clientSurvey.questions;
var b=HDT.clientSurvey.questionsVersion;
for(var a=0;
a<d.length;
a++){var c=new HDT.clientSurvey.question(b,d[a][0],d[a][1],d[a][2],d[a][3],d[a][4]);
HDT.clientSurvey.questionsArray.push(c)
}},isAnswered:function(b){var a=HDT.clientSurvey.getQuestionByFieldName(b);
var c=a.getAnswer();
if(c&&(c!="")){return true
}return false
},isAnsweredWithValue:function(b,d){var a=HDT.clientSurvey.getQuestionByFieldName(b);
var c=a.getAnswer();
if(c==d){return true
}return false
},getQuestionByFieldName:function(b){for(var a=0;
a<HDT.clientSurvey.questionsArray.length;
a++){if(HDT.clientSurvey.questionsArray[a].getQuestionFormName()==b){return HDT.clientSurvey.questionsArray[a]
}}return new HDT.clientSurvey.question()
}};

