// Developed by Roy Miller 20011001 mo

//This file contains the array creation statements which will be used to build the appointment database


function funCreateInterfaceModify(intCount) {
	strStorage  = "<table width=100% cellpadding=0 border=0 cellspacing=0>";
	strStorage += "<tr><td align=center width=50%>";
	if (arrAppointment[intCount].flagDelete >= 1) {
		strStorage += "<a href=javascript:subButtonDeleteRecord('" + arrAppointment[intCount].AppID + "');>Delete</a>";
		} // end if
	strStorage += "</td>";
	strStorage += "<td align=center width=*>";
	if (arrAppointment[intCount].flagEdit >= 1) {
		strStorage += "<a href=javascript:subButtonEditRecord('" + arrAppointment[intCount].AppID + "');>Edit</a>";
		} // end if
	strStorage += "</td></tr>";
	strStorage += "</table>";

	return strStorage;
	} // end function funCreateInterfaceModify(intCount) 

function funCompileAppointments(arrAppointment, strSearchFor, flgStyle) {

	var strStorage = "";

	switch (flgStyle) {
		case "day of the month":
			for (var intCount=0; intCount < arrAppointment.length; intCount++) {
				if (arrAppointment[intCount].AppDate == strSearchFor) {
//3					strStorage += "<a href='javascript://' onmouseover=\"status='"+ arrAppointment[intCount].SubjectLong +"';return true\" onmouseout=\"status='';return true\" onclick='open_all(\"GlanceAppointment.htm?"+ arrAppointment[intCount].AppID +"\");'>";
//3					strStorage += "<a href='javascript://' onmouseover=\"subTooltipShow(this,event,'"+ arrAppointment[intCount].SubjectLong +"')\" onmouseout=\"subTooltipHide()\" onclick='open_all(\"GlanceAppointment.htm?"+ arrAppointment[intCount].AppID +"\");'>";
//3					strStorage += "<a href='javascript://' onmouseover=\"subTooltipShow(this,event,'<table><tr><td width=20>"+ arrAppointment[intCount].SubjectLong +"</td></tr></table>')\" onmouseout=\"subTooltipHide()\" onclick='open_all(\"GlanceAppointment.htm?"+ arrAppointment[intCount].AppID +"\");'>";
					strStorage += "<a href='javascript://' onmouseover=\"subTooltipPopUp("+ (intCount+500) +")\" onmouseout=\"subTooltipPopDown()\" onfocus='if(this.blur)this.blur()' onclick='open_all(\"GlanceAppointment.htm?"+ arrAppointment[intCount].AppID +"\");'>";
arrTooltipMessages[intCount+500] = arrAppointment[intCount].POCName +"<br>"+ arrAppointment[intCount].SubjectLong;
//					strStorage += "<a href='javascript://' onmouseover=\"popUp('HM_Menu"+ (intCount+100) +"',event)\" onmouseout=\"popDown('HM_Menu"+ (intCount+100) +"')\" onclick='open_all(\"GlanceAppointment.htm?"+ arrAppointment[intCount].AppID +"\");'>";
//					strStorage += "<a href='javascript://' onmouseover='popUp(&quot;HM_Menu1&quot;,event)' onmouseout='popDown(&quot;HM_Menu1&quot;)' onclick='open_all(\"GlanceAppointment.htm?"+ arrAppointment[intCount].AppID +"\");'>";
// original					strStorage += "<a href='javascript://' onmouseover=\"status='"+ arrAppointment[intCount].SubjectLong +"';return true\" onmouseout=\"status='';return true\" onclick='open_all(\"GlanceAppointment.htm?"+ arrAppointment[intCount].AppID +"\");'>";
					strStorage += arrAppointment[intCount].AppTime ;
					if ( arrAppointment[intCount].AppEpochTimeEnd > arrAppointment[intCount].AppEpochTime ) {
						strStorage += "-" + arrAppointment[intCount].AppTimeEnd;
						} // end if
					strStorage += " " + arrAppointment[intCount].SubjectShort ;
					strStorage += "</a><br>";
//  subBuildMenuEntry( (intCount+100), arrAppointment[intCount].SubjectLong);
					} // end if
					
				} // next intCount
			break;
		case "daily scheduler":
			for (var intCount=0; intCount < arrAppointment.length; intCount++) {
				if (arrAppointment[intCount].AppDate == strSearchFor) {
					strStorage += "<tr><td valign='top'><b>";
					strStorage += arrAppointment[intCount].AppTime ;
					if ( arrAppointment[intCount].AppEpochTimeEnd > arrAppointment[intCount].AppEpochTime ) {
						strStorage += "-" + arrAppointment[intCount].AppTimeEnd;
						} // end if
					strStorage += "&nbsp;</b><br>";
					strStorage += funCreateInterfaceModify(intCount);
					strStorage += "</td>";
					strStorage += "<td>";
					strStorage += "<b>" + arrAppointment[intCount].SubjectLong +"</b><br>";
					strStorage += arrAppointment[intCount].POCName +" ";
					strStorage += arrAppointment[intCount].POCNumber +"<br>";
					strStorage += arrAppointment[intCount].LocationBuilding +" ";
					strStorage += arrAppointment[intCount].LocationRoom +"<br>";
					strStorage += arrAppointment[intCount].FreeFormText +"<br>";
					if (arrAppointment[intCount].txtURL != "") {
						strStorage += "<a href='" +arrAppointment[intCount].txtURL +"' target=new>";
						strStorage += arrAppointment[intCount].txtURL;
						strStorage += "</a>";
						} // end if
					} // end if
					
				} // next intCount
			break;

		case "month at a glance":
			var anyreminders = false;
			var strTempDate = "";

			for (var intCount=0; intCount < arrAppointment.length; intCount++) {
				// only want to see appointment for this year-month
				if (arrAppointment[intCount].AppDate.slice(0,7) == strSearchFor) {
					anyreminders = true;

					// since the appointments are sorted by date/time, then running through the list of appointments and testing for date change will result in a faster output
					if (arrAppointment[intCount].AppDate != strTempDate) {
						strTempDate = arrAppointment[intCount].AppDate;
						strStorage += "<tr><td valign='top'><b>" + months[mymonth] + " " + arrAppointment[intCount].AppDate.slice(8) + "&nbsp;</b>";
						} else {
						strStorage += "<tr><td valign=top>";
						} // end if		


					strStorage += "<br>";
					strStorage += funCreateInterfaceModify(intCount);
					strStorage += "</td>";
					strStorage += "<td valign='top'><b>";
					strStorage += arrAppointment[intCount].AppTime ;
					if ( arrAppointment[intCount].AppEpochTimeEnd > arrAppointment[intCount].AppEpochTime ) {
						strStorage += "-" + arrAppointment[intCount].AppTimeEnd;
						} // end if
					strStorage += "&nbsp;</b></td><td>";
					strStorage += "<b>" + arrAppointment[intCount].SubjectLong +"</b><br>";
					strStorage += arrAppointment[intCount].POCName +" ";
					strStorage += arrAppointment[intCount].POCNumber +"<br>";
					strStorage += arrAppointment[intCount].LocationBuilding +" ";
					strStorage += arrAppointment[intCount].LocationRoom +"<br>";
					strStorage += arrAppointment[intCount].FreeFormText +"<br>";
					if (arrAppointment[intCount].txtURL != "") {
						strStorage += "<a href='" +arrAppointment[intCount].txtURL +"' target=new>";
						strStorage += arrAppointment[intCount].txtURL;
						strStorage += "</a>";
						} // end if
					} // end if
				} // next intCount
				
			if(!anyreminders) {
				strStorage += "<tr><td>There is nothing scheduled for this month.</td></tr>";
				} // end if
			break;

		case "Look Ahead":
			var anyreminders = false;
			var strTempDate = "";

			var strEpochNow = new Date();
			var strEpochEnd = new Date();
			strEpochNow = Math.floor( strEpochNow.getTime() / 1000);
			strEpochEnd = Math.floor( strEpochEnd.getTime() / 1000) + (7*24*60*60);
			for (var intCount=0; intCount < arrAppointment.length; intCount++) {
				// only want to see appointments between strEpochNow and strEpochEnd
//				if (arrAppointment[intCount].AppDate.slice(0,7) == strSearchFor) {
				if ( (arrAppointment[intCount].AppEpochTime >= strEpochNow) && (arrAppointment[intCount].AppEpochTime < strSearchFor) ) {
					anyreminders = true;

					// since the appointments are sorted by date/time, then running through the list of appointments and testing for date change will result in a faster output
					if (arrAppointment[intCount].AppDate != strTempDate) {
						strTempDate = arrAppointment[intCount].AppDate;
						strStorage += "<tr><td valign='top'><b>" + months[arrAppointment[intCount].AppDate.slice(5,7)-1] + " " + arrAppointment[intCount].AppDate.slice(8) + ",&nbsp;</b>";
						} else {
						strStorage += "<tr><td valign=top>";
						} // end if		

					strStorage += "<br>";
					strStorage += funCreateInterfaceModify(intCount);
					strStorage += "</td>";
					strStorage += "<td valign='top'><b>";
					strStorage += arrAppointment[intCount].AppTime ;
					if ( arrAppointment[intCount].AppEpochTimeEnd > arrAppointment[intCount].AppEpochTime ) {
						strStorage += "-" + arrAppointment[intCount].AppTimeEnd;
						} // end if
					strStorage += "&nbsp;</b></td><td>";
					strStorage += "<b>" + arrAppointment[intCount].SubjectLong +"</b><br>";
					strStorage += arrAppointment[intCount].POCName +" ";
					strStorage += arrAppointment[intCount].POCNumber +"<br>";
					strStorage += arrAppointment[intCount].LocationBuilding +" ";
					strStorage += arrAppointment[intCount].LocationRoom +"<br>";
					strStorage += arrAppointment[intCount].FreeFormText +"<br>";
					if (arrAppointment[intCount].txtURL != "") {
						strStorage += "<a href='" +arrAppointment[intCount].txtURL +"' target=new>";
						strStorage += arrAppointment[intCount].txtURL;
						strStorage += "</a>";
						} // end if
					} // end if
				} // next intCount
				
			if(!anyreminders) {
				strStorage += "<tr><td>There is nothing scheduled for this period.</td></tr>";
				} // end if
			break;

		case "Glance Appointment":
			var anyreminders = false;
			var strTempDate = "";

			for (var intCount=0; intCount < arrAppointment.length; intCount++) {
				// only want to see appointments between strEpochNow and strEpochEnd
//				if (arrAppointment[intCount].AppDate.slice(0,7) == strSearchFor) {
				if  (arrAppointment[intCount].AppID == strSearchFor ) { 
					anyreminders = true;

					// since the appointments are sorted by date/time, then running through the list of appointments and testing for date change will result in a faster output
					if (arrAppointment[intCount].AppDate != strTempDate) {
						strTempDate = arrAppointment[intCount].AppDate;
// document.write("date = "+ arrAppointment[intCount].AppDate +"<br>");
// document.write("date = "+ arrAppointment[intCount].AppDate.slice(5,7) +"<br>");
mymonth = arrAppointment[intCount].AppDate.slice(5,7) - 1;
						strStorage += "<tr><td valign='top'><b>" + months[mymonth] + " " + arrAppointment[intCount].AppDate.slice(8) + ",&nbsp;</b>";
						} else {
						strStorage += "<tr><td valign=top>";
						} // end if		

					strStorage += "<br>";
					strStorage += funCreateInterfaceModify(intCount);
					strStorage += "</td>";
					strStorage += "<td valign='top'><b>";
					strStorage += arrAppointment[intCount].AppTime ;
					if ( arrAppointment[intCount].AppEpochTimeEnd > arrAppointment[intCount].AppEpochTime ) {
						strStorage += "-" + arrAppointment[intCount].AppTimeEnd;
						} // end if
					strStorage += "&nbsp;</b></td><td>";
					strStorage += "<b>" + arrAppointment[intCount].SubjectLong +"</b><br>";
					strStorage += arrAppointment[intCount].POCName +" ";
					strStorage += arrAppointment[intCount].POCNumber +"<br>";
					strStorage += arrAppointment[intCount].LocationBuilding +" ";
					strStorage += arrAppointment[intCount].LocationRoom +"<br>";
					strStorage += arrAppointment[intCount].FreeFormText +"<br>";
					if (arrAppointment[intCount].txtURL != "") {
						strStorage += "<a href='" +arrAppointment[intCount].txtURL +"' target=new>";
						strStorage += arrAppointment[intCount].txtURL;
						strStorage += "</a>";
						} // end if
					} // end if
				} // next intCount
				
			if(!anyreminders) {
				strStorage += "<tr><td>There is nothing scheduled for this period.</td></tr>";
				} // end if
			break;

		default:
			break;
			// nothing selected
		} // end switch
	
	return strStorage;
	} // end function funCompileAppointments(arrAppointment, strSearchFor, flgStyle)

