

LinksPanel = function LinksPanel(container, containingWindow, id) {
    LinksPanel.initializeBase(this, [ container, containingWindow, id, false ]);
}
LinksPanel.prototype = {
    _linksContainer: null,
    _closeButton: null,
    _linksTitleText: null,
    _isHeightInitialized: false,
    IsShowing: false,
    
    OnLoad: function LinksPanel$OnLoad() {
        this._initialize();
    }, 
    
    OnUnLoad: function LinksPanel$OnUnLoad() {
    },
    
    _initialize: function LinksPanel$_initialize() {
        if (Manifest.SupportingLinks.length < 1) {
            this.Hide();
            return;
        }
        
        this._linksTitleText = $(this.ID + 'LinksTitleText');
        SfKernel.Util.SetText(this._linksTitleText, Localization.LinksResource.PresentationLinks);
        
        this._closeButton = $(this.ID + 'CloseButton');
        this._closeButton.setAttribute('title', Localization.LinksResource.Close);
        this._closeButton.observe('mouseover', Function.createDelegate(this, this._closeButtonOnMouseOver));
        this._closeButton.observe('mouseout', Function.createDelegate(this, this._closeButtonOnMouseOut));
        this._closeButton.observe('click', Function.createDelegate(this, this._closeButtonOnClick));
        
        this._linksContainer = $(this.ID + 'Container');
        for (var i = 0; i < Manifest.SupportingLinks.length; ++i) 
        {
            this._appendLinkElement(Manifest.SupportingLinks[i], (!(i % 2)));
        }
    },
    
    Show: function LinksPanel$Show() {
        $(this.ID).style.display = 'block';
        this.IsShowing = true;
        // firefox 2 on mac has an issue with scrollbars showing through, so we disable them when we pop a box.
        if($('CurrentSlideArea').offsetLeft == ($('PresentationCardArea').offsetLeft+1))
        {
            $('PresentationCardAreaScrollDiv').style.overflowY = 'hidden';
        }	
    },
    
    Hide: function LinksPanel$Hide() {
        $(this.ID).style.display = 'none';
        this.IsShowing = false;
    },
    
    _initializeHeight: function LinksPanel$_initializeHeight() {
        var containerHeight = this.GetDiv().getHeight() - $(this.ID + 'Heading').getHeight() - 2;
        $(this.ID + 'Container').setStyle({ height: containerHeight + 'px' });
        this._isHeightInitialized = true;
    },
    
    _onPlay: function LinksPanel$_onPlay(sender, args) {
    },
    
    _closeButtonOnMouseOver: function LinksPanel$_closeButtonOnMouseOver(sender, args) {
        this._closeButton.className = 'dialogCloseButtonOver';
    },
    
    _closeButtonOnMouseOut: function LinksPanel$_closeButtonOnMouseOut(sender, args) {
        this._closeButton.className = 'dialogCloseButtonNormal';
    }, 
     
    _closeButtonOnClick: function LinksPanel$_closeButtonOnClick(sender, args) {
        this._closeButton.className = 'dialogCloseButtonNormal'; //add onclick state?
        this.Hide();
    },   
    
    _appendLinkElement: function LinksPanel$_appendLinkElement(link, isEven) {
        var element = document.createElement('div');
        this._linksContainer.appendChild(element);
        element.className = (isEven) ? 'linksItem' : 'linksItemAlt';
        var a = document.createElement('a');
        element.appendChild(a);
        a.setAttribute('href', link.Url);
        a.setAttribute('target', 'new');
        a.setAttribute('title', link.Url);
        a.appendChild(document.createTextNode(link.Description));
    }
}

