--===================================================
--									
--									GHI Timer
--								GHI_Timer.lua
--
--				Calling of functions on a requested interval
--	
-- 						(c)2012 The Gryphonheart Team
--								All rights reserved
--===================================================

function GHI_Timer(func, interval, onceOnly)
	GHCheck("GHI_Timer", { "function", "number", "nilBoolean" }, { func, interval, onceOnly });
	local class = GHClass("GHI_Timer","frame");

	local lastCall = GetTime();

	class:SetScript("OnUpdate", function(self)
		if GetTime() > lastCall + interval then
			lastCall = GetTime();
			if onceOnly then
				class:SetScript("OnUpdate", function(self) end);
			end
			func();
		end
	end);

	return class;
end
