SITES = Array("http://www.realtimesoft.com", "http://www.microsoft.com", "http://www.apple.com", "http://www.intel.com")
'position for each IE instance, can be in one of the following formats for each entry:
'<x,y,width,height>: normal window at specified position with specified size, for example "10,10,400,300"
'<monitor,m>: maximized window on specified monitor, for example "3,m"
'<monitor,f>: fullscreen window on specified monitor, for example "3,f"
POSITION = Array("2,f", "3,m", "-2000,300,400,300")
Const INTERVAL = 0 'number of seconds between site changes, set to zero if sites shouldn't be changed
Const TERMINATE_EXISTING_INSTANCES = False 'True if existing instances of IE should get closed at startup, False otherwise

Set sh = CreateObject("WScript.Shell")
Set sys = CreateObject("UltraMon.System")
Set wnd = CreateObject("UltraMon.Window")

If TERMINATE_EXISTING_INSTANCES = True Then
	For Each w In wnd.GetAppWindows(False)
		exe = w.ProcessExe
		pos = InStrRev(exe, "\")
		If pos > 0 Then
			If StrComp(Mid(exe, pos + 1), "iexplore.exe", 1) = 0 Then
				w.Close
			End If
		End If
	Next
End If

ie7 = False
ieVer = sh.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Version")
If ieVer <> "" Then
	ieVer = Left(ieVer, InStr(ieVer, ".") - 1)
	If CLng(ieVer) >= 7 Then ie7 = True
End If

ReDim browsers(UBound(POSITION))
For i = 0 To UBound(browsers)
	Set ie = CreateObject("InternetExplorer.Application")

	x = 0
	y = 0
	cx = 0
	cy = 0
	monId = 0
	fullscreen = False
	posVal = Split(POSITION(i), ",")
	If UBound(posVal) = 3 Then
		x = CLng(posVal(0))
		y = CLng(posVal(1))
		cx = CLng(posVal(2))
		cy = CLng(posVal(3))
	Else
		monId = CLng(posVal(0))
		If posVal(1) = "f" Then fullscreen = True

		Set mon = sys.Monitors(monId - 1)
		x = mon.Left
		y = mon.Top
		cx = mon.Width
		cy = mon.Height
	End If
	
	If ie7 = False Then
		ie.Visible = True
		If fullscreen = True Then ie.FullScreen = True
	End If
	
	ie.Left = x
	ie.Top = y
	ie.Width = cx
	ie.Height = cy
	
	If ie7 = True Then
		ie.Visible = True
		If fullscreen = True Then ie.FullScreen = True
	End If

	If monId <> 0 And fullscreen = False Then
		'maximize the window
		wnd.HWnd = ie.HWND
		wnd.ShowState = 3 'SHOWSTATE_MAXIMIZED
		wnd.ApplyChanges 0
	End If
	
	Set browsers(i) = ie
Next

site = 0
If INTERVAL = 0 Then
	For i = 0 To UBound(browsers)
		Set ie = browsers(i)
		ie.Navigate sites(site)
		
		site = site + 1
		If site > UBound(sites) Then site = 0
	Next
Else
	Do While True
		For i = 0 To UBound(browsers)
			Set ie = browsers(i)
			ie.Navigate sites(site)
			
			site = site + 1
			If site > UBound(sites) Then site = 0
		Next
		
		WScript.Sleep INTERVAL * 1000
	Loop
End If
