﻿Class DataClass
	Public	Objects

	Private Sub Class_Initialize()
		Set Objects = CreateObject("Scripting.Dictionary")
	End Sub

	Public Sub Initialize()
		Set Objects.Item("urlreplacements") = CreateObject("Scripting.Dictionary")
		Set Objects.Item("session") = New SessionClass
		Set Objects.Item("debug") = New DebugClass
		'Load default language xml in dictionary
		Set Objects.Item("language") = CreateObject("Scripting.Dictionary")
		Set Objects.Item("language_nl") = CreateObject("Scripting.Dictionary")
		Set Objects.Item("language_de") = CreateObject("Scripting.Dictionary")

		Set nl = Objects.Item("language_nl")
			nl.Item("CurPos") = "Huidige positie"
			nl.Item("Status") = "Status"
			nl.Item("NoStops") = "Geen stops bekend"
			nl.Item("Stops") = "Stops"
		Set de = Objects.Item("language_de")
			de.Item("CurPos") = "Gegenwärtige Position"
			de.Item("Status") = "Status"
			de.Item("NoStops") = "Kein Stopps bekannt"
			de.Item("Stops") = "Stopps"

				'Data.Objects.Item("Language").Item("Click&Find")="Klik&Vind"
				'Data.Objects.Item("Language").Item("The Netherlands")="Nederland"
				'Data.Objects.Item("Language").Item("Andalusia")="Andalusie"
				'Data.Objects.Item("Language").Item("Belgium")="Belgi&#235;"
				'Data.Objects.Item("Language").Item("Spain")="Spanje"
		
		Set Data.Objects.Item("statecolors") = CreateObject("Scripting.Dictionary")
			Data.Objects.Item("statecolors").Item("D") = "#ccccff" 'Purple
			Data.Objects.Item("statecolors").Item("E") = "#ccffcc" 'Green
			Data.Objects.Item("statecolors").Item("F") = "#cccccc" 'Gray
			Data.Objects.Item("statecolors").Item("S") = "#ffcccc" 'Red
			Data.Objects.Item("statecolors").Item("T") = "#ffcccc" 'Red
			Data.Objects.Item("statecolors").Item("U") = "#ffcccc" 'Red

		Set Data.Objects.Item("statedescriptions") = CreateObject("Scripting.Dictionary")
			Data.Objects.Item("statedescriptions").Item("D") = "First update while driving. (D)"
			Data.Objects.Item("statedescriptions").Item("E") = "Update while driving. (E)" 
			Data.Objects.Item("statedescriptions").Item("F") = "First update stopped. (F)"
			Data.Objects.Item("statedescriptions").Item("S") = "Update while stopped. (S)"
			Data.Objects.Item("statedescriptions").Item("T") = "Update while stopped. (T)"
			Data.Objects.Item("statedescriptions").Item("U") = "Last update stopped. (U)"
	End Sub

	Public Sub RunScript(Sc)
		execute(replace(Sc,"~",chr(34)))
	End Sub

End Class

