if(eq($Info.IsExternalReport, 1)
	&& eq(VarValueWhenExists(%user.extentions, $Info.ReportExtention, ConstName{openwithoutwamenu}), true))
{
	Begin Component
	Type = RequestFlow

Begin StrVariable Mode
			When( eq(SubString($Info.ReportExtention, 0, 3), xls) || eq(SubString($Info.ReportExtention, 0, 3), xml))
			{
				value = ANONYMOUS_EXTERNAL
			}
			else
			{
				value = EXTERNAL
			}
End

		Begin Request
			RequestType	= Report
			ElemTemplate = "reportareaexternal.txt"
			StrTemplate = "reportareaexternal.htm"
			Mode		= StrVariable.Mode()
			SID 		= $params.sid
			FID			= $Params.FID
			Lang		= $Params.Lang
			RID			= $Params.RID
			Index		= $Params.Index
			RulerId		= $Info.RulerId
			ConvertorId	= $Params.ConvertorId
			OutputMode	= $Params.OutputMode
			Audit		= true
			AuditEventType = Open

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

		Begin Request
			RequestType = Report
			ElemTemplate = StrVariable.ElemTemplate()
			StrTemplate  = StrVariable.StrTemplate()

			SID		= WhenExists($STD.csid, $params.sid)
			FID		= $Params.FID
			Lang	= $Params.Lang
			RID		= $Params.RID
			Mode	= StrVariable.Mode()
			CacheKey   = $Info.CacheKey
			Index		= $Params.Index
			RulerId		= $Info.RulerId
			ConvertorId	= $Params.ConvertorId
			RulerCommand= $Params.RulerCommand
			LastTopPage  	= $Params.LastTopPage
			LastBottomPage  = $Params.LastBottomPage
			Direction 		= $Params.Direction
			ReportListContext = $Params.ReportListContext
			FindString 		= $Params.FindString
			FindCase		= $Params.FindCase
			FindWholeWord	= $Params.FindWholeWord
			MatchedFind		= $Params.MatchedFind
			OutputMode		= $Params.OutputMode

			//--------------------------------------------------------------------
			// To Support External files (non HTML) we need to decorate
			// the URL with "ZReportFileName".
			//
			// To support all wierd plugins Active-X and external programs
			// We must put the FileName in 3 places.
			//
			// 1. In the Mime-Tipe of the response
			//    (happend automaticaly, should be suficient but is not)
			//
			// 2. at the end of the Query string
			//	ZReportFileName	  = $Params.ZReportFileName
			//	PDF Reader needs it in Internet Explorer
			//
			// 3. At the end of the URL Path
			//  	Path = # Program.Name + "/" + $Params.ZReportFileName
			//	AFP Viewer needs in in Internet Explorer
			//-----------------------------------------------------------------------
			when(eq(Counter.OpenBinaryReport(), 1))
			{
				ZReportFileName	= $Info.ReportFileName
			}

			when(eq(Counter.OpenTextReportBody(), 1) || eq(Counter.OpenBinaryReport(), 1))
			{
				ReportCacheKey  = $Info.ReportCacheKey
				NoBrowserCache	= %User.Applicationfeatures.ReportInBrowserCacheFeature.value
			}

			when(eq(Counter.OpenTextReportBody(), 1))
			{
				Target = $Info.TargetInPage
			}

			when(notempty(StrVariable.PagePart()))
			{
				PagePart = StrVariable.PagePart()
			}

		when(eq(Counter.OpenTextReportBody(), 1) && noteq(StrVariable.PagePart(), "ALL"))
		{
			Target = $Info.TargetInPage
		}


			u = StrVariable.u()
		End
	End
}

Begin Component EmptyFind
	Begin Counter EmptyFind
		when ((eq($Info.IsExternalReport, 0) || eq($Info.IsDHTMLReport, 1)) &&
		      eq($Position.TopPage, 0)
		      && eq($Position.BottomPage, "-1") &&	(notempty($Params.FindString) || notempty($Params.IconsForSearch)))
		{
			value = 1
		}
		else
		{
			value = 0
		}
	End
End

//------------------------------------------------
// Definition of The Report Title component
//------------------------------------------------
Begin Component ScreenParts.ContentTitle
	if(eq($Info.IsExternalReport, 1) || eq (Counter.EmptyFind(), 1)||eq($Info.IsDHTMLReport, 1))
	{
		Begin StrVariable ElemTemplate
			value = "reportcommonarea.txt"
		End
		Begin StrVariable StrTemplate
			value = "reportcommonarea.htm"
		End
		Begin StrVariable Mode
			value = INFO
		End
		Begin Counter OpenTextReportBody
			value = 0
		End
		Begin Counter OpenBinaryReport
			value = 0
		End

		DoTemplate(ReportRequestUrl)
	}
	else
	{
		Begin label
			Label = "''"
		End
	}
