 
 	@getPathToScript: ->
 		if not @pathToScript
-			for s, idx in DOM.matchSelector(document.documentElement, "script")
-				if m = s.src.match("(.*/)cui\.js$")
-					@pathToScript = m[1]
-					@script = s
-					break
-			assert(@pathToScript, "CUI", "Could not determine script path.")
+			scripts = document.getElementsByTagName('script')
+			cui_script = scripts[scripts.length - 1]
+			if m = cui_script.src.match("(.*/).*?\.js$")
+				@pathToScript = m[1]
+			else
+				assert(@pathToScript, "CUI", "Could not determine script path.")
 
 		@pathToScript
 


		@CSS = new CUI.CSSLoader()

		@getPathToScript()
		trigger_viewport_resize = =>
			console.info("CUI: trigger viewport resize.")
			Events.trigger

	CUI.__downloadDataElement = nodes[1]
	CUI.DOM.append(document.body, nodes)


CUI.getPathToScript()


if not window.addEventListener
	alert("Your browser is not supported. Please update to a current version of Google Chrome, Mozilla Firefox or Internet Explorer.")
else
