function eBayTopper(root)
{
	var items = root.SearchResult[0].ItemArray.Item || [];
	var allitems = root.ItemSearchURL;
	var item1 = Math.floor(Math.random() * items.length);
	var item2 = Math.floor(Math.random() * items.length);
	var item3 = Math.floor(Math.random() * items.length);
   	var html = [];

	html.push("<table style='background: #ffffcc;' 'width=600' cellspacing='1' cellpadding='1'>");
	html.push("<tr><td class='size14' colspan=3><b>Flipper su <font color='Red'>e</font><font color='blue'>b</font><font color='#ffcc00'>a</font><font color='green'>y</font></b></td>\n");
	html.push("<td colspan=3 class=\"right10\"><a href=\"" + allitems + "\" class=\"llink\" target=\"_blank\">vedi tutti i flipper su eBay</a></td></tr>\n");
	html.push("<tr>\n");

	if (items[item1].GalleryURL) {
		html.push("<td align=center>");
		html.push("<a class='llink' target='_blank' href='" + items[item1].ViewItemURLForNaturalSearch + "'>");
		html.push("<img valign=bottom border=0 height='50' width='50' src='" + items[item1].GalleryURL + "' " + "</a></td>\n");
	} else {
		html.push("<td align=center><img height='50' width='50' src='&nbsp;' " + "</td>\n");
	}
	html.push("<td class='size10'><a class='llink' target='_blank' href='" + items[item1].ViewItemURLForNaturalSearch + "'>" + items[item1].Title + "</a> <nobr>EUR ");
	html.push(items[item1].ConvertedCurrentPrice.Value.toFixed(2) + "</nobr></td>\n");

	if (items[item2].GalleryURL) {
		html.push("<td align=center>");
		html.push("<a class='llink' target='_blank' href='" + items[item2].ViewItemURLForNaturalSearch + "'>");
		html.push("<img valign=bottom border=0 height='50' width='50' src='" + items[item2].GalleryURL + "' " + "</a></td>\n");
	} else {
		html.push("<td align=center><img height='50' width='50' src='&nbsp;' " + "</td>\n");
	}
	html.push("<td class='size10'><a class='llink' target='_blank' href='" + items[item2].ViewItemURLForNaturalSearch + "'>" + items[item2].Title + "</a> <nobr>EUR ");
	html.push(items[item2].ConvertedCurrentPrice.Value.toFixed(2) + "</nobr></td>\n");

	if (items[item3].GalleryURL) {
		html.push("<td align=center>");
		html.push("<a class='llink' target='_blank' href='" + items[item3].ViewItemURLForNaturalSearch + "'>");
		html.push("<img valign=bottom border=0 height='50' width='50' src='" + items[item3].GalleryURL + "' " + "</a></td>\n");
	} else {
		html.push("<td align=center><img height='50' width='50' src='&nbsp;' " + "</td>\n");
	}
	html.push("<td class='size10'><a class='llink' target='_blank' href='" + items[item3].ViewItemURLForNaturalSearch + "'>" + items[item3].Title + "</a> <nobr>EUR ");
	html.push(items[item3].ConvertedCurrentPrice.Value.toFixed(2) + "</nobr></td>\n");

	html.push("</tr></table>\n");
	document.getElementById("ebayTopper").innerHTML = html.join("");
}

