//--------------------------------------------------
// Report Area - This file is used by ReportRequest
// to define text and DHTML reports main content area.
//
// The component Report.Body is filled with the report pages - each charachter in a cell in the matrix,
// using other template files (reportpage.txt & reportcoloring.txt)
//
// * Report Title *
// This template also defines functions for Report Title
// Report Title HTML is built on the fly in
// js_report.js in the function BuildReportTitle()
//--------------------------------------------------
#include "generaltemplate.txt"

Begin Component	Report.sizeSelection
	if(exists($RulersInfo.DefaultFontSize) && noteq($RulersInfo.DefaultFontSize, 0 ) && (exists($RulersInfo.IsForce) && noteq($RulersInfo.IsForce, 0)) && (notexists($std.frc)))
	{
		Begin Label
			when(exists($UserData.FontSize))
			{
				Label = "'"  + $UserData.FontSize  + "'"
			}
			else
			{
				Label = "'"  + $RulersInfo.DefaultFontSize  + "pt'"
			}
		End
	}
	else
	{
		Begin Label
			when(eq($Info.IsExternalReport, 1) || eq($Info.IsDHTMLReport, 1))
			{
				Label = null
			}
			else
			{
				when(exists($STD.f))
				{
					Label = "'" + $STD.f + "'"
				}
				else
				{
					Label = (*) Action("GetFontSizeFromCookies()")
				}
			}
		End
	}
End

// This is here to find the default notes mode (RVM)
Begin Component AddTagIconModes
	Begin Counter DefaultRVM
		value = 1 // 0 - normal mode, 1 - text mode, 2... - icons ID
	End

	Begin Counter IsTextReport
		when(eq($Info.IsExternalReport, 1) || eq($Info.IsDHTMLReport, 1))
		{
			value = 0
		}
		else
		{
		 	value=1
		}
	End
	if(eq(%User.Applicationfeatures.TagIconFeature.ischecked, 1) && eq(Counter.IsTextReport(),1))
	{
		ForEach(TagIcon in %user.TagIcons)
		{
			Begin Label
				Label = "NoteModes[" + [TagIcon].id + "] = new NoteMode(" + [TagIcon].id + ", '" + [TagIcon].icon_src + "', '" + [TagIcon].icon_src + "', '" +  VarName([TagIcon]) + "', '" + [TagIcon].description{!WA Common.LangSuffix}  +"') ;"
			End

			if(eq([TagIcon].default, 1) )//set as default mode
			{
				Begin Counter DefaultRVM
					value = [TagIcon].id
				End
			}
		}
	}

	Begin Counter RVM
		when(exists($UserData.RVM))
		{
			value = $UserData.RVM
		}
		else
		{
			when(eq(%User.ApplicationFeatures.NotesModeByDefault.value, 1) && noteq($Params.auditeventtype, "PrepareToPrint") && noteq($Params.auditeventtype, "localprint"))
			{
				value = Counter.DefaultRVM()
			}
			else
			{
				value = 0
			}
		}
	End
End

Begin Component ShowTitle
	// take real user data for this frame, not from the cache
	if(noteq(Counter.RVM(), 0) || noteq(GetQueryStringParameter(GetRequestActualParameter(u),"ShowTitle"), "0"))
	{
		Begin Counter ShowTitle
			value = 1
		End

		Begin Label
			label = "true"
		End
	}
	else
	{
		Begin Counter ShowTitle
			value = 0
		End

		Begin Label
			label = "false"
		End
	}
End


Begin Component Report.DHTMLJS
	if(eq($Info.IsDHTMLReport, 1) && eq(Counter.ShowTitle(), 0))
	{
		Begin label
			Label = "<script language=JavaScript src='htmls/bmc-ctd-dal.js'></script>"
			EscapeType = None
		End
	}
End

