function greeting() {
      var myDate = new Date();
      var myHour = myDate.getHours();

	var nIndex = 0;
      if(myHour < 6) nIndex = 0;
      else if(myHour < 9) nIndex = 1;
      else if(myHour < 12) nIndex = 2;
      else if(myHour < 14) nIndex = 3;
      else if(myHour < 17) nIndex = 4;
      else if(myHour < 19) nIndex = 5;
      else if(myHour < 22) nIndex = 6;
      else nIndex = 7;
  

	var strReturn = "<span class=\"px1\">" + myDate.getYear() + m_strDates[0] +
		(myDate.getMonth() + 1) + m_strDates[1] + 
		myDate.getDate() + m_strDates[2] + "&nbsp;&nbsp;&nbsp;" +
       	m_strDates[3] + m_strDays[myDate.getDay()] + "&nbsp;&nbsp;&nbsp;" +
       	m_strDates[4] + "&nbsp;&nbsp;" + m_strWelcomeText[nIndex] + "</span>";

	return strReturn;
}

function changepage(nIndex) {
	var pageName = m_aryPageIDs[nIndex];

	var strBody = pageName + ".htm";

	document.all("modules").innerHTML = getmoduletab(nIndex);

	parent.main_body.location.href=strBody;
}

function weeklyscripture() {
	return m_strWeeklyScripture;
}

function versionType() {
	return "";
/*	var strText = "&nbsp&nbsp" + 
		"<a href=\"#\" class=\"px2\">" + m_strVersionType[0] + "</a>|" +
		"<a href=\"#\" class=\"px2\">" + m_strVersionType[1] + "</a>|";

	return strText;
*/
}

function getlogoimage() {
	var nIndex = Math.floor(Math.random() * 20);
	var strImage = "/images/dcac_logo_" + nIndex + ".jpg";
	return strImage;
}

function logohtml(nWidth) {
	var strText = "<table cellpadding=\"0\" cellspacing=\"0\">" + 
		"<tr>" +
			"<td width=\"150\" align=\"center\"><a href = \"http://www.cmalliance.org\" target=\"main_body\">" + 
				"<img border=\"no\" src=\"/images/dcac_top.gif\"></a></td>" +
			"<td style=\"cursor:hand\" onclick=\"parent.location.href='default.htm'\" background=\"" + 
				getlogoimage() + "\" width=\"" + (nWidth - 150) +"\" align=\"center\">" + 
				"<b><font color=\"white\" size=\"6\">" + m_strChurchName + "</font><br>" +
				"<font color=\"yellow\" face=\"courier\" size = \"5\">Danbury Chinese Alliance Church</font><br>" +
				"<font color=\"white\" size=\"3\">http://dcac-cma.org</font></b></td>" +
		"</tr>" + 
	"</table>";

	return strText;
}

function BuildTab(strType, nIndex)
{
	var strStyle = "style=\"cursor:hand;color:white\" " +
			"onmouseover=\"this.style.color='red'\" " +
			"onmouseout=\"this.style.color='white'\" " + 
			"onclick=\"javascript:changepage('" + nIndex + "');\" ";
	var outer;
	var inner;

	switch (strType) {
	case 'active':
		outer = "selected";
		inner = "";
		strStyle = "style=\"color:green\" ";
		break;
	case 'leftneighbor':
		outer = "normalboxOut";
		inner = "selectedR";
		break;
	case 'rightneighbor':
		outer = "normalboxOut";
		inner = "selectedL";
		break;
	case 'other':
		outer = "normalboxOut";
		inner = "normalboxIn";
		break;
	}

	return "<TD " + strStyle + "align=\'center\'>" + 
			"<DIV class=\'" + outer+ "\'><DIV class=\'" + inner + "\'><DIV class=\'modulelink\'>" + 
			m_aryPageCaps[nIndex] + "</DIV></DIV></DIV></TD>\r\n";
}

function getmoduletab(nActiveIndex) {
	//var strText = "<table cellspacing=0 cellpadding=0><tr><td>"
	var strText = "<table border=\'0\' cellspacing=\'0\' cellpadding=\'0\'><tr>\r\n";

		for(i = 0; i < m_aryPageCaps.length; i++)
		{
			if(i + 1 == nActiveIndex)
			{
				strText += BuildTab("rightneighbor", i);
				continue;
			}
			else if(i - 1 == nActiveIndex)
			{
				strText += BuildTab("leftneighbor", i);
				continue;
			}
		    
			else if(i == nActiveIndex)
			{ 
				strText += BuildTab("active", i);
				continue;
			}
		
			else strText += BuildTab("other", i);
		}

	strText += "</tr></table>";

	/*strText += "</td></tr>";

	strText += "<tr height=20><td class=\"px1\" style = \"background:#63B8EE; \">" + 
		"<marquee scrollamount=3><script language=\"javascript\">document.write(weeklyscripture())</script></marquee>" +
		"</td></tr></table>";
*/
	return strText;

}