function eBayFooter(root)
{
	var items = root.SearchResult[0].ItemArray.Item || [];
	var allitems = root.ItemSearchURL;
	var item1 = Math.floor(Math.random() * items.length);
	var item2 = Math.floor(Math.random() * items.length);
	var item3 = Math.floor(Math.random() * items.length);
   	var html = [];

	html.push("<table 'style='background: #ffffcc;' 'width=600' cellspacing='1' cellpadding='1'>");
	html.push("<tr><td class='size12' width=20><b><font color='Red'>e</font><br><font color='blue'>b</font><br><font color='#ffcc00'>a</font><br><font color='green'>y</font></b></td>\n");

	if (items[item1].GalleryURL) {
		html.push("<td align=center>");
		html.push("<a class='llink' target='_blank' href='" + items[item1].ViewItemURLForNaturalSearch + "'>");
		html.push("<img valign=bottom border=0 height='50' width='50' src='" + items[item1].GalleryURL + "' " + "</a></td>\n");
	} else {
		html.push("<td align=center><img height='50' width='50' src='&nbsp;' " + "</td>\n");
	}
	html.push("<td class='size10'><a class='llink' target='_blank' href='" + items[item1].ViewItemURLForNaturalSearch + "'>" + items[item1].Title + "</a> <nobr>EUR ");
	html.push(items[item1].ConvertedCurrentPrice.Value.toFixed(2) + "</nobr></td>\n");

	if (items[item2].GalleryURL) {
		html.push("<td align=center>");
		html.push("<a class='llink' target='_blank' href='" + items[item2].ViewItemURLForNaturalSearch + "'>");
		html.push("<img valign=bottom border=0 height='50' width='50' src='" + items[item2].GalleryURL + "' " + "</a></td>\n");
	} else {
		html.push("<td align=center><img height='50' width='50' src='&nbsp;' " + "</td>\n");
	}
	html.push("<td class='size10'><a class='llink' target='_blank' href='" + items[item2].ViewItemURLForNaturalSearch + "'>" + items[item2].Title + "</a> <nobr>EUR ");
	html.push(items[item2].ConvertedCurrentPrice.Value.toFixed(2) + "</nobr></td>\n");

	if (items[item3].GalleryURL) {
		html.push("<td align=center>");
		html.push("<a class='llink' target='_blank' href='" + items[item3].ViewItemURLForNaturalSearch + "'>");
		html.push("<img valign=bottom border=0 height='50' width='50' src='" + items[item3].GalleryURL + "' " + "</a></td>\n");
	} else {
		html.push("<td align=center><img height='50' width='50' src='&nbsp;' " + "</td>\n");
	}
	html.push("<td class='size10'><a class='llink' target='_blank' href='" + items[item3].ViewItemURLForNaturalSearch + "'>" + items[item3].Title + "</a> <nobr>EUR ");
	html.push(items[item3].ConvertedCurrentPrice.Value.toFixed(2) + "</nobr></td>\n");

	html.push("</tr><tr><td colspan=7 valign=top class=\"right10\"><a href=\"" + allitems + "\" class=\"llink\" target=\"_blank\">vedi tutti i flipper</a></td>\n");
	html.push("</tr></table>\n");
	document.getElementById("ebayFooter").innerHTML = html.join("");
}

function eBayResults(root)
{
		var items = root.SearchResult[0].ItemArray.Item || [];
    	var html = [];

		html.push("<table width=80%>\n");
		if (items.length)
			document.getElementById("ebayres").style.display = '';
		for (i = 0; i < items.length; ++i ) {
			html.push("<tr>\n");
			if (items[i].GalleryURL) {
				html.push("<td align=center>");
				html.push("<a class='llink' target='_blank' href='" + items[i].ViewItemURLForNaturalSearch + "'>");
				html.push("<img valign=bottom border=0 height='50' width='50' src='" + items[i].GalleryURL + "' " + "</a></td>\n");
			} else {
				html.push("<td align=center>");
				html.push("<a class='llink' target='_blank' href='" + items[i].ViewItemURLForNaturalSearch + "'>");
				html.push("<img valign=bottom border=0 height='50' width='50' src='/nogallery.gif'></a></td>\n");
			}
			html.push("<td class='size12'><b><a class='llink' target='_blank' href='" + items[i].ViewItemURLForNaturalSearch + "'>" + items[i].Title.replace(/[,\-]/ig, ' ') + "</a></b></td>");
			html.push("<td class='size12'>");
			html.push(items[i].ConvertedCurrentPrice.CurrencyID + " ");
			html.push(items[i].ConvertedCurrentPrice.Value.toFixed(2) + "</td>\n");
			html.push("</tr>\n");
		}			
		html.push("<tr><td colspan=3>&nbsp;</td></tr>");
		html.push("<tr><td colspan=3 class=\"right10\"><a href=\"" + root.ItemSearchURL + "\" class=\"llink\" target=\"_blank\">vedi tutti i " + root.TotalItems + " oggetti su eBay</a></td></tr>\n");
		html.push("</table>\n");
  		document.getElementById("ebayResults").innerHTML = html.join("");
}
