/* 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('202435608','2002','Audi','A6','Lotus of Durham','$19,950','http://newsobserver.com/images/hotdeals/202435608/Hot_Deals.jpg')); cars.add(new HotDeal('208987094','2004','Honda','Odyssey','Capital Ford','$18,595','http://newsobserver.com/images/hotdeals/208987094/Hot_Deals.jpg')); cars.add(new HotDeal('209230080','2005','Ford','F150','Capital Ford','$27,795','http://newsobserver.com/images/hotdeals/209230080/Hot_Deals.jpg')); cars.add(new HotDeal('133353043','2004','Hummer','H2','Westgate Imports','$28,900','http://newsobserver.com/images/hotdeals/133353043/Hot_Deals.jpg')); cars.add(new HotDeal('209230212','2004','Ford','Excursion','Capital Ford','$24,995','http://newsobserver.com/images/hotdeals/209230212/Hot_Deals.jpg')); // Generate HTML cars.render();