/*
 * Display a randome set of products in random order on the home page
 *
 * (c) Copyright 2009 Hen's Teeth Network, Inc. All rights reserved. www.hens-teeth.net
 */
function randomizeProducts(containerId, prodList)
{
	var numProducts = 12;			// number of products to display on the page
	var openDiv = '<div style="float: left; width: 18%; max-width: 18%; margin: 5px; padding: 5px; height: 270px;">';

	/*** Nothing below this line should need to be changed ***/

	var contentList = new Array();
	var newContent = '';
	var i;
	for (i = 0; i < prodList.length; i++)
	{
		var key = prodList[i];
		var html = $('#' + key).html();
		contentList.push(html);
	}
	$('#' + containerId).html('<h1>nothing here yet...</h1>');
	for (i = 0; i < numProducts; i++)
	{
		var element = Math.round(Math.random() * (contentList.length - 1));		// pick a random element from 0 to the last in the array
		var newDiv = openDiv + contentList[element] + '</div>';					// create a new div for this random product
		newContent += newDiv;
		contentList.splice(element, 1);											// delete this product from the list of products
	}
	$('#' + containerId).html(newContent);										// replace the content of the container with the random products
}