if(eq(Counter.ShowTitle(), 1))
{
	if (noteq($Position.TopPage, 0) && eq($Info.IsExternalReport, 0))// && eq($Info.IsDHTMLReport, 0))
	{
		Begin Component TextReportTitle
			Begin Label
				Label = "true"
			End
		End
	}

	Begin Component IsReportVisible
		Begin Counter IsReportVisible
			when (noteq($Position.TopPage, 0) || eq($Info.IsExternalReport, 1))
			{
				value = 1
			}
			else
			{
				value = 0
			}
		End

		Template(HTMLScaleCombo)
		{
			Begin StrVariable CurrentScale
				when(exists($STD.S))
				{
					value = string($STD.S)
				}
				else
				{
					value = "1.0"
				}
			End

			Begin ComboBox
				Name = scaleSelector
				Type = DropDown
				Direction = {!WA lang.UIMode}

				Begin Option
					DisplayString = "25%"
					ValueName = "0.25"
					when (eq(StrVariable.CurrentScale(), String("0.25")))
					{
						Selected = true
					}
				End

				Begin Option
					DisplayString = "50%"
					ValueName = "0.5"
					when (eq(StrVariable.CurrentScale(), String("0.5")))
					{
						Selected = true
					}
				End

				Begin Option
					DisplayString = "75%"
					ValueName = "0.75"
					when (eq(StrVariable.CurrentScale(), String("0.75")))
					{
						Selected = true
					}
				End

				Begin Option
					DisplayString = "100%"
					ValueName = "1.0"
					when (eq(StrVariable.CurrentScale(), String("1.0")))
					{
						Selected = true
					}
				End

				Begin Option
					DisplayString = "150%"
					ValueName = "1.5"
					when (eq(StrVariable.CurrentScale(), String("1.5")))
					{
						Selected = true
					}
				End

				Begin Option
					DisplayString = "200%"
					ValueName = "2.0"
					when (eq(StrVariable.CurrentScale(), String("2.0")))
					{
						Selected = true
					}
				End

				Begin Event.OnChange
					PostAction = "SetScale()"
				End
			End
		}
	End

	if(noteq($Position.TopPage, 0))
	{
		Begin Component Templates
			Template (ReportRequest)
			{
				Begin Event.OnClick
					when (eq(Counter.PageNavigatMode(), 2))
					{
						PreCondition = "ValidateNumber()"
					}

					Begin Request
						RequestType	= Report				{ const }
						SID	= WhenExists($STD.csid, $params.sid)					{ const }
						FID	= $Params.FID					{ const }
						Lang = $Params.Lang					{ const }
						RID	= $Params.RID					{ const }

						ReportListContext = $Params.ReportListContext		{ const }

						// Page Navigation Mode = 0 - use default pages position
						// Page Navigation Mode = 1 - use page navigation images (top, ..., bottom)
						// Page Navigation Mode = 2 - GoTo Page (take page number from edit box)

						when (eq(Counter.PageNavigatMode(), 2))
						{
							Direction		= Current
							LastTopPage		= (*) Action("GetPageNumberValue()")
							LastBottomPage	= (*) Action("GetPageNumberValue()")
						}
						else
						{
							when (eq(Counter.PageNavigatMode(), 1))
							{
								Direction = (*) Action("szDirection")

								// in Matched Find, this might vary
								LastTopPage = (*) Action("nTopPage")
								LastBottomPage = (*) Action("nBottomPage")
							}
							else
							{
								Direction = StrVariable.Direction()
								LastTopPage		= String($Position.TopPage)
								LastBottomPage	= String($Position.BottomPage)
							}
						}

						// Find Mode = 0 - use default find params
						// Find Mode = 1 - don't use find params (clear)
						// Find Mode = 2 - get find string from edit box
						when (noteq(Counter.FindMode(), 1))
						{
							when (eq(Counter.FindMode(), 0))
							{
								FindString		= $Params.FindString
							}
							else
							{
								FindString		= (*) Action( "SetFindString()" )
							}
							//when fist find, use default find parameters from configuration
							when(Empty($Params.FindString) )
							{
								FindCase		= %User.Applicationfeatures.CaseSensitiveFeatureDefaultSel.Value
								FindWholeWord	= %User.Applicationfeatures.WholeWordFeatureDefaultSel.Value
								MatchedFind	= %User.Applicationfeatures.MatchedFeatureDefaultSel.Value
							}
							else
							{
								FindCase		= $Params.FindCase
								FindWholeWord	= $Params.FindWholeWord
								MatchedFind	= $Params.MatchedFind
							}
						}
						else
						{
							FindString = String()
						}

						Index			= $Params.Index				{const}
						RulerId			= $Info.RulerId				{const}
						RulerCommand	= $Params.RulerCommand		{const}
						ConvertorId		= $Params.ConvertorId		{const}
						when (noteq($Params.OutputMode,auto))
						{
							OutputMode		= $Params.OutputMode
						}
						else
						{
							OutputMode		= WhenExists($UserData.OutputMode)
						}
						Mode			= INFO				{const}
						CacheKey		= DoCache		{const}
						ReportCacheKey	= DoCache	{const}

						when(eq(%User.GeneralSettings.ReportsTarget, 0))
						{
							ErrorFlowStr	= "onerrorrlback.htm" {const}
							ErrorFlowElem	= "onerrorrlback.txt" {const}
						}
						else
						{
							ErrorFlowStr	= "onerrorclose.htm" {const}
							ErrorFlowElem	= "onerrorclose.txt" {const}
						}

						u=$Params.u

					End
				End
			}

			Template (ResetDefaultCounters)
			{
				// default values
				// if you change default value restore it after using template - for improving performance
				Begin Counter PageNavigatMode
					value = 0
				End

				Begin Counter FindMode
					value = 0
				End
			}

			DoTemplate(ResetDefaultCounters)
		End

		//==============================================
		// Report Navigation
		//==============================================
		Begin Component AvailableDirections
			Begin Label
				Label = String($Directions.AvailableTop) + "," + String($Directions.AvailablePrev) + "," + String($Directions.AvailableNext) + "," + String($Directions.AvailableBottom)
				EscapeType = JS
			End
		End

		Begin Component PagesMaxSize
			Begin Label
				Label = String(%User.Report.MaxSize)
			End
		End

		Begin Component function.GoToPageAction
			Begin Counter PageNavigatMode
				value = 2
			End

			if(ExistsAndEqual(%User.Applicationfeatures.ReportViewGoToFeature.ischecked, 1) )
			{
				DoTemplate(ReportRequest)
				DoTemplate(ResetDefaultCounters)
			}
		End

		Begin Component function.PageNavigationAction
			Begin Counter PageNavigatMode
				value = 1
			End
			DoTemplate(ReportRequest)
			DoTemplate(ResetDefaultCounters)
		End

		Begin Component FromToPages
			//---------------------
			// From To Page
			//---------------------
			// in binary mode $Position.BottomPage = -1 so nothing will be printed.
			if(eq($Position.BottomPage, $Position.TopPage))
			{
				Begin label
					row	= 0
					col	= 2

					Label = {!WA Lang.ConcatFunction}
								(" {!WA ReportTitle.Page} ", $Position.TopPage, " {!WA ReportTitle.Of} ", $Info.pages)
				End
			}
			else
			{
				if(gt($Position.BottomPage, $Position.TopPage))
				{
					Begin label
						row	= 0
						col	= 2

						Label = {!WA Lang.ConcatFunction}
									(" {!WA ReportTitle.Pages} ", $Position.TopPage + "-" + $Position.BottomPage,
												" {!WA ReportTitle.Of} ", $Info.pages)
					End
				}
			}
		End

		//===================================================
		// Find
		//===================================================
		// we are in a text report and have pages (not in not found)
		if ( noteq($Info.FindAvailable,0) && noteq($Position.TopPage,0) && ExistsAndEqual(%User.Applicationfeatures.ReportFindFeature.ischecked, 1) )// && eq($Info.IsDHTMLReport, 0))
		{
			if (notempty($Params.FindString))
			{
				Begin Component FindEnable
					Begin label
						label = "true"
					End
				End

				Begin Component InitFindStr
					Begin label
						label = $Params.FindString
						EscapeType = JS
					End
				End

				// FindDirections

				Begin Component FindPrevPagesEnable
					Begin label
						when(eq($Directions.AvailableFindPrevUp, 1))
						{
							label = "true"
						}
						else
						{
							label = "false"
						}
					End
				End

				Begin Component FindNextPagesEnable
					Begin label
						when(eq($Directions.AvailableFindNextDown, 1))
						{
							label = "true"
						}
						else
						{
							label = "false"
						}
					End
				End

				Begin Component FindDirection
					Begin Label
						label = $Params.Direction
						EscapeType = None
					End
				End

				Begin Component function.ClearFind
					Begin Counter FindMode
						value = 1
					End
					Begin StrVariable Direction
						value = "current"
					End
					DoTemplate (ReportRequest)
					DoTemplate(ResetDefaultCounters)

				End

				Begin Component function.FindPrev
					if(eq($Directions.AvailableFindPrevUp, 1))
					{
						Begin StrVariable Direction
							value = FindPrevUp
						End

						DoTemplate(ReportRequest)
					}
				End

				Begin Component function.FindNext
					if(eq($Directions.AvailableFindNextDown, 1))
					{
						Begin StrVariable Direction
							value = FindNextDown
						End

						DoTemplate(ReportRequest)
					}
				End
			}

			Begin Component function.OpenAdvancedFindWindow
				Begin Event.OnClick
					Begin OpenWindow
						TargetWindow		= WindowByName
						TargetWindowName	= FindPopup
						TargetWindowParameters	= "toolbar=0,statusbar=0,menubar=0,resizable=0,width=320,height=270"

						Begin Request
							RequestType		= FindWindow					{ const }
							SID				= WhenExists($STD.csid, $params.sid)					{ const }
							FID				= $Params.FID					{ const }
							Lang			= $Params.Lang					{ const }
							RID				= $Params.RID					{ const }
							FindString		= (*) Action("SetFindString()")	{ const }
							TopPage			= String($Position.TopPage)		{ const }
							BottomPage		= String($Position.BottomPage)	{ const }
							Pages			= (*) Action("wa_ReportPageCount")	{ const }
							ReportContext	= $Params.ParamsString			{ const }
							ErrorFlowStr	= "onerrorclose.htm"			{ const }
							ErrorFlowElem	= "onerrorclose.txt"			{ const }

							Begin VariableAttribute u
								ReportWindow = (*) Action("parent.name")	{ const }
								FindAvailable = $Info.FindAvailable	{ const }
								when(ExistsAndEqual($UserData.Approval, 1))
								{
										Approval =1
								}
								RVM = (*) Action("wa_nNoteMode")
								when (ExistsAndNotEqual($userData.copies,0) || NotExists($userData.copies))
								{
									copies = WhenExists($userData.copies, "1")
								}
							End
						End
					End
				End
			End

			Begin Component function.FindTextInReport
				Begin Counter FindMode
					value = 2
				End

				Begin StrVariable Direction
						value = FindDown
				End

				DoTemplate(ReportRequest)
				DoTemplate(ResetDefaultCounters)

			End
		}

 
		//--------------------------------------------------
		// Font size combo box definition
		//--------------------------------------------------
		if(ExistsAndEqual(%User.Applicationfeatures.ReportViewFontSizeFeature.ischecked, 1) )
		{
			Begin Component FontSizeStr
				if(eq($Info.IsDHTMLReport, 0))
				{
					if(noteq($Info.IsExternalReport, 1) && noteq($Position.TopPage, 0))
					{
						Begin Label
							Label = "{!WA ReportTitle.FontSize}"
						End
					}
				}
				else
				{
					if(noteq($Position.TopPage, 0))
					{
						Begin Label
							Label = "{!WA ReportTitle.Zoom}"
						End
					}
				}

			End

			Begin Component FontSizeComboBox
				if(eq($Info.IsDHTMLReport, 0))
				{
					if(noteq($Info.IsExternalReport, 1) && noteq($Position.TopPage, 0))
					{
						if(exists($RulersInfo.DefaultFontSize) && noteq($RulersInfo.DefaultFontSize, 0) )
						{
							Begin StrVariable CurrentFontSize
								when(exists( $UserData.FontSize ))
								{
									value = $UserData.FontSize +  "pt"
								}
								else
								{
									value = $RulersInfo.DefaultFontSize  + "pt"
								}
							End

						}
						else
						{
							Begin StrVariable CurrentFontSize
								when(exists($STD.F))
								{
									value = string($STD.F)
								}
								else
								{
									value = string()
								}
							End
						}

						Begin ComboBox
							Name = sizeSelector
							Type = DropDown
							Direction = {!WA lang.UIMode}
							
							Begin Option
								DisplayString = "6 {!WA ReportTitle.pt}"
								ValueName = "6pt"
								when (eq(StrVariable.CurrentFontSize(), String("6pt")))
								{
									Selected = true
								}
							End
							
							Begin Option
								DisplayString = "7 {!WA ReportTitle.pt}"
								ValueName = "7pt"
								when (eq(StrVariable.CurrentFontSize(), String("7pt")))
								{
									Selected = true
								}
							End
							
							Begin Option
								DisplayString = "8 {!WA ReportTitle.pt}"
								ValueName = "8pt"
								when (eq(StrVariable.CurrentFontSize(), String("8pt")))
								{
									Selected = true
								}
							End

							Begin Option
								DisplayString = "9 {!WA ReportTitle.pt}"
								ValueName = "9pt"
								when (eq(StrVariable.CurrentFontSize(), String("9pt")))
								{
									Selected = true
								}
							End

							Begin Option
								DisplayString = "10 {!WA ReportTitle.pt}"
								ValueName = "10pt"
								when (eq(StrVariable.CurrentFontSize(), String("10pt")))
								{
									Selected = true
								}
							End

							Begin Option
								DisplayString = "12 {!WA ReportTitle.pt}"
								ValueName = "12pt"
								when (eq(StrVariable.CurrentFontSize(), String("12pt")))
								{
									Selected = true
								}
							End

							Begin Option
								DisplayString = "14 {!WA ReportTitle.pt}"
								ValueName = "14pt"
								when (eq(StrVariable.CurrentFontSize(), String("14pt")))
								{
									Selected = true
								}
							End

							Begin Option
								DisplayString = "18 {!WA ReportTitle.pt}"
								ValueName = "18pt"
								when (eq(StrVariable.CurrentFontSize(), String("18pt")))
								{
									Selected = true
								}
							End

							Begin Option
								DisplayString = "22 {!WA ReportTitle.pt}"
								ValueName = "22pt"
								when (eq(StrVariable.CurrentFontSize(), String("22pt")))
								{
									Selected = true
								}
							End

							Begin Event.OnChange
								PreCondition = "CheckForceAndSetFontSize()"

								Begin Request
									RequestType	= Report
									SID			= WhenExists($STD.csid, $params.sid)
									FID			= $Params.FID
									Lang		= $Params.Lang
									RID			= $Params.RID
									Index		= $Params.Index
									RulerId		= $Info.RulerId
									RulerCommand = $Params.RulerCommand
									ConvertorId	= $Params.ConvertorId
									ReportListContext = $Params.ReportListContext
									FindString		= $Params.FindString
									FindCase		= $Params.FindCase
									FindWholeWord	= $Params.FindWholeWord
									MatchedFind		= $Params.MatchedFind
									when (noteq($Params.OutputMode,auto))
									{
										OutputMode		= $Params.OutputMode
									}
									else
									{
										OutputMode		= WhenExists($UserData.OutputMode)
									}
									Mode			= INFO
									CacheKey		= DoCache
									ReportCacheKey	= DoCache
									Direction		= Current
									LastTopPage		= String($Position.TopPage)
									LastBottomPage	= String($Position.BottomPage)

									Begin VariableAttribute STD
										F = (*) Action("GetSizeSelectorValue()")
										x = (*) Action("x_CharSize()")
										y = (*) Action("y_CharSize()")
										when(exists ($UserData.Force) && eq($UserData.Force, "false") )
										{
											frc = "0"
										}
										when(ExistsAndEqual($UserData.Approval, 1))
										{
												Approval =1
										}
									End
								End
							End
						End
					}
				}
				else
				{
					DoTemplate(HTMLScaleCombo)
				}
			End
		}

		Begin Component Report.Force
			Begin Label
				when(exists( $STD.frc) && eq( $STD.frc, 0))
				{
					Label = "false"
				}
				else
				{
					when(exists($UserData.Force))
					{
						Label = $UserData.Force
					}
					else
					{
						when(exists($RulersInfo.IsForce) && noteq($RulersInfo.IsForce, 0))
						{
							Label = "true"
						}
						else
						{
							Label = "false"
						}
					}
				}
			End
		End

		Begin Component Report.IsOverlayDefaultFont
			Begin Label
				when(exists($RulersInfo.DefaultFontSize) && noteq($RulersInfo.DefaultFontSize, 0) && exists($RulersInfo.IsForce) && noteq($RulersInfo.IsForce, 0) && notexists($UserData.FontSize))
				{
					Label = "true"
				}
				else
				{
					Label = "false"
				}
			End
		End

		Begin Component function.MessageBox
			Begin OpenWindow
				TargetWindow		= WindowByName
				TargetWindowName	= DefaultFontPopup
				TargetWindowParameters	= "toolbar=0,statusbar=0,menubar=0,resizable=1,width=425,height=150"	{const}

				Begin Request
					RequestType	= Base
					SID		= WhenExists($STD.csid, $params.sid)
					FID		= $Params.FID
					Lang		= $Params.Lang
					StrTemplate 	= "defaultfontmessage.htm"
					ElemTemplate	= "defaultfontmessage.txt"

					Begin VariableAttribute u
						RID		= $Params.RID
						Index	= $Params.Index
						RulerId	= $Info.RulerId
						RulerCommand	= $Params.RulerCommand
						ConvertorId		= $Params.ConvertorId
						ReportListContext = $Params.ReportListContext
						FindString		= $Params.FindString
						FindCase		= $Params.FindCase
						FindWholeWord	= $Params.FindWholeWord
						MatchedFind		= $Params.MatchedFind
						when (noteq($Params.OutputMode,auto))
						{
							OutputMode		= $Params.OutputMode
						}
						else
						{
							OutputMode		= WhenExists($UserData.OutputMode)
						}
						Direction		= Current
						LastTopPage		= String($Position.TopPage)
						LastBottomPage	= String($Position.BottomPage)
						FontSize		= (*) Action("GetSizeSelectorValue()")
					End
				End
			End
		End
	}

	if(eq($Info.IsDHTMLReport, 0) && eq($Info.ReportExtention, "html"))
	{ // this might be a HTML report that supports scaling.
		Begin Component HTMLDocScaleComboBox
			DoTemplate(HTMLScaleCombo)
		End

		Begin Component HTMLDocGotoPageAction
			Begin Label
				label = "HTMLDocGotoPage()"
				EscapeType=None
			End
		End
	}


	Begin Component FindIndicTooltip
		//----------------------------------------------------------------
		// Find Icons Definition.
		// The Icon appears when the Find search-option is utilized
		// (for text report only)
		//----------------------------------------------------------------
		if(exists($Params.FindString) && noteq($Params.FindString, String()))
		{
			Begin StrVariable CaseSens
				when (eq($FindDescription.CaseSens, "true"))
				{
					value = "{!WA ReportTitle.Y}"
				}
				else
				{
					value = "{!WA ReportTitle.N}"
				}
			End

			Begin StrVariable WholeWord
				when (eq($FindDescription.WholeWord, "true"))
				{
					value = "{!WA ReportTitle.Y}"
				}
				else
				{
					value = "{!WA ReportTitle.N}"
				}
			End

			Begin StrVariable Matched
				when (eq($FindDescription.Matched, "true"))
				{
					value = "{!WA ReportTitle.Y}"
				}
				else
				{
					value = "{!WA ReportTitle.N}"
				}
			End

			Begin Label
				when({!WA lang.IsRTL})
				{
					Label = "{!WA ReportTitle.FindWhat}"
				}
				else
				{
					Label = "{!WA ReportTitle.FindWhat}: " + $FindDescription.FindWhat + "," + $FindDescription.Separator + "{!WA ReportTitle.CaseSens}: " + StrVariable.CaseSens() + "," + $FindDescription.Separator + "{!WA ReportTitle.WholeWord}: " + StrVariable.WholeWord() + "," + $FindDescription.Separator + "{!WA ReportTitle.Matched}: " + StrVariable.Matched()
				}
				EscapeType = JS
			End
		}
	End

	Begin Component RulerIndicTooltip
		//----------------------------------------------------------------
		// Ruler Icons Definition
		// The icon appears when a ruler is applied to the report
		//----------------------------------------------------------------
		if(exists($Info.RulerId) && noteq($Info.RulerId, String()))
		{
			Begin Label
				when({!WA lang.IsRTL})
				{
					label = "{!WA ReportTitle.LogicalView}"
				}
				else
				{
					label = "{!WA ReportTitle.LogicalView}: " + $ Info.RulerDescription
				}
				EscapeType = JS
			End
		}
	End

	Begin Component IndexIndicTooltip
		//----------------------------------------------------------------
		// Index Icons Definition
		// The icon appears when an Index is applied to the report
		//----------------------------------------------------------------
		if(exists($Params.Index) && notempty($Params.Index))
		{
			Begin Label
				when({!WA lang.IsRTL})
				{
					label =  "{!WA ReportTitle.Index}"
				}
				else
				{
					label = "{!WA ReportTitle.Index}: " + $Info.IndexeDescription
				}
				EscapeType = JS
			End
		}
	End

	//=============================================
	// Disconnect Action
	//=============================================
	if(notexists($STD.NoDscnt) || noteq($STD.NoDscnt, 1))
	{
		if(eq(%User.GeneralSettings.ReportsTarget, 0) && eq(%User.Applicationfeatures.Logoutfeature.ischecked , 1))
		{
			Begin Component function.Disconnect
				Begin Event.OnClick
					Begin Request
						RequestType	= Logout		{ const }
						SID			= WhenExists($STD.csid, $params.sid)	{ const }
						FID			= $Params.FID	{ const }
						Lang		= $Params.Lang	{ const }
					End
				End
			End
		}
	}


	//===========================================================================
	// Menus Actions
	//===========================================================================

	//==============================================================
	// Report List Menu
	//==============================================================
	if(eq(%User.Applicationfeatures.ReportBackToRLFeature.ischecked, 1) && eq(%User.GeneralSettings.ReportsTarget,0) && (notexists($STD.NoRL) || noteq($STD.NoRL, 1)))
	{
		Begin Component function.UnfilteredRLAction
			Begin Event.OnClick
				when(noteq(%User.GeneralSettings.ReportsTarget, 0))
				{
					PostAction = "FocusOpener()"
				}
				
				Begin OpenWindow
					TargetWindow 			= WindowByName
					TargetWindowName		= "WA_MAIN"

					Begin Request
						RequestType		= ReportListWindow
						ElemTemplate	= "folderscreenparts.txt"
						StrTemplate		= "wascreenparts.htm"
						FID				= $Params.FID
						Lang			= $Params.Lang
						Sort			= $ReportListContext.Sort
						Mode			= NONE
						CacheKey		= DoNotCache
						Filter = (*) Action("wa_szReadOnlyFilter")
						when(exists($std.gtc))
						{
							gettotalcount = $std.gtc 
						}

						when(exists($ReportListContext.ReportListFields))
						{
							ReportListFields = $ReportListContext.ReportListFields
						}

						Begin VariableAttribute u
							SID = WhenExists($STD.csid, $params.sid)
							WSF = $Info.IsSupported.WithSubfolders
						End
					End
				End
			End
		End

		Begin Component function.FilteredRLAction
			Begin Event.OnClick
				when(noteq(%User.GeneralSettings.ReportsTarget, 0))
				{
					PostAction = "FocusOpener()"
				}
	
				Begin OpenWindow
					TargetWindow 			= WindowByName
					TargetWindowName		= "WA_MAIN"

					Begin Request
						RequestType		= ReportListWindow
						ElemTemplate	= "folderscreenparts.txt"
						StrTemplate		= "wascreenparts.htm"
						FID				= $Params.FID
						Lang			= $Params.Lang
						Sort			= $ReportListContext.Sort
						Mode			= NONE
						CacheKey		= DoNotCache
						when(exists($std.gtc))
						{
							gettotalcount = $std.gtc 
						}

					
						when(exists($ReportListContext.ReportListFields))
						{
							ReportListFields = $ReportListContext.ReportListFields
						}
						ReportListFields = WhenExists($ReportListContext.ReportListFields)

						Filter			= $ReportListContext.Filter
						LastTopRID		= $ReportListContext.LastTopRID
						LastBottomRID	= $ReportListContext.LastBottomRID
						Direction		= $ReportListContext.Direction
						

						Begin VariableAttribute u
							SID = WhenExists($STD.csid, $params.sid)
							WSF = $Info.IsSupported.WithSubfolders
						End

					End
				End
			End
		End

		if(ExistsAndEqual(%User.Applicationfeatures.FilterFeature.ischecked, 1) )
		{
			Begin Component function.FilterAction
				Begin Event.OnClick
					Begin OpenWindow
						TargetWindow 			= WindowByName
						TargetWindowName		= FilterPopup
						TargetWindowParameters	= "toolbar=0,statusbar=0,menubar=0,resizable=0,width=575,height=585"

						Begin	Request
							RequestType		= FilterWindow
							SID				= WhenExists($STD.csid, $params.sid)
							FID				= $Params.FID
							Lang			= $Params.Lang
							Filter		= (*)Action("UnEscapeFilterStr(wa_szParams_Filter)") //$ReportListContext.Filter
							ErrorFlowStr	= "onerrorclose.htm"
							ErrorFlowElem	= "onerrorclose.txt"
							u				= $ReportListContext.u 
						End
					End
				End
			End
		}
	}

	if (eq(counter.IsReportVisible(),1))
	{
		// when we send URL by mail, we encrypt and encode the Index field, so users won't change it
		// in the browser's address bar.
		// Report request knows how to handle this, and decrypt it correctly before using it,
		// but other requests, like note list and host print, need it decrypted.
		// We need to store it in JavaScript variable, in order to be able to use it in reportpage.txt as well.
		if(NotEmpty($Params.Index))
		{
			Begin Component IndexPath
				Begin Label
					when(eq(find($Params.Index, "="), NotFound())
						|| eq(find($Params.Index, "="), Minus(Len($Params.Index), 1))
						|| eq(find($Params.Index, "=="), Minus(Len($Params.Index), 2)))
					{
						label = decrypt($Params.Index, true)
					}
					else
					{
						label = $Params.Index
					}
					EscapeType = JS
				End
			End
		}

		//============================================================
		// Print Menu
		//============================================================
		if(exists ($Info.IsSupported.HostPrint) && eq($Info.IsSupported.HostPrint, true)
			&& ExistsAndEqual(%User.Applicationfeatures.ReportRemoutePrintFeature.ischecked, 1)
			&& (ExistsAndNotEqual($userData.copies,0) || NotExists($userData.copies))
		  )
		{
			Begin Component function.HostPrintAction
				Begin Event.OnClick
					Begin	OpenWindow
						TargetWindow		= WindowByName
						TargetWindowName	= RemotePrintPopup
						TargetWindowParameters	= "toolbar=0,statusbar=0,menubar=0,resizable=1,width=1000,height=600"

						Begin Request
							RequestType	= RemotePrintParams
							SID		= WhenExists($STD.csid, $params.sid)
							FID		= $Params.FID
							SubId	= $Params.SubID
							RID		= $Params.RID
							Lang	= $Params.Lang
							ErrorFlowStr	= "onerrorclose.htm"
							ErrorFlowElem	= "onerrorclose.txt"
							StrTemplate		= "remoteprintmf.htm"
							ElemTemplate	= "remoteprintmf.txt"
							IndexPath	= $Params.Index
							IndexPath	= (*) Action("wa_IndexPath")

							Begin VariableAttribute u
								when(NotEmpty($Params.Index) )
								{
									HasIndexes	= "false"
								}
								else
								{
									HasIndexes	= $Info.HasIndexes
								}

								ReportName	= $info.ReportName
								OrgEncoding = $Info.OrgEncoding
								Language = $Info.Language
							End
						End
					End
				End
			End
		}

		if(ExistsAndEqual(%User.Applicationfeatures.ReportPrintFeature.ischecked, 1) && (ExistsAndNotEqual($userData.copies,0)  || NotExists($userData.copies)) )
		{
			Begin Component function.LocalPrintAction
			Begin Event.OnClick
					Begin OpenWindow
						TargetWindow = WindowByName
						TargetWindowName = "_blank"
						TargetWindowParameters = "toolbar=0,statusbar=0,menubar=0,resizable=1,width=10,height=10,"

						Begin Request
							RequestType	= Base
							sid	= $params.sid
							Lang		= $Params.Lang
							ElemTemplate= "localoperation.txt"
							StrTemplate	= "localoperation.htm"

							Begin VariableAttribute u
								Operation = "print"
								sid	= $params.sid
								rid	= $Params.RID
								fid	= $Params.FID
								subid	= $Params.SubID
								rulerid	= $Params.RulerID
								index	= (*) Action("wa_IndexPath")
								rname	= $info.ReportName
								rpages	= (*) Action("wa_ReportPageCount")
								rext	= $info.ReportExtention
								convid	= $Params.ConvertorId
								pageset	= %User.Report.MaxSize
								repview	= "1"

								when(eq($Info.IsExternalReport, 1) || eq($Info.IsDHTMLReport, 1))
								{
									istext = "0"
									OutputMode = WhenExists($Params.OutputMode, WhenExists($UserData.OutputMode))
								}
								else
								{
									istext = "1"
									OutputMode = "2"
								}

								OrgEncoding = $Info.OrgEncoding
								Language = $Info.Language

								Mode		= text
								MaxPages	= (*) Action("wa_ReportPageCount")
								Direction	= Current
								ReportName	= $info.ReportName
								Index		= $Params.Index
								RulerCommand= $Params.RulerCommand
								ConvertorId	= $Params.ConvertorId
								ReportListContext = $params.ReportListContext

								ShowLV = $Info.HasLogicalViews
								when(NotEmpty($Params.Index) )
								{
									ShowIND = 0
								}
								else
								{
									ShowIND = $Info.HasIndexes
								}


								when(eq($Info.HasIndexes, 1) && eq(VarValueWhenExists(%user.extentions, $Info.ReportRealExtention, ConstName{forceindex}), true))
								{
									Force = true
								}
								CanRunActiveX = (*) Action("CanRunActiveX()")
							
								
							End
						End
					End
				End
			End
		}

		if (noteq($Info.IsExternalReport,1) && ExistsAndEqual(%User.Applicationfeatures.ReportPreparePrintFeature.ischecked, 1) && (ExistsAndNotEqual($userData.copies,0) || NotExists($userData.copies)) )
		{
			Begin Component function.PrepareToPrintAction
				Begin Event.OnClick
					Begin	OpenWindow
						TargetWindow		= WindowByName
						TargetWindowName	= PrepareToPrintPopup
						TargetWindowParameters	= "toolbar=0,statusbar=0,menubar=0,resizable=1,width=630,height=410"

						Begin Request
							RequestType	= report
							ErrorFlowStr	= "onerrorclose.htm"
							ErrorFlowElem	= "onerrorclose.txt"
							StrTemplate 	= "prepare.htm"
							ElemTemplate	= "prepare.txt"

							// Need for correct IsSupport checking
							SID		= WhenExists($STD.csid, $params.sid)
							FID		= $Params.FID
							RID			= $Params.RID
							SubId	= $Params.SubId
							Lang	= $Params.Lang

							Begin VariableAttribute u
								//--------------------
								//Report Data
								//--------------------
								RID			= $Params.RID
								Mode		= text
								MaxPages	= (*) Action("wa_ReportPageCount")
								Direction	= Current
								ReportName	= $info.ReportName
								Index		= $Params.Index
								RulerId		= $Info.RulerId
								RulerCommand= $Params.RulerCommand
								ConvertorId	= $Params.ConvertorId
								ReportListContext = $params.ReportListContext
								OrgEncoding = $Info.OrgEncoding
								Language = $Info.Language

								ShowLV = $Info.HasLogicalViews
								when(NotEmpty($Params.Index) )
								{
									ShowIND = 0
								}
								else
								{
									ShowIND = $Info.HasIndexes
								}


								when(eq($Info.HasIndexes, 1) && eq(VarValueWhenExists(%user.extentions, $Info.ReportRealExtention, ConstName{forceindex}), true))
								{
									Force = true
								}
								hasnotes = $Info.hasnote
							End
						End
					End
				End
			End
		}

		//======================================================================
		// Report Menu
		//======================================================================

		// Local Save
		if ( eq(counter.IsReportVisible(),1) && ExistsAndEqual(%User.Applicationfeatures.ReportSaveFeature.ischecked, 1) && (ExistsAndNotEqual($userData.copies,0) || NotExists($userData.copies)) )
		{
			Begin Component function.SaveAsAction

				Begin Event.OnClick
					Begin OpenWindow
						TargetWindow = WindowByName
						TargetWindowName = "_blank"
						TargetWindowParameters = "toolbar=0,statusbar=0,menubar=0,resizable=1,width=10,height=10,"

						Begin Request
							RequestType		= Base
							sid		=	$params.sid
							Lang			= $Params.Lang
							ElemTemplate = "localoperation.txt"
							StrTemplate = "localoperation.htm"

							Begin VariableAttribute u
								Operation = "save"
								sid		=	$params.sid
								rid		=	$Params.RID
								fid		=	$Params.FID
								subid	=	$Params.SubID
								rulerid	=	$Params.RulerID
								index	=	(*) Action("wa_IndexPath")
								rname	=	$info.ReportName
								ReportName = $info.ReportName
								rpages	=	(*) Action("wa_ReportPageCount")
								rext	=	$info.ReportExtention
								convid	=	$Params.ConvertorId
								pageset	=	%User.Report.MaxSize
								repview	=	"1"

								when(eq($Info.IsExternalReport, 1) || eq($Info.IsDHTMLReport, 1))
								{
									istext = "0"
								}
								else
								{
									istext = "1"
								}

								// Since this is base request, Info.IsSupported.CreateDocument is not set properly,
								// because the SID parameter isn't set, so we need to pass it from here
								when(eq($Info.IsSupported.CreateDocument, true))
								{
									isDSR = "1"
								}

							when (noteq($Params.OutputMode,auto))
							{
								OutputMode		= $Params.OutputMode
							}
							else
							{
								OutputMode		= WhenExists($UserData.OutputMode)
							}
							
								Mode		= text
								MaxPages	= (*) Action("wa_ReportPageCount")
								Direction	= Current
								ReportName	= $info.ReportName
								Index		= $Params.Index
								RulerCommand= $Params.RulerCommand
								ConvertorId	= $Params.ConvertorId
								ReportListContext = $params.ReportListContext
								OrgEncoding = $Info.OrgEncoding
								Language = $Info.Language

								ShowLV = $Info.HasLogicalViews
								when(NotEmpty($Params.Index) )
								{
									ShowIND = 0
								}
								else
								{
									ShowIND = $Info.HasIndexes
								}


								when(eq($Info.HasIndexes, 1) && eq(VarValueWhenExists(%user.extentions, $Info.ReportRealExtention, ConstName{forceindex}), true))
								{
									Force = true
								}
								CanRunActiveX = (*) Action("CanRunActiveX()")
							
							End
						End
					End
				End
			End
		}

		// Local mail
		if ( eq(%User.Applicationfeatures.ReportMailFeature.ischecked, 1) && (ExistsAndNotEqual($userData.copies,0) || NotExists($userData.copies)) )
		{
			Begin Component function.SendMailAction
				Begin Event.OnClick
					Begin OpenWindow
						TargetWindow = WindowByName
						TargetWindowName = "_blank"
						TargetWindowParameters	= "toolbar=0,statusbar=0,menubar=0,resizable=0,width=630,height=500"

						Begin Request
							RequestType	= report				{const}
							ElemTemplate= "mail.txt"
							StrTemplate	= "mail.htm"
							SID		= WhenExists($STD.csid, $params.sid)
							FID		= $Params.FID
							RID			= $Params.RID
							Lang	= $Params.Lang

							Begin VariableAttribute u
								SUBID		= $Params.SubID
								MaxPages	= (*) Action("wa_ReportPageCount")
								ReportName	= $info.ReportName
								ReportExt	= $info.ReportExtention
								RID			= $Params.RID
								Index		= (*) Action("wa_IndexPath")
								ConvertorId	= $Params.ConvertorId
								RulerID		= $Params.RulerID
								OrgEncoding = $Info.OrgEncoding
								Language 	= $Info.Language

								when(eq($Info.IsExternalReport, 1) || eq($Info.IsDHTMLReport, 1))
								{
									istext = "0"
								}
								else
								{
									istext = "1"
								}

								ShowLV = $Info.HasLogicalViews
								ShowTR = $Info.HasTransformers
								when(NotEmpty($Params.Index) )
								{
									ShowIND = 0
								}
								else
								{
									ShowIND = $Info.HasIndexes
								}

								//we have to put it as integer, but not as a string:
								when(eq($Params.OutputMode, PAGE) || ExistsAndEqual($UserData.OutputMode, 2))
								{
									OutputMode = 2
								}
								else
								{
									OutputMode = 1
								}


								when(eq($Info.HasIndexes, 1) && eq(VarValueWhenExists(%user.extentions, $Info.ReportRealExtention, ConstName{forceindex}), true))
								{
									Force = true
								}
								CanRunActiveX = (*) Action("CanRunActiveX()")
							End
						End
					End
				End
			End
		}

//   Begin Counter ApprovalSupported
//			value = Number(WhenExists ($Info.IsSupported.Approval, 0))
//	End
// ExistsAndEqual($Info.ApprovalStatus, "c") || 
// ExistsAndEqual($Info.ApprovalStatus, "?") ||  
// ExistsAndEqual($Info.ApprovalStatus, "d") ||  
// ExistsAndEqual($Info.ApprovalStatus, "r") ||
// ExistsAndEqual($Info.ApprovalStatus, "s") ||
// ExistsAndEqual($Info.ApprovalStatus, "a") ||  
// ExistsAndEqual($Info.ApprovalStatus, "b") ||
// $Info.ApprovalStatus changed by $UserData.astatus
		// Approve only from Approvals
		
		if ( ( eq(counter.ApprovalSupported(), 1) && eq(%User.ApplicationFeatures.ApprovalsApprove.IsChecked, 1)) &&
 		       (ExistsAndEqual($UserData.Approval, 1) && ExistsAndEqual($Info.IsSupported.Approvalsinreportlist, 0) &&
   		       ( ExistsAndEqual($UserData.astatus, "c") || 
		         ExistsAndEqual($UserData.astatus, "r") )) ||
 		       (ExistsAndEqual($Info.IsSupported.Approvalsinreportlist, 1)
			     &&  
			    (ExistsAndEqual($UserData.Approval, 1) &&             // open from approval filter
    	         ((ExistsAndEqual($UserData.astatus, "?") ||  
		          ExistsAndEqual($UserData.astatus, "r")  ||
				  ExistsAndEqual($UserData.astatus, "c")) 
				 )
				) 
                ||
 		        (!ExistsAndEqual($UserData.Approval, 1) 		     // open from report list
    			  && 
		         (ExistsAndEqual($UserData.astatus, "?") ||  
		          ExistsAndEqual($UserData.astatus, "s") 
	 			 )
			    )
			  ) 				 
			) 
		{
				Begin Component function.ApproveAction
					Begin Event.OnClick
						Begin OpenWindow
							TargetWindow			= WindowByName
							TargetWindowName	= ApprovalActionPopup	{const}
							TargetWindowParameters	= "toolbar=0,statusbar=0,menubar=0,resizable=1,width=330,height=250"

							Begin Request
								RequestType	= Base				{const}
								ElemTemplate= "approvalaction.txt"	{const}
								StrTemplate	= "approvalaction.htm"	{const}
								ErrorFlowStr	= "onerrorclose.htm"	{const}
								ErrorFlowElem	= "onerrorclose.txt"	{const}
								SID		= WhenExists($STD.csid, $params.sid)			{const}
								FID		= $Params.FID			{const}
								Lang	= $Params.Lang			{const}

								Begin VariableAttribute u
									Action = "approve"
									ShowMode = "report"
									ReportName	= $info.ReportName				{const}
									RID			= $params.RID					{const}
									
									FindString	= $params.FindString
									Index		= $params.Index
									RulerId		= $params.RulerId
									ConvertorId	= $Params.ConvertorId		{const}
									RulerCommand= $params.RulerCommand
									when (noteq($Params.OutputMode,auto))
									{
										OutputMode		= $Params.OutputMode
									}
									else
									{
										OutputMode		= WhenExists($UserData.OutputMode)
									}
									//IconsForSearch
									Audit = $params.Audit
									PageNumber = WhenExists($params.PageNumber, 1)
									ReportListContext	= $Params.ReportListContext
									an = WhenExists($UserData.an)
								End
							End 
						End   
					End     
				End
			}

		// Reject only from Approvals
//		if ( (ExistsAndEqual($UserData.Approval, 1) && eq(counter.ApprovalSupported(), 1) && eq(%User.ApplicationFeatures.ApprovalsReject.IsChecked, 1)) && 
//		   ( ExistsAndEqual($Info.ApprovalStatus, "c") ||  
//		     ExistsAndEqual($Info.ApprovalStatus, "?") ||   
//		     ExistsAndEqual($Info.ApprovalStatus, "a") ||  
//		     ExistsAndEqual($Info.ApprovalStatus, "b") ))
// $Info.ApprovalStatus changed by $UserData.astatus
		if (( eq(counter.ApprovalSupported(), 1) && eq(%User.ApplicationFeatures.ApprovalsReject.IsChecked, 1)) &&
 		       (ExistsAndEqual($UserData.Approval, 1) && ExistsAndEqual($Info.IsSupported.Approvalsinreportlist, 0) &&
   		       ( ExistsAndEqual($UserData.astatus, "c") || 
			     ExistsAndEqual($UserData.astatus, "a") 
		         )) ||
 		       (ExistsAndEqual($Info.IsSupported.Approvalsinreportlist, 1)
			     &&  
			    (ExistsAndEqual($UserData.Approval, 1) &&       // open from approval filter
    	         (ExistsAndEqual($UserData.astatus, "?") ||  
			      ExistsAndEqual($UserData.astatus, "a") ||
				  ExistsAndEqual($UserData.astatus, "c")				  
				 )
				) 
                ||
 		        (!ExistsAndEqual($UserData.Approval, 1)         // open from report list
    			  && 
		         (ExistsAndEqual($UserData.astatus, "?") ||  
			      ExistsAndEqual($UserData.astatus, "d") ||  
		          ExistsAndEqual($UserData.astatus, "b") 
	 			 )
			    )
			  ) 				 
			) 

		{
				Begin Component function.RejectAction
					Begin Event.OnClick
						Begin OpenWindow
							TargetWindow			= WindowByName
							TargetWindowName	= ApprovalActionPopup	{const}
							TargetWindowParameters	= "toolbar=0,statusbar=0,menubar=0,resizable=1,width=330,height=250"

							Begin Request
								RequestType	= Base				{const}
								ElemTemplate= "approvalaction.txt"	{const}
								StrTemplate	= "approvalaction.htm"	{const}
								ErrorFlowStr	= "onerrorclose.htm"	{const}
								ErrorFlowElem	= "onerrorclose.txt"	{const}
								SID		= WhenExists($STD.csid, $params.sid)			{const}
								FID		= $Params.FID			{const}
								Lang	= $Params.Lang			{const}

								Begin VariableAttribute u
									Action = "reject"
									ShowMode = "report"
									ReportName	= $info.ReportName				{const}
									RID			= $params.RID					{const}
									
									FindString	= $params.FindString
									Index		= $params.Index
									RulerId		= $params.RulerId
									RulerCommand= $params.RulerCommand
									ConvertorId		= $Params.ConvertorId		{const}
									when (noteq($Params.OutputMode,auto))
									{
										OutputMode		= $Params.OutputMode
									}
									else
									{
										OutputMode		= WhenExists($UserData.OutputMode)
									}
									Audit = $params.Audit
									PageNumber = WhenExists($params.PageNumber, 1)
									ReportListContext	= $Params.ReportListContext
									an = WhenExists($UserData.an)
								End
							End 
						End   
					End     
				End
			}
			
			// History
			if (eq(counter.ApprovalSupported(), 1) && eq(%User.ApplicationFeatures.ApprovalsHistory.IsChecked, 1) && 
			      (ExistsAndEqual($Info.HasHistory, 1 ) || ExistsAndEqual($UserData.HasHistory, 1 ) ))
			{
				Begin Component function.HistoryAction
					Begin Event.OnClick
						Begin OpenWindow
							TargetWindow			= WindowByName
							TargetWindowName	= HistoryPopup	{const}
							TargetWindowParameters	= "toolbar=0,statusbar=0,menubar=0,resizable=1,scrollbars=1,width=800,height=500"

							Begin Request
								RequestType	= ApprovalHistory				{const}
								ElemTemplate= "approvalhistory.txt"	{const}
								StrTemplate	= "approvalhistory.htm"	{const}
								ErrorFlowStr	= "onerrorclose.htm"	{const}
								ErrorFlowElem	= "onerrorclose.txt"	{const}
								SID		= WhenExists($STD.csid, $params.sid)			{const}
								FID		= $Params.FID			{const}
								Lang	= $Params.Lang			{const}
								RID			= $params.RID					{const}
								Begin VariableAttribute u
									ReportName = $info.ReportName 				{const}
									an = WhenExists($UserData.an)
								End
							End
						End
					End
				End
			}
			

			// Subscription
			if (ExistsAndEqual($Info.IsSupported.subscription, 1) && eq(%User.ApplicationFeatures.SubscriptionReport.IsChecked, 1)  )
			{
				Begin Component function.SubscriptionAction
						Begin Event.OnClick
							Begin OpenWindow
										TargetWindow 		= WindowByName		{const}
										TargetWindowName 	= SubscriptionPopup	{const}
										TargetWindowParameters	= "toolbar=0,statusbar=0,menubar=0,resizable=1,width=630,height=700"	{const}
										Begin Request
											RequestType	= RemotePrintParams	{const}
											SID 		= WhenExists($STD.csid, $params.sid)		{const}
											FID			= $Params.FID		{const}
											SubId	= $Params.SubID
											Lang		= $Params.Lang		{const}
											RID			= $Params.RID
											ErrorFlowStr	= "onerrorclose.htm"	{const}
											ErrorFlowElem	= "onerrorclose.txt"	{const}
											StrTemplate		= "subscription.htm"	{const}
											ElemTemplate	= "subscription.txt"	{const}
											IndexPath	= $Params.Index
											IndexPath	= (*) Action("wa_IndexPath")
											subscription = "1"
											Email = (*) Action("subscriptionEmail") {const} 
		
											Begin VariableAttribute u
												when(NotEmpty($Params.Index) )
												{
													HasIndexes	= "false"
												}
												else
												{
													HasIndexes	= $Info.HasIndexes
												}
				
												ReportName	= $info.ReportName
												OrgEncoding = $Info.OrgEncoding
												Language = $Info.Language
												FromReport = 1
											End
										End
									End
								End
					End
			}	

		//===========================================================================
		// Report Tools Menu
		//===========================================================================

		// Logical Views
		if( (notexists($STD.NoLV) || noteq($STD.NoLV, 1)) && eq(%User.Applicationfeatures.ReportLVFeature.ischecked, 1))
		{
			if( notempty($Info.RulerId) && eq($info.HasRulerCommands, true) && eq($Info.IsDHTMLReport, 0))
			{
				Begin Component function.DynLogicalView
					Begin Event.OnClick
						Begin OpenWindow
							TargetWindow = WindowByName
							TargetWindowName = RulerParamPopup
							TargetWindowParameters = "toolbar=0,statusbar=0,menubar=0,resizable=1,width=800,height=400"

							Begin Request
								RequestType		= RulerParamsList
								SID				= WhenExists($STD.csid, $params.sid)
								FID				= $Params.FID
								Lang			= $Params.Lang
								RID				= $Params.RID
								RulerId			= $Info.RulerId
								SubId			= $Params.SubID
								ReportContext	= $Params.ParamsString
								ErrorFlowStr	= "onerrorclose.htm"
								ErrorFlowElem	= "onerrorclose.txt"

								Begin VariableAttribute u
									ReportName			= $info.ReportName
									ReportListContext	= $Params.ReportListContext
									ReportWindow		= (*) Action("parent.name")
									when(ExistsAndEqual($UserData.Approval, 1))
									{
											Approval =1
									}
								End
							End
						End
					End
				End
			}

			// Logical View  Support
			if (eq(%User.Applicationfeatures.ReportLVFeature.ischecked, 1)
				&& ( eq($Info.IsDHTMLReport, 0) ) &&
				noteq($Info.IsExternalReport, 1) &&
				eq($Info.reportrealextention, "txt") )
			{
				Begin Component LVIsSupported
					Begin Label
						Label = "true"
					End
				End
			}
		}

		// Notes

		if( eq(%User.Applicationfeatures.NoteFeature.ischecked, 1) && (eq($Info.hasnote,1)||eq(%User.Applicationfeatures.NoteAddFeature.ischecked , 1)))
		{
			Begin Component function.Notes
				Begin Event.OnClick
					Begin	OpenWindow
						TargetWindow 			= WindowByName
						TargetWindowName		= NotePopup
						TargetWindowParameters	= "toolbar=0,statusbar=0,menubar=0,resizable=1,width=640,height=480"
						Begin Request
							RequestType		= NoteListWindow
							SID 			= WhenExists($STD.csid, $params.sid)
							FID				= $Params.FID
							Lang			= $Params.Lang
							RID				= $Params.RID
							Mode			= LIST
							CacheKey		= DoCache
							ReportContext	= $Params.ParamsString
							ErrorFlowStr	= "onerrorclose.htm"
							ErrorFlowElem	= "onerrorclose.txt"

							Begin VariableAttribute u
								RID			= $Params.RID
								RulerId		= $Info.RulerId
								RulerCommand = $Params.RulerCommand
								Index		= (*) Action("wa_IndexPath")
								FindString	= $Params.FindString
								FindCase	= $Params.FindCase
								FindWholeWord = $Params.FindWholeWord
								MatchedFind	= $Params.MatchedFind
								when (noteq($Params.OutputMode,auto))
								{
									OutputMode		= $Params.OutputMode
								}
								else
								{
									OutputMode		= WhenExists($UserData.OutputMode)
								}
								TopPage		= String($Position.TopPage)
								BottomPage	= String($Position.BottomPage)
								ReportName	= $info.ReportName
								Pages		= (*) Action("wa_ReportPageCount")
								OpenTagNoteTab = false
								RefreshWhat = Report
								ReportWindow = (*) Action("parent.name")
								OrgEncoding = $Info.OrgEncoding
								Language = $Info.Language
								RVM = (*) Action("wa_nNoteMode")
								when(ExistsAndEqual($UserData.Approval, 1))
								{
										Approval =1
								}
								when (ExistsAndNotEqual($userData.copies,0) || NotExists($userData.copies))
								{
									copies = WhenExists($userData.copies, "1")
								}
							End
						End
					End
				End
			End
		}

		Begin Component OpenNoteWindow
			Begin Event.OnClick
				Begin OpenWindow
					TargetWindow 			= WindowByName
					TargetWindowName		= NotePopup
					TargetWindowParameters	= "toolbar=0,statusbar=0,menubar=0,resizable=1,width=640,height=480"

					Begin Request
						RequestType = NoteListWindow
						SID			= WhenExists($STD.csid, $params.sid)
						FID			= $Params.FID
						Lang		= $Params.Lang
						SubID		= $Params.SubID
						RID			= $Params.RID
						NID			= (*) Action("NID")
						ReportContext	= $Params.ParamsString
						Mode			= LIST
						CacheKey		= DoCache
						ErrorFlowStr	= "onerrorclose.htm"
						ErrorFlowElem	= "onerrorclose.txt"

						Begin VariableAttribute u
							RID				= $Params.RID
							RulerId			= $Info.RulerId
							RulerCommand	= $Params.RulerCommand
							Index			= (*) Action("wa_IndexPath")
							FindString		= $Params.FindString
							FindCase		= $Params.FindCase
							FindWholeWord	= $Params.FindWholeWord
							MatchedFind		= $Params.MatchedFind
							TopPage			= String($Position.TopPage)
							BottomPage		= String($Position.BottomPage)
							ReportName		= $info.ReportName
							Pages			= String($Info.Pages)
							ReportWindow 	= (*) Action("parent.name")
							OrgEncoding 	= $Info.OrgEncoding
							Language 		= $Info.Language
							when (noteq($Params.OutputMode,auto))
							{
								OutputMode		= $Params.OutputMode
							}
							else
							{
								OutputMode		= WhenExists($UserData.OutputMode)
							}
							OpenTagNoteTab	= false
							RefreshWhat = Report
							RVM				= (*) Action("wa_nNoteMode")
							when(ExistsAndEqual($UserData.Approval, 1))
							{
								Approval =1
							}
						End //user data
					End // request
				End // open window
			End // onclick
		End

		// Indexes
		if(notexists($STD.NoIdx) || noteq($STD.NoIdx, 1) &&  eq(%User.Applicationfeatures.IndexFeature.ischecked, 1))
		{
			if(eq($Info.HasIndexes,1))
			{
				Begin Component function.Indexes
					Begin Event.OnClick
						Begin	OpenWindow
							TargetWindow 			= WindowByName
							TargetWindowName 		= IndexPopup
							TargetWindowParameters	= "toolbar=0,statusbar=0,menubar=0,width=620,height=465"
							Begin Request
								RequestType		= Index
								SID 			= WhenExists($STD.csid, $params.sid)
								FID				= $Params.FID
								Lang			= $Params.Lang
								RID				= $Params.RID
								ReportContext	= $Params.ParamsString
								ErrorFlowStr	= "onerrorclose.htm"
								ErrorFlowElem	= "onerrorclose.txt"

								Begin VariableAttribute u
									ReportWindow = (*) Action("parent.name")
									ShowLV = $Info.HasLogicalViews
									ShowTR = $Info.HasTransformers
									OrgEncoding = $Info.OrgEncoding
									Language = $Info.Language
									IsText = Counter.IsTextReport()
									CanRunActiveX = (*) Action("CanRunActiveX()")
									when (noteq($Params.OutputMode,auto))
									{
										OutputMode		= $Params.OutputMode
									}
									else
									{
										OutputMode		= WhenExists($UserData.OutputMode)
									}
									when ( ExistsAndEqual(%User.Applicationfeatures.indexfeatureClearValues.ischecked, 1) )
									{
										IndexPath = (*) Action("ParseIndexes()")
									}
									else
									{
											IndexPath = $Params.Index
									}

									when(eq(VarValueWhenExists(%user.extentions, $Info.ReportRealExtention, ConstName{forceindex}), true))
									{
										Force = true
									}
									when(ExistsAndEqual($UserData.Approval, 1))
									{
										Approval =1
									}
									when (ExistsAndNotEqual($userData.copies,0) || NotExists($userData.copies))
									{
										copies = WhenExists($userData.copies, "1")
									}
								End
							End
						End
					End
				End
			}
		}

		if((!ExistsAndEqual($STD.NoLV, 1)) && noteq($Position.TopPage, 0) )
		{
			//=========================================================================
			// Logical View Management Menu
			//=========================================================================
			if( eq(%User.Applicationfeatures.ReportLVFeature.ischecked, 1) )
			{
				if(notempty($Info.RulerId))
				{
					Begin Component function.ClearRulerAction
						Begin Event.OnClick
			  				Begin Request
									RequestType	= Report
									SID		= WhenExists($STD.csid, $params.sid)
									FID		= $Params.FID
									RID		= $Params.RID
									Lang	= $Params.Lang
									SubId	= $Params.SubID
									ReportListContext = $Params.ReportListContext
									Index = $Params.Index
									ConvertorId = $Params.ConvertorId
									cachekey = docache
									reportcachekey = docache
									when(notempty($Params.FindString))
									{
										FindString	= $Params.FindString
										MatchedFind	= $Params.MatchedFind
										FindWholeWord = $Params.FindWholeWord
										FindCase 	= $Params.FindCase
									}
									when(noteq($Params.OutputMode, AUTO) || ExistsAndNotEqual($UserData.OutputMode, 0))
									{
										OutputMode = $Params.OutputMode
									}
									if(ExistsAndEqual($UserData.Approval, 1))
									{
										Begin VariableAttribute u
												Approval =1
										End
									}
								End
						End
					End
				}

				if (eq($Info.IsSupported.RulerManagement, true) && eq(%User.Applicationfeatures.ReportLVFeature.ischecked, 1) )
				{
					Begin Component LogicalViewManagementTemplates
						Template (LogicalViewManagement)
						{
							Begin Event.OnClick
								Begin OpenWindow
									TargetWindow		= WindowByName
									TargetWindowName	= StrVariable.TargetWindowName()
									TargetWindowParameters	= "toolbar=0,statusbar=0,menubar=0,resizable=1,width=425,height=100"	{const}

									Begin Request
										RequestType	= Base
										SID		= WhenExists($STD.csid, $params.sid)
										FID		= $Params.FID
										Lang		= $Params.Lang
										SubId		= $Params.SubID
										StrTemplate	= "rulermanagement.htm"
										ElemTemplate	= "rulermanagement.txt"


										Begin VariableAttribute u
											Mode		= StrVariable.Mode()
											RID		= $Params.RID
											RulerId		= $Info.RulerId
											RulerName	= $Info.RulerDescription
											IsRulerPublic	= $Info.IsRulerPublic
											ShowType	= "0"
											RulerReportNameMask = $Info.RulerReportNameMask
										End
									End
								End
							End
						}

						Template (LVEditor)
						{
							if(IsRequestExists(LogicalViewText))
							{
								Begin Strvariable encoding
										When(eq("{!WA Common.PdfEncoding}", "unicode"))
										{
											value = "utf-8"
										}
										else
										{
											value = "{!WA Common.PdfEncoding}"
										}
								End
								Begin Strvariable encoding
									When(noteq(find(Strvariable.encoding(),">"),NotFound()))
									{
										value = substring(Strvariable.encoding(),0,find(Strvariable.encoding(),">"))
									}
								End
								
								Begin Event.OnClick
										Begin Request
											RequestType		= Base						{const}
											SID				= WhenExists($STD.csid, $params.sid)				{const}
											FID				= $Params.FID				{const}
											StrTemplate		= "logicalvieweditor.htm"	{const}
											ElemTemplate	= "logicalvieweditor.txt"	{const}
											Lang			= $Params.Lang				{const}

											Begin VariableAttribute u
												operation = "logicalview" {const}
												encoding = Strvariable.encoding()
												baseUrl =  (*) Action ("GetBaseUrl()") {const}
												location = (*) Action ("location.href.split('?')[0]") {const}
												RID	= $Params.RID						{const}
												ReportName	= $info.ReportName			{const}
												RulerID		= StrVariable.RulerID()
												RulerName	= StrVariable.RulerName()
												Index		= (*) Action("wa_IndexPath")	{const}
												ProxyAddress = %User.GeneralSettings.ProxyAddress
												ProxyPort = String(%User.GeneralSettings.ProxyPort)
												CharSet = "{!WA lang.CharSet}"
												DisplayFont = "{!WA lang.DisplayFont}"
												EditFont = "{!WA lang.EditFont}"
												UIFont = "{!WA lang.UIFont}"
												HelpDir = "{!WA Common.HelpDir}"
												Language = "{!WA lang.LangName}"
												DParamDisplayName = "yes"
												when( eq($Info.IsSupported.PrivateLV,0) )
												{
													IsPrivateLVSupported = "false"
												}
												else
												{
													IsPrivateLVSupported = "true"
												}
												WAVersion = $Params.Version
												when(eq(%User.Applicationfeatures.Helpfeature.ischecked , 0) )
												{
													label = "false"
												}
												else
												{
													label = "true"
												}
												when (ExistsAndEqual(%User.Applicationfeatures.Helpfeature.ischecked, "1"))
												{
													showHelp = "true"
												}
												else
												{
													showHelp = "false"
												}
											End
									End
								End
							}
						}
					End

					if( eq(%User.Applicationfeatures.ReportLVManagmentCreateFeature.ischecked, 1) )
					{
						Begin Component function.CreateRulerAction
							Begin StrVariable RulerID
								value = String()
							End
							Begin StrVariable RulerName
								value = String()
							End

							DoTemplate(LVEditor)
						End
					}

					if (notempty($Info.RulerId))
					{
						if(eq(%User.Applicationfeatures.ReportLVManagmentDeleteFeature.ischecked, 1))
						{
							Begin Component function.DeleteRulerAction
								Begin StrVariable TargetWindowName
									value = DeleteRulerPopup
								End

								Begin StrVariable Mode
									value = Delete
								End

								DoTemplate(LogicalViewManagement)
							End
						}

						if( eq(%User.Applicationfeatures.ReportLVManagmentRenameFeature.ischecked, 1) )
						{
							Begin Component function.RenameRulerAction
								Begin StrVariable TargetWindowName
									value = RenameRulerPopup
								End

								Begin StrVariable Mode
									value = Rename
								End

								DoTemplate(LogicalViewManagement)
							End
						}

						if(eq(%User.Applicationfeatures.ReportLVManagmentEditFeature.ischecked, 1) )
						{
							Begin Component function.EditRulerAction
								Begin StrVariable RulerID
									value = $Params.RulerID
								End
								Begin StrVariable RulerName
									value = $Info.RulerDescription
								End

								DoTemplate(LVEditor)
							End
						}
					}
				}
			}

			//=======================================================================
			// Ruler List Requests
			//=======================================================================
			Begin Component function.RulerListRequest
				Begin Counter ShowExportDefinitionIcons
					value = %User.GeneralSettings.ShowExportDefinitionIcons
				End

				Begin QueryString
					Begin Request
						RequestType = RulerList		{const}
						SID		= WhenExists($STD.csid, $params.sid)		{const}
						SUBID	= $Params.SubID		{const}
						FID		= $Params.FID			{const}
						Lang	= $Params.Lang		{const}
						RID		= $Params.RID {const}
						ShowExportDefinitionIcons = Counter.ShowExportDefinitionIcons() {const}
						nobrowsercache = true

						Begin VariableAttribute u
							ReportListContext = $Params.ReportListContext {const}
						End
					End
				End
			End

			if(eq(Counter.ShowExportDefinitionIcons(), 0))
			{
				Begin Component function.RulerInfoRequest
					Begin QueryString
						Begin Request
							RequestType = RulerList			{const}
							SID		= WhenExists($STD.csid, $params.sid)			{const}
							SUBID	= $Params.SubID			{const}
							FID		= $Params.FID			{const}
							Lang	= $Params.Lang			{const}
							RID		= $Params.RID			{const}
							MODE	= INFO					{const}
							RulerId	= (*) Action("szRulerId") {const}
							strtemplate = "rulerinfo.htm"	{const}
							elemtemplate = "rulerinfo.txt"	{const}
						End
					End
				End
			}

			if (exists($Info.RulerId))
			{
				Begin Component Report.RulerID
					Begin Label
						Label = $Info.RulerId
					End
				End
			}

			Begin Component function.OpenReport
				Begin Event.OnClick

					Begin Request
						RequestType = Report	{const}
						SID		= WhenExists($STD.csid, $params.sid)	{const}
						FID		= $Params.FID		{const}
						Lang	= $Params.Lang	{const}
						RID		= $Params.RID	{const}
						ReportListContext = $Params.ReportListContext {const}
						RulerId		= (*) Action("szRulerId")
						ConvertorId	= (*) Action("szTransformerId")
						Mode		= INFO			{const}
						CacheKey	= DoCache		{const}
						ReportCacheKey = DoCache	{const}
						// OutputMode = Auto (defualt) or Page or Document

						Index = $Params.Index	{const}
						when(notempty($Params.FindString))
						{
							FindString	= $Params.FindString
							MatchedFind	= $Params.MatchedFind
							FindWholeWord = $Params.FindWholeWord
							FindCase 	= $Params.FindCase
						}
						u=$Params.u
					End
				End
			End
		}
	} // End of visible report
}
// End of Show Title

