sub init()
    mBind(["itemIcon", "itemLabel", "group", "itemPoster", "itemflecha"])
    m.top.id = "markuplistitem"
	m.parent = m.top.getParent()
	m.parent.observeField("itemSelected", "onItemSelectedChanged")
	
end sub

sub showcontent()
    itemcontent = m.top.itemContent
    m.itemlabel.text = itemcontent.title
	showfocus()
end sub

sub showfocus()
    if m.top.focusPercent > 0.5 then
	   m.itemPoster.opacity = m.top.focusPercent
       m.itemlabel.color = "#313233"
    else 
	   m.itemPoster.opacity = m.top.focusPercent
       m.itemlabel.color = "#FFFFFF"
    end if
end sub

sub onItemSelectedChanged()
    itemSelected = m.parent.itemSelected
    m.itemicon.visible = false
    if m.top.index = itemSelected then
        m.itemicon.visible = true
		m.itemicon.uri = "pkg:/images/icons/enable.png"
    end if
end sub

sub widthChanged() 
    updateLayout()
end sub

sub heightChanged() 
    updateLayout()
end sub

sub updateLayout() 
    if m.top.height > 0 and m.top.width > 0 
	    m.itemPoster.width = m.top.width
        m.itemPoster.height = m.top.height
    end if
end sub

sub itemHasFocus()
	if m.top.itemContent <> invalid
        if (m.top.itemHasFocus) then
	        m.itemlabel.color = "#FFFFFF"
	        m.itemPoster.uri = "pkg:/images/login/dns-edit-focus.png"
        else
	        m.itemlabel.color = "#313233"
	        m.itemPoster.uri = "pkg:/images/login/dns-edit.png"
        end if
	end if
end sub

sub focusPercentChanged() 
    if m.top.listHasFocus and m.top.focusPercent > 0.5 
	    m.itemlabel.color = "#313233"
	    m.itemPoster.uri = "pkg:/images/login/dns-edit.png"
    else 
	    m.itemlabel.color = "#FFFFFF"
	    m.itemPoster.uri = "pkg:/images/login/dns-edit-focus.png"
    end if 
end sub