
  local mytexture = "Interface\\AddOns\\oUF_D3OrbsRaid\\statusbar"
  local whitetexture = "Interface\\AddOns\\oUF_D3OrbsRaid\\white"
  
  ----------------
  -- VALUE FORMAT
  ---------------- 
  
  local function do_format(v)
    local string = ""
    if v > 1000000 then
      string = (floor((v/1000000)*10)/10).."m"
    elseif v > 1000 then
      string = (floor((v/1000)*10)/10).."k"
    else
      string = v
    end  
    return string
  end
  
  local function updateHealth(self, event, unit, bar, min, max)
  
    local tmpunitname = UnitName(unit)      
    if tmpunitname:len() > 4 then
      tmpunitname = tmpunitname:sub(1, 4)
    end
    
    local c = max - min
    local d = floor(min/max*100)
    
    local newmin = do_format(min)
    local newmax = do_format(max)
    local diff = do_format(max-min)
    
    color = RAID_CLASS_COLORS[select(2, UnitClass(unit))]

    bar:SetStatusBarColor(0.15,0.15,0.15)
    bar.bg:SetVertexColor(0.6,0.0,0)
    
    if d == 100 then
      self.Name:SetTextColor(color.r,color.g,color.b)
      self.Name:SetText(tmpunitname)
    elseif min > 1 then
      self.Name:SetTextColor(1,0,0)
      self.Name:SetText(diff)
    else
      self.Name:SetTextColor(0.4,0.4,0.4)
      self.Name:SetText("dead")    
      bar.bg:SetVertexColor(0.25,0.25,0.25)
    end
    

    
  end
  
  local stylefunc = function(self, unit)
  
    self:SetHeight(30)
    self:SetWidth(30)
    self:SetFrameStrata("LOW")

    self.DebuffHighlight = self:CreateTexture(nil, "BACKGROUND")
    self.DebuffHighlight:SetAllPoints(self)
    self.DebuffHighlight:SetTexture(whitetexture)
    self.DebuffHighlight:SetVertexColor(0, 0, 0, 1) -- set alpha to 0 to hide the texture
    self.DebuffHighlightAlpha = 1
    self.DebuffHighlightFilter = true
  
    self.Health = CreateFrame("StatusBar",nil,self)
    self.Health:SetFrameStrata("LOW")
    self.Health:SetPoint("TOPLEFT",self,"TOPLEFT",2,-2)
    self.Health:SetPoint("BOTTOMRIGHT",self,"BOTTOMRIGHT",-2,2)
    self.Health:SetStatusBarTexture(mytexture)
    self.Health:SetOrientation("VERTICAL") 
  
    self.Health.bg = self.Health:CreateTexture(nil, "BORDER")
    self.Health.bg:SetAllPoints(self.Health)
    self.Health.bg:SetTexture(mytexture)
  
    self.Name = self.Health:CreateFontString(nil, "OVERLAY")
    self.Name:SetPoint("CENTER", 0, 0)
    self.Name:SetFont(NAMEPLATE_FONT,12,"THINOUTLINE")
    self.Name:SetShadowColor(0,0,0,0)
    self.Name:SetTextColor(1, 1, 1)
  
    local ricon = self.Health:CreateTexture(nil, "OVERLAY")
    ricon:SetHeight(10)
    ricon:SetWidth(10)
    ricon:SetPoint("BOTTOM", self.Name, "TOP", 0, -1)
    ricon:SetTexture"Interface\\TargetingFrame\\UI-RaidTargetingIcons"
    self.RaidIcon = ricon
      
    self.Range = true 
    self.inRangeAlpha = 1.0
    self.outsideRangeAlpha = 1
  
    self.PostUpdateHealth = updateHealth
  
    return self
  end
  
  local actstyle = "d3orbraid"
 
  oUF:RegisterStyle(actstyle, stylefunc)
  oUF:SetActiveStyle(actstyle)
  
  
  local raid = {}
  for i = 1, 8 do
    table.insert(raid, oUF:Spawn("header", "oUF_Raid"..i))
    if i == 1 then
      raid[i]:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 20, -20)
    else
      raid[i]:SetPoint("TOPLEFT", raid[i-1], "TOPRIGHT", 2, 0)    
    end
    raid[i]:SetManyAttributes("showRaid", true, "yOffset", -2, "groupFilter", i)
    raid[i]:Show()
  end