// Freeze Support
Begin Component FreezeUsed

	if (eq(Counter.RVM(), 0) && notempty($Info.RulerId) &&
   	    (noteq($RulersInfo.EmptyTL, 1) || noteq($RulersInfo.EmptyTM, 1) || noteq($RulersInfo.EmptyTR, 1) ||
		 noteq($RulersInfo.EmptyML, 1) || noteq($RulersInfo.EmptyMR, 1) ||
		 noteq($RulersInfo.EmptyBL, 1) || noteq($RulersInfo.EmptyBM, 1) || noteq($RulersInfo.EmptyBR, 1)
		)
	   )
	{
			// With FREEZE Ruler
		Begin Counter FreezeUsed
			value = 1
		End

		Begin Label
			Label = "true"
		End
	}
	else
	{
		Begin Counter FreezeUsed
			value = 0
		End
		Begin Label
			Label = "false"
		End
	}
End

if (eq(Counter.FreezeUsed(), 1))
{
	//-------------------------------------------------------------------------
	// Definition of Row size component
	//-------------------------------------------------------------------------
	Begin Component FreezParts.TopRowPixHeight
		Begin Label
			Label = String($RulersInfo.TopRowPixHeight)
		End
	End

	Begin Component FreezParts.BottomRowPixHeight
		Begin Label
			Label = String($RulersInfo.BottomRowPixHeight)
		End
	End

	//-------------------------------------------------------------------------
	// Definition of Cols size component
	//-------------------------------------------------------------------------
	Begin Component FreezParts.LeftColPixWidth
		Begin Label
			Label = String($RulersInfo.LeftColPixWidth)
		End
	End

	Begin Component FreezParts.RightColPixWidth
		Begin Label
			Label = String($RulersInfo.RightColPixWidth)
		End
	End

	Begin Component FreezParts.XSize
		Begin Label
			when(exists($STD.x))
			{
				Label = $STD.x
			}
			else
			{
				Label = (*) Action("x_CharSize()")
			}
		End
	End

	Begin Component FreezParts.YSize
		Begin Label
			when(exists($STD.y))
			{
				Label = $STD.y
			}
			else
			{
				Label = (*) Action("y_CharSize()")
			}
		End
	End
}

