
_G[gTable] = {};

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


-- Called on Init
_G[gTable].OnInit = function(pObj)
	pObj.mState = 0;
	aState   = pObj.mState;
	aCurCell = pObj.mCurCell;
end


-- Called after data being loaded from disk
_G[gTable].OnLoad = function(pObj)
	aState   = pObj.mState;
	aCurCell = pObj.mCurCell;
end


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

   if aState == 5 and (not pObj.mAlpha:AncIsChanging()) then
      aState          = aState + 1
      pObj.mState     = aState;

		_G[aTmpVal].NormalSize(pObj);
		pObj.mCb:Disappear();
      cm.DisableObject(pObj);
      cm.SetGlobalValIndirect(pObj, "SetFlag1", true);
      cm.GetShowInfo(pObj, "InfoStr2", "InfoTime2");
   	IcPlaySample("PH_SFX_GOOD_JOB");

   end

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
  	      cm.GetShowInfo(pObj, "InfoStr1", "InfoTime1");
		   return true;
		end
		return true;


	elseif pName == pObj.mCsData:GetString("KeyObject1")
      or  pName == pObj.mCsData:GetString("KeyObject2")
      or  pName == pObj.mCsData:GetString("KeyObject3")
      or  pName == pObj.mCsData:GetString("KeyObject4")
      or  pName == pObj.mCsData:GetString("KeyObject5") then

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

      pObj:StartFadeRects(PhFadeAnotherTimeShort);
      aState          = aState + 1
      pObj.mState     = aState;
      aCurCell        = aCurCell + 1;
      pObj.mCurCell   = aCurCell;
		pObj:StopParticleEmission(false);
		_G[pActorObj.mScriptTag].OnUse(pActorObj, pObj);
	   return true;

	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;




