-- start of an animation

--[[
-- Possible parameters:
anim.run()
anim.run(client)
anim.run(client, scene)
anim.run(nil, scene)
anim.run(client, "name", scene)
anim.run("name", scene) --> anim.run("", scene)
anim.run("name")
--]]

anim = anim or {}

ghf.Modifier = getClass("Modifier")
ghf.ModifierRoot = getClass("ModifierRoot")
ghf.ModifierGroup = getClass("ModifierGroup")
ghf.ModifierFraction = getClass("ModifierFraction")
ghf.ModifierAlpha = getClass("ModifierAlpha")
ghf.ModifierDelay = getClass("ModifierDelay")

ghf.Modifier.kInitialized = ghf.bit1
ghf.Modifier.kIsDone = ghf.bit2

function anim.run(...)
	local argc = 1

	local lClient = nil
	local lName = ""
	local lScene = scene

    if type(arg[argc]) == "table" then
		lClient = arg[argc]
		argc = argc + 1
    end

    if isString(arg[argc]) then
		lName = arg[argc]
		argc = argc + 1
    end

    if isTable(arg[argc]) then
		lScene = arg[argc]
    end

    local group = anim.animation(lScene, lName)
    if (lClient) then
		group.client = lClient
    end

	return group
end

-- setup for the shortcut functions
function anim.setup(t, modClass)
    local t = table.copy(t)
    t.class = modClass
    return t
end

-- alpha shortcut
function anim.alpha(t)
    return anim.setup(t, "ModifierAlpha")
end