//for Overlay
Begin Component function.ChangeFontSize
	Begin Event.OnClick
		Begin Request
			RequestType = Report	{const}
			SID		= WhenExists($STD.csid, $params.sid)	{const}
			FID		= $Params.FID	{const}
			Lang	= $Params.Lang	{const}
			RID		= $Params.RID	{const}
			ReportListContext = $Params.ReportListContext {const}
			RulerId		= $Params.RulerId
			Mode		= INFO			{const}
			CacheKey	= DoCache		{const}
			ReportCacheKey = DoCache	{const}
			ConvertorId	= $Params.ConvertorId {const}
			Index = $Params.Index		{const}
			Direction		= Current
			LastTopPage		= String($Position.TopPage)
			LastBottomPage	= String($Position.BottomPage)

			when(notempty($Params.FindString))
			{
				FindString	= $Params.FindString
				MatchedFind	= $Params.MatchedFind
				FindWholeWord = $Params.FindWholeWord
				FindCase	= $Params.FindCase
			}

			Begin VariableAttribute u
				FontSize = (*)Action("GetFontSizeFromCookies()")
				RVM = (*) Action("wa_nNoteMode")
				when(ExistsAndEqual($UserData.Approval, 1))
				{
						Approval =1
				}
			End
		End
	End
End

