<!--
//See _db_structure.js for DB table structure
//
// List of DB functions, ©2002 Spa-hitz Software
function BuildDBEntry(cntr, LVIndicatorCode )
{
	var LoopStart;
	var LoopEnd;

	var CodeName;
	var WebSite;
	var LinkNumber = 0;
	var EMail;
	var InCommunity;

	//var LVIndicatorCode = "b"; // e=event, p=park, b=business, s=school, g=govt, a=apt, m=misc

	if (cntr == -1) // write all
	{
		LoopStart = 0;
		LoopEnd = DBList.length;
	} else {
		LoopStart = cntr;
		LoopEnd = cntr;
	}
	if (cntr == -1) // write all
		document.write("<TABLE BORDER=0 BORDERCOLOR=black WIDTH=100% BGCOLOR=#4A4137 CELLSPACING=0 CELLPADDING=0>");

		switch (LVIndicatorCode)
		{
			case 'e':
			case 'p':
			case 'b':
			case 's':
			case 'g':
			case 'a':
			case 'm':
				break;
			default:
				LVIndicatorCode = 'b';
		}

		for (var i = LoopStart; i < LoopEnd; i++)
		{
			CodeName = GetField(i,2);
			InCommunity = GetField(i,3);
			WebSite = GetField(i,5);
			EMail = GetField(i,6);

			// Begin a new table row
			document.write("  <TR>");

			// Add the entity name
			document.write("    <TD WIDTH=200 VALIGN=TOP NOWRAP HEIGHT=17");
			document.write(" STYLE='mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; border-left-style: none; border-left-width: medium; border-right: .5pt solid windowtext; border-top-style: none; border-top-width: medium; border-bottom: .5pt solid windowtext; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; padding-bottom: 0in'>");
			document.write("<FONT FACE=Arial SIZE=2>");

			// If a website exists, also add a globe link
			if (WebSite != "")
			{
				LinkNumber++;
				document.write('<A HREF="http://' + WebSite + '"');
				document.write(" onmouseover=ShowPic('L'," + LinkNumber + ",'" + CodeName + "')");
				document.write(" onmouseout=HidePic('L'," + LinkNumber + ",'" + CodeName + "')>");
				document.write('<IMG BORDER=0 SRC="images/globe15x15pixels1.gif" ALT="Visit Our Site, Click Here!" ID="Link"' + LinkNumber + ' NAME="Link' + LinkNumber + '" LOWSRC="images/globe15x15pixels2.gif" WIDTH="15" HEIGHT="15">');
				document.write("</A> ");
			}

			// If website exists, put link around name, else just put name
			if (WebSite != "")
			{
				document.write("<FONT COLOR=#FFDC7E><B>");
				document.write('<A HREF="http://' + WebSite + '">');
			}
			document.write(GetField(i,1));
			if (WebSite != "")
			{	document.write("</B></A></FONT>");	}

			// If entity is in the community, add an image
			if (InCommunity == "Y")
			{	document.write(' <IMG BORDER=0 SRC="images/' + LVIndicatorCode + '-lv.gif" width=14 height=15>');		}

			// If e-mail is included, show the image
			if (EMail != "")
			{
				LinkNumber++;
				document.write("<A HREF=mailto:" + EMail + " onMouseOver=ShowPic('M'," + LinkNumber + ",'" + CodeName + "') onMouseOut=HidePic('M'," + LinkNumber + ",'" + CodeName + "')>");
				document.write("<IMG BORDER=0 SRC=images/email1.gif ID=Mail" + LinkNumber + " NAME=Mail" + LinkNumber + " LOWSRC=images/email4.gif WIDTH=14 HEIGHT=14></A>");
			}

			// Now end the entity cell
			document.write("</FONT></TD>");

			// Add the phone number
			document.write("    <TD WIDTH=100 VALIGN=TOP ALIGN=center NOWRAP HEIGHT=17");
			document.write(" STYLE='mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; border-left-style: none; border-left-width: medium; border-right: .5pt solid windowtext; border-top-style: none; border-top-width: medium; border-bottom: .5pt solid windowtext; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; padding-bottom: 0in'>");
			document.write("<FONT FACE=Arial SIZE=2>");

			if (WebSite != "")
			{	document.write("<FONT COLOR=#FFDC7E>");	}
			document.write(GetField(i,7));
			if (WebSite != "")
			{	document.write("</FONT>");	}
			document.write("</FONT></TD>");

			// Add the Street address
			document.write("    <TD WIDTH=* VALIGN=TOP NOWRAP HEIGHT=17");
			document.write(" STYLE='mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; border-left-style: none; border-left-width: medium; border-right: .5pt solid windowtext; border-top-style: none; border-top-width: medium; border-bottom: .5pt solid windowtext; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; padding-bottom: 0in'>");
			document.write("<FONT FACE=Arial SIZE=2>");

			if (WebSite != "")
				document.write("<FONT COLOR=#FFDC7E>");
			document.write(GetField(i,8));
			if (WebSite != "")
				document.write("</FONT>");

			document.write("</FONT></TD>");

			// End the table row
			document.write("  </TR>");
		}
	if (cntr == -1) // write all
		document.write("</TABLE>");
}

function GetField(iRow, iField)
{
	// Get the string value of the specified field (column) for the specified row
	if (iRow < 0 | iRow > DBList.length)
		return "";

	var strDelim = "•"; // constant table delimiter
	var iPosit;
	
	var strRow = DBList[iRow];

	if (iField < 0)
		return "";

	for (var i = 1; i < iField; i++)
	{
		iPosit = strRow.indexOf(strDelim, 0);
		strRow = strRow.substr(iPosit + 1, 99999);
	}

	iPosit = strRow.indexOf(strDelim);
	if (iPosit < 0)
	{	return(strRow);	}
	else
	{	return(strRow.substr(0, iPosit));	}
}
//-->