End
//----------------------------------------------------
// Definition of The Content Area of Report component
//----------------------------------------------------
Begin Component ScreenParts.ContentArea
	Begin Counter OpenReportBody
		value = 1
	End

	if(eq($Info.IsExternalReport, 1))
	{
		Begin StrVariable ElemTemplate
			value = "reportareaexternal.txt"
		End
		Begin StrVariable StrTemplate
			value = "reportareaexternal.htm"
		End
		Begin Counter OpenBinaryReport
			value = 1
		End
	}
	else
	{
		Begin Counter OpenTextReportBody
			value = 1
		End

		if (eq (Counter.EmptyFind(), 1))
		{
			Begin StrVariable ElemTemplate
				value = "reportfindempty.txt"
			End
			Begin StrVariable StrTemplate
				value = "reportfindempty.htm"
			End
		}
		else
		{
			Begin StrVariable ElemTemplate
				value = "reportcommonarea.txt"
			End
			Begin StrVariable StrTemplate
				value = "reportcommonarea.htm"
			End

			Begin StrVariable Mode
				when((exists($UserData.RVM) && noteq($UserData.RVM,0)) || eq(%User.ApplicationFeatures.NotesModeByDefault.value, 1))
				{
					value = NOTE
				}
				else
				{
					value = TEXT
				}
			End

			if (noteq(StrVariable.Mode(), NOTE) && 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 StrVariable PagePart
					value = ALL
				End
			}

			if(eq($Info.IsDHTMLReport, 1))
			{
				Begin StrVariable u
					value = $Params.u + "&ShowTitle=0"
				End
			}
			else
			{
				Begin StrVariable u
						value = $Params.u
				End
			}
			
		}
	}

	DoTemplate(ReportRequestUrl)
End

//----------------------------------------------------
// Definition of The Sub title of Report component
//----------------------------------------------------
Begin Component ScreenParts.SubTitle
	Begin label
		Label = "{!WA Report.Title} - " +
					replace(replace(%User.ApplicationFeatures.ReportListLoginInfo{!WA Lang.DesktopName}.value
						, "%%user", GetUser())
						, "%%host", GetHost())
	End
End

//----------------------------------------------------
// Definition of The Dummy Folder Path component
//----------------------------------------------------
Begin Component ScreenParts.FolderPath
	Begin label
		Label = "''"
	End
End

Begin Component ScreenParts.FolderTree
	Begin label
		Label = "''"
	End
End

Begin Component GetFocusIfNeeded
	if(exists($UserData.GF) && eq($UserData.GF, 1))
	{
		Begin Label
			label = "top.focus();"
		End
	}
End

if(eq(SubString($Info.ReportExtention, 0, 3), htm) || eq($Info.IsDHTMLReport, 1))
{
	Begin Component TitleHeight
		Begin Label
			Label = "130"
		End
	End

	Begin Component HTMLReportVariables
		Begin Label
			label = "var wa_szHTMLHeaderText = '"
			EscapeType = None
		End

		Begin Label
			label = {!WA Lang.ConcatFunction}("{!WA ReportPage.Page}", "(#page)")
			EscapeType = JS
		End

		Begin Label
			label = "';var wa_szHTMLHeaderStyle = '"
			EscapeType = None
		End

		if({!WA lang.IsRTL})
		{
			Begin Label
				label = "text-align:right"
				EscapeType = None
			End
		}

		Begin Label
			label = "';var wa_HTMLFirstPage = "
			EscapeType = None
		End

		Begin Label
			when(eq($Position.TopPage, 0))
			{
				label = "1"
			}
			else
			{
				label = String($Position.TopPage)
			}
			EscapeType = None
		End

		Begin Label
			label = ";var wa_HTMLScale = " + WhenExists($STD.s, "GetScaleFromCookies()") + ";"
			EscapeType = None
		End

		//Find support
		Begin Label
			label = "var wa_szHTMLFindString = '" + WhenExists($Params.FindString) + "';"
			EscapeType = None
		End

		Begin Label
			when(ExistsAndEqual($Params.FindCase, 1))
			{
				label = "var wa_bHTMLFindCase = true;"
			}
			else
			{
				label = "var wa_bHTMLFindCase = false;"
			}
			EscapeType = None
		End

		Begin Label
			when(ExistsAndEqual($Params.FindWholeWord, 1))
			{
				label = "var wa_bHTMLFindWholeWord = true;"
			}
			else
			{
				label = "var wa_bHTMLFindWholeWord = false;"
			}
			EscapeType = None
		End
	End
}

Begin Component ForceIndex
	if(eq($Info.HasIndexes, 1) && empty($Params.Index)
		&& eq(VarValueWhenExists(%user.extentions, $Info.ReportRealExtention, ConstName{forceindex}), true))
	{
		Begin Label
			label = "bForceIndex = true;"
			EscapeType = NONE
		End
	}
End
}

// We need to remove scrolls in case we manually use the Acrobat Reader Activex
if(eq($Info.ReportExtention, pdf))
{
	Begin Component ScreenParts.ScrollMainFrame
		Begin label
			Label = no
		End
	End
}
