_G[gTable] = {};

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


-- Called on Init
_G[gTable].OnInit = function(pObj)
	pObj.mState = 0;
	pObj.mCsData:SetVal("Downsizing", false);
end


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

end


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

   if pObj.mState == 0 then

      if cm.GetGlobalBoolIndirect(pObj, "ActivatorFlag1") then
         pObj.mState    = pObj.mState    + 1;
      	pObj.mCurCell  = pObj.mCurCell  + 1;

      	local aNum = pObj:GetFirstActive(0);
      	pObj:SetActive(0, aNum, false);
      	pObj:SetActive(1, aNum, false);
      	pObj:SetActive(0, aNum + 1, true);
      	pObj:SetActive(1, aNum + 1, true);

		   local aStr = pObj.mCsData:GetString("ObjSfxId");
		   IcPlaySample(aStr);

      end

   end

	cm.ZoomOutUpdate(pObj);

end


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

	pObj.mDiscovered = true;
	if pName == "" then

		if pObj.mCurImg == 0 then
			_G[aTmpVal].GetBigger(pObj, PhGetBigTime);
			return true;
		else

			if pObj.mState == 1 then

            if not cm.SpawnObject(pObj, 0, pObj.mBigPos, "SpawnObject") then
               return true;
            end

            pObj.mState    = pObj.mState + 1;
         	pObj.mCurCell  = pObj.mCurCell + 1;
				pObj:SetActive(0, pPolyNum, false);
				pObj:SetActive(1, pPolyNum, false);

         	_G[aTmpVal].NormalSize(pObj);
				pObj.mCb:Disappear();
				pObj.mDiscovered = false;
				pObj:StopParticleEmission(false);
				IcPlaySample("PH_SFX_OBJ_PICKUP");
				return true;
			end

			cm.GetShowInfo(pObj, "InfoStr1", "InfoTime1");
			return true;
		end

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

	return false;
end



-- Called on draw
_G[gTable].OnDraw =  cm.DrawZoomable;


-- Zooms Out
_G[gTable].NormalSize = cm.ZoomOut;


-- Zooms In
_G[gTable].GetBigger = cm.ZoomIn;


