//--------------------------------------------------
// Report Page parts - This file is used by ReportRequest
// to build the different parts of a report page
// (but not Report.Body which is defined in reportarea.txt)
//--------------------------------------------------
if(eq($Info.IsDHTMLReport, 1))
{
	Begin Component Page.Header
		//class = Header
		Begin Label
			label = "<script>g_bmc_ctd_dal_page_num = " + $Info.PageNumber + ";</script>"
			EscapeType=NONE
		End
	End

	Begin Component Page.Body
		//class = PageBody
	End

	Begin Component Page.Footer
		//class = PageFooter
	End
}
else
{
	Begin Component FreezeParts
		Begin Counter FreezeParts
			when (eq($Params.PagePart, "ALL"))
			{
				value = 1
			}
		End

		Template (StartFreezePart)
		{
			if (eq($Info.PageNumber, $Position.TopPage))
			{
				Begin Label
					Label =  "<script>StartFreezePartDiv('" + $info.pagepart + "')</script>"
					EscapeType = NONE
				End
			}
		}
	End

	if(eq($info.pagepart, "MM") || eq($info.pagepart, "ML") || eq($info.pagepart, "MR"))
	{
		Begin Component Page.Header
			if (eq(Counter.FreezeParts(), 1))
			{
				Begin Counter ScrollablePart
					value = 1
				End
				DoTemplate(StartFreezePart)
			}

			Begin StrVariable headerClass
				when ( (eq($Params.auditeventtype, "PrepareToPrint") || eq($Params.auditeventtype, "localPrint")) && eq(%User.Applicationfeatures.ReportPreparePrintHeaderFooterFeature.IsChecked,1) )
				{
					value = "PrepareToPrintHeader"
				}
				else
				{
					value = "header"
				}
			End
			Begin StrVariable PageHeaderOpenTag
				when(eq($Info.PageCount, 0)) // we don't need page break before first page
				{
					value = "<pre class=" + StrVariable.headerClass() + "><span id=Page"
				}
				else
				{
					value = "<pre class=" + StrVariable.headerClass() + " style='page-break-before:always;'><span id=Page"
				}
			End

			Begin Label
				label = StrVariable.PageHeaderOpenTag()	+ $Info.PageNumber + "><script>document.write(ReversePageNumberHeader(EvalJSParameter('"
				EscapeType = none
			End

			Begin Label
				when( noteq($Params.auditeventtype, "PrepareToPrint") &&  noteq($Params.auditeventtype, "localPrint") && eq(%User.applicationfeatures.ReportViewHeaderFeature.ischecked,1) ) 
				{
					label = replace(replace(%User.applicationfeatures.reportviewheaderfeaturelabel{!WA Lang.DesktopName}.value, "%%pages", $Info.Pages), "%%page", $Info.PageNumber)
				}
				else
				{
					when ( (eq($Params.auditeventtype, "PrepareToPrint") || eq($Params.auditeventtype, "localPrint")) && ExistsAndEqual($userdata.printheaderfooter,"1") )
					{
						label = replace(replace(replace(replace(%User.Applicationfeatures.ReportPreparePrintHeaderFooterHeaderFeatureLabel{!WA Lang.DesktopName}.value, "%%pages", $Info.Pages), "%%page", $Info.PageNumber), "%%report_name", $Info.ReportName), "%%centered", string())
					}
					else
					{
						label = string()
					}
				}
				EscapeType = JS
			End
			Begin Label
				label = "')));</script></span></pre>"
				EscapeType = none
			End
		End
	}
	else
	{
		if (eq(Counter.FreezeParts(), 1))
		{
			Begin Component Page.Header
				Begin Counter ScrollablePart
					value = 0
				End
				DoTemplate(StartFreezePart)
			End
		}
	}

	Begin Component Page.BeginBody
		Begin Counter NotesMode
			when((notexists($UserData.RVM) && eq(%User.ApplicationFeatures.NotesModeByDefault.value, 1) && noteq($Params.auditeventtype, "PrepareToPrint") && noteq($Params.auditeventtype, "localToPrint"))
					|| (exists($UserData.RVM) && noteq($UserData.RVM, 0)))
			{
				value = 1
			}
		End

		if(eq(Counter.NotesMode(), 1))
		{
			Begin Label
				Label = "<div class=PageDiv id='p" + $Info.PageNumber + "' name='p" + $Info.PageNumber + "'>"
				EscapeType = None
			End
		}
		else
		{
			if (notempty($Info.RulerId))
			{
				Begin Label
					Label = "<script>PagePartName='" + $Info.PagePart + $Info.PageNumber + "';</script><div class=PageDiv id='" + $Info.PagePart + $Info.PageNumber + "'>"
					EscapeType = None
				End
			}
		}
	End

	Begin Component Page.Body
		type	= normalPreformated
		class	= PageBody
		
		if (exists(#TagIconList))
		{
			Begin Label
				label = "<script>"
				EscapeType = None
			End

			ForEach(#TagIconList)
			{
				Begin Label
					Label = "ATID(" + [].IconType + "," + [].Line + "," + [].Offset + "," + $Info.PageNumber + ",'" + [].Date + "','" + [].Time + "','" + EscapeJS([].User) + "','" + EscapeJS([].Text) + "');"
					EscapeType = None
				End

				if(noteq(Counter.NotesMode(), 1))//set layer for each icon
				{
					Begin Layer
						name = [].line + "_" + [].offset + "_" + $Info.PageNumber
						row = [].line
						col = [].offset
						colwidth = 1
					End
				}
			}

			Begin Label
				label = "</script>"
				EscapeType = None
			End
		}
		else
		{
			Begin Label
				label = "<p></p>"
				EscapeType = None
			End
		}
		if (exists(#NoteList))
		{
			ForEach(#NoteList)
			{
				Begin HyperLink
					row = [].line
					col = [].offset
					colwidth = [].length
					when(eq(Counter.NotesMode(), 1))
					{
						class="rpNote"
					}

					TargetName = [].NID

					Begin Event.OnClick
						PostAction = "openNoteWindow('" + EscapeJS([].NID) + "')"
					End
				End // hyperlink
			} // foreach
		} // if
	End

	if(eq(Counter.NotesMode(), 1) || ExistsAndNotEmpty($Info.RulerId))
	{
		Begin Component Page.EndBody
			Begin Label
				Label = "</div>"
				EscapeType = None
			End

			Begin Label
				when(eq(Counter.NotesMode(), 1))
				{
					Label = "<script>PreparePageNotes(" + $Info.PageNumber + ");</script>"
				}
				else
				{
					Label = "<script>WriteOverlay();</script>"
				}
				EscapeType = None
			End
		End
	}
	

	Begin Component Page.Footer
		if(eq(Counter.FreezeParts(), 1)
			&& (eq($Info.PageNumber, $Position.BottomPage) || eq (Counter.ScrollablePart(), 0)))
		{
			Begin Label
				Label =  "</div><script>EndFreezePartDiv('" + $info.pagepart + "');</script>"
				EscapeType = None
			End
		}

		Begin Label
			when ( exists($UserData.printnotes) && !eq($UserData.printnotes,"0") && eq($Info.hasnote,1))
			{
				Label = "<script>PrintNotes('" + $Info.PageNumber + "');</script>"
			}
			EscapeType = None
		End	


		Begin Label
			label = "<pre class=" + StrVariable.headerClass() + "><script>document.write(EvalJSParameter('"
			EscapeType = None
		End

		Begin Label
			when(noteq($Params.auditeventtype, "PrepareToPrint") && noteq($Params.auditeventtype, "localToPrint") && eq(%User.applicationfeatures.ReportViewFooterFeature.ischecked, 1))
			{
				label = replace(replace(%User.applicationfeatures.reportviewfooterfeaturelabel{!WA Lang.DesktopName}.value, "%%pages", $Info.Pages), "%%page", $Info.PageNumber)
			}
			else
			{
					when ( (eq($Params.auditeventtype, "PrepareToPrint") || eq($Params.auditeventtype, "localToPrint")) && ExistsAndEqual($userdata.printheaderfooter,"1") )
					{
						label = replace(replace(replace(replace(%User.Applicationfeatures.ReportPrintHeaderFooterFooterFeatureLabel{!WA Lang.DesktopName}.value, "%%pages", $Info.Pages), "%%actual_page", $Info.PageNumber), "%%report_name", $Info.ReportName), "%%centered", string())
					}
			}
			
			EscapeType = JS
		End

		Begin Label
			label = "'));</script></pre>"
			EscapeType = None
		End
		
	End
}
