function writeArray2Table(arrayOfEntities){

	//given an array of entity information this function creates a formatted HTML table
	//each item in arrayOfEntities is presented
	//format for each item in arrayOfEntities is "name,url,imagefile,address,city,zip,phone"
	//    in a comma delimited format


	document.write ("<table border=1 cellspacing=0 cellpadding=6 bordercolor=#C0C0C0 width=600>");

	//use a for loop to create the body of the table

	for (var i=0; i < arrayOfEntities.length; i++) {

		entityString = arrayOfEntities[i];
		entityInfoArray = entityString.split(",");
		entityName = entityInfoArray[0];
		entityURL = entityInfoArray[1];
		entityImg = entityInfoArray[2];
		entityAddress = entityInfoArray[3];
		entityCity = entityInfoArray[4];
		entityZip = entityInfoArray[5];
		entityPhone = entityInfoArray[6];
		
		if ((i % 2) == 0) document.write ("<tr>");
		document.write ("<td valign=top class=txt_9 bgcolor=#F8F0D0 width=50% ><p class=txt_9>");
		if (entityImg.length != 0) {
			document.write ("<a href=http://" + entityURL + ">");
			document.write ("<img border=0 width=122 height=71 src=../images/" + entityImg + " align=left></a>");
		}
		else {

			document.write ("<img border=0 width=122 height=71 src=../images/ghost.gif" + " align=left></a>");
		}
		document.write ("<b>" + entityName + "</b><br>");
		document.write ( entityAddress + "<br>" );
		document.write ( entityCity );
		if (entityZip.length != 0) document.write (" " + entityZip);
		document.write ( "<br>");
		document.write ( entityPhone + "<br>" );
		document.write ("<a href=http://" + entityURL + "><font color=#800000>" + entityURL + "</font></a><br>" );
		document.write ("</td>");
		if ((i % 2) == 1) document.write ("</tr>");
	}

	//finish with an blank cell if necessary and close the table

	if ((i % 2) == 1) document.write ("<td valign=top class=txt_9 bgcolor=#F8F0D0 width=50% >&nbsp;</td></tr>");
	document.write ("</table>");

}

function writeGrowerArray2Table(arrayOfEntities){

	//given an array of entity information this function creates a formatted HTML table
	//each item in arrayOfEntities is presented
	//format for each item in arrayOfEntities is "name,url, vine location,address,city,zip,phone"
	//    in a comma delimited format


	document.write ("<table border=1 cellspacing=0 cellpadding=6 bordercolor=#C0C0C0>");

	//use a for loop to create the body of the table

	for (var i=0; i < arrayOfEntities.length; i++) {

		entityString = arrayOfEntities[i];
		entityInfoArray = entityString.split(",");
		entityName = entityInfoArray[0];
		entityURL = entityInfoArray[1]; 
		vinesAt = entityInfoArray[2];
		entityAddress = entityInfoArray[3];
		entityCity = entityInfoArray[4];
		entityState = entityInfoArray[5];
		entityZip = entityInfoArray[6];
		entityPhone = entityInfoArray[7];
		
	
		
		if ((i % 3) == 0) document.write ("<tr>");
		document.write ("<td valign=top class=txt_9 bgcolor=#F8F0D0 width=200 ><p class=txt_9>");
		if (entityURL.length == 0) document.write ("<b>" + entityName + "</b><br>");
		if (entityURL.length != 0) document.write ("<b><a href=http://" + entityURL + ">" + entityName + "</a></b><br>");
		
		if (vinesAt.length != 0) document.write ("at " + vinesAt + "<br>");		
		document.write ( entityAddress + "<br>" );
		document.write ( entityCity + ", ");
		document.write ( entityState + " ");
		if (entityZip.length != 0) document.write (entityZip);
		document.write ( "<br>");
		document.write ( entityPhone + "<br>");
		document.write ( "</td>");
		if ((i % 3) == 2) document.write ("</tr>");
	}

	//finish with an blank cell if necessary and close the table
	if ((i % 3) == 1) document.write ("<td valign=top class=txt_9 bgcolor=#F8F0D0 width=200 >&nbsp;</td><td valign=top class=txt_9 bgcolor=#F8F0D0 width=200 >&nbsp;</td></tr>");
	if ((i % 3) == 2) document.write ("<td valign=top class=txt_9 bgcolor=#F8F0D0 width=200 >&nbsp;</td></tr>");

	
	
	document.write ("</table>");

}

function writeWineryTable(arrayOfEntities){

	//given an array of entity information this function creates a formatted HTML table
	//each item in arrayOfEntities is presented
	//format for each item in arrayOfEntities is "name,url,imagefile,plus four delimited lines of various info"
	//    in a comma delimited format


	document.write ("<table border=1 cellspacing=0 cellpadding=6 bordercolor=#C0C0C0 width=600>");

	//use a for loop to create the body of the table

	for (var i=0; i < arrayOfEntities.length; i++) {

		entityString = arrayOfEntities[i];
		entityInfoArray = entityString.split(",");
		entityName = entityInfoArray[0];
		entityURL = entityInfoArray[1];
		entityImg = entityInfoArray[2];
		entityLine1 = entityInfoArray[3];
		entityLine2 = entityInfoArray[4];
		entityLine3 = entityInfoArray[5];
		entityLine4 = entityInfoArray[6];
		
		if ((i % 2) == 0) document.write ("<tr>");
		document.write ("<td valign=top class=txt_9 bgcolor=#F8F0D0 width=50% ><p class=txt_9>");
		document.write ("<table border=0 cellpadding=0 cellspacing=0 width=105 align=left>");
		document.write ("<tr valign=top><td width=100 valign=top align=center>");
		
		if (entityImg.length >= 1) document.write ("<img border=0 src='../images/labels/" + entityImg + "' >");
		document.write ("</td><td width=5><img border=0 width=5 height=100 src=../images/ghost.gif" + ">");
		document.write ("</td></tr></table>");
		
		if (entityURL.length == 0) document.write ("<b>" + entityName + "</b><br>");
		if (entityURL.length != 0) document.write ("<b><a href=http://" + entityURL + ">" + entityName + "</a></b><br>");

		if (entityLine1.length >=1) document.write ( entityLine1 + "<br>" );
		if (entityLine2.length >=1) document.write ( entityLine2 + "<br>" );
		if (entityLine3.length >=1) document.write ( entityLine3 + "<br>" );
		if (entityLine4.length >=1) document.write ( entityLine4 + "<br>" );
		
		document.write ("</td>");
		if ((i % 2) == 1) document.write ("</tr>");
	}

	//finish with an blank cell if necessary and close the table

	if ((i % 2) == 1) document.write ("<td valign=top class=txt_9 bgcolor=#F8F0D0 width=50% >&nbsp;</td></tr>");
	document.write ("</table>");

}
