<cfsetting enablecfoutputonly="Yes">
<cfinclude template="/go/setMallVars.cfm">
<!--- <CFQUERY NAME=GetMall DATASOURCE="#datasource#">
	select * from Mall
	where MallID = #MallID#
</CFQUERY>
<CFSET PageType = "Information">
<CFSET CellColor="#MFCellClr#">
<CFSET Title = "#GetMall.Name# Shopping Hours">
<!--- <CFSET UseImg = "mallhourshead.gif"> --->

<CFIF IsDefined("URL.Year")>
	<CFSET ThisYear=URL.Year>
<CFELSE>
	<CFSET ThisYear=Year(now())>
</CFIF>
<CFIF IsDefined("URL.Month")>

	<CFSET ThisMonth=URL.Month>
	<CFIF ThisMonth EQ 0>
		<CFSET ThisYear = ThisYear - 1>
		<CFSET ThisMonth = 12>
	</CFIF>
	<CFIF ThisMonth EQ 13>
		<CFSET ThisYear = ThisYear + 1>
		<CFSET ThisMonth = 1>
	</CFIF>
	
<CFELSE>
    <CFSET ThisMonth = Month(now())>
</CFIF>

<CFIF IsDefined("URL.day")>
  <CFSET today=URL.day>
<CFELSEIF thisMonth eq month(now())>
  <CFSET today = day(now())>
<cfelse>
  <cfset today = 1>
</CFIF>

<CFSET LastMonth = ThisMonth - 1>
<CFSET NextMonth = ThisMonth + 1> --->

<cfoutput>
<table cellpadding="2" cellspacing="0" border="1">
<tr>
  <td align="center">
    <TABLE BORDER=0 align="left" width="175">
	<tr>
	  <td align="left">
	    <TABLE cellpadding="0" cellspacing="0" border="0" align="left" width="175">
		  <TR bgColor="#MallTableBGColor#">
            <TD valign="middle" align="center" width="30"><A HREF="displayhours.cfm?Year=#ThisYear#&Month=#LastMonth#&MallID=#MallID#"><!--- <IMG SRC="/rimages/arrowl.gif" BORDER=0> ---><-</A></TD>
            <TD valign="middle" width="115" align="center"><font face="arial" size="2"><b>#MonthAsString(ThisMonth)#, #ThisYear#</b></FONT></TD>
            <TD valign="center" width="30"><A HREF="displayhours.cfm?Year=#ThisYear#&Month=#NextMonth#&MallID=#MallID#"><!--- <IMG SRC="/rimages/arrowr.gif" BORDER=0> --->-></A></TD>