Begin Component RID
	Begin Label
		Label = $Params.RID
		EscapeType = JS
	End
End

Begin Component ReportPageCount
	Begin Label
		Label = String($Info.Pages)
		EscapeType = None
	End
End

if(notempty($Params.FindString))
{
	Begin Component HasFindString
		Begin Label
			label = "true"
			EscapeType = None
		End
	End
}

Begin Component FindAvailable
	Begin Label
		Label = String($Info.FindAvailable)
		EscapeType = None
	End
End

if(eq($Params.MatchedFind, true))
{
	Begin Component IsMatchedFind
		Begin Label
			label = "true"
			EscapeType = None
		End
	End
}

Begin Component TopPage
	Begin Label
		Label = String($Position.TopPage)
		EscapeType = None
	End
End

Begin Component BottomPage
	Begin Label
		Label = String($Position.BottomPage)
		EscapeType = None
	End
End

Begin Component LastTopPage
	Begin Label
		Label = String($Params.LastTopPage)
		EscapeType = None
	End
End



//==============================================
// Report Name
//==============================================
Begin Component ReportName
	Begin Label
		Label = $info.ReportName
		EscapeType = JS
	End
End

Begin Component ReportNameInTitle
	Begin Label
		Label = $info.ReportName
		EscapeType = HTMLWithSpaces
	End
