function overlay(curobj){var subobj=jQuery('#viewcars');jQuery(subobj).toggle();var currentPossession=jQuery(curobj).position();if(jQuery.browser.msie){jQuery(subobj).css({'top':currentPossession.top+5,'left':currentPossession.left+32})}else{jQuery(subobj).css({'top':currentPossession.top+5,'left':currentPossession.left-(jQuery(subobj).width()+46)})}return false}function overlayclose(){jQuery('#viewcars').hide()}jQuery.fn.liScroll=function(settings){settings=jQuery.extend({travelocity:0.07},settings);return this.each(function(){var $strip=jQuery(this);$strip.css({position:'relative',left:'100%','list-style-type':'none',margin:'0',padding:'0'});var stripWidth=0;var $mask=$strip.wrap('<div class="mask" style="position: relative;left: 0;top: 8px;width: 292px;overflow: hidden;"></div>');var $eventcontainer=$strip.parent().wrap('<div class="eventcontainer" style="border: 1px solid #000;background: #fff;width: 292px;height: 27px;margin: 0 3px;padding: 0;overflow: hidden;"></div>');var containerWidth=$strip.parent().parent().width();$strip.find("li").each(function(i){stripWidth+=jQuery(this,i).width()});$strip.width(stripWidth);var defTiming=stripWidth/settings.travelocity;var totalTravel=stripWidth+containerWidth;function scrollnews(spazio,tempo){$strip.animate({left:'-='+spazio},tempo,"linear",function(){$strip.css("left",containerWidth);scrollnews(totalTravel,defTiming)})}scrollnews(totalTravel,defTiming);$strip.hover(function(){jQuery(this).stop()},function(){var offset=jQuery(this).offset();var residualSpace=offset.left+stripWidth;var residualTime=residualSpace/settings.travelocity;scrollnews(residualSpace,residualTime)})})};function formatPrice(nStr){nStr+='';var x=nStr.split('.');var x1=x[0];var x2=x.length>1?'.'+x[1]:'';var rgx=/(\d+)(\d{3})/;while(rgx.test(x1)){x1=x1.replace(rgx,'$1'+','+'$2')}return x1+x2}function carsHQ_callback(jsonData){if(jsonData.featuredDealer.length>0){var FD=jsonData.featuredDealer;var FV=jsonData.featuredVehicle;var VP=jsonData.vehiclePhoto;var SE=jsonData.salesEvent;jQuery('#carsHQ_widget').css({width:'300px','text-align':'left',margin:'0px auto','margin-top':'1em','padding-bottom':'3px','font-family':'Lucida Grande, Arial, sans-serif','background-color':'#990000','font-size':'11px'});var randomDealer,badge;randomDealer=Math.floor(Math.random()*FD.length);var dealer_ID=FD[randomDealer].dealer_ID;var business_name=FD[randomDealer].business_name;if(FD[randomDealer].badge){badge=FD[randomDealer].badge}else{badge=''}var type=FD[randomDealer].type;var city=FD[randomDealer].city;var state=FD[randomDealer].state;var zipCode=FD[randomDealer].zipCode;var phone=FD[randomDealer].phone;if(typeof(newspaperDomain)!='undefined'){CreatorDomain=newspaperDomain}var featuredHead=jQuery('<div></div>').css({'background-color':'#e1e1e1',width:'auto',margin:'0 3px',border:'#900 solid','border-width':'3px 0'});var headH3=jQuery('<h3></h3>').css({margin:'2px 0 6px 0','text-align':'left','padding-left':'3px','font-size':'16px',width:'200px'}).html('<a href="http://www.carshq.com/search/page/search_results/top/1/zip/'+zipCode+'/radius/50" target="_blank" title="carsHQ: View all Top Vehicles" style="font-family: Lucida Grande, Arial, sans-serif;text-decoration: none;color: #000;background-color: inherit;"><span style="color:#990000;">Top</span>Vehicles</a>');jQuery(featuredHead).append(headH3);var headLink=jQuery('<a></a>').attr({href:'http://www.carshq.com/zip/'+zipCode,target:'_blank'}).css({'float':'right','margin-top':'-31px','margin-right':'-3px','font-family':'Lucida Grande, Arial, sans-serif',color:'#000'}).html('<img src="http://www.carshq.com/gfx/topVehicle_head.gif" title="carsHQ: Home Page" style="border:none;"/>');jQuery(featuredHead).append(headLink);jQuery('#carsHQ_widget').append(featuredHead);var featuredVehicleList,featuredTop,vehicle_ID,year,make,model,price,sale_price;if(FV.length>0){var featuredVehicleCount=0;featuredVehicleList=[];for(var i=0;i<FV.length;i++){if(FV[i].dealer_ID==dealer_ID){featuredVehicleList[featuredVehicleCount]=i;featuredVehicleCount+=1}}var randomNumber=Math.floor(Math.random()*featuredVehicleList.length);var randomVehicle=featuredVehicleList[randomNumber];vehicle_ID=FV[randomVehicle].vehicle_ID;year=FV[randomVehicle].year;make=FV[randomVehicle].make;model=FV[randomVehicle].model;price=FV[randomVehicle].price;sale_price=FV[randomVehicle].sale_price;var featuredBadge;if(type=='dealership'){if(badge!=''){featuredTop=jQuery('<div></div>').css({'background-color':'#fff',margin:'0 3px',width:'auto',height:'48px'});var badgeContent=jQuery("<a></a>").attr({href:"http://www.carshq.com/search/page/search_results/dealer_id/"+dealer_ID+"/zip/"+zipCode+"/radius/50",target:"_blank"}).css({'float':'left','width':'100%','text-align':'center','line-height':'48px','height':'48px'}).html('<img src="http://www.carshq.com/gfx/badges/'+badge+'" title="'+business_name+'"  style="border:medium none;margin:8px auto auto;width:135px;height:35px;text-align:center;"/>');jQuery(featuredTop).append(badgeContent)}else{featuredTop=jQuery('<div></div>').css({'background-color':'#fff',margin:'0 3px',width:'auto',height:'48px'});featuredBadge=jQuery('<a/>').attr({href:'http://www.carshq.com/search/page/search_results/dealer_id/'+dealer_ID+'/zip/'+zipCode+'/radius/50',target:'_blank'}).css({'float':'left','width':'100%','text-align':'center','line-height':'48px','height':'48px'}).text(business_name);jQuery(featuredTop).append(featuredBadge)}if(featuredVehicleCount>1){var peel=jQuery('<a></a>').click(function(){overlay(this)}).html('<img src="http://www.carshq.com/gfx/newpeel.gif" title="More Top Vehicles for Dealer" style="float: right;margin: 0;margin-top: -48px;padding: 0;border: none;"/>');jQuery(featuredTop).append(peel)}}else{featuredTop=jQuery('<div></div>').css({'background-color':'#fff',margin:'0 3px',width:'auto',height:'48px'});featuredBadge=jQuery('<div/>').css({'float':'left','width':'100%','text-align':'center','line-height':'48px','height':'48px','color':'#000'});jQuery(featuredBadge).append('<span style="padding: 4px 0 0 0;font-size: 11px;font-weight: bolder;">Phone: '+phone+'</span>');jQuery(featuredBadge).append('<span style="padding: 4px 0 0 0;font-size: 11px;font-weight: bolder;">'+city+', '+state+'</span>');jQuery(featuredTop).append(featuredBadge)}}jQuery("#carsHQ_widget").append(featuredTop);var photoLink,vehiclePhoto;var photo=jQuery("<div></div>").css({'vertical-align':'top',width:'98%',margin:'3px'});if(VP.length>0){for(var j=0;j<VP.length;j++){if(VP[j].vehicle_ID==vehicle_ID){vehiclePhoto=VP[j].photo}}if(vehiclePhoto){photoLink=jQuery("<a></a>").attr({href:"http://www.carshq.com/search/page/detail/id/"+vehicle_ID+"/dealer_id/"+dealer_ID+"/zip/"+zipCode+"/radius/50",title:"View this "+make+" "+model+" at carsHQ",target:"_blank"}).html('<img src="http://www.carshq.com/gfx/180x135/'+vehiclePhoto+'" title="View this '+year+' '+make+' '+model+' at carsHQ" style="float: left;width: 53%;border: 2px #fff solid;"/>')}}else{photoLink=jQuery("<a></a>").attr({href:"http://www.carshq.com/search/page/detail/id/"+vehicle_ID+"/dealer_id/"+dealer_ID+"/zip/"+zipCode,title:"View this "+year+" "+make+" "+model+"at carsHQ",target:"_blank"}).html('<img src="http://www.carshq.com/gfx/180x135/no_pic.jpg" title="No Image Available" style="float: left;width: 53%;border: 2px #fff solid;"/>')}jQuery(photo).append(photoLink);var sash=jQuery("<div></div>").css({'float':'right',opacity:'.80',filter:'alpha(opacity=80)','-moz-opacity':'0.8','background-color':'#fff',width:'44.5%','text-align':'center','vertical-align':'top',margin:'0',height:'121px'});jQuery(sash).append('<span style="display: block;padding: 16px 0 8px 0;font-size:14px;font-weight: bolder;">'+year+'</span>');jQuery(sash).append('<span style="display: block;padding: 0;font-size: 12px;font-weight: bolder;color: #990000;">'+make+'</span>');jQuery(sash).append('<span style="display: block;padding: 0;color: #990000;">'+model+'</span>');var bottomSash=jQuery("<span>").css({display:'block','padding-top':'8px','padding-bottom':'10px','font-size':'14px','font-weight':'bolder'});if(price!='0'){if(sale_price!='0'){jQuery(bottomSash).html('<span style="font-size: 98%;text-decoration: line-through;font-weight:normal;">$'+formatPrice(price)+'</span><br />$'+formatPrice(sale_price))}else{jQuery(bottomSash).text('$'+formatPrice(price))}}else{jQuery(bottomSash).text("Contact for price")}jQuery(sash).append(bottomSash);jQuery(photo).append(sash);jQuery(photo).append('<p style="clear:both;"></p>');jQuery("#carsHQ_widget").append(photo);if(SE.length>0){var salesEventLI,seName,seDescription;var buildUL=0;var salesEventUL=jQuery("<ul></ul>").attr("id","salesEvent");for(var k=0;k<SE.length;k++){if(SE[k].dealer_ID==dealer_ID){seName=SE[k].name;seDescription=SE[k].description;salesEventLI=jQuery("<li></li>").css({'white-space':'nowrap','float':'left',margin:'0',padding:'0',background:'#fff'}).html("<strong>"+seName+"</strong> "+seDescription);jQuery(salesEventUL).append(salesEventLI);buildUL++}}if(buildUL>0){jQuery("#carsHQ_widget").append(salesEventUL);jQuery(function(){jQuery(salesEventUL).liScroll({travelocity:0.05})})}}var viewcars=jQuery("<div></div>").css({position:'absolute',display:'none',border:'3px solid #990000','background-color':'#eeeeee',width:'224px',padding:'8px','z-index':'101'}).attr("id","viewcars");var leftLogo=jQuery("<div></div>").css({'float':'left',width:'135px','margin-top':'-5px'});var leftLogoLink=jQuery("<a></a>").attr({href:"http://www.carshq.com/zip/"+zipCode,target:"_blank"}).html('<img src="http://www.carshq.com/gfx/carsHQsmall_logo.gif" style="border:none;" title="carsHQ: Home Page" />');jQuery(leftLogo).append(leftLogoLink);jQuery(viewcars).append(leftLogo);var rightLogo=jQuery("<div></div>").css({'float':'right','margin-right':'1px'});var rightLogoLink=jQuery("<a></a>").click(function(){overlayclose();return false}).html('<img src="http://www.carshq.com/gfx/close.gif" style="border:none;" title="Close Window" />');jQuery(rightLogo).append(rightLogoLink);jQuery(viewcars).append(rightLogo);jQuery(viewcars).append('<p style="clear:both;"></p>');if(featuredVehicleList.length>1){var vc_ID,vc_year,vc_make,vc_model,vc_price,vc_sale_price,carbox,final_price,vc_vehiclePhoto;for(var jj=0;jj<featuredVehicleList.length;jj++){vc_ID=featuredVehicleList[jj];var vc_vehicle_ID=FV[vc_ID].vehicle_ID;if(vc_vehicle_ID!=vehicle_ID){vc_year=FV[vc_ID].year;vc_make=FV[vc_ID].make;vc_model=FV[vc_ID].model;vc_price=FV[vc_ID].price;vc_sale_price=FV[vc_ID].sale_price;carbox=jQuery("<div></div>").css({'float':'left',width:'64px',height:'64px',margin:'4px','margin-bottom':'12px',padding:'2px 0'});if(VP.length>0){for(var l=0;l<VP.length;l++){if(VP[l].vehicle_ID==vc_vehicle_ID){vc_vehiclePhoto=VP[l].photo}}var vc_link;if(vc_vehiclePhoto){vc_link=jQuery("<a></a>").attr({href:"http://www.carshq.com/search/page/detail/id/"+vc_vehicle_ID+"/dealer_id/"+dealer_ID+"/zip/"+zipCode+"/radius/50",title:"View this "+vc_year+" "+vc_make+" "+vc_model+" at carsHQ.com",target:"_blank"}).html('<img src="http://www.carshq.com/gfx/96x72/'+vc_vehiclePhoto+'" width="60" title="view this '+vc_year+' '+vc_make+' '+vc_model+' at carsHQ.com" />');jQuery(carbox).append(vc_link)}else{vc_link=jQuery("<a></a>").attr({href:"http://www.carshq.com/search/page/detail/id/"+vc_vehicle_ID+"/dealer_id/"+dealer_ID+"/zip/"+zipCode+"/radius/50",title:"View this "+vc_year+" "+vc_make+" "+vc_model+" at carsHQ.com",target:"_blank"}).html('<img src="http://www.carshq.com/gfx/96x72/no_pic.jpg" width="60" title="view this '+vc_year+' '+vc_make+' '+vc_model+' at carsHQ.com" />');jQuery(carbox).append(vc_link)}jQuery(viewcars).append(carbox)}if(vc_price!='0'){if(vc_sale_price!='0'){final_price=jQuery('<span></span>').css({'font-size':'98%','text-decoration':'line-through'}).text('$'+formatPrice(vc_price));jQuery(carbox).append(final_price);vc_sale_price='<br />$'+formatPrice(vc_sale_price);jQuery(carbox).append(vc_sale_price)}else{jQuery(carbox).append('$'+formatPrice(vc_price))}}else{jQuery(carbox).append("Contact for price")}}}var bottomLink;var bottom=jQuery("<div/>").css({'text-align':'center','background-color':'#fff','margin-top':'1px','padding-bottom':'1px',width:'99%',height:'35px',clear:'left'});if(badge!==""){bottomLink=jQuery("<a></a>").attr({href:"http://www.carshq.com/search/page/search_results/dealer_id/"+dealer_ID+"/zip/"+zipCode+"/radius/50",target:"_blank"}).html('<img src="http://www.carshq.com/gfx/badges/'+badge+'" border="0" title="'+business_name+'" />');jQuery(bottom).append(bottomLink)}else{bottomLink=jQuery("<a></a>").attr({href:"http://www.carshq.com/search/page/search_results/dealer_id/"+dealer_ID+"/zip/"+zipCode+"/radius/50",target:"_blank"}).text(business_name);jQuery(bottom).append(bottomLink)}jQuery(viewcars).append(bottom)}jQuery("#carsHQ_widget").append(viewcars)}if(jsonData.topVehicleClassified.length>0){var tvc=jsonData.topVehicleClassified;var objCount;if(tvc.length<7){objCount=jsonData.topVehicleClassified.length}else{objCount=7}var topVehicleHolder=jQuery('<div></div>').css({padding:'0',margin:'0','font-size':'11px','font-family':'sans-serif','background-color':'#fff',border:'thick solid #900'});var topVehicleHeader=jQuery('<div></div').css({padding:'0.5em 0','padding-left':'132px',margin:'0','border-bottom':'thick #900 solid',background:'#fff url(http://widgets.fccinteractive.com/verticals/carshq.com/images/cars_logo_125.gif) no-repeat left center',color:'#900','font-size':'large','font-weight':'bold'}).text("Classifieds");jQuery(topVehicleHolder).append(topVehicleHeader);var objRandom,topVehicleID,topVehicleDescription,topVehicleLinerLink;var randomNumberList=[];var randomNumberCount=0;var topVehicleLiner=jQuery('<ul/>').css({'padding':'0 5px','margin':'0'});while(randomNumberList.length<objCount){objRandom=Math.floor(Math.random()*tvc.length);if(jQuery.inArray(objRandom,randomNumberList)==-1){randomNumberList[randomNumberCount]=objRandom;randomNumberCount++;topVehicleID=jsonData.topVehicleClassified[objRandom].id;topVehicleDescription=jsonData.topVehicleClassified[objRandom].description;if(randomNumberList.length!=objCount){topVehicleLinerLink=jQuery("<li/>").css({'list-style':'none','border-bottom':'1px solid #ccc',padding:'5px 7px','font-size':'11px',margin:'0','text-align':'left'})}else{topVehicleLinerLink=jQuery("<li/>").css({'list-style':'none',padding:'5px 7px','font-size':'11px',margin:'0','text-align':'left'})}var linerLink=jQuery('<a/>').attr({'title':topVehicleID,'href':'http://www.carshq.com/search/page/listing/id/'+topVehicleID+'/newspaper/'+CreatorDomain}).css({color:'#900','text-decoration':'none'}).hover(function(){jQuery(this).css('text-decoration','underline')},function(){jQuery(this).css('text-decoration','none')}).text(topVehicleDescription+' '+String.fromCharCode(187));jQuery(topVehicleLinerLink).append(linerLink);jQuery(topVehicleLiner).append(topVehicleLinerLink)}}jQuery(topVehicleHolder).append(topVehicleLiner);var topVehicleFooter=jQuery('<div></div>').css({padding:'0.5em',margin:'0','background-color':'#900',color:'#fff','text-align':'right'}).html('<a href="http://www.carshq.com/search/page/listing/newspaper/'+CreatorDomain+'" title="view all" style="color: #fff;text-decoration: none;">View All '+String.fromCharCode(187)+'</a>');jQuery(topVehicleHolder).append(topVehicleFooter);jQuery('#carsHQ_widget').append(topVehicleHolder)}}