/* Hot Deal Object Container * Used to encapsulate and render a series of HotDeal * objects */ HotDealContainer = function() { this.contents = new Array(); this.add = function(oHotDeal) { this.contents[this.contents.length] = oHotDeal; } this.render = function() { var container = document.getElementById('HotDeals_Loader').parentNode; var list = document.createElement('ul'); for(var i=0; i block. All constructor arguments are optional but * should be in this order: * @param str id - Car ID (PaID) * @param str year - Year * @param str make - Make * @param str model - Model * @param str dealer - Dealer * @param str price - Price * @param str photoURL - Photo URL */ HotDeal = function (id,year,make,model,dealer,price,photoURL) { this.id = (id==null) ? '' : id; this.year = (year==null) ? '' : year; this.make = (make==null) ? '' : make; this.model = (model==null) ? '' : model; this.dealer = (dealer==null)? '' : dealer; this.price = (price==null) ? '' : price; this.photo = (photoURL==null) ? '' : photoURL; this.getNode = function(node) { var li,img,makeModel,price,dealer; li = document.createElement('li'); li.id = 'HD_' + this.id; li.onclick = goToURL; li.onmouseover = rollOver; li.onmouseout = rollOut; li.title = 'View details...'; img = document.createElement('img'); img.src = this.photo; img.width = 85; img.height = 63; img.alt = this.year + ' ' + this.make + ' ' + this.model; li.appendChild(img); makeModel = document.createElement('span'); makeModel.className = 'make-model'; makeModel.innerHTML = this.year + ' '+ this.make + ' ' + this.model; li.appendChild(makeModel); price = document.createElement('span'); price.className = 'price'; price.innerHTML = this.price; li.appendChild(price); dealer = document.createElement('span'); dealer.className = 'dealer'; dealer.innerHTML = this.dealer; li.appendChild(dealer); return li; } } function goToURL() { window.location='http://www.cars.com/go/search/detail.jsp?aff=triangle&paId=' + this.id.replace('HD_',''); } function rollOver() { this.className += ' HD_over'; } function rollOut() { this.className = ''; } var cars = new HotDealContainer(); cars.add(new HotDeal('222872746','2007','Chevrolet','Monte Carlo','Leith Lincoln Mercury','$13,688','http://newsobserver.com/images/hotdeals/222872746/Hot_Deals.jpg')); cars.add(new HotDeal('234053932','1999','Volkswagen','Beetle','Leith Volkswagen','$8,950','http://newsobserver.com/images/hotdeals/234053932/Hot_Deals.jpg')); cars.add(new HotDeal('134475611','2006','Chevrolet','Express','Doug Jones Chevrolet','$19,995','http://newsobserver.com/images/hotdeals/134475611/Hot_Deals.jpg')); cars.add(new HotDeal('134341723','2005','Mazda','Tribute','Doug Jones Chevrolet','$16,995','http://newsobserver.com/images/hotdeals/134341723/Hot_Deals.jpg')); cars.add(new HotDeal('229418270','2002','Chevrolet','Silverado','Autopark Honda','$13,950','http://newsobserver.com/images/hotdeals/229418270/Hot_Deals.jpg')); // Generate HTML cars.render();