Class InitialDataClass
	Public CountryList(), VehicleType, TrailerType, CountryType
	Public LandmarkType, MaterialType, MaterialSubType
	Public StopType,SpaceType	

	Private Sub Class_Initialize()
		Set CountryType = CreateObject("Scripting.Dictionary")	
		Call GetCountries()
		Set VehicleType = CreateObject("Scripting.Dictionary")	
		Call GetVehicleTypes()
		Set TrailerType = CreateObject("Scripting.Dictionary")	
		Call GetTrailerTypes()
		Set LandmarkType = CreateObject("Scripting.Dictionary")	
		Call GetLandmarkTypes()
		Set MaterialType = CreateObject("Scripting.Dictionary")	
		Call MaterialTypes()
		'window.status="Hallo Stef getal=0"
		Set MaterialSubType = CreateObject("Scripting.Dictionary")	
		'window.status="Hallo Stef getal=1"
		Call MaterialSubTypes()
		'window.status="Hallo Stef getal=2"
		Set StopType = CreateObject("Scripting.Dictionary")	
		Call GetStopTypes()
		'window.status="Hallo Stef getal=3"
		Set SpaceType = CreateObject("Scripting.Dictionary")	
		Call GetSpaceTypes()
		'window.status="Hallo Stef getal=4"
	End Sub	

	Private Sub GetCountries()
		'On Error Resume Next
		set XMLDoc = Tools.GetXml(Data.Objects("session").URL_Database & "tbCountry?")
		Set nodes = XMLDoc.selectNodes("//T")
		if nodes.Length > 0 then
			Redim CountryList(nodes.Length-1)
			count = 0
			for each node in nodes
				set CountryList(count) = new TypeDetail
					for each attr in node.attributes
						select case lcase(attr.Name)
							case "id":	CountryList(count).ID = attr.value
							case "d":	CountryList(count).Description = attr.value
							case "g":	CountryList(count).GifFileName = attr.value
						end select
					next
					Set CountryType(CountryList(Count).ID) = CountryList(Count)
					count = count + 1
			next
		End If
		Data.Objects.Item("countrylist") = CountryList
		Set Data.Objects.Item("countrytype") = CountryType
	End Sub

	Private Sub GetVehicleTypes()
		on error resume next
		set XMLDoc = Tools.GetXml(Data.Objects("session").URL_Database & "tbVehicleType?")
		Set nodes = XMLDoc.selectNodes("//T")
		if nodes.Length > 0 then
			for each node in nodes
				set V = new TypeDetail
					V.Border = Empty
					for each attr in node.attributes
						select case lcase(attr.Name)
							case "id":	V.ID = clng(attr.value)
							case "d":	V.Description = attr.value
							case "g":	V.GifFileName = "\vehicletypes\" & attr.value
							case "b":	V.Border = cLng(attr.value)
						end select
					next
					Set VehicleType.Item(V.ID) = V
			next
		End If
		Set Data.Objects.Item("vehicletype") = VehicleType
	End Sub

	Private Sub GetTrailerTypes()
		set XMLDoc = Tools.GetXml(Data.Objects("session").URL_Database & "tbTrailerType?")
		Set nodes = XMLDoc.selectNodes("//T")
		if nodes.Length > 0 then
			for each node in nodes
				set V = new TypeDetail
					V.Border = "none"
					for each attr in node.attributes
						select case lcase(attr.Name)
							case "id":	V.ID = clng(attr.value)
							case "d":	V.Description = attr.value
							case "g":	V.GifFileName = "\trailertypes\" &attr.value
							case "b":	V.Border = attr.value
						end select
					next
					Set TrailerType.Item(V.ID) = V
			next
		End If
		Set Data.Objects.Item("trailertype") = TrailerType
	End Sub

	Private Sub GetLandmarkTypes()
		set XMLDoc = Tools.GetXml(Data.Objects("session").URL_Database & "tbLandmarkType?")
		Set nodes = XMLDoc.selectNodes("//T")
		if nodes.Length > 0 then
			for each node in nodes
				set V = new TypeDetail
					for each attr in node.attributes
						select case lcase(attr.Name)
							case "id":	V.ID = clng(attr.value)
							case "d":	V.Description = attr.value
							case "g":	V.GifFileName = "\landmark\" + attr.value
						end select
					next
					Set LandmarkType.Item(V.ID) = V
			next
		End If
		Set Data.Objects.Item("landmarktype") = LandmarkType
	End Sub

	Private Sub GetStopTypes()
		set XMLDoc = Tools.GetXml(Data.Objects("session").URL_Database & "tbStopType?")
		Set nodes = XMLDoc.selectNodes("//T")
		if nodes.Length > 0 then
			for each node in nodes
				set V = new TypeDetail
					for each attr in node.attributes
						select case lcase(attr.Name)
							case "id":	V.ID = clng(attr.value)
							case "d":	V.Description = attr.value
							case "g":	V.GifFileName = "\stoptype\" + attr.value
						end select
					next
					Set StopType.Item(V.ID) = V
			next
		End If
		Set Data.Objects.Item("stoptype") = StopType
	End Sub

	Private Sub GetSpaceTypes()
		set XMLDoc = Tools.GetXml(Data.Objects("session").URL_Database & "tbSpaceType?")
		Set nodes = XMLDoc.selectNodes("//T")
		if nodes.Length > 0 then
			for each node in nodes
				set V = new TypeDetail
					for each attr in node.attributes
						select case lcase(attr.Name)
							case "id":	V.ID = clng(attr.value)
							case "d":	V.Description = attr.value
							case "g":	V.GifFileName = "\spacetype\" + attr.value
						end select
					next
					Set SpaceType.Item(V.ID) = V
			next
		End If
		Set Data.Objects.Item("spacetype") = SpaceType
	End Sub

	Private Sub GetCompanyTypes()
		set XMLDoc = Tools.GetXml(Data.Objects("session").URL_Database & "tbCompanyType?")
		Set nodes = XMLDoc.selectNodes("//T")
		if nodes.Length > 0 then
			for each node in nodes
				set V = new CompanyTypeDetail
					for each attr in node.attributes
						select case lcase(attr.Name)
							case "id":	V.ID = clng(attr.value)
							case "d":		V.Description = attr.value
							case "b":		V.DotBorder = attr.value
							case "c":		V.BackGroundColor = attr.value
						end select
					next
					Set CompanyType.Item(V.ID) = V
			next
		End If
		Set Data.Objects.Item("companytype") = CompanyType
	End Sub

	Private Sub MaterialTypes()
		set XMLDoc = Tools.GetXml(Data.Objects("session").URL_Database & "tbMaterialType?")
		Set nodes = XMLDoc.selectNodes("//T")
		if nodes.Length > 0 then
			for each node in nodes
				set V = new TypeDetail
					for each attr in node.attributes
						select case lcase(attr.Name)
							case "id":	V.ID = clng(attr.value)
							case "d":	V.Description = attr.value
							case "g":	V.GifFileName = "material\" + attr.value
						end select
					next
					Set MaterialType.Item(V.ID) = V
			next
		End If
		Set Data.Objects.Item("materialtype") = MaterialType
	End Sub

	Private Sub MaterialSubTypes()
		'window.status = "Hallo Stef *A*"
		set XMLDoc = Tools.GetXml(Data.Objects("session").URL_Database & "tbMaterialSubType?")
		'window.status = "Hallo Stef *B*"
		Set nodes = XMLDoc.selectNodes("//T")
		'window.status = "Hallo Stef *C*"
		if nodes.Length > 0 then
			for each node in nodes
				set V = new TypeDetail
					for each attr in node.attributes
						select case lcase(attr.Name)
							case "id":	V.ID = clng(attr.value)
							case "d":	V.Description = attr.value
										'alert(attr.value)
							case "g":	V.GifFileName = "material\" + attr.value
						end select
					next
					Set MaterialSubType.Item(V.ID) = V
			next
		End If
		Set Data.Objects.Item("materialsubtype") = MaterialSubType
	End Sub

End Class

Class CompanyTypeDetail
	Public id, Description, DotBorder, BackgroundColor
End Class

Class TypeDetail
	Public ID, Description, GifFileName, Border
End Class
