local chatborder = CreateFrame("Button", nil, ChatFrame1EditBox)
chatborder:SetBackdrop(GameTooltip:GetBackdrop())
chatborder:SetBackdropColor(0,0,0,0)
chatborder:EnableMouse(false)

local chateditbox = CreateFrame("Button", nil, ChatFrame1EditBox)
chateditbox:SetBackdrop(GameTooltip:GetBackdrop())
chateditbox:SetBackdropColor(0,0,0,0)

hooksecurefunc("ChatEdit_UpdateHeader", function(editbox)
	if ACTIVE_CHAT_EDIT_BOX then
		local type = editbox:GetAttribute("chatType")
		local frame = string.sub(ACTIVE_CHAT_EDIT_BOX:GetName(),1,10)
		
		if ( type == "CHANNEL" ) then
			local id = GetChannelName(editbox:GetAttribute("channelTarget"))
			if id == 0 then	
				chatborder:SetBackdropBorderColor(0.5,0.5,0.5)
				chateditbox:SetBackdropBorderColor(0.5,0.5,0.5)
				chateditbox:SetBackdropColor(0.5/3,0.5/3,0.5/3)
			else 
				chatborder:SetBackdropBorderColor(ChatTypeInfo[type..id].r,ChatTypeInfo[type..id].g,ChatTypeInfo[type..id].b)
				chateditbox:SetBackdropBorderColor(ChatTypeInfo[type..id].r,ChatTypeInfo[type..id].g,ChatTypeInfo[type..id].b)
				chateditbox:SetBackdropColor(ChatTypeInfo[type..id].r/3,ChatTypeInfo[type..id].g/3,ChatTypeInfo[type..id].b/3)
			end
		else
			chatborder:SetBackdropBorderColor(ChatTypeInfo[type].r,ChatTypeInfo[type].g,ChatTypeInfo[type].b)
			chateditbox:SetBackdropBorderColor(ChatTypeInfo[type].r,ChatTypeInfo[type].g,ChatTypeInfo[type].b)
			chateditbox:SetBackdropColor(ChatTypeInfo[type].r/3,ChatTypeInfo[type].g/3,ChatTypeInfo[type].b/3)
		end
		
		chatborder:SetParent(ACTIVE_CHAT_EDIT_BOX)
		chatborder:ClearAllPoints()
		chatborder:SetPoint("TOPLEFT", frame.."TopLeftTexture",0,0)
		chatborder:SetPoint("BOTTOMRIGHT", frame.."BottomRightTexture",0,1)
		chateditbox:SetParent(ACTIVE_CHAT_EDIT_BOX)
		chateditbox:ClearAllPoints()
		chateditbox:SetPoint("TOPLEFT", ACTIVE_CHAT_EDIT_BOX:GetName().."Left", "TOPLEFT", -1, -3)
		chateditbox:SetPoint("BOTTOMRIGHT", ACTIVE_CHAT_EDIT_BOX:GetName().."Right", "BOTTOMRIGHT", 1, 3)
		chateditbox:SetFrameLevel(_G[frame.."EditBox"]:GetFrameLevel()-1)

	else
		chatborder:SetBackdropBorderColor(0,0,0,0)
		chateditbox:SetBackdropBorderColor(0,0,0,0)
		chateditbox:SetBackdropColor(0,0,0,0)
	end
	
	for chatframe=1,CURRENT_CHAT_FRAME_ID do
		for i=6,8 do select(i, _G["ChatFrame"..chatframe.."EditBox"]:GetRegions()):Hide() end
		_G["ChatFrame"..chatframe.."EditBoxFocusLeft"]:Hide()
		_G["ChatFrame"..chatframe.."EditBoxFocusLeft"].Show = _G["ChatFrame"..chatframe.."EditBoxFocusLeft"].Hide
		_G["ChatFrame"..chatframe.."EditBoxFocusMid"]:Hide()
		_G["ChatFrame"..chatframe.."EditBoxFocusMid"].Show = _G["ChatFrame"..chatframe.."EditBoxFocusMid"].Hide
		_G["ChatFrame"..chatframe.."EditBoxFocusRight"]:Hide()
		_G["ChatFrame"..chatframe.."EditBoxFocusRight"].Show = _G["ChatFrame"..chatframe.."EditBoxFocusRight"].Hide
	end

end)