#include <_XMLDomWrapper.au3>
#include <File.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <resources.au3>
#include "includes/functions.inc.au3"
#include "includes/gui.inc.au3"

Global $g_eventerror = 0
Global $oError = ObjEvent("AutoIt.Error","MyErrFunc")

Global $gVersionChecked = 0


;; Main
_main()
Func _main()
	Global $GuiWidth = 370, $GuiHeight = 177
	Local $GuiPosX = (@DesktopWidth - $GuiWidth) / 2, $GuiPosY = (@DesktopHeight - $GuiHeight) / 2

	Global $GUi = GUICreate("SMACheck - smacbans.com", $GuiWidth, $GuiHeight, $GuiPosX, $GuiPosY)
	$GUiBG = GUICtrlCreatePic("", 0, 0, 370, 177)
		_ResourceSetImageToCtrl($GUiBG, "img_bg", $RT_RCDATA)
		GUICtrlSetState(-1, $GUI_DISABLE)
	$gInput = GUICtrlCreateLabel("SteamID:", 0, 50, 368, 17, $SS_CENTER)
		GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
		GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
	$gSteamId = GUICtrlCreateInput("", 112, 70, 145, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
		GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
	$gButton_Submit = GUICtrlCreateButton("Check", 144, 104, 83, 25, $BS_CENTER)
		GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
		GuiCtrlSetState(-1, 512)
	$gCopyright = GUICtrlCreateLabel("©2012 SMACbans.com", 0, 159, 368, 17, $SS_RIGHT)
		GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
		GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
	$gVersion = GUICtrlCreateLabel("v" & $VERSION, 2, 159, 369, 17, $SS_LEFT)
		GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
		GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
	GUISetState(@SW_SHOW)


	While 1
		Switch GUIGetMsg()
			Case $GUI_EVENT_CLOSE
				ExitLoop
			Case $gButton_Submit
				$iSteamId = StringStripWS(GUICtrlRead($gSteamId), 8)
				If $iSteamId = "" Then
					GUISetState(@SW_DISABLE, $GUi)
					MsgBox(16, "ERROR", "Please enter a SteamId or SteamId64.")
					GUISetState(@SW_ENABLE, $GUi)
					WinActivate($GUi)
					GUISwitch($GUi)
				ElseIf StringLeft($iSteamId, 6) = 765611 Then
					$iSteamId = steamId64ToSteamId($iSteamId)
				EndIf

				If StringLeft($iSteamId, 6) = "STEAM_" Then
					GUISetState(@SW_DISABLE, $GUi)
					gui_Info($iSteamId)
					GUISetState(@SW_ENABLE, $GUi)
					WinActivate($GUi)
					GUISwitch($GUi)
				EndIf
				resetInput($gSteamId)
		EndSwitch
	WEnd
	GUIDelete()
EndFunc