var CFC={};Com.update(CFC,{DATA_URL:"/index.php/CashForClunkers",BODYSTYLES:{},CARLIST:[],CARSEARCHLIST:[],CARDICT:{},DROPDOWN_MAX:10,CAT_TRUCK_1:["Compact Trucks,","GVWR &lt; 8,500 lbs.","Wheelbase &lt;= 115 in."],CAT_TRUCK_2:["Medium, Large Trucks, ","GVWR &lt;= 8,500 lbs.","Wheelbase &gt; 115 in."],CAT_VAN_1:["Most minivans/vans,","GVWR &lt; 8,500 lbs.","Wheelbase <= 124 in."],CAT_VAN_2:["Large Vans","GVWR &gt;= 8,500 lbs.","Wheelbase &gt; 115 in."],CREDIT_NODE:1,EXPLAIN_NODE:2,errors:[],cc_precache_elem:null,wizard_container_elem:null,wizard_elem:null,center_frame_elem:null,step1_elem:null,searchbox_elem:null,dropdown_elem:null,searchtext:"",last_searchtext:"",results:[],old_car:{},desired_bodystyle:null,desired_credit:null,desired_mpg:null,credit_matrix:[],stagger_keyevents:{keydown:false,keypress:false},dropdown_selected_idx:-1,step1_result_elem:null,step2_elem:null,step3_elem:null,step4_elem:null,initialize:function(a){this.retrieveData();this.setupMarkers.apply(this,a)},precacheCarChooser:function(){this.cc_precache_elem=Com.getElement("cc_precache_holder");if(this.cc_precache_elem===null){CFC.cc_precache_elem=document.createElement("div");CFC.cc_precache_elem.setAttribute("id","cc_precache_holder");CFC.cc_precache_elem.innerHTML=CFC.emitPrecacheCarChooser();document.body.appendChild(CFC.cc_precache_elem)}CarChooser.showFlashContent("cc_precache_div",false,"",true);Com.getElement("cc_precache_div").style.display="block"},setupMarkers:function(c,d){var a,b;b=Com.getElementsByTagAndClassName(c,d);for(a=0;a<b.length;a+=1){Com.addEvent(b[a],"click",CFC.showWizard)}},showWizard:function(){var b="",f="",a,c={},e=0,d=0;CFC.precacheCarChooser();if(CFC.wizard_elem!==null){return}if(Com.isIE6()){a=Com.getScrollXY();d=a.top;e=a.left;c=CFC.detectIe6Coordnates();e+=c.left;d+=c.top;f+="background: black none;filter:alpha(opacity=40);position: absolute; left: "+0+"px; top: "+0+"px; width: "+document.body.offsetWidth+"px; height: "+document.body.offsetHeight+"px; ";b="position: absolute; top: "+d+"px; left: "+e+"px; "}else{f="background: transparent url(/images/cfc/transparent.png);width: 100%; height: 100%; padding-top: 5px; padding-bottom: 15px; padding-left: 15px; padding-right: 15px; position: fixed; left: 0;top: 0";b="margin: auto;"}CFC.wizard_container_elem=document.createElement("div");CFC.wizard_container_elem.setAttribute("id","CFC.wizard_container");Com.setElementStyle(CFC.wizard_container_elem,f);Com.setElementClass(CFC.wizard_container_elem,"CFC_container");document.body.appendChild(CFC.wizard_container_elem);CFC.wizard_elem=document.createElement("div");CFC.wizard_elem.setAttribute("id","CFC.wizard");Com.setElementStyle(CFC.wizard_elem,b);Com.setElementClass(CFC.wizard_elem,"CFC_w");CFC.wizard_elem.innerHTML=CFC.emitWindow();if(Com.isIE6()){document.body.appendChild(CFC.wizard_elem);window.onscroll=CFC.onWindowScrollForIe6}else{CFC.wizard_container_elem.appendChild(CFC.wizard_elem)}CFC.center_frame_elem=Com.getElement("CFC.center_frame");CFC.showStepOne()},onWindowScrollForIe6:function(){var d={},f,a,e=0,g=0,c,b;f=Com.getElement("CFC.wizard");if(f!==null){d=CFC.detectIe6Coordnates();g+=d.left;e+=d.top;f.style.top=(CFC.getWindowScrollY()+e)+"px";f.style.left=(CFC.getWindowScrollX()+g)+"px";a=Com.getElement("CFC.dropdown");if(a!==null){c=(CFC.absTopOffset(CFC.searchbox_elem)+(22+4))-CFC.absTopOffset(f);b=CFC.absLeftOffset(CFC.searchbox_elem)+1;a.style.top=(CFC.getWindowScrollY()+c)+"px";a.style.left=(CFC.getWindowScrollX()+b)+"px"}}},detectIe6Coordnates:function(){var c,b=0,a=0;c=Com.getElement("container_contentLONG");if(c!==null){b=CFC.absLeftOffset(c)}b+=10;a+=5;return{left:b,top:a}},destroyWizard:function(){this.destroyDropDown();if(this.wizard_elem!==null){Com.removeElement(this.wizard_elem);this.wizard_elem=null}if(this.wizard_container_elem!==null){Com.removeElement(this.wizard_container_elem);this.wizard_container_elem=null}if(Com.isIE6()){window.onscroll=null}},retrieveData:function(){var a=new Com.Ajax();a.ok=this.recordData;a.er=this.retrieveFailure;a.ex({url:this.DATA_URL,method:"get",query:""})},recordData:function(f){var a,b,d;try{d=Com.evalJSON(f.responseText);b=CFC.scrubData(d);CFC.CARLIST=b.carlist;CFC.BODYSTYLES=b.bodystyles;if(b.errors!==undefined){CFC.errors=b.errors}}catch(c){CFC.generateErrorData()}for(a=0;a<CFC.CARLIST.length;a+=1){CFC.CARSEARCHLIST[a]=CFC.CARLIST[a][0].toLowerCase();CFC.CARDICT[CFC.CARSEARCHLIST[a]]={mpg:CFC.CARLIST[a][1]}}},retrieveFailure:function(a){CFC.generateErrorData()},scrubData:function(a){if(a.carlist===undefined||a.bodystyles===undefined){throw new Error("No data available")}return a},generateErrorData:function(a){return{carlist:[],bodystyles:{},errors:["We apologize for the inconvenience.  We have encountered an internal error and can retrieve the old cars list"]}},onWizardCloseClick:function(){this.destroyWizard()},showStepOne:function(){this.step1_elem=document.createElement("div");this.step1_elem.setAttribute("id","CFC.step1");Com.setElementClass(this.step1_elem,"CFC_w_step CFC_w_step_one");this.step1_elem.innerHTML=this.emitStepOne();this.center_frame_elem.appendChild(this.step1_elem);this.searchbox_elem=Com.getElement("CFC.searchbox")},onGoClick:function(a){this.onComplete()},onSearchTextBlur:function(a){setTimeout(CFC.destroyDropDown,500)},onSearchTextKeyPress:function(a){setTimeout(function(){CFC.staggerCompleteCall("keypress")},50)},onSearchTextKeyDown:function(a){var d,f,c,e=false,b=false;f={38:-1,40:1};a=(a)?a:window.event;d=a.keyCode;if(d===13){this.onComplete();return false}if(d===27){this.destroyDropDown();return false}if(d===38||d===40){if(this.dropdown_elem!==null){this.moveTo(this.getNewDropDownIndex(f[d]));return false}e=true}if(Com.isIE()&&d===8||d===46){b=true}setTimeout(function(){CFC.staggerCompleteCall("keydown",e,b)},50);return true},staggerCompleteCall:function(a,c,b){b=(b===undefined)?false:b;c=(c===undefined)?false:c;this.stagger_keyevents[a]=true;if(this.stagger_keyevents.keydown&&(b||this.stagger_keyevents.keypress)){this.stagger_keyevents={keydown:false,keypress:false};this.startComplete(c)}},createDropDown:function(){var a;if(this.dropdown_elem!==null){return false}a="position: absolute; left: "+(this.absLeftOffset(this.searchbox_elem)+1)+"px; top: "+(this.absTopOffset(this.searchbox_elem)+20)+"px; ";this.dropdown_elem=document.createElement("div");this.dropdown_elem.setAttribute("id","CFC.dropdown");Com.setElementClass(this.dropdown_elem,"CFC_w_dropdown");Com.setElementStyle(this.dropdown_elem,a);if(Com.isIE6()){document.body.appendChild(this.dropdown_elem)}else{this.wizard_container_elem.appendChild(this.dropdown_elem)}return true},getNewDropDownIndex:function(c){var b=(this.results.length>this.DROPDOWN_MAX)?this.DROPDOWN_MAX:this.results.length,a=this.dropdown_selected_idx+c;if(a<-1){return this.results.length-1}if(a>=b){return -1}return a},getDropDownEntryIndex:function(a){return parseInt(a.id.replace("CFC.dropdown_entry_",""),10)},onDropDownEntryMouseOver:function(a){Com.setElementClass(a,"CFC_w_dropdown_item_over");this.dropdown_selected_idx=this.getDropDownEntryIndex(a)},onDropDownEntryMouseOut:function(a){Com.setElementClass(a,"CFC_w_dropdown_item")},onDropDownEntryClick:function(a){this.searchbox_elem.value=this.results[this.getDropDownEntryIndex(a)];this.onComplete()},filterData:function(d){var b,c,a;this.results=[];c=d.toLowerCase().split(" ");for(b=0;b<this.CARLIST.length;b+=1){if(this.testDataPoint(this.CARSEARCHLIST[b],c)){this.results.push(this.CARLIST[b][0])}}},testDataPoint:function(b,c){var a;for(a=0;a<c.length;a+=1){if(b.toLowerCase().indexOf(c[a])===-1){return false}}return true},destroyDropDown:function(){if(CFC.dropdown_elem===null){return}Com.removeElement(CFC.dropdown_elem);CFC.dropdown_elem=null},startComplete:function(b){var a="";if(this.searchbox_elem.value===this.last_searchtext&&!b){return}if(!b){this.searchtext=this.searchbox_elem.value;this.last_searchtext=this.searchtext;this.filterData(this.searchtext)}if(this.searchtext.length===0){this.destroyDropDown();return}a=this.emitDropDown();if(a.length){this.createDropDown();this.dropdown_elem.innerHTML=a}else{this.destroyDropDown()}this.dropdown_selected_idx=-1},moveTo:function(a){var b,c;c=(this.results.length>this.DROPDOWN_MAX)?this.DROPDOWN_MAX:this.results.length;for(b=0;b<c;b+=1){CFC.onDropDownEntryMouseOut(Com.getElement("CFC.dropdown_entry_"+b))}if(a>-1){this.onDropDownEntryMouseOver(Com.getElement("CFC.dropdown_entry_"+a))}else{this.dropdown_selected_idx=a}this.searchbox_elem.value=(a===-1)?this.searchtext:this.results[a]},resetResults:function(){this.old_car={};this.desired_bodystyle=null;this.desired_credit=null;this.desired_mpg=null},onComplete:function(){this.resetResults();this.searchtext=this.searchbox_elem.value;this.destroyDropDown();this.destroyStepTwo();this.destroyStepThree();this.destroyStepFour();if(this.CARDICT[this.searchtext.toLowerCase()]){this.old_car={car:this.searchtext,mpg:this.CARDICT[this.searchtext.toLowerCase()].mpg};this.showStepOneResult(true);this.showStepTwo();return}this.showStepOneResult(false)},showStepOneResult:function(a){this.step1_result_elem=Com.getElement("CFC.step1_result");if(this.step1_result_elem===null){this.step1_result_elem=document.createElement("div");this.step1_result_elem.setAttribute("id","CFC.step1_result");this.step1_elem.appendChild(this.step1_result_elem)}Com.setElementClass(this.step1_result_elem,(a?"CFC_w_qualify":"CFC_w_qualify CFC_bold"));this.step1_result_elem.innerHTML=a?this.emitStepOneSuccess():this.emitStepOneFailure()},showStepTwo:function(){this.step2_elem=Com.getElement("CFC.step2");if(this.step2_elem===null){this.step2_elem=document.createElement("div");this.step2_elem.setAttribute("id","CFC.step2");Com.setElementClass(this.step2_elem,"CFC_w_step");this.center_frame_elem.appendChild(this.step2_elem)}this.step2_elem.innerHTML=this.emitStepTwo()},destroyStepTwo:function(){if(this.step2_elem!==null){Com.removeElement(this.step2_elem);this.step2_elem=null}},calcPassengerCar:function(c){var b,a=[];b=22-c;if(b<4){return[]}if(b<10){return[[[this.CREDIT_NODE,22,3500],[this.CREDIT_NODE,c+10,4500]]]}if(b>=10){return[[[this.CREDIT_NODE,22,3500],[this.CREDIT_NODE,22,4500]]]}return[]},calcCategoryMpg:function(h,a,g,e,f){var d,c=[],b=[];c=(f===undefined)?[]:[Com.merge([this.EXPLAIN_NODE],f)];d=a-h;if(d<0){return[]}if(d<g){return[Com.merge([[this.CREDIT_NODE,h+g,3500],[this.CREDIT_NODE,h+e,4500]],c)]}if(d>=g&&d<e){return[Com.merge([[this.CREDIT_NODE,a,3500],[this.CREDIT_NODE,h+e,4500]],c)]}if(d>=e){return[Com.merge([[this.CREDIT_NODE,a,3500],[this.CREDIT_NODE,a,4500]],c)]}return[]},calcSuv:function(a){return this.calcCategoryMpg(a,18,2,5)},calcVan:function(a){return Com.merge(this.calcCategoryMpg(a,18,2,5,this.CAT_VAN_1),this.calcCategoryMpg(a,15,1,2,this.CAT_VAN_2))},calcTruck:function(a){return Com.merge(this.calcCategoryMpg(a,18,2,5,this.CAT_TRUCK_1),this.calcCategoryMpg(a,15,1,2,this.CAT_TRUCK_2))},onBodystyleClick:function(a){this.destroyStepFour();this.desired_bodystyle=a.value.toLowerCase();this.showStepThree()},showStepThree:function(){var b=[],a={sedan:this.calcPassengerCar,"coupe/hatchback":this.calcPassengerCar,convertible:this.calcPassengerCar,wagon:this.calcPassengerCar,suv:this.calcSuv,"minivan/van":this.calcVan,truck:this.calcTruck};this.step3_elem=Com.getElement("CFC.step3");if(this.step3_elem===null){this.step3_elem=document.createElement("div");this.step3_elem.setAttribute("id","CFC.step3");Com.setElementClass(this.step3_elem,"CFC_w_step");this.center_frame_elem.appendChild(this.step3_elem)}this.credit_matrix=a[this.desired_bodystyle].call(this,this.old_car.mpg);this.step3_elem.innerHTML=this.emitStepThree()},destroyStepThree:function(){if(this.step3_elem!==null){Com.removeElement(this.step3_elem);this.step3_elem=null}},onCreditClick:function(b){var a=b.value.split(":");this.desired_credit=a[0];this.desired_mpg=a[1];this.showStepFour()},showStepFour:function(b,a){this.step4_elem=Com.getElement("CFC.step4");if(this.step4_elem===null){this.step4_elem=document.createElement("div");this.step4_elem.setAttribute("id","CFC.step4");Com.setElementClass(this.step4_elem,"CFC_w_step CFC_mpb_zero_nbb CFC_bold");this.center_frame_elem.appendChild(this.step4_elem)}this.step4_elem.innerHTML=this.emitStepFour()},destroyStepFour:function(){if(this.step4_elem!==null){Com.removeElement(this.step4_elem);this.step4_elem=null}},onSeeEligibleCars:function(){var a={filters:{bodystyle:this.desired_bodystyle,mpg_combined:this.desired_mpg,max_price:45000,cfc:true}};CarChooser.createCookie("carchooser.wizard","passed");CarChooser.setCookieState(Com.serializeJSON(a));window.location.href="/carchooser"},emitPrecacheCarChooser:function(){return'<div id="cc_precache_div" style="display:none">  <!-- empty --></div>'},emitWindow:function(){return'<table cellspacing="0" cellpadding="0" border="0" class="CFC_w_frame_top"><tr><td class="CFC_w_frame_top_left">  <h2 class="CFC_w_frame_top_h1">Is Cash for Clunkers for YOU?</h2></td><td><img class="CFC_w_frame_top_close" onclick="CFC.onWizardCloseClick()" src="/images/cfc/widget_frame_top_right-trans.gif" /></td></tr></table><div id="CFC.center_frame" class="CFC_w_frame_center"></div><div class="CFC_w_frame_bottom"></div>'},emitStepOne:function(){return'<div class="CFC_w_step_title">  <div class="CFC_w_step_circle CFC_mt_10">1</div>  <div class="CFC_w_step_text">Enter the Year, Make, Model and Style of your old vehicle:</div></div><div class="CFC_w_input">  <div class="CFC_w_button_go">    <input onclick="CFC.onGoClick()" src="/images/cfc/btn_go_main2.gif" id="CFC.go" class="CFC_w_btn_go" border="0" type="image" />  </div>  <input id="CFC.searchbox" id="cfc.cfc.searchbox" class="CFC_w_vehicle_input" onkeypress="CFC.onSearchTextKeyPress(event)" onkeydown="CFC.onSearchTextKeyDown(event)" onblur="CFC.onSearchTextBlur(event)" type="text" value="" />  <div class="CFC_w_search_format">(Search Format: 1995 Ford Taurus 3.4L V8)</div></div>'},emitDropDown:function(){var b,a="";for(b=0;b<this.results.length;b+=1){a+='<div id="CFC.dropdown_entry_'+b+'" class="CFC_w_dropdown_item"style="cursor: pointer; width: 100%;"onmouseover="CFC.onDropDownEntryMouseOver(this)" onmouseout="CFC.onDropDownEntryMouseOut(this)" onclick="CFC.onDropDownEntryClick(this)" >'+this.results[b]+"</div>";if(b===(this.DROPDOWN_MAX-1)){break}}if(a.length===0){a=""}return a},emitStepOneSuccess:function(){return'<p>Congratulations, your car qualifies for a Cash for Clunkers credit!</p><p class="CFC_bold">It has an EPA combined fuel economy of   <span class="CFC_w_alert">'+this.old_car.mpg+" mpg</span></p>"},emitStepOneFailure:function(){return'<p>Unfortunately, your old car does not qualify for the program.</p><p>If you believe that your car meets the requirements for the program, you can check its fuel economy at <a href="http://fueleconomy.gov" target="_blank">fueleconomy.gov</a>.</p><hr noshade="noshade" class="CFC_hr" /><table class="CFC_w_table">  <tr>    <td width="272" class="CFC_w_table_td">      Looking for savings?<br />      Check out our<br />     <a href="/rebates">       <img class="CFC_w_btn_promo" src="/images/cfc/btn_rebate_center.gif" alt="Rebate Center" />     </a>    </td>    <td class="CFC_w_or">&nbsp;</td>    <td width="273" class="CFC_w_table_td">      Find your new<br />car using our<br />      <a href="/carchooser">        <img class="CFC_w_btn_promo" src="/images/cfc/btn_car_chooser.gif" alt="Car Chooser" />      </a>    </td>  </tr></table>'},emitStepTwo:function(){var c,a,b;b='<div class="CFC_w_step_title">  <div class="CFC_w_step_circle CFC_mt_10">2</div>  <div class="CFC_w_step_text">Pick the type of new car you want to see the minimum mpg you need.</div></div><table class="CFC_w_table CFC_w_border CFC_w_yellow">  <tbody>    <tr>';a=0;for(c=0;c<this.BODYSTYLES.length;c+=1){b+='<td class="CFC_bodystyle_td"><input id="CFC.bodystyle.'+this.BODYSTYLES[c].replace("/","-").toLowerCase()+'" type="radio" name="CFC_bodystyle" value="'+this.BODYSTYLES[c]+'" onclick="CFC.onBodystyleClick(this)" /><label for="CFC.bodystyle.'+this.BODYSTYLES[c].replace("/","-").toLowerCase()+'">'+this.BODYSTYLES[c]+"</label></td>";a+=1}b+="    </tr>  </tbody></table>";return b},emitStepThree:function(){var f,c,b=[],a=[],e,d;d='<div class="CFC_w_step_title">  <div class="CFC_w_step_circle">3</div>  <div class="CFC_w_step_text">Pick the credit amount you want:</div></div><table class="CFC_w_table CFC_center">  <caption class="CFC_caption">Your new car must be under <span class="CFC_w_alert">$45,000</span> and get at least...</caption>  <tbody>';for(f=0;f<this.credit_matrix.length;f+=1){d+="<tr>";for(c=0;c<this.credit_matrix[f].length;c+=1){a=this.credit_matrix[f][c].slice();e=a.shift();if(e===this.CREDIT_NODE){b=a.slice();b.push((c===0)?false:true);d+=this.emitCreditMpgCalculation.apply(this,b)}else{if(e===this.EXPLAIN_NODE){d+=this.emitCreditMpgExplanation(a)}}}d+="</tr>";if(f<(this.credit_matrix.length-1)){d+='<tr>  <td colspan="3" class="CFC_hr_td">    <hr class="CFC_credit_row_hr" noshade="noshade" />  </td></tr>'}}d+="  </tbody></table>";return d},emitCreditMpgCalculation:function(b,c,a){return'<td class="CFC_w_border_'+(a?"l":"none")+'">  <input class="CFC_w_border_r_input" id="CFC.credit_mpg.'+c+"_"+b+'" type="radio" name="CFC.credit"  value="'+c+":"+b+'" onclick="CFC.onCreditClick(this)"  />  <label class="CFC_w_border_r_label" for="CFC.credit_mpg.'+c+"_"+b+'">    <span class="CFC_w_mpg">'+b+" mpg</span> for $"+c+"  </label></td>"},emitCreditMpgExplanation:function(c){var b,a='<td class="CFC_w_credit_explain">  <ul class="CFC_ul">';for(b=0;b<c.length;b+=1){a+="<li>"+c[b]+"</li>"}a+="  </ul></td>";return a},emitStepFour:function(a){return'<div class="CFC_w_step_title">  <div class="CFC_w_step_circle CFC_mt_10">4</div>  <div class="CFC_w_step_text">    Go to our Car Chooser to see eligible new cars.  </div>  <img onclick="CFC.onSeeEligibleCars()" class="CFC_w_btn_eligible" src="/images/cfc/btn_eligible_cars.gif" alt="See Eligible Cars" />  <div class="CFC_w_reminder">Don\'t forget to request a free Internet price quote from multiple dealers to maximize your savings!</div></div>'},absTopOffset:function(a){var b=0;while(a){b+=a.offsetTop;a=a.offsetParent}return b},absLeftOffset:function(a){var b=0;while(a){b+=a.offsetLeft;a=a.offsetParent}return b},getWindowScrollY:function(){return parseInt(window.pageYOffset||(document.documentElement.scrollTop||0),10)},getWindowScrollX:function(){return parseInt(window.pageXOffset||(document.documentElement.scrollLeft||0),10)}});