function MenuItem(id, contentPageName, target, url, frameID, enabled, popUpArgs, fontDefinition, foreColor, foreColorSelected, foreColorHover, backColor, backColorSelected, backColorHover, cssClass, selectedCssClass, hoverCssClass, bottomImage, bottomHoverImage, bottomSelectedImage)
{
    this.ClassName = "MenuItem";
    this.Parent = null;
    this.Id = id;
    this.ContentPageName = contentPageName;
    this.Target = target;
    this.Url = url;
    this.FrameID = frameID;
    this.Enabled = enabled;
    this.Index = -1;
    this.PopUpArgs = popUpArgs;
    this.Link = document.createElement("A");
    this.Link.href = "#";

    this.ForeColor = foreColor;
    this.ForeColorSelected = foreColorSelected;
    this.ForeColorHover = foreColorHover;
    this.BackColor = backColor;
    this.BackColorSelected = backColorSelected;
    this.BackColorHover = backColorHover;
    
    this.FontDefinition = fontDefinition;
    this.CssClass = cssClass;
    this.SelectedCssClass = selectedCssClass;
    this.HoverCssClass = hoverCssClass;

    this.BottomImage = bottomImage;
    this.HoverBottomImage = bottomHoverImage;
    this.SelectedBottomImage = bottomSelectedImage;

    var ctrl = document.getElementById(this.Id);
    var obj = this;
    this.Ctrl = ctrl;
	
    if (ctrl) 
    { 
        this.RegisterEvent (ctrl, "mouseover", function() { obj.MouseOver(); }); 
        this.RegisterEvent (ctrl, "mouseout", function() { obj.Normal(); }); 

        if (this.Target != "AutoPostBack")
        { 
	        this.RegisterEvent (ctrl, "click", function() { obj.Click(); }); 
        }	
    }
}

MenuItem.prototype.RegisterEvent = function(ctrl, eventname, func) 
{
	if( ctrl.addEventListener ) 
	{
		ctrl.addEventListener(eventname, func, false);
	} 
	else if ( ctrl.attachEvent ) 
	{
		ctrl.attachEvent("on" + eventname, func);
	}
};

MenuItem.prototype.Click = function() {
    if (!this.Enabled) {
        return;
    }

    if (this.Url == "") {
        return;
    }

    var target;
    var frameID;

    if (this.Target == "Undefined") {
        target = this.Parent.Target;
    }
    else {
        target = this.Target;
    }

    if (this.FrameID == "") {
        frameID = this.Parent.FrameID;
    }
    else {
        frameID = this.FrameID;
    }

    switch (target) {
        case "Self":
//            this.Link.href = this.Url;
//            this.Link.target = "_self";
//            this.Link.click();
            window.location = this.Url;
            break;
        case "Blank":
            window.open(this.Url);
            break;
        case "Parent":
            this.Link.href = this.Url;
            this.Link.target = "_parent";
            this.Link.click();
            break;
        case "IFrame":
            if (frameID != "") {
                this.Parent.Page.getElementById(frameID).src = this.Url;
                this.Parent.SetSelectedIndex(this.Index);
            }
            break;
        case "PopUp":
            if (this.PopUpArgs != "") {
                this.Parent.Page.window.open(this.Url, "newWin", this.PopUpArgs);
            }
            break;
    }
};

MenuItem.prototype.MouseOver = function() {
    if (this.Parent != null) {
        if (this.Index != this.Parent.SelectedIndex) {
            switch (this.FontDefinition) {
                case "CssClass":
                    this.SetVisualElements(this.ForeColorHover, this.BackColorHover, this.HoverBottomImage, this.CssClassHover);
                    break;
                default:
                    this.SetVisualElements(this.ForeColorHover, this.BackColorHover, this.HoverBottomImage, "");
                    break;
            }
        }
        else {
            this.Ctrl.style.cursor = "default";
        }
    }
    else {
        switch (this.FontDefinition) {
            case "CssClass":
                this.SetVisualElements(this.ForeColorHover, this.BackColorHover, this.HoverBottomImage, this.CssClassHover);
                break;
            default:
                this.SetVisualElements(this.ForeColorHover, this.BackColorHover, this.HoverBottomImage, "");
                break;
        }

    }
};

MenuItem.prototype.Normal = function() {
    if (this.Parent != null) {
        if (this.Index != this.Parent.SelectedIndex) {
            switch (this.FontDefinition) {
                case "CssClass":
                    this.SetVisualElements(this.ForeColor, this.BackColor, this.BottomImage, this.CssClass);
                    break;
                default:
                    this.SetVisualElements(this.ForeColor, this.BackColor, this.BottomImage, "");
                    break;
            }
        }
    }
    else {
        switch (this.FontDefinition) {
            case "CssClass":
                this.SetVisualElements(this.ForeColor, this.BackColor, this.BottomImage, this.CssClass);
                break;
            default:
                this.SetVisualElements(this.ForeColor, this.BackColor, this.BottomImage, "");
                break;
        }
    }
    this.Ctrl.style.cursor = "pointer";
};

MenuItem.prototype.Selected = function() {
//    debugger;
    switch (this.FontDefinition) {
        case "CssClass":
            this.SetVisualElements(this.ForeColorSelected, this.BackColorSelected, this.SelectedBottomImage, this.CssClassSelected);
            break;
        default:
            this.SetVisualElements(this.ForeColorSelected, this.BackColorSelected, this.SelectedBottomImage, "");
            break;
    }
    this.Ctrl.style.cursor = "default";
};

MenuItem.prototype.SetVisualElements = function(foreColor, backColor, bottomImage, cssClass) {
    //    debugger;
    var cells = this.Ctrl.getElementsByTagName("TD");
    if (cells.length > 0) {
        var count = 0;
        for (count = 0; count < cells.length; count++) {
            if (cssClass != "") {
                cells[count].className = this.cssClass;
            }
            if (cells[count].id == this.Id + "_Underline") {
                var images = cells[count].getElementsByTagName("IMG");
                if (images.length > 0) {
                    images[0].src = bottomImage;
                }
            }
            cells[count].style.color = foreColor;
        }
    }
    this.Ctrl.style.borderColor = foreColor;

    //var images = this.Ctrl.getElementsByTagName("IMG");
};
