if(eq(%User.Applicationfeatures.AddTextFooter.ischecked, 1) && ! ( (ExistsAndEqual($UserData.LoginFrame, 1)) || (ExistsAndEqual($Std.LoginFrame, 1)) ))
{
	Begin Component
		Type = RequestFlow

		Begin Request
			RequestType = Base
			ElemTemplate = "loginframesetfooter.txt"
			StrTemplate = "loginframesetfooter.htm"
			u = $params.u
			Lang = $Params.Lang
		End
	End
}
else
{
	if(eq(%User.Applicationfeatures.HideWebAccessURL.ischecked, 1) && !ExistsAndEqual($UserData.LoginFrame, 1))
	{
		Begin Component
			Type = RequestFlow
	
			Begin Request
				RequestType = Base
				ElemTemplate = "loginframeset.txt"
				StrTemplate = "loginframeset.htm"
				u = $params.u
				Lang = $Params.Lang
			End
		End
	}
	else
	{
			if(eq(%User.Applicationfeatures.ApplyAutomaticLogin.IsChecked, 1) && NotEmpty(Env("REMOTE_USER"))
					&& !ExistsAndEqual($UserData.SelectDomain, 1) && (!ExistsAndEqual($UserData.classiclogin, 1)))
			{
				Begin Component LoginFlow
					Type = RequestFlow
		
					if(Empty(%User.Applicationfeatures.RepositoryName4AutomaticLogin.Value))
					{
						If(NotExists($Domains."1")) // only one repository defined
						{
							Begin StrVariable AutoLoginRepositoryId
								value = $Domains."0".ID
							End
		
							Begin Counter AutoLoginRepositoryType
								value = $Domains."0".Type
							End
						}
						else
						{
							Begin StrVariable AutoLoginRepositoryId
								value = GetRequestActualParameter("Domain")
							End
		
							if(NotEmpty(StrVariable.AutoLoginRepositoryId()))
							{
								Begin Counter AutoLoginRepositoryType
									value = 0
								End
		
								ForEach(domain in $Domains)
								{
									if(eq([domain].Name, StrVariable.AutoLoginRepositoryId())
									|| eq([domain].ID,   StrVariable.AutoLoginRepositoryId()))
									{
										Begin StrVariable AutoLoginRepositoryId
											value = [domain].ID
										End
		
										Begin Counter AutoLoginRepositoryType
											value = [domain].Type
										End
									}
								}
		
								if(eq(Counter.AutoLoginRepositoryType(), 0))// passed repository not found, so we clear repository ID
								{
									Begin StrVariable AutoLoginRepositoryId
										value = string()
									End
								}
							}
						}
					}
					else
					{
						// Try to find the repository ID. If it is not found, we leave StrVariable.AutoLoginRepositoryId()
						// and the user will have to select a repository.
						ForEach(domain in $Domains)
						{
							if(eq([domain].Name, %User.Applicationfeatures.RepositoryName4AutomaticLogin.Value)
							|| eq([domain].ID,   %User.Applicationfeatures.RepositoryName4AutomaticLogin.Value))
							{
								Begin StrVariable AutoLoginRepositoryId
									value = [domain].ID
								End
		
								Begin Counter AutoLoginRepositoryType
									value = [domain].Type
								End
							}
						}
					}
					Begin StrVariable NetworkUserId
						when ( (eq(%User.Applicationfeatures.loginConvertNetworkUserToMFUser.ischecked, 1))
										&& ((eq(%User.Applicationfeatures.loginConvertNetworkUserToMFUserRemoveDomain.ischecked, 1)))  
										&&(!eq(Find(Env("REMOTE_USER"), "\"),NotFound())) )
						{
							value = SubString(Env("REMOTE_USER"), Plus(Find(Env("REMOTE_USER"), "\"), 1))
						}
						else
						{
							value = Env("REMOTE_USER")
						}
					End

					if(eq(%User.Applicationfeatures.loginConvertNetworkUserToMFUser.ischecked, 1))
					{
						Begin StrVariable MFUserId
							value = GetIniFileSetting("../config/users.ini", "Network2MFUsers", StrVariable.NetworkUserId(), StrVariable.NetworkUserId())
						End
					}
					else
					{
						Begin StrVariable MFUserId
							value = StrVariable.NetworkUserId()
						End
					}

					Begin Request
						Lang = $Params.Lang
		
						when(Empty(StrVariable.AutoLoginRepositoryId()))
						{
							when(Empty(%User.Applicationfeatures.RepositoryName4AutomaticLogin.Value))
							{
								RequestType = $Params.RequestType
								u = $params.u + "&SelectDomain=1"
							}
							else
							{
								RequestType = Error
								ErrorString = Replace("{!WA Errors.BMCWAS2693E}", "%1", %User.Applicationfeatures.RepositoryName4AutomaticLogin.Value)
							}
						}
						else
						{
							RequestType = LoginRequest
							NoBrowserCache = 1
							User = StrVariable.MFUserId()		
		
							Domain = StrVariable.AutoLoginRepositoryId()
							CheckPassword = false
							when( !ExistsAndEqual($UserData.StartFilter, "0") && ExistsAndEqual(%User.Applicationfeatures.LoginFilterSelectFeature.value, 1))
		    			{
		        			u = $params.u + "&StartFilter=1"
		    			} 
		    			else
		    			{
		        		u = $params.u
		    			}
		
						}
					End
				End
			}
			else
			{
				Template(HiddenClass)
				{
					Begin Label
						Label = "class=Hidden"
						EscapeType = None
					End
				}
		
				Begin Component UserName
					Begin Label
						when(exists($UserData.User))
						{
							Label = "'" + EscapeJS($UserData.User) + "'"
						}
						else
						{
							Label = "GetCookie('UserName')"
						}
		
						EscapeType = None
					End
				End
		
				if((ExistsAndEqual($UserData.ShowUserName, 0) && ExistsAndNotEmpty($UserData.User))
					|| ExistsAndEqual($UserData.SelectDomain, 1))
				{
					Begin Component UserNameFieldStyle
						DoTemplate(HiddenClass)
					End
				}
		
				if(ExistsAndEqual($UserData.SelectDomain, 1))
				{
					Begin Component PasswordFieldStyle
						DoTemplate(HiddenClass)
					End
		
					Begin Component SelectDomainModeIfNeeded
						Begin Label
							label = "bSelectDomainMode = true;"
									+ "f.u.value = f.u.value.replace(/SelectDomain\=1/, '');"
									+ "f.RequestType.value = 'LoginWindow';"
									+ "var o = findObject('toggleLink'); if(o) o.className = 'Hidden';"
							EscapeType = None
						End
					End
				}
		
				Template(SelectedDomain)
				{
					Begin Component SelectedDomain
						Begin Label
							label = "selectDomain('" + EscapeJS([domain]) + "');"
							EscapeType = None
						End
					End
				}
		
				Begin Component	Repositories
					ForEach(domain in $Domains)
					{
						Begin Label
							label = "AR('" + EscapeJS([domain].ID) + "','" + EscapeJS([domain].Name) + "');" + NewLine()
							EscapeType = None
						End
					}
				End
		
				if(ExistsAndNotEmpty($std.host))
				{
					Begin Component DomainFieldStyle
						DoTemplate(HiddenClass)
					End
		
					DoTemplate(SelectedDomain on $std.host as domain)
				}
				else
				{
					if(exists($UserData.domain))
					{
						Begin Component DomainFieldStyle
							DoTemplate(HiddenClass)
						End
		
						DoTemplate(SelectedDomain on $UserData.domain as domain)
					}
					else
					{
						// if admin selects to hide the host selection, then the default will be
						// selected, but the field will be hidden
						if(eq(%User.Applicationfeatures.LoginHostSelection.ischecked, 0))
						{
							Begin Component DomainFieldStyle
								DoTemplate(HiddenClass)
							End
						}
		
						if(exists($UserData.SelDomain))
						{
							DoTemplate(SelectedDomain on $UserData.SelDomain as domain)
						}
						else
						{
							Begin Component SelectedDomain
								Begin Label
									label = "selectDomain(GetCookie('HostName') || '" + EscapeJS($DefaultDomainID) + "');"
									EscapeType = None
								End
							End
						}
					}
				}
		
				if(ExistsAndEqual($std.ShowFilter, "0") || ExistsAndEqual($UserData.ShowFilter, "0")||ExistsAndEqual(%User.Applicationfeatures.LoginFilterFeature.ischecked,0))
				{
					Begin Component FilterFieldStyle
						DoTemplate(HiddenClass)
					End
				}
		
				if(ExistsAndEqual($UserData.StartFilter, "0"))
				{
						Begin Component StartFilter
							Begin Label
								label = "f.StartFilter.checked = false;"
								EscapeType = None
							End
						End
				}
					
				else
				{
					if(ExistsAndEqual($UserData.StartFilter, "1") || ExistsAndEqual(%User.Applicationfeatures.LoginFilterSelectFeature.value, 1))
					{
						Begin Component StartFilter
							Begin Label
								label = "f.StartFilter.checked = true;"
								EscapeType = None
							End
						End
					}
				}
		
				if(ExistsAndEqual($UserData.ChPswd, 1))
				{
					Begin Component ToggleChangePasswordIfNeeded
						Begin Label
							label = "toggleChangePassword();" + NewLine()
							EscapeType = None
						End
					End
				}
		
				Begin Component uAddValue
					Begin VariableAttribute u
						StartFilter = (*) ControlName(StartFilter)
					End
				End
		
				Begin Component HiddenFields
					Begin RequestData StdRequest
						Begin Request
							RequestType = Base
						End
					End
		
					Begin Hidden
						Name = std
						Value = [StdRequest].params.std
					End
		
					Begin Hidden
						Name = u
						Value = $params.u
					End
		
					Begin Hidden
						name = lang
						value = $Params.lang
					End
				End
		
				Begin Component SubmitUrl
					Begin Url
						URL = $Params.Directory
					End
				End
		
				Begin Component Version
					Begin Label
						label = {!WA Lang.ConcatFunction}("{!WA Common.Version}", " ", $Params.Version)
					End
				End
		
				///////////////////////////////////
				// Language Selection componenets
				///////////////////////////////////
				Begin Component RequestLang
					Begin Label
						Label = $Params.lang
					End
				End
		
				if(eq(%User.Applicationfeatures.ChangePassword.ischecked, 1))
				{
					Begin Component ToggleChangePasswordLink
						Begin Label
							label = "<a href='-{!WA LoginWindow.ChPaswd}' onclick='toggleChangePassword();return false;' class=text id=toggleLink>{!WA LoginWindow.ChPaswd}</a>"
							EscapeType = None
						End
					End
				}
		
				Begin Component SupportedLanguages
					ForEach(language in %User.Languages)
					{
						Begin Label
							label = " " + [language]
						End
					}
				End
		
				if(eq(%User.Applicationfeatures.ChangeUILanguage.ischecked, 1))
				{
					Begin Component ChangeLanguageLink
						Begin Label
							label = "<a href='-{!WA LangSelection.ChangeLanguage}' onclick='toggleLangMenu();return false;' class=Text id=changeLangLink>{!WA LangSelection.ChangeLanguage}</a>"
							EscapeType = None
						End
					End
		
					Begin Component ChangeLanguage
						Begin Event.OnClick
							Begin Request
								RequestType = $Params.RequestType
								StrTemplate	= $Params.StrTemplate
								ElemTemplate= $Params.ElemTemplate
								Lang = (*) Action("szLanguage")
								u = (*) Action("szCurrentU")
							End
						End
					End
		
					Begin Component DefaultLang
						Begin Label
							Label = %User.generalsettings.language
							EscapeType = JS
						End
					End
		
					Begin Component CurrentLang
						Begin Label
							when(empty($Params.lang))
							{
								label = %User.generalsettings.language
							}
							else
							{
								label = $Params.lang
							}
		
							EscapeType = JS
						End
					End
		
					Begin Component LanguagesList
						ForEach(language in %User.Languages)
						{
							if(eq(VarValue(%User.Applicationfeatures, "SupportUIIn" + [language], ischecked), 1))
							{
								Begin Label
									Label = "AL('" + [language] + "','" + [language].display + "');"
									EscapeType = None
								End
							}
						}
					End
				}
		
				#include "login_background.txt"
			}
		}
}

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

Begin Component ConvertNetwork2MFUser
	Begin Label
		Label = %User.Applicationfeatures.loginConvertNetworkUserToMFUser.ischecked
	End
End


Begin Component RepositoryName4AutomaticLogin
	Begin Label
		label = %User.Applicationfeatures.RepositoryName4AutomaticLogin.Value
	End
End

if (!ExistsAndEqual($UserData.classiclogin, 1)){
	Begin Component ApplyAutomaticLogin
		Begin Label
			Label = %User.Applicationfeatures.ApplyAutomaticLogin.IsChecked
		End
	End
}

Begin Component singlesignonwithoauth2
	Begin Label
		Label = %User.Applicationfeatures.singlesignonwithoauth2.ischecked
	End
End


Begin Component OAuth2AutheticationUri
	Begin Label
		Label = %User.Applicationfeatures.oauth2autheticationuri.value
	End
End

Begin Component OAuth2ClientId
	Begin Label
		Label = %User.Applicationfeatures.oauth2clientid.value
	End
End

Begin Component OAuth2CallBackUri
	Begin Label
		Label = %User.Applicationfeatures.oauth2callbackuri.value
	End
End

Begin Component OAuth2Scope
	Begin Label
		Label = %User.Applicationfeatures.oauth2scope.value
	End
End



Begin Component VerifyUserToken
	Begin Label
		Label =  %User.Applicationfeatures.verifyusertoken.ischecked
	End
End

Begin Component LoginProhibitClassicUi
	Begin Label
		Label =  %User.Applicationfeatures.LoginProhibitClassicUi.ischecked
	End
End
