function xamlItem(target, index) {
    this.target = target;
    this.index = index;
    this.xaml = null;
    this.defaultJs = true;
    this.clickHandler = null;
    this.xamlUrl = this.target.findName("itemXaml" + this.index.toString()).text;
    target.addEventListener("mouseEnter", Silverlight.createDelegate(this, this.handleMouseEnter));
    target.addEventListener("mouseLeave", Silverlight.createDelegate(this, this.handleMouseLeave));
    target.addEventListener("mouseLeftButtonUp", Silverlight.createDelegate(this, this.handleClick));
    target.addEventListener("mouseLeftButtonDown", Silverlight.createDelegate(this, this.handleMouseDown));
}

xamlItem.prototype.handleMouseEnter = function(sender, eventArgs) {
    var itemBackground = this.target.findName("itemBackground" + this.index.toString());
    itemBackground.fill = "#FF626262";
}

xamlItem.prototype.handleMouseLeave = function(sender, eventArgs) {
    var itemBackground = this.target.findName("itemBackground" + this.index.toString());
    itemBackground.fill = "#FF424242";
}

xamlItem.prototype.handleClick = function(sender, eventArgs) {
    var itemBackground = this.target.findName("itemBackground" + this.index.toString());
    itemBackground.fill = "#FF626262";
    
    if (this.clickHandler != null) {
        this.clickHandler(this);
    }
}

xamlItem.prototype.handleMouseDown = function(sender, eventArgs) {
    var itemBackground = this.target.findName("itemBackground" + this.index.toString());
    itemBackground.fill = "#FF222222";
}