/*******************************************************************************************
 Purpose: 		This function will use the storage frame to show a welcome text (from dynamic
 				options defined in the GeneralNav frameset).

 Created By: 	Steven Skarupa
 Create On:		8/2000

 History:
 Date			Modifier		Change
 ---------- 	---------------	----------------------------------------------------------------
 01/16/2001		Neal Tillotson	added call to ReplaceHourlyMessage()
 11/07/2001		Steven Skarupa	Added the ability to override the call to storage frame by 
 								passing in a welcome text string.
*******************************************************************************************/
function WriteWelcomeText(pstrWelcomeText)
{
	var strText;
	if (typeof pstrWelcomeText == "undefined")
	{		
		if(typeof top.frames['Storage'] == "undefined")
		{
			strText = 'Preview default welcome text here';
		}
		else
		{
			strText = top.frames['Storage'].strWelcomeText;
		}
	}
	else
	{
		strText = pstrWelcomeText;
	}
	strText = ReplaceHourlyMessage(strText);
	document.write(strText);	
}


/*******************************************************************************************
 Purpose: 		This function will generate a time-specific message and embed 
 				it in the WelcomeText that is used on the Welcome Main page IF that
				WelcomeText has the string 'HOURLYMESSAGE'

 Created By: 	Neal Tillotson
 Create On:		1/16/2001

 History:
 Date			Modifier		Change
 ---------- 	---------------	----------------------------------------------------------------

*******************************************************************************************/
function ReplaceHourlyMessage(pstrWelcomeText)
{

	var day = new Date();
	var hr = day.getHours();
	var strHourlyMessage = "";
	var strNewWelcomeMessage = "";
	var regexp = /HOURLYMESSAGE/;

	if ((hr == 1) ||(hr == 2))
		{
		strHourlyMessage = "Good evening, "
		}
    else if ((hr == 5) ||(hr == 6) || (hr ==7) || (hr ==8) || (hr == 9) || (hr ==10))
		{
		strHourlyMessage = "Good morning, "
		}
	else if (hr==11) 
		{
		strHourlyMessage = "Good morning, "
		}
	else if (hr==12) 
		{
		strHourlyMessage = "Good afternoon, "
		}
	else if ((hr==13) || (hr==14) || (hr ==15) || (hr ==16))
		{
		strHourlyMessage = "Good afternoon, "
		}
	else if (hr==17) 
		{
		strHourlyMessage = "Hello, "		
		}
	else if (hr==18) 
		{
		strHourlyMessage = "Good evening, "		
		}
	else if ((hr==19) || (hr==20) || (hr==21) || (hr==22))
		{
		strHourlyMessage = "Good evening, "		
		}
	else if (hr==23)
		{
		strHourlyMessage = "Good evening, "		
		}
	else if (hr==0)
		{
		strHourlyMessage = "Good evening, "				}

	// Replace the substring HOURLYMESSAGE, if it's there, with strHourlyMessage
	strNewWelcomeMessage = pstrWelcomeText.replace(regexp,strHourlyMessage)

	return strNewWelcomeMessage;

}
