function appendStockItems(container, items, maxItems)
{
  for(i = 0; i < maxItems; i++)
  {
    appendStockItem(container, items[i]);
  }
}

function appendStockItem(container, item)
{
  var stockItem = $('<div class="sockItemContainer">' + item.description + '</div>');
  stockItem.appendTo(container);
  
  // Lots of style fixups for IE.
  var imgDivs = $(stockItem).find("tr:first-child > td:nth-child(1) > div");
  if (imgDivs && imgDivs.length > 0)
  {
    imgDivs[0].style.width = "230";
  }
  
  var contentCell = $(stockItem).find("tr > td:nth-child(2)");
  if (contentCell && contentCell.length > 0)
  {
	contentCell[0].width = 330;
  }
  
  var contentDivs = $(contentCell).find("div");
  if (contentDivs && contentDivs.length > 0)
  {
    contentDivs[0].style.width = "280";
  }
}

function loadStockFeed(url, container)
{
  var callback = function(feed) {
    appendStockItems(container, feed.items, 3);
  };
      
  try {
    jQuery.getFeed({url: url, success: callback});
  } 
  catch (ignored)
  {
    if (jQuery.browser.msie && window.XDomainRequest)
    {
    	var xdr = new XDomainRequest();
    	xdr.open("get", url);
    	xdr.onload = function() {
    		var dom = new ActiveXObject("Microsoft.XMLDOM");
    		dom.async = false;
    		dom.loadXML(this.responseText);
    		var feed = new JFeed(dom);
    		callback(feed);
    	};
    	xdr.send();
    }
  }
}
