

function renderProductListHtml()
{

	if (phoneList.mobilePhones.length > 0)
	{
		var productTemplateHtml = document.getElementById("productTemplate").innerHTML.replace(/&gt;/g, ">").replace(/&lt;/g, "<");
		var finalHtml = "";

		var productHtml = null;
		var phone = null;

		var currentColumn = 0;


		finalHtml += "<table>";
		for (var j = 0; j < phoneList.mobilePhones.length; j++)
		{
			//Column
				currentColumn++;
				if (currentColumn > columnCount)
				{
					//Last column in row
					currentColumn = 1;
				}
				else
				{
					//vertical separator line
						if (j != 0)
						{
							finalHtml += "<td class=\"productlistVertSep\"><img src=\"/MobileAdvisor/images/clear.gif\" height=\"1\" width=\"1\"></td>";
						}
				}
				if (currentColumn == 1)
				{
					//horizontal seperator
						if (j != 0)
						{
							finalHtml += "<tr><td class=\"productlistHorzSep\" colspan=\"" + ((columnCount * 2) - 1) + "\"></td></tr>";
						}

					finalHtml += "<tr>";
				}
			//Actual product
				phone = phoneList.mobilePhones[j];
				productHtml = productTemplateHtml;
				productHtml = productHtml.replace(/#name#/g, phone.name);
				productHtml = productHtml.replace(/#description#/g, phone.description); // Phone description yet to be implemented
				productHtml = productHtml.replace(/#phone_url#/g, phone.shopUrl);
				productHtml = productHtml.replace(/#phone_price#/g, phone.price);
				productHtml = productHtml.replace(/#min_price#/g, phone.priceTotalForBindingPeriod);
				productHtml = productHtml.replace(/#product_index#/g, j);
				productHtml = productHtml.replace(/#image_url_thumbnail#/g, phone.imageUrlThumbnail);
				finalHtml += "<td>" + productHtml + "</td>";

			//Column
				if (currentColumn == columnCount)
				{
					finalHtml += "</tr>";
				}
		}
		finalHtml += "</table>" + "<div class=\"productlistBottom\"></div>";

	}
	else
	{
		
		//no phones matched filter criterie
		finalHtml = document.getElementById("noProductsMatchedTemplate").innerHTML.replace(/&gt;/g, ">").replace(/&lt;/g, "<");
	}

	return finalHtml;

}
