Function g_BlurModal
    Me.setActive
    Me.focus    
End Function

Class SDIClass
    
    Public QueryString
    Public PageTexts
    Public SiteSettings
    Public ServerVariables
    
    Public PageLanguage
    Public Charset
    Public User
    Public SessionTimeout
    Public ImageBase
    
    Public Languages
    
    Public Profile

	Private OpenedWindowsCount
	
	Private Sub Class_Initialize()
		OpenedWindowsCount = 0
		
		Set QueryString = New CollectionSEClass
		Set PageTexts = New CollectionSEClass
		Set SiteSettings = New CollectionSEClass
		Set ServerVariables = New CollectionSEClass
		
		ImageBase = "/admin/backoffice/images/"
		
		on error resume next
		Set Profile = New CollectionSEClass
		
		if GetCookie("profile") <> "" Then
		    
		    Profile.SplitEx GetCookie("profile"), "@","#"
    		
		    sets = Profile("settings")
		    Profile.Set "settings", New CollectionSEClass
		    Profile("settings").SplitEx sets, "-","_"
    		
		    Set settings = Profile("settings")
		    For i=1 to settings.Count
		        sets = settings(i)
		        settings.Set settings.key(i), New CollectionSEClass
		        settings(i).SplitEx sets, "<", ">"
		    Next
		Else
		    Profile.Add "skin", ""
		    Profile.Add "language", "ru"
		    Profile.Add "skinpath", "/admin/"
		    
		    Profile.Add "settings", New CollectionSEClass
        End if		
		on error goto 0
		
		Set Languages = New CollectionSEClass
	End Sub
	
	Private Sub Class_Terminate()
		' // .........
	End Sub
	
    Sub GetLanguagesSet()
        Dim HTTP, i
        Set HTTP = New HTTPExClass
        HTTP.Init PROCESSORURL
        'HTTP.WaitForObject = False
        HTTP.Clear
        HTTP.CallProcessor("requestlanguages")
        For i=1 to HTTP.ProcessorResponse.Count
            Set col = New CollectionSEClass
            col.SplitEx HTTP.ProcessorResponse(i), "#", "@"
            Languages.Add col("Id"), col
        Next
    End Sub
	
	Function CreateNameFromLink(link)
	    CreateNameFromLink = ReplaceEx(link, Array("/","\",".",",","?","&","=",":",".",";","}","{","-"), "_")
	End Function
	
	Function [Open](link, width, height)
		ssleft = Window.screenLeft + Window.Document.Body.offsetWidth + 20
		sstop = Window.screenTop - 21 + OpenedWindowsCount*21
		sname = CreateNameFromLink(link)
		OpenedWindowsCount = OpenedWindowsCount + 1
		Set [Open] = Window.Open(link,"wnd_" & sname,"status=no,help=no,resizable=1,scrollbars=1,top=" & sstop & ",left=" & ssleft & ", width=" & width & ",height=" & height)
	End Function

	Function Dialog(link, width, height)
		sname = CreateNameFromLink(link)
		OpenedWindowsCount = OpenedWindowsCount + 1
		Set Dialog = Window.Open (link, "dlg_" & sname, "status=yes,help=no,resizable=no,scrollbars=no,width=" & width & ",height=" & height) 'top=" & sstop & ",left=" & ssleft & ",
	End Function

	Function RDialog(link, width, height)
		sname = CreateNameFromLink(link)
		OpenedWindowsCount = OpenedWindowsCount + 1
		Set RDialog = Window.Open (link, "dlg_" & sname, "status=yes,help=no,resizable=yes,scrollbars=no,width=" & width & ",height=" & height) 'top=" & sstop & ",left=" & ssleft & ",
	End Function

	Function Modal(link, Params, Width, Height)	
		Modal = Window.ShowModalDialog(link, Params, "status:no; help:no; scroll:no; dialogWidth:" & Width & "px; dialogHeight:" & Height & "px;")
	End Function	

	Function RModal(link, Params, Width, Height)	
		RModal = Window.ShowModalDialog(link, Params, "status:no; help:no; scroll:no; resizable:yes; dialogWidth:" & Width & "px; dialogHeight:" & Height & "px;")
	End Function	

	Function RModeless(link, Params, Width, Height)	
		RModeless = Window.ShowModelessDialog(link, Params, "status:no; help:no; scroll:no; resizable:yes; dialogWidth:" & Width & "px; dialogHeight:" & Height & "px;")
	End Function	

    Function IsDialog()
	    on error resume next
	    d = Window.returnValue
	    errnum = err.number
	    on error goto 0
	    IsDialog = CBool(errnum = 0)
    
    End Function
    
    Function InitializeQuery()
        Dim sloc
        sloc = Window.Location.Search
        QueryString.SplitEx Mid(sloc, 2), "=", "&"
    End Function
	
End Class