Begin Component Index.SID
	Begin Label
		Label = WhenExists($STD.csid, $params.sid)
	End
End

Begin Component Index.FID
	Begin Label
		Label = $Params.FID
	End
End

Begin Component Index.RID
	Begin Label
		Label = WhenExists($Params.RID,  WhenExists($UserData.RID))
	End
End

if(exists($UserData.Language))
{
	Begin Component Index.Language
		Begin Label
			Label = $UserData.Language
		End
	End
}

if(exists($UserData.OrgEncoding))
{
	Begin Component Index.Encoding
		Begin Label
			Label = $UserData.OrgEncoding
		End
	End
}

Begin Component Index.Mode
	Begin Counter IsSQLMode
		when(ExistsAndEqual($Info.IsSupported.RepSqlIndex, true))
		{
			value = 1
		}
		else
		{
			value = 0
		}
		
	End
	
	Begin Label
		when( eq(Counter.IsSQLMode(),1))
		{
			Label = SQL
		}
		else
		{
			Label = TREE
		}
	End
End

Template(IncIndexLevel)
{
	Begin Counter IndexLevel
		inc = 1
	End
}



Template(DecIndexLevel)
{
	Begin Counter IndexLevel
		dec = 1
	End
}


Template (IndexNode)
{
				
		Begin StrVariable FixIndexName
			value = Replace(Replace(Replace(RTrim([IndexParam].name), "\", "\\"), "'", "\\'"), DoubleQuote(), "\" + DoubleQuote())
		End

		//add the index to its parent
		//set it as parent
		Begin Label
			Label = "AddSubIndexToParent('" + StrVariable.FixIndexName()  + "');"
			EscapeType = NONE
		End
		
		
		//iteration on its childs
		Foreach(index in [IndexParam].indexes)
		{
			DoTemplate(IndexNode on  [index] as IndexParam)
		}
		
		Begin Label
			Label = "ResetParent();"
			EscapeType = NONE
		End
		
		//set it as parent
		DoTemplate(DecIndexLevel) 
		
}

Begin Component Index.IndexValuesRequestQS

if(exists($Params.RID) || exists( $UserData.RID))
{
	Begin QueryString
		Begin Request
			RequestType = IndexValues  {const}
			SID = WhenExists($STD.csid, $params.sid)  {const}
			FID = $Params.FID {const}
			RID = WhenExists($Params.RID, $UserData.RID) {const}
			lang = $Params.Lang
			mask = (*) Action("szMask")
			indexpath = (*) Action("szIndexPath")
			valueid = (*) Action("szValueID")
			value = (*) Action("szValue")
			direction = (*) Action("szDirection")
		End
	End
}
End

Begin Component Index.IndexNameRequestQS
if(exists($Params.RID) || exists( $UserData.RID))
{
	Begin QueryString
		Begin Request
			RequestType = Index {const}
			SID = WhenExists($STD.csid, $params.sid) {const}
			FID =  $Params.FID {const}
			RID = WhenExists($Params.RID, $UserData.RID) {const}
			mode=INFO
			ElemTemplate = "indexnamerequest.txt"		{ const }
			StrTemplate     = "indexvaluerequest.htm"		{ const }
		End
	End
}
End

Begin Component IndexPath
	Begin Label
		label = WhenExists($UserData.IndexPath)
		EscapeType = JS
	End
End

Begin Component Index.JAVASCRIPT
	Begin Label
		when(ExistsAndEqual($Info.IsSupported.RepSqlIndex, true))
		{
			label = "<script src='{!WA Common.HtmlsDir}/js_index_dsr.js'></script>"
		}
		else
		{
			label = "<script src='{!WA Common.HtmlsDir}/js_index_mfr.js'></script>"
		}		
		EscapeType = NONE
	End
End		