</TR></TABLE>
	  </td>
	</tr>
	<TR>
		<TD VALIGN=TOP><!--- <IMG SRC="../images/dotclear.gif" alt="" HEIGHT="6" border=1> --->
			<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 align="center">
              <TR>
					<FONT FACE="ARIAL,HELVETICA">
					<TD width="22" ALIGN="CENTER"><FONT SIZE="-3"><B>SU</B></FONT></TD>
					<TD width="22" ALIGN="CENTER"><FONT SIZE="-3"><B>MO</B></FONT></TD>
					<TD width="22" ALIGN="CENTER"><FONT SIZE="-3"><B>TU</B></FONT></TD>
					<TD width="22" ALIGN="CENTER"><FONT SIZE="-3"><B>WE</B></FONT></TD>
					<TD width="22" ALIGN="CENTER"><FONT SIZE="-3"><B>TH</B></FONT></TD>
					<TD width="22" ALIGN="CENTER"><FONT SIZE="-3"><B>FR</B></FONT></TD>
					<TD width="22" ALIGN="CENTER"><FONT SIZE="-3"><B>SA</B></FONT></TD>
					</FONT>
				</TR>
				<tr>
				  <td colspan="7"><img src="http://mallimages.mallfinder.com/dotclear.gif" width="1" height="3"></td>
				</tr>
				</CFOUTPUT>
				<CFSET XFirstD = CreateDate(ThisYear, ThisMonth, 1)>
				<CFSET XLast = DaysInMonth(XFirstD)>
				<CFSET XLastD = CreateDate(ThisYear, ThisMonth, XLast)>
				<CFSET FirstDay = DayOfWeek(XFirstD)>
				<CFSET FirstWeek = 1>
				<CFSET DOW = 1>
				<CFSET XCurr = 0>
				<CFQUERY DATASOURCE="#datasource#" NAME="GetHours">
					SELECT * from MallHours WHERE MallID=#MallID#
						AND (StartDate <= #XLastD#) AND
							(EndDate >= #XFirstD#)
					ORDER BY StartDate
				</CFQUERY>
				<CFSET HoursArray = ArrayNew(1)>
				<CFLOOP QUERY="GetHours">
					<CFLOOP INDEX="ThisDay" FROM="1" TO=#XLast#>
						<CFSET ChkD = CreateDate(ThisYear, ThisMonth, ThisDay)>
						<CFIF DateCompare(ChkD, #GetHours.StartDate#) GE 0>
							<CFIF DateCompare(ChkD, #GetHours.EndDate#) LE 0>
								<!--- Put the date info in --->
								<CFIF DayOfWeek(chkD) EQ 1>
									<CFSET HoursArray[ThisDay] = GetHours.Sun>
								</CFIF>
								<CFIF DayOfWeek(chkD) EQ 2>
									<CFSET HoursArray[ThisDay] = GetHours.Mon>
								</CFIF>
								<CFIF DayOfWeek(chkD) EQ 3>
									<CFSET HoursArray[ThisDay] = GetHours.Tue>
								</CFIF>
								<CFIF DayOfWeek(chkD) EQ 4>
									<CFSET HoursArray[ThisDay] = GetHours.Wed>
								</CFIF>
								<CFIF DayOfWeek(chkD) EQ 5>
									<CFSET HoursArray[ThisDay] = GetHours.Thu>
								</CFIF>
								<CFIF DayOfWeek(chkD) EQ 6>
									<CFSET HoursArray[ThisDay] = GetHours.Fri>
								</CFIF>
								<CFIF DayOfWeek(chkD) EQ 7>
									<CFSET HoursArray[ThisDay] = GetHours.Sat>
								</CFIF>
							</CFIF>
						</CFIF>
					</CFLOOP>
				</CFLOOP>
				<cfoutput><TR></cfoutput>
				<CFLOOP CONDITION="((XCurr LE XLast) OR (DOW LT 8))">
					<CFIF DOW EQ 8>
						<CFSET DOW = 1>
						<CFSET FirstWeek = 0>
						<cfoutput><TR></cfoutput>
					</CFIF>
					<CFSET IsBlank = 0>
					<CFIF FirstWeek EQ 1>
						<CFIF FirstDay GT DOW>
							<CFSET IsBlank = 1>
						<CFELSE>
							<CFIF XCurr EQ 0>
								<CFSET XCurr = 1>
							</CFIF>
						</CFIF>
					</CFIF>
					<CFIF XCurr GT XLast>
						<CFSET IsBlank = 1>
					</CFIF>
					<cfoutput>
					<cfif thisMonth lt 10>
					  <cfset useMonth = 0 & thisMonth>
					<cfelse>
					  <cfset useMonth = thisMonth>
					</cfif>
					
					<cfif xcurr lt 10>
					  <cfset useDay = 0 & xcurr>
					<cfelse>
					  <cfset useDay = xcurr>
					</cfif>
					<TD VALIGN="TOP" ALIGN="LEFT" align="center" width="22" <cfif xcurr eq toDay>bgcolor="#MallTableBGColor#"</cfif><FONT SIZE="2"></cfoutput><CFIF IsBlank EQ 0><CFOUTPUT><center><a href="displayhours.cfm?day=#xcurr#&month=#thisMonth#&year=#thisYear#"><cfif xcurr eq toDay><strong>#XCurr#</strong><cfelse>#XCurr#</cfif></a></center></CFOUTPUT></CFIF><cfoutput></FONT></TD></cfoutput>
					<CFIF DOW EQ 7>
						<cfoutput></TR></cfoutput>
					</CFIF>
                    <CFSET DOW = DOW + 1>
					<CFIF XCurr NEQ 0>
						<CFSET XCurr = XCurr + 1>
					</CFIF>
				</CFLOOP>
			<cfoutput></TABLE>
		</TD></TR>
		<tr>
		  <td width="175"><cfinclude template="weekView.cfm"></td>
		</tr>
	</TABLE>
</cfoutput>
<CFIF #GetMall.HoursText# NEQ "">
<CFOUTPUT>#GetMall.HoursText#</cfoutput>
</cfif>
<cfsetting enablecfoutputonly="No">




