// Combined YAHOO.Edmunds and YAHOO.Edmunds.UserTrack. This is a temp file to get external sites to follow the Edmunds UI. When all necessary files are deployed, this file should be removed and references should be adjusted.
// NO FILE ON WWW.EDMUNDS.COM SHOULD LINK TO THIS FILES
if(typeof YAHOO.Edmunds=="undefined"){YAHOO.Edmunds={VERSION:"0.0.8",BUILD:"1"};YAHOO.Edmunds.Cookie=function(B,A){this.cookieName=B;this.timeToLiveSeconds=A};YAHOO.Edmunds.Cookie.VERSION="0.0.2";YAHOO.Edmunds.Cookie.prototype={getTimeToLive:function(){return this.timeToLiveSeconds},getCookieName:function(){return this.cookieName}};YAHOO.Edmunds.Core={timestamp:0,VERSION:"0.0.1"};YAHOO.Edmunds.Util={activeXEnabled:!!YAHOO.util.Connect.getConnectionObject(),query_vars:[],VERSION:"0.0.2",offspring:function(){var E=YAHOO.util.Dom.getElementsByClassName("edmui-offspring");var B=[];var C=[];for(var D=0;D<E.length;D++){B=[];C=E[D].childNodes;for(var F=0;F<C.length;F++){if(C[F].nodeType==1){B.push(C[F])}}if(B.length==1){YAHOO.util.Dom.addClass(B[0],"only-child")}else{for(var A=0;A<B.length;A++){if(A===0){YAHOO.util.Dom.addClass(B[A],"first-child")}else{if(A==B.length-1){YAHOO.util.Dom.addClass(B[A],"last-child")}}if(A%2){YAHOO.util.Dom.addClass(B[A],"odd-child")}else{YAHOO.util.Dom.addClass(B[A],"even-child")}}}}},getQueryString:function(C){if(!this.query_vars.length){var B,D,E;E=window.location.search.substr(1,window.location.search.length);if(E.length<1){return""}B=E.split("&");for(var A=0;A<B.length;A++){D=B[A].split("=");this.query_vars[D[0]]=D[1]}}return this.query_vars[C]},dispatchEvent:function(C,B){var A;if(document.createEvent){A=document.createEvent("MouseEvents");A.initMouseEvent(B,true,true,window,0,0,0,0,0,false,false,false,false,0,null)}else{if(document.createEventObject){A=document.createEventObject()}else{return }}if(C.dispatchEvent){C.dispatchEvent(A)}else{if(C.fireEvent){C.fireEvent("on"+B,A)}}}};if(YAHOO.register){YAHOO.register("edmunds",YAHOO.Edmunds,{version:YAHOO.Edmunds.VERSION,build:YAHOO.Edmunds.BUILD})}(function(){Array.prototype.getKey=function(B){for(var A=0;A<this.length;A++){if(typeof this[A]=="string"){if(this[A]==B){return A}}else{if(typeof this[A]=="object"){if(this[A].id==B){return A}}}}return null};Array.prototype.trim=function(){var B=[];for(var A=0;A<this.length;A++){if(this[A].trim()){B.push(this[A])}}return B};String.prototype.htmlEntities=function(){return this.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")};String.prototype.stripTags=function(){return this.replace(/<([^>]+)>/g,"")};String.prototype.synop=function(D){var A=this;A=A.trim().stripTags().replace("--","-");if(A.length<=D){return A}else{A=A.substring(0,D);var C=false;var B,F,E;while(!C&&A){F=A.length-1;E=F+1;B=A.substring(F,E);if(B!=" "&&B!="."){A=A.substring(0,A.length-1)}else{C=true}}return A}};String.prototype.trim=function(D){if(!D){return this.replace(/^\s+|\s+$/g,"")}else{var B=D.length;var A=this.indexOf(D);var C=this;if(A==-1){return this}else{C=this.substring(A+B)}A=C.lastIndexOf(D);if(A==-1){return C}else{return C.substring(0,A)}}};YAHOO.Edmunds.Core.timestamp=new Date().getTime()})()};
YAHOO.Edmunds.UserTrack={VERSION:"0.0.3",ini:function(){this.root_path="/";this.edmunds_cookie_name="edmunds";this.zip_cookie_name="zip";this.dma_cookie_name="dma";this.edw_cookie_name="edw";this.apache_cookie_name="Apache";this.edw_timestamp_cookie_name="edwtimestamp";this.state_cookie_name="state";this.countyfips_cookie_name="countyfips";this.session=new YAHOO.Edmunds.Cookie("EdmundsSession",-1);this.oneYear=new YAHOO.Edmunds.Cookie("EdmundsYear",60*60*24*365*10);this.thirtyMinute=new YAHOO.Edmunds.Cookie("EdmundsThirtyMinute",60*30);this.DELIM="&"},setStateCountyInfo:function(B){var C=B.responseXML.getElementsByTagName("state");if(C&&C[0]&&C[0].childNodes[0]){this.setCookieValue(this.state_cookie_name,C[0].childNodes[0].nodeValue,this.oneYear)}var A=B.responseXML.getElementsByTagName("county-fips");if(A&&A[0]&&A[0].childNodes[0]){this.setCookieValue(this.countyfips_cookie_name,A[0].childNodes[0].nodeValue,this.oneYear)}var D=B.responseXML.getElementsByTagName("dma");if(D&&D[0]&&D[0].childNodes[0]){this.edmunds_domain=".edmunds.com";this.setCookieValue(this.dma_cookie_name,D[0].childNodes[0].nodeValue,this.oneYear)}this.doneFlag=true},setDMAInfo:function(A){var B=A.responseXML.getElementsByTagName("dma");if(B&&B[0]&&B[0].childNodes[0]){this.edmunds_domain=".edmunds.com";this.setCookieValue(this.dma_cookie_name,B[0].childNodes[0].nodeValue,this.oneYear)}this.dmaDoneFlag=true},displayError:function(){this.doneFlag=true},displayDmaError:function(){this.dmaDoneFlag=true},getAjaxRequest:function(){req=false;if(window.XMLHttpRequest&&!(window.ActiveXObject)){try{req=new XMLHttpRequest()}catch(A){req=false}}else{if(window.ActiveXObject){try{req=new ActiveXObject("Msxml2.XMLHTTP")}catch(A){try{req=new ActiveXObject("Microsoft.XMLHTTP")}catch(A){req=false}}}}return req},queryStateCountyInfo:function(B){var A=this.getAjaxRequest();if(A){var C=this;this.doneFlag=false;A.open("GET","/zipcode/queryZIP.jsp?zipcode="+B,false);A.onreadystatechange=function(){if(A.readyState==4){C.setStateCountyInfo(A)}else{C.displayError(A)}};A.send(null)}},queryDMAByInetAddr:function(){var A=this.getAjaxRequest();if(A){var B=this;this.doneFlag=false;A.open("GET","/zipcode/queryDMA.jsp",false);A.onreadystatechange=function(){if(A.readyState==4){B.setDMAInfo(A)}else{B.displayDmaError(A)}};A.send(null)}},getEdmundsCookie:function(){var A=this.getCookieValue(this.edmunds_cookie_name,true);if(A==null||A==""){return this.getCookieValue(this.apache_cookie_name,true)}else{return A}},getEdwCookie:function(){return this.getCookieValue(this.edw_cookie_name,true)},getEdwTimestampCookie:function(){return YAHOO.Edmunds.Core.timestamp},setEdwTimestamp:function(){},getEdwTimestamp:function(){return YAHOO.Edmunds.Core.timestamp},getZipCookie:function(){var A=this.getCookieValue(this.zip_cookie_name,false);if(A==null){return""}return A},setZipCookie:function(A){this.queryStateCountyInfo(A);return(this.setCookieValue(this.zip_cookie_name,A,this.oneYear))},getDmaCookie:function(){var A=this.getCookieValue(this.dma_cookie_name,false);if(A==null){var B=this.getZipCookie();if(B.length>0){this.queryStateCountyInfo(B);A=this.getCookieValue(this.dma_cookie_name,false)}else{this.queryDMAByInetAddr();A=this.getCookieValue(this.dma_cookie_name,false)}}else{if(A.split(":")[1]=="IP"){var B=this.getZipCookie();if(B.length>0){this.queryStateCountyInfo(B);A=this.getCookieValue(this.dma_cookie_name,false)}}}if(A!=null){A=A.split(":")[0]}else{A=""}return A},setDmaCookie:function(A){return(this.setCookieValue(this.dma_cookie_name,A,this.oneYear))},getCookieValue:function(F,A){var B=document.cookie;if(B==null||B.length==0){return null}if(A){return(this.getCookie(F))}else{var E=this.getCookieValue(this.session.getCookieName(),true);if(E!=null){var C=this.getEdmundsData(F,E);if(C!=null){return(unescape(C))}}var D=this.getCookieValue(this.oneYear.getCookieName(),true);if(D!=null){var C=this.getEdmundsData(F,D);if(C!=null){return(unescape(C))}}}return null},setCookieValue:function(L,E,I,J){if(!E||E==""||E=="null"){return }if(J){var B=new Date();if(I&&I.getTimeToLive()==-1){B=false}else{var C=B.getTime();C+=I.getTimeToLive()*1000;B.setTime(C)}return(this.setCookie(L,E,B,this.root_path,this.edmunds_domain))}else{var K=this.getCookieValue(I.getCookieName(),true);var A="";E=escape(E);if(K===null){A=this.DELIM+L+"="+E}else{var D=K.indexOf(this.DELIM+L+"=");if(D!=-1){if(RegExp){var F=new RegExp(L+"=[^"+this.DELIM+"]*");var H=L+"="+E;A=K.replace(F,H)}else{var G=K.indexOf(this.DELIM,D+1);A=this.DELIM+L+"="+E;if(D===0&&G===-1){}else{if(D===0){A+=K.substring(G)}else{if(G==-1){A+=K.substring(0,D)}else{A+=K.substring(0,D);A+=K.substring(G)}}}}}else{A=K+this.DELIM+L+"="+E}}return(this.setCookieValue(I.getCookieName(),A,I,true))}},getEdmundsData:function(E,B){var D=E+"=";var C=B.indexOf(this.DELIM+D);if(C==-1){return null}else{C++}var A=B.indexOf(this.DELIM,C);if(A==-1){A=B.length}return(B.substring(C+D.length,A))},getCookie:function(C){var B="; "+document.cookie;var E=C+"=";var D=B.indexOf("; "+E);if(D==-1){return null}else{D+=2}var A=B.indexOf(";",D);if(A==-1){A=B.length}return(B.substring(D+E.length,A))},setCookie:function(B,D,A,F,C,E){if(C==undefined||C==""){C=".edmunds.com"}var G=escape(B)+"="+D+((A)?"; expires="+A.toGMTString():"")+((F)?"; path="+F:"")+((C)?"; domain="+C:"")+((E)?"; secure":"");return(document.cookie=G)},migrateCookies:function(){var D=new Date(1);var C=this.getCookie("edmunds");if(C&&(C==="null"||C==="")){this.setCookie("edmunds","",D,this.root_path,this.edmunds_domain)}var E=this.getCookie("zip");if(E){this.setZipCookie(E);this.setCookie("zip","",D,this.root_path,this.edmunds_domain)}var F=["FN","LN","CID","EMAIL","THSN","THA","ET","savedcar"];for(var B=0;B<F.length;B++){var A=F[B];var G=this.getCookie(A);if(G){this.setCookieValue(A,G,this.session);this.setCookie(A,"",D,this.root_path,this.edmunds_domain)}}}};YAHOO.Edmunds.Cookie.Session=new YAHOO.Edmunds.Cookie("EdmundsSession",-1);YAHOO.Edmunds.Cookie.OneYear=new YAHOO.Edmunds.Cookie("EdmundsYear",60*60*24*365*10);YAHOO.Edmunds.Cookie.ThirtyMinute=new YAHOO.Edmunds.Cookie("EdmundsThirtyMinute",60*30);YAHOO.Edmunds.UserTrack.ini();YAHOO.Edmunds.UserTrack.migrateCookies();