_G[gTable] = {};

local aTmpVal  = gTable;
cm.SetupTable(_G[aTmpVal]);


-- Called on Init
_G[gTable].OnInit = function(pObj)
	pObj.mState = 0;
	_G[aTmpVal].StartParticleSystem(pObj, 1);
end


-- Called after data being loaded from disk
_G[gTable].OnLoad = function(pObj)
	_G[aTmpVal].StartParticleSystem(pObj, 1);
end


--Called after level being reloaded
_G[gTable].OnLevelLoad = function(pObj)

	if not pObj:ParticleEmitterOn() then
		_G[aTmpVal].StartParticleSystem(pObj, 1);
	end

end

-- Called on a update
_G[gTable].OnUpdate = function(pObj)

end


-- Called on a succesful click
_G[gTable].OnClick =  function(pObj, pName, pActorObj, pPolyNum, pX, pY)

	pObj.mDiscovered = true;
	local aState     = pObj.mState;

	if pName == "" then
      cm.GetShowInfo(pObj, "InfoStr1", "InfoTime1");
		return true;

	elseif pName == pObj.mCsData:GetString("KeyObject1") then
		_G[pActorObj.mScriptTag].OnUse(pActorObj, pObj);
		return false;

	else
		cm.ObjDoesNotWork(pObj);
		return false;
	end

	return false;
end



-- Called on draw
_G[gTable].OnDraw =  function(pObj, pG)

	local aRpos = pObj.mSmPos;
	local aImg  = IcImageWrap(pObj.mSmallImage);
	assert(aImg);
	local aRect = aImg:GetCelRect(pObj.mCurCell);
	pG:DrawImage(aImg:GetImage(), aRpos.x, aRpos.y, aRect);

end


-- Called to start the particle system
_G[gTable].StartParticleSystem = function(pObj, pIndex)

	pObj.mDiscovered = true;
   local aPsysName = pObj.mCsData:GetString("ParticleSystemName");
   pObj:SetupParticleSystem(aPsysName);
   pObj:StartParticleEmission(pIndex);

end