End

//--------------------------------------
// Correct Font for report pages
//--------------------------------------


Begin Component Report.Fontfamily
//for text repors in unicode
if(eq("{!WA lang.CharSet}", "UTF-8") && eq($Info.IsExternalReport, 0) && eq($Info.IsDHTMLReport, 0) )
{
	//get font list for Report Encoding&Language from server
	Begin RequestData FontListData
		Begin Request
			RequestType 	= FontList
			Encoding	= $Info.OrgEncoding
			Language 	= $Info.Language

		End
	End
}
	//set font string in PageBody style
	if(exists([FontListData]) && exists([FontListData].FixFontList) )
	{
		Begin Counter CurrentNum
			value = 0
		End

		Begin Label
			Label = "font-family: "
			EscapeType = None
		End
		ForEach([FontListData].FixFontList)
		{
			Begin Label
				Label = "'" + [] + "'"
				EscapeType = None
			End

			Begin Counter CurrentNum
				inc = 1
			end

			//put ',' for all fonts, except last
			if(noteq(Counter.CurrentNum(), [FontListData].fixfontsnumber))
			{
				Begin Label
					Label = ", "
					EscapeType = None
				End
			}
		}

		Begin Label
			Label = ", monospace;"
			EscapeType = None
		End
	}
	else
	{
		Begin Label
			Label = String()
			EscapeType = None
		End
	}
