_G[gTable] = {};

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

-- Called on Init
_G[gTable].OnInit = function(pObj)

	pObj.mState		  = 1;
	pObj.mDiscovered = true;
	_G[aTmpVal].SpawnParticleSystem(pObj, "PH_PSYS_GEN_SCROLL_SPIRAL");

end


-- Called after data being loaded from disk
_G[gTable].OnLoad = function(pObj)

	if pObj.mState == 1 then
	_G[aTmpVal].SpawnParticleSystem(pObj, "PH_PSYS_GEN_SCROLL_SPIRAL");
   end

end


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

   if pObj.mState == 1 then
      if not pObj:ParticleEmitterOn() then
         pObj.mState = pObj.mState + 1;
      	pObj.mDiscovered = false;
      	pObj.mIsDone     = true;
      end
	end

end


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

	return false;
end



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

	local aImg  = IcImageWrap(pObj.mSmallImage);
	assert(aImg);
	local aRpos = pObj.mSmPos;
	local aRect = aImg:GetCelRect(pObj.mCurCell);

	if pObj.mCsData:GetBool("Used") or pObj.mCsData:GetBool("MovingToSlot") then
		pG:SetColorizeImages(true);
		pG:SetColor(Color(255, 255, 255, pObj.mAlpha:AncGetVal()));
	end
	pG:DrawImage(aImg:GetImage(), aRpos.x, aRpos.y, aRect);

end


-- Called to spawn particle system
_G[gTable].SpawnParticleSystem =  function(pObj, pName)

   pObj:SetupParticleSystem(pName);
   pObj:StartParticleEmission(0);

end

