if(!window.IBDOM){
alert("IBDOM Not loaded!");
}
IBDOM.IBElement.methods["hide"]=function(){
this.style.display="none";
};
IBDOM.IBElement.methods["show"]=function(){
_a=arguments;
dv=_a[0]?_a[0]:"block";
this.style.display=dv;
};
function noop(){
}
function handleError(s){
if((location.href.indexOf("staging")!=-1)||(location.href.indexOf("stg-web")!=-1)||(location.href.indexOf("localhost")!=-1)||(location.href.indexOf("://172")!=-1)){
alert("ERROR: "+s);
}
}
if(window.DWREngine){
DWREngine.setErrorHandler(handleError);
}
function signOutResponse(_2){
if(document.cookie&&document.cookie.length>0){
var _3=new Date();
_3.setTime(0);
document.cookie="InternetBrandsProfileId=; expires="+_3.toGMTString()+"; path=/";
}
top.location.href="./search";
}
if(!window.imageUrlPrefix){
imageUrlPrefix="//cdcssl.ibsrv.net";
}
if(!window.dynImageUrlPrefix){
dynImageUrlPrefix="//www.carsdirect.com";
}
AKAMAI_RESIZE_PREFIX=dynImageUrlPrefix+"/used_cars/images/autoResize?";
IMAGE_CACHE=new Array();
BLANK_IMAGE_URL="//cdcssl.ibsrv.net/common/x.gif";
function addImageToCache(_4){
theImage=IMAGE_CACHE[scape(_4)];
if(!theImage){
theImage=IMAGE_CACHE[scape(_4)]=new Image();
theImage.src=BLANK_IMAGE_URL;
theImage.srcToProcess=_4;
}
return theImage;
}
function processCachedImages(){
for(imgKey in IMAGE_CACHE){
if(!IMAGE_CACHE[imgKey].src||(theImage.src==BLANK_IMAGE_URL)){
IMAGE_CACHE[imgKey].src=IMAGE_CACHE[imgKey].srcToProcess;
}
}
}
function findElement(e,c,_7){
foundElement=false;
te=e;
while(te&&!foundElement){
if(te&&te.tagName&&(te.tagName.toLowerCase()==_7)&&te.className&&(te.className.indexOf(c)!=-1)){
foundElement=te;
}else{
te=te.parentNode;
}
}
return te;
}
function freezeEvent(e){
if(e.preventDefault){
e.preventDefault();
}
e.returnValue=false;
e.cancelBubble=true;
if(e.stopPropagation){
e.stopPropagation();
}
return false;
}
function getEvent(_9){
return (_9?_9:window.event);
}
function getEventElement(e){
return (e.srcElement?e.srcElement:(e.target?e.target:e.currentTarget));
}
function populateSelect(_b,_c,_d,_e,_f,_10){
_b.removeAllChildren();
matchingIndex=0;
if(_d){
firstOption=_b.appendChild(document.createElement("option"));
firstOption.text=_d;
firstOption.value=_e;
}
selectMatch=false;
for(mcount=0;(selectItem=_c[mcount]);mcount++){
opt=_b.appendChild(document.createElement("option"));
opt.text=opt.value=selectItem;
if(_f&&(_f!="undefined")&&(_f.toLowerCase()==opt.value.toLowerCase())){
opt.selected="selected";
selectMatch=true;
}
}
if(!selectMatch){
_b.selectedIndex=0;
}
if(_10){
setTimeout(function(){
_10.call();
},0);
}
}
function registerEvent(o,_12,_13){
if(o.addEventListener){
o.addEventListener(_12,_13,false);
}else{
if(o.attachEvent){
o.attachEvent("on"+_12,_13);
}else{
o["on"+_12]=_13;
}
}
}
function selectPullDownValue(po,v){
found=false;
for(i=0;opt=po.options[i];i++){
if(opt.value==v){
found=true;
opt.selected=true;
}else{
opt.selected=false;
}
}
if(found){
changeAction=po.onchange;
if(changeAction){
po.onchange.call();
}
}
}
function scape(s){
return window.encodeURIComponent?window.encodeURIComponent(s):escape(s);
}
function getStrippedWhite(s){
return s.replace(/[ \r\n\t\f\s]+/gi,"");
}
function getTrimmed(s){
return s.replace(/^[ \r\n\t\f\s]+/gi,"").replace(/[ \r\n\t\f\s]+$/gi,"");
}
function getInt(s){
s=s.replace(/^ *0+/gi,"");
if((s=="")||(s.indexOf(".")==0)){
s=0;
}
i=parseInt(s);
return i;
}
function error(_1a){
if($e("messages")){
$e("messages").innerHTML+=_1a+"<br />";
}else{
alert(_1a);
}
}
function debugObject(obj){
if($e("messages")){
for(var key in obj){
debug(key+" = "+obj[key]);
}
}
}
function debug(_1d){
if($e("messages")){
$e("messages").innerHTML+=_1d+"<br />";
}
}
function setPermCookie(k,v){
document.cookie=k+"="+v+"; path=/; expires=Tue, 12 Mar 2030 19:17:48 GMT";
}
function getCookieValue(_20){
cFields=document.cookie.split("; ");
kanswer=null;
for(cc=0;!kanswer&&(ck=cFields[cc]);cc++){
cks=ck.split("=");
kanswer=((cks[0]==_20)?cks[1]:null);
}
return kanswer;
}
function getScrollX(){
var sx=0;
if(self.pageXOffset){
sx=self.pageXOffset;
}else{
if(document.documentElement&&document.documentElement.scrollLeft){
sx=document.documentElement.scrollLeft;
}else{
if(document.body){
sx=document.body.scrollLeft;
}
}
}
return sx;
}
function getScrollY(){
var sy=0;
if(self.pageYOffset){
sy=self.pageYOffset;
}else{
if(document.documentElement&&document.documentElement.scrollTop){
sy=document.documentElement.scrollTop;
}else{
if(document.body){
sy=document.body.scrollTop;
}
}
}
return sy;
}
function getWindowWidth(){
var ww=0;
if(self.innerWidth){
ww=self.innerWidth;
}else{
if(document.documentElement&&document.documentElement.clientWidth){
ww=document.documentElement.clientWidth;
}else{
if(document.body){
ww=document.body.clientWidth;
}
}
}
return ww;
}
function getWindowHeight(){
var wh=0;
if(self.innerHeight){
wh=self.innerHeight;
}else{
if(document.documentElement&&document.documentElement.clientHeight){
wh=document.documentElement.clientHeight;
}else{
if(document.body){
wh=document.body.clientHeight;
}
}
}
return wh;
}
function makeWindow(u,w,h){
window.open(u,"","width="+w+",height="+h+",scrollbars,resizable,status,toolbar,titlebar");
}
eLA_Win=null;
eLA_url="//www.carsdirect.com/Advisor/AdvisorMainFrame.html";
function open_eLA_Window(){
if(!eLA_Win||eLA_Win.closed){
eLA_Win=window.open(eLA_url,"eLA_Win","width=378,height=465,resizable=0");
}else{
if(!eLA_Win.closed){
eLA_Win.focus();
}
}
}
function populateMakes(_28){
domMake=$e("makeControl").removeAllChildren();
selectedItem=0;
for(mcount=0;(makeItem=_28[mcount]);mcount++){
opt=IBDOM.IBElement.getAugmentedElement(domMake.appendChild(document.createElement("option")));
opt.text=opt.value=makeItem;
if(make.toLowerCase()==makeItem.toLowerCase()){
opt.selected=true;
opt.setClassValue("selected");
selectedItem=mcount;
PREVIOUS_SELECTED_MAKE=opt;
processMakeChange(domMake);
}
}
domMake.selectedIndex=selectedItem;
}
PREVIOUS_SELECTED_MAKE=null;
function processMakeChange(_29){
if(PREVIOUS_SELECTED_MAKE){
PREVIOUS_SELECTED_MAKE.unsetClassValue("selected");
}
if(_29.selectedIndex!=0){
chosenMake=IBDOM.IBElement.getAugmentedElement(_29.options[_29.selectedIndex]);
chosenMake.setClassValue("selected");
PREVIOUS_SELECTED_MAKE=chosenMake;
chosenMakeValue=chosenMake.value;
if(chosenMakeValue){
make=chosenMakeValue;
UsedCarSearchManager.getAllModelsWithListings(chosenMakeValue,populateModels);
}
}
}
function setModelsCount(_2a){
if(_2a&&(_2a!="null")){
$e("listingsCount").setTextData(IBDOM.Utils.getFormattedNumber(_2a));
$e("listingsMeta").setTextData(" listings");
}
}
function populateModels(_2b){
populateSelect($e("modelControl"),_2b,null,null,model);
}
PREVIOUS_SELECTED_MODEL=null;
function processModelChange(_2c){
if(PREVIOUS_SELECTED_MODEL){
PREVIOUS_SELECTED_MODEL.unsetClassValue("selected");
}
if(_2c.selectedIndex!=0){
chosenModel=IBDOM.IBElement.getAugmentedElement(_2c.options[_2c.selectedIndex]);
chosenModel.setClassValue("selected");
PREVIOUS_SELECTED_MODEL=chosenModel;
chosenModelValue=chosenModel.value;
if(chosenModelValue){
model=chosenModelValue;
}
}
}
function validateForm(_2d){
if(_2d.phone){
_2d.phone.value=stripPhone(_2d.phone.value);
}
if(_2d.altphone&&!(_2d.altphone.value==""||_2d.altphone.value==null)){
_2d.altphone.value=stripPhone(_2d.altphone.value);
}
var msg="";
if(_2d.firstName){
msg+=checkFirstName(_2d.firstName.value);
}
if(_2d.lastName){
msg+=checkLastName(_2d.lastName.value);
}
if(_2d.firstname&&!_2d.firstName){
msg+=checkFirstName(_2d.firstname.value);
}
if(_2d.lastname&&!_2d.lastName){
msg+=checkLastName(_2d.lastname.value);
}
if(_2d.email){
msg+=checkEmail(_2d.email.value);
}
if(_2d.phone){
msg+=checkPhone(_2d.phone.value);
}
if(_2d.altphone&&!(_2d.altphone.value==""||_2d.altphone.value==null)){
msg+=checkPhone(_2d.altphone.value);
}
if(_2d.email&&_2d.email2){
msg+=confirmEmail(_2d.email.value,_2d.email2.value);
}
if(msg!=""){
alert(msg);
return false;
}else{
if(msg==""){
return true;
}
}
}
function checkEmail(_2f){
var _30="";
if(!(/^[a-z0-9_+.-]+\@([a-z0-9-]+\.)+[a-z0-9]{2,4}$/i.test(_2f))){
_30="Please enter a valid email address.\n";
}
return _30;
}
function checkPhone(_31){
var _32="";
var _33=_31.replace(/[\(\)\.\-\ ]/g,"");
if(isNaN(_33)){
_32="The phone number contains illegal characters.";
}
if(!(_33.length==10)){
_32="Phone number should be ten digits. Make sure you included an area code.\n";
}
return _32;
}
function confirmEmail(_34,_35){
var _36="";
if(_34!=_35){
_36="Email addresses do not match.\n";
}
return _36;
}
function checkFirstName(_37){
var _38="";
_37=getStrippedWhite(_37);
if(_37==""){
_38="Please enter a first name.\n";
}
return _38;
}
function checkLastName(_39){
var _3a="";
_39=getStrippedWhite(_39);
if(_39==""){
_3a="Please enter a last name.\n";
}
return _3a;
}
function stripPhone(_3b){
var _3c=_3b.replace(/[\(\)\.\-\ ]/g,"");
return _3c;
}
function showInterstitialScreen(){
stit=$e("interstitial");
if(stit){
scrollX=getScrollX();
scrollY=getScrollY();
w=getWindowWidth();
h=getWindowHeight();
stit.style.width=(w+"px");
stit.style.height=(h+"px");
stit.style.top=(scrollX+"px");
stit.style.left=(scrollY+"px");
stit.show("block");
}
}
function hideInterstitialScreen(){
if($e("interstitial")){
$e("interstitial").hide();
}
}
function imgProcessor(dO){
this.src=dO.imgLocation;
}
function processImageRange(_3e,_3f,_40,_41,_42){
_40=IBDOM.IBElement.getAugmentedElement(_40);
if(_41[_3e]){
_40.removeAllChildren();
for(imgIndex=_3e;(imgIndex<=_3f)&&(_41&&(img=_41[imgIndex]));imgIndex++){
thumbLocation=IBDOM.Utils.getString([AKAMAI_RESIZE_PREFIX+"width=60&thumb=true&imageNum=",img.sequenceNumber,"&listingId=",img.usedListing.listingId]);
fullImageLocation=IBDOM.Utils.getString([AKAMAI_RESIZE_PREFIX+"width="+IMAGEVIEWER.big_image_width+"&imageNum=",img.sequenceNumber,"&listingId=",img.usedListing.listingId]);
imageObject={};
imageObject["altData"]=_42+" / Image: "+(imgIndex+1);
imageObject["imgLocation"]=thumbLocation;
imageObject["imgClickUrl"]=fullImageLocation;
_40.appendChild($t("previewImage","img").setDataProcessor(imgProcessor).populate(imageObject));
addImageToCache(fullImageLocation);
}
setTimeout(function(){
processCachedImages();
},IMAGEVIEWER.preload_big_images_wait);
}
IMAGEVIEWER.current_start=_3e;
}
IMAGEVIEWER={images_per_batch:10,current_start:0,current_viewer_listing:null,current_lister:null,current_tag_line:null,current_page:0,big_image_width:300,preload_big_images_wait:5000};
function showImageInViewer(_43,_44){
if(_43){
_44.gFEBCN("viewerImage","img").src=_43;
}
}
function imageViewerPreviousBatch(){
start=IMAGEVIEWER.current_start-IMAGEVIEWER.images_per_batch;
end=start+IMAGEVIEWER.images_per_batch-1;
if(start<0){
start=0;
end=IMAGEVIEWER.images_per_batch-1;
}
processI0mageRange(start,end,IMAGEVIEWER.current_lister,IMAGEVIEWER.current_viewer_listing,IMAGEVIEWER.current_tag_line);
}
function imageViewerNextBatch(){
start=IMAGEVIEWER.current_start+IMAGEVIEWER.images_per_batch;
end=start+IMAGEVIEWER.images_per_batch-1;
if(end>(IMAGEVIEWER.current_viewer_listing.length*2)){
start=0;
end=IMAGEVIEWER.images_per_batch-1;
}
processImageRange(start,end,IMAGEVIEWER.current_lister,IMAGEVIEWER.current_viewer_listing,IMAGEVIEWER.current_tag_line);
}
function getFeedbackPopup(){
POPUP_OFFSET_TOP=35;
POPUP_OFFSET_LEFT=165;
popup=$e("feedbackPopup");
scrollX=getScrollX();
scrollY=getScrollY();
popup.style.left=IBDOM.Utils.getString([(scrollX+POPUP_OFFSET_LEFT),"px"]);
popup.style.top=IBDOM.Utils.getString([(scrollY+POPUP_OFFSET_TOP),"px"]);
popup.show("block");
}
function closeFeedbackPopup(){
$e("feedbackPopup").hide();
}
function submitFeedback(_45){
comments=_45.comments.value;
theRating=null;
for(i=0;!theRating&&(i<_45.rating.length);i++){
if(_45.rating[i].checked){
theRating=_45.rating[i].value;
}
}
email=_45.email.value;
msg=checkEmail(email);
if(!theRating){
alert("Please pick a rating");
if(_45.rating.focus){
_45.rating.focus();
}
}else{
feedbackManager.submitFeedback(theRating,comments,email,endFeedback);
}
return false;
}
function endFeedback(_46){
if(_46){
$e("feedbackContent").hide();
$e("feedbackThanks").show("block");
}
}
function replaceBadImages(){
var _47=new Image();
_47.src=imageUrlPrefix+"/usedcars/images/no_photo_temp.png";
for(var i=0;i<document.images.length;i++){
if(!document.images[i].complete||document.images[i].onerror==true){
document.images[i].src=_47.src;
var _49=document.images[i].className;
if(_49=="dealerImg"||_49=="contactLogo"){
document.images[i].width="88";
}
}
}
}