function subBuildMenuEntry (menuID, strText) {
	// 2002010221.11 tu
	// this function receives a string which will be used to create a menu item
alert(menuID +"\n"+ strText);
	eval("HM_Array"+ menuID +" = [ [200,'mouse_x_position + 20', 'mouse_y_position', 'white', ,'#336699',,,,0,0,0,1,0,1,'null','null',,],['"+ strText +"',,0,0,0] ]");

	} // end function subBuildMenuEntry (strText)

function funPad(strValue, strPad, strLength) {

	while (strValue.length < strLength) {

		strValue = strPad + strValue;

		} // end loop

	return strValue;

	} // end function funPad(strValue, strPad)

	

function addtoAppointment(AppID, AppEpochTime, AppEpochTimeEnd,  AppDate, AppTime, AppDateEnd, AppTimeEnd, SubjectShort, SubjectLong, POCOrg, POCName, POCNumber, LocationBuilding, LocationRoom, HostName, HostDepartment, FreeFormText, txtURL, flagEdit, flagDelete) {

  this.AppID = AppID;
  this.AppEpochTime = AppEpochTime;
  this.AppEpochTimeEnd = AppEpochTimeEnd;
  this.AppDate = AppDate;
  this.AppTime = AppTime;
  this.AppDateEnd = AppDateEnd;
  this.AppTimeEnd = AppTimeEnd;
  this.SubjectShort = SubjectShort;
  this.SubjectLong = SubjectLong;
  this.POCOrg = POCOrg;
  this.POCName = POCName;
  this.POCNumber = POCNumber;
  this.LocationBuilding = LocationBuilding;
  this.LocationRoom = LocationRoom;
  this.POCNumber = POCNumber;
  this.HostName = HostName;
  this.HostDepartment = HostDepartment;
  this.FreeFormText = FreeFormText;
  this.txtURL = txtURL;
  this.flagEdit = flagEdit;
  this.flagDelete = flagDelete;
  } //end function