End

Begin Component  HideHelp
	if(eq(%User.Applicationfeatures.Helpfeature.ischecked , 0) )
	{
		Begin Label
			label = "HideHelpUI();"
		End
	}
End

// Note view support
if(noteq(Counter.RVM(), 0))
{
	Begin Component NoteMode
		Begin Label
			label = Counter.RVM()
			EscapeType = None
		End
	End

	Begin Component ReportBodyClass
		Begin Label
			label = "'ReportNoteMode'"
			EscapeType = None
		End
	End
}

if(eq(%User.Applicationfeatures.NoteAddFeature.ischecked , 1))
{
	Begin Component function.AddNoteAction
		Begin Event.OnClick
			Begin OpenWindow
				TargetWindow = WindowByName
				TargetWindowName =  (*) Action("parent.name")

				Begin Request
					RequestType		= AddNewNote
					ElemTemplate	= "addnewnote.txt"
					SID				= WhenExists($STD.csid, $params.sid)
					FID				= $Params.FID
					Lang			= $Params.Lang
					RID				= $Params.RID
					RulerId		= $Info.RulerId
					IndexPath		= $Params.Index
					PageNum			= (*) Action("CurTextSelection.nPage")
					NoteName		= (*) Action("GetNoteName()")
					NoteText		= (*) Action("GetNoteText()")
					NoteCoordLine	= (*) Action("GetNoteLine()")
					NoteCoordOffset	= (*) Action("GetNoteCol()")
					NoteCoordLength = (*) Action("CurTextSelection.nLen")
					Begin VariableAttribute u
						cfl = (*) Action("nFindLayer")
						pfl = (*) Action("nPrevFindLayer")
						RID			= $Params.RID
						RulerId		= $Info.RulerId
						RulerCommand = $Params.RulerCommand
						Index		= (*) Action("wa_IndexPath")
						when (noteq($Params.OutputMode,auto))
						{
							OutputMode		= $Params.OutputMode
						}
						else
						{
							OutputMode		= WhenExists($UserData.OutputMode)
						}
						TopPage		= String($Position.TopPage)
						BottomPage	= String($Position.BottomPage)
						ReportName	= $info.ReportName
						Pages		= (*) Action("wa_ReportPageCount")
						OpenTagNoteTab = false
						RefreshWhat = Report
						ReportWindow = (*) Action("parent.name")
						OrgEncoding = $Info.OrgEncoding
						Language = $Info.Language
						RVM = (*) Action("wa_nNoteMode")
						ReportListContext=$Params.ReportListContext		{ const }
						when(ExistsAndEqual($UserData.Approval, 1))
						{
								Approval =1
						}
						Direction		= current			{const}
						FindString		= $Params.FindString
						MatchedFind	= $Params.MatchedFind
						FindCase		= $Params.FindCase
						FindWholeWord	= $Params.FindWholeWord
					End
				End
			End
		End
	End
}

