local M = {}		
local timer = 0
local timer2 = 0
local timer3 = 0
local timer4 = 0
local cycleComplete = 0
local cycleStarting = 0
local cycleHeadComplete = 0
local cycleHeadStarting = 0

local function onInit()
	electrics.values["doorfl"] = 0
		electrics.values["doorfr"] = 0
	electrics.values["doorrl"] = 0
		electrics.values["doorrr"] = 0
	timer2 = 0
	timer = 0
	timer3 = 0
	timer4 = 0
	cycleStarting = 0
	cycleComplete = 0
	cycleHeadStarting = 0
	cycleHeadComplete = 0

end

local function onReset()
	electrics.values["doorfl"] = 0
		electrics.values["doorfr"] = 0
	electrics.values["doorrl"] = 0
		electrics.values["doorrr"] = 0
	timer2 = 0
	timer = 0
	timer3 = 0
	timer4 = 0
	cycleStarting = 0
	cycleComplete = 0
	cycleHeadStarting = 0
	cycleHeadComplete = 0

end

local function updateGFX(dt) 
  if electrics.values["doorFLCoupler_notAttached"] == 1 then
	timer = timer + dt
	
	if timer >= 0.0000 then
	electrics.values["doorfl"] = 1	
	end
		if timer >= 0.26 then
	electrics.values["doorfl"] = 0	
	end
	
  else
	electrics.values["doorfl"] = 0

	timer = 0	
  end
  
   if electrics.values["doorFRCoupler_notAttached"] == 1 then
	timer2 = timer2 + dt
	
	if timer2 >= 0.0000 then
	electrics.values["doorfr"] = 1	
	end
		if timer2 >= 0.26 then
	electrics.values["doorfr"] = 0	
	end
	
  else
	electrics.values["doorfr"] = 0

	timer2 = 0	
  end
  
     if electrics.values["doorRRCoupler_notAttached"] == 1 then
	timer3 = timer3 + dt
	
	if timer3 >= 0.0000 then
	electrics.values["doorrr"] = 1	
	end
		if timer3 >= 0.26 then
	electrics.values["doorrr"] = 0	
	end
	
  else
	electrics.values["doorrr"] = 0

	timer3 = 0	
  end
  
   if electrics.values["doorRLCoupler_notAttached"] == 1 then
	timer4 = timer4 + dt
	
	if timer4 >= 0.0000 then
	electrics.values["doorrl"] = 1	
	end
		if timer4 >= 0.26 then
	electrics.values["doorrl"] = 0	
	end
	
  else
	electrics.values["doorrl"] = 0

	timer4 = 0	
  end

end

-- public interface
M.onInit = onInit
M.onReset = onReset
M.updateGFX = updateGFX

return M