// applies to client logos
// if true, will display generated html in alert dialog
var debugClientLogos = false;
// if false, will not write to page;
var writeHTMLClientLogos = true;


// The Central Randomizer 1.3 (C) 1997 by Paul Houle (paul@honeylocust.com)
// See:  http://www.honeylocust.com/javascript/randomizer.html
// real: rnd();    integer: rand(someNumber)
rnd.today=new Date();
rnd.seed=rnd.today.getTime();
function rnd() { rnd.seed = (rnd.seed*9301+49297) % 233280; return rnd.seed/(233280.0); };
function rand(number) { return Math.floor(rnd()*number); };

// width max ~ 145px;

function showClientLogos()
	{

	var clients = new Array
		(
			{
			imageName:"ebay.gif",
			alt:"eBay",
			imageWidth:125,
			imageHeight:54
			}, 

			{
			imageName:"pepperidge.gif",
			alt:"Pepperidge Farms",
			imageWidth:142,
			imageHeight:50
			}, 

			{
			imageName:"skype.gif",
			alt:"Skype",
			imageWidth:105,
			imageHeight:47
			}, 

			{
			imageName:"visa.gif",
			alt:"Visa",
			imageWidth:125,
			imageHeight:40
			}, 
			
			{
			imageName:"paypal.gif",
			alt:"Paypal",
			imageWidth:106,
			imageHeight:29
			}, 
			
			{
			imageName:"power_reviews.gif",
			alt:"Power Reviews",
			imageWidth:104,
			imageHeight:29
			}, 
		
			{
			imageName:"gnc.gif",
			alt:"GNC Live Well",
			imageWidth:136,
			imageHeight:30
			}, 

			{
			imageName:"usps.gif",
			alt:"USPS",
			imageWidth:103,
			imageHeight:18
			}, 

			{
			imageName:"campbell_ewald.gif",
			alt:"Campbell Ewald",
			imageWidth:107,
			imageHeight:9
			}, 

			{
			imageName:"draft_fcb.gif",
			alt:"Draft FCB",
			imageWidth:92,
			imageHeight:16
			}, 

			{
			imageName:"pierce.gif",
			alt:"Pierce",
			imageWidth:57,
			imageHeight:66
			}, 

			{
			imageName:"euro_rscg.gif",
			alt:"Euro RSCG",
			imageWidth:121,
			imageHeight:27
			}, 

			{
			imageName:"vox_entertainment.gif",
			alt:"VOX Enterainment",
			imageWidth:125,
			imageHeight:17
			}, 

			{
			imageName:"yahoo.gif",
			alt:"Yahoo!",
			imageWidth:135,
			imageHeight:26
			}, 

			{
			imageName:"think360.gif",
			alt:"Think 360 Incorporated",
			imageWidth:130,
			imageHeight:33
			}, 

			{
			imageName:"frs_health_energy.gif",
			alt:"FRS Health Enerby",
			imageWidth:100,
			imageHeight:54
			}, 

			{
			imageName:"cbs_television.gif",
			alt:"CBS Television Distribution",
			imageWidth:139,
			imageHeight:20
			}, 

			{
			imageName:"campbell_soup.gif",
			alt:"Campbell Soup Company",
			imageWidth:140,
			imageHeight:24
			}, 

			{
			imageName:"aol.gif",
			alt:"AOL",
			imageWidth:125,
			imageHeight:42
			}, 

			{
			imageName:"circle_one.gif",
			alt:"Circle One",
			imageWidth:93,
			imageHeight:42
			}
		
		)


			/*  old client logos			
			{ imageName:"hit.gif", alt:"Hit Entertainment", imageWidth:75, imageHeight:75 }, 
			{ imageName:"sesame_workshop.gif", alt:"Sesame Workshop", imageWidth:73, imageHeight:46 }, 
			{ imageName:"aaa.gif", alt:"AAA", imageWidth:83, imageHeight:51 }, 
			{ imageName:"cellfire.gif", alt:"Cellfire", imageWidth:86, imageHeight:24 }, 
			{ imageName:"jakks_pacific.gif", alt:"Jakk's Pacific", imageWidth:127, imageHeight:33 }, 
			{ imageName:"espn.gif", alt:"ESPN", imageWidth:89, imageHeight:23 }, 			
			{ imageName:"refinery.gif", alt:"Refinery", imageWidth:103, imageHeight:49 }, 
			{ imageName:"nma.gif", alt:"NMA", imageWidth:69, imageHeight:35 }, 			
			{ imageName:"ion.gif", alt:"ION", imageWidth:75, imageHeight:43 }, 			
			{ imageName:"swirl.gif", alt:"Swirl", imageWidth:110, imageHeight:9 }, 
			{ imageName:"insight_express.gif", alt:"Insight Express", imageWidth:125, imageHeight:30 }, 
			{ imageName:"spot_runner.gif", alt:"Spot Runner", imageWidth:106, imageHeight:42 }, 			
			{ imageName:"insider_pages.gif", alt:"Insider Pages", imageWidth:105, imageHeight:24 }, 
			{ imageName:"on_the_go.gif", alt:"On The Go", imageWidth:48, imageHeight:61 }, 
			{ imageName:"entertainment.gif", alt:"Entertainment", imageWidth:113, imageHeight:30 }, 
			*/

	var allLogos = clients.length;
	var storeRandomOrder = new Array();

	// set array and make sure to pick each number only once.
	// uses the length of the array and randomly picks all numbers in array only once
	// eg: 6 elements in array "logos"; populates new array with the numbers 0 - 5 in random order
	// uses that randomly ordered array as the basis to create random display order of images in "logos" array.
	for (x=0;x<allLogos;x++)
		{
		storeRnd = storeRandomOrder.length;
		// for first number, there is nothing to compare, so just put number in array
		if (x==0) {  r = rand(allLogos); storeRandomOrder[x] = r; }
		// otherwise, start comparing to make sure no repeats
		else
			{
			repeat=true;
			while (repeat == true)
				{
				repeat = false;
				r = rand(allLogos);
				for (k=0;k<=storeRnd;k++) { if (r==storeRandomOrder[k])  { repeat=true; } }
				storeRandomOrder[x] = r;
                }
			}
		}

	// -----------------------------------
	
	// now that order of random images is set,
	// just create a table and pop images in.

	// for now, leave at 3 columns; 
	// because this table also tied to a stylesheet defining the width of the table
	// if this needs to be changed later on, take an approximate width measurement
	// of the new display table and modify "clientLogoTable" in stylesheets
	var howManyColumns = 4;
	
	var bot = '<table border="0" cellpadding="0" cellspacing="10" class="clientLogoTable" align="center">\r<tr>\r';
	var emptyTD = '<td></td>\r';
	var eol = '<\/tr>\r\r<tr>\r';
	var eot = '<\/tr>\r</table>';
	var td1 = '<td align="center">';
	var td2 = '<\/td>\r';

	var img1 = '<img src="images/our_clients/'; /* */
	var alt = '" alt="';
	var ttl = '" title="';
	var wdth = '" width="';
	var hght = '" height="';
	
	var endImg = '" border="0" />';	
	

	if (!howManyColumns) {howManyColumns=1}
	var counter = 0;
	var remainder = 0;
	dt = bot;
	for (i=0; i<allLogos; i++)
		{
		whichImage = storeRandomOrder[i];
		//alert(whichImage);
		remainder = (i % howManyColumns);   
		counter = i+1;
		
		var newImage = img1 + clients[whichImage]["imageName"] +  ttl + clients[whichImage]["alt"] +  alt + clients[whichImage]["alt"] + wdth + clients[whichImage]["imageWidth"] + hght + clients[whichImage]["imageHeight"] + endImg;
		
		
		dt = dt + td1 + newImage + td2;
		//dt = dt + "<TD>" + holder[i] + "<\/TD>\r";
		// if more images to proccess and end of row reached.
		if ((counter != allLogos) && (counter % howManyColumns == 0))
		{ dt += eol; }
		// if all images processed
		if (counter == allLogos)
		{ 
		// howManyColumns - remainder - 1
		// means the number of blank columns left to fill in, in the row
		// if last image processed is not the last image in the row;
		// fill table with blank <TD>s to make table grammatically correct
		for (temp=0; temp<(howManyColumns - remainder - 1); temp++)
			{ dt = dt + emptyTD; }
		// otherwise, last image in array is also last image in row, and just finish off table
		dt = dt + eot;
		}
		}	

	if ( debugClientLogos ) { alert(dt); }
	if ( writeHTMLClientLogos ) { document.getElementById("logoContainer").innerHTML = dt; }		
	
	}