Begin Component IsMFR
	Begin Label
		when(eq($Info.IsSupported.HostPrint, 1))
		{
			Label = "1"
		}
		else
		{
			Label = "0"
		}
	End
End

if(eq(%User.Applicationfeatures.NotesViewModes.ischecked, 1) && eq(Counter.IsTextReport(),1))
{
	Begin Component function.ChangeModeReportAction
		Begin Event.OnClick
			Begin Request
				RequestType = Report	{const}
				SID		= WhenExists($STD.csid, $params.sid)	{const}
				FID		= $Params.FID	{const}
				Lang	= $Params.Lang	{const}
				RID		= $Params.RID	{const}
				ReportListContext = $Params.ReportListContext {const}
				RulerId		= $Info.RulerId			{const}
				ConvertorId	= $Params.ConvertorId	{const}
				Mode		= INFO					{const}
				CacheKey	= DoCache				{const}
				ReportCacheKey = DoCache			{const}
				Index			= $Params.Index		{const}
				Direction		= current			{const}
				LastTopPage		= $Position.TopPage {const}
				LastBottomPage	= $Position.BottomPage {const}
				FindString		= $Params.FindString
				MatchedFind	= $Params.MatchedFind
				FindCase		= $Params.FindCase
				FindWholeWord	= $Params.FindWholeWord

				Begin VariableAttribute u
					cfl = (*) Action("nFindLayer")
					pfl = (*) Action("nPrevFindLayer")
					when(eq(Counter.RVM(), 0))
					{
						RVM = Counter.DefaultRVM()
					}
					else
					{
						RVM = 0
					}

					ForEach(attr in $UserData)
					{
						if(noteq(VarName([attr]), ConstName{RVM}) && noteq(VarName([attr]), ConstName{cfl}) && noteq(VarName([attr]), ConstName{pfl}))
						{
							Begin Attribute
								name = VarName([attr])
								value = [attr]
							End
						}
					}
				End
			End
		End
	End
}

Begin Component function.SaveIcons
	Begin QueryString
		Begin Request
			RequestType = NoteMultiUpdate			{const}
			SID		= WhenExists($STD.csid, $params.sid)			{const}
			FID		= $Params.FID			{const}
			Lang	= $Params.Lang			{const}
			RID		= $Params.RID			{const}
			RulerId= $Info.RulerId {const}
			IndexPath	= $Params.Index {const}
			MultiNoteData =  (*) Action("GetMultiNoteData()"){const}
			strtemplate = "warequestinfo.htm"	{const}
			elemtemplate = "addmultinote.txt"	{const}
			ErrorFlowStr	= "onerrorajax.htm"
			ErrorFlowElem	= "onerrorajax.txt"
		End
	End
End


Begin Component User
	Begin label
		Label = GetUser()
		EscapeType = JS
	End
End

Begin Component NotesAdminName
	Begin label
		when(eq(%User.Applicationfeatures.TagIconSecurityFeature.value , 1))
		{
			Label = %User.Applicationfeatures.NotesAdministrator.value
		}
		else
		{
		 	Label = String()
		}
		EscapeType = JS
	End
End

Begin Component TagIconSupport
	Begin label
		when(eq(%User.Applicationfeatures.TagIconFeature.ischecked , 1) )
		{
			label = "true"
		}
		else
		{
			Label = "false"
		}
		EscapeType = None
	End
End


Begin Component DeleteTagIconSupport
	Begin label
		when(eq(%User.Applicationfeatures.TagIconDeleteFeature.ischecked , 1) )
		{
			label = "true"
		}
		else
		{
			Label = "false"
		}
		EscapeType = None
	End
End

Begin Component ChangeTagIconSupport
	Begin label
		when(eq(%User.Applicationfeatures.TagIconChangeFeature.ischecked , 1) )
		{
			label = "true"
		}
		else
		{
			Label = "false"
		}
		EscapeType = None
	End
End

Begin Component TagIconSecurity
	Begin label
		when(eq(%User.Applicationfeatures.TagIconSecurityFeature.value , 1) )
		{
			label = "true"
		}
		else
		{
			Label = "false"
		}
		EscapeType = None
	End
End




if(eq(%User.Applicationfeatures.ZebraReport.value, 1)
	&& NotEq($Info.IsExternalReport, 1) && NotEq($Info.IsDHTMLReport, 1))
{
	Begin Component ZebraReportIfNeeded
		Begin Label
			label = "ZebraReport();"
			EscapeType = None
		End
	End
}
else
{
	Begin Component ZebraReportIfNeeded
		Begin Label
			label = "NonZebraReport();"
			EscapeType = None
		End
	End
	
}


#include "logo.txt"
//readonly filter support
#include "filterreadonly.txt"

Begin Component ReportListFilter
	Begin label
				label = $ReportListContext.Filter
				EscapeType = None
	End
End


Begin Component BackToRreportListUnFiltered
		Begin Label
				Label = %User.Applicationfeatures.ReportBackToRLFeatureUnFiltered.ischecked
		End	
End
Begin Component BackToRreportListWithAppliedFilter
		Begin Label
				Label = %User.Applicationfeatures.ReportBackToRLFeatureWithAppliedFilter.ischecked
		End	
End
Begin Component BackToRreportListNewFilter
		Begin Label
				Label = %User.Applicationfeatures.ReportBackToRLFeatureNewFilter.ischecked
		End	
End
Begin Component ReportListType
	Begin Label
		Label = WhenExists($ReportListContext.Type) {const}
	End
End

Begin Component IsDHTMLReport
	Begin Label
		when(eq($Info.IsDHTMLReport, 1))
		{
			Label = "true"
		}
		else
		{
			Label = "false"
		}
		EscapeType = None
	End
End

Begin Component PrevFindLayer
	Begin Label
			Label = WhenExists($UserData.pfl,"-1")
	End
End

Begin Component CurrentFindLayer
	Begin Label
			Label = WhenExists($UserData.cfl,"-1")
	End
End


Begin Component PrintIconLocation
	Begin Label
		Label = %User.Applicationfeatures.ReportPrintIconLocation.value
	End
End

Begin Component PrintAsActiveXPlugIn
	Begin Label
		Label = %User.Applicationfeatures.ReportPrintDialogType.value
	End
End

Begin Component RunSaveAsActiveXPlugIn
	Begin Label
		Label = %User.Applicationfeatures.ReportSaveDialogType.value
	End
End

Begin Component RunMailAsActiveXPlugIn
	Begin Label
		Label = %User.Applicationfeatures.ReportMailDialogType.value
	End
End

Begin Component PrintNotes
			Begin Label
				when (ExistsAndNotEqual($UserData.PrintNotes,"0") &&  eq($Info.hasnote,1))
				{
					Label = "1"
				}
				else
				{
					Label = "0"
				}
			End
End

Begin Component PrintNotesMode
			Begin Label
				Label = Number(WhenExists($UserData.printnotes))
				EscapeType = None
			End
End


Begin Component PrintImmediate
		Begin Label
			when (ExistsAndEqual($UserData.PrintImmediate,"1"))
			{
				Label = "1"
			}
			else
			{
				Label = "0"
			}
			EscapeType = None
	End
End


Begin Component PrepreToPrintFontSize
	Begin Label
		Label = WhenExists(%User.Applicationfeatures.ReportPreparePrintFontSize.value, "9") + "pt"
	End
End


Begin Component PreparePrintTagIcons
	Begin Label
		Label = WhenExists(%User.Applicationfeatures.ReportPreparePrintTagIconsFeature.ischecked)
	End
End


Begin Component PrepreToPrintOrinetation
	Begin Label
		Label = WhenExists($UserData.printOrientation)
	End
End

Begin Component PrepreToPrintAutoRotate
	Begin Label
		Label = WhenExists($UserData.printAutoRorate)
	End
End

Begin Component PrepreToPrintShrink
	Begin Label
		Label = WhenExists($UserData.printShrink)
	End
End


Begin Component CloseReport

			Begin Counter rid2Type
				when ( ExistsAndNotEmpty($info.approvalname) )
				{
					value = 44
				}
				else
				{
					when ( ExistsAndNotEmpty($info.indexedescription) )
					{
						value = 34
					}
					else
					{
						when ( ExistsAndNotEmpty($info.rulerid) )
						{
							value = 75
						}
						else
						{
							value = 0
						}
					}
				}
			End
			Begin StrVariable rid2
				when ( ExistsAndNotEmpty($info.approvalname) )
				{
					value = $info.approvalname
				}
				else
				{
					when ( ExistsAndNotEmpty($info.indexedescription) )
					{
						value = substring($info.indexedescription,1)
					}
					else
					{
						when ( ExistsAndNotEmpty($info.rulerid) )
						{
							value = $info.rulerid
						}					
						else
						{
							value = string()
						}
					}
				}
				End 



		Begin url
			Begin Request
				RequestType	= CloseReport				{ const }
				SID	= WhenExists($STD.csid, $params.sid)					{ const }
				FID	= $Params.FID					{ const }
				RID	= $Params.RID					{ const }
				RID2Type	= Counter.rid2Type()
				RID2	= StrVariable.rid2()
			End
		End
End

//Begin component TestA
//		Begin LogEvent
//			loglevel = error
//			logmessage = "astatus " + WhenExists($UserData.astatus)
//			logcontext = "Login of a user via Web Access"
//	    End	
//End
