
    function _mainNavigation(id)
    {
        var _this = this;
        _this.element = document.getElementById(id);
        _this.topUL = null;
        _this.subNavDivs = [];

        for (var i = 0; i < _this.element.childNodes.length; i++)
        {
            if (_this.element.childNodes[i].nodeName == "UL")
                _this.topUL = _this.element.childNodes[i];
            else if (_this.element.childNodes[i].nodeType == 1 && _this.element.childNodes[i].className.substr(0, 15) == "Sub-Navigation ")
                _this.subNavDivs.push(_this.element.childNodes[i]);
        }

        for (var i = 0; i < _this.topUL.childNodes.length; i++)
        {
            if (_this.topUL.childNodes[i].nodeName == "LI")
            {
                if (window.attachEvent)
                    _this.topUL.childNodes[i].attachEvent("onmousemove", function (e) { _this._liMouseMove(e); });
                else if (window.addEventListener)
                    _this.topUL.childNodes[i].addEventListener("mousemove", function (e) { _this._liMouseMove(e); }, false);
            }
        }

        function _cancelBubble(e)
        {
            if (e.preventDefault) 
            {
                e.preventDefault();
                e.stopPropagation();
            } 
            else 
            {
                e.returnValue = false;
                e.cancelBubble = true;
            }
        }

        if (window.attachEvent)
            _this.element.attachEvent("onmousemove", function (e) { _cancelBubble(typeof event != "undefined" ? event : e); });
        else if (window.addEventListener)
            _this.element.addEventListener("mousemove", function (e) { _cancelBubble(e); }, false);

        if (window.attachEvent)
            document.attachEvent("onmousemove", function (e) { _this._closeAll(); });
        else if (window.addEventListener)
            document.addEventListener("mousemove", function (e) { _this._closeAll(); }, false);
    }
    _mainNavigation.prototype._closeAll = function ()
    {
        for (var i = 0; i < this.subNavDivs.length; i++)
            this.subNavDivs[i].style.display = "none";
    };
    _mainNavigation.prototype._liMouseMove = function (e)
    {
        var 
            _this = this,
            evt = typeof event != "undefined" ? event : e,
            _el = evt.srcElement ? evt.srcElement : evt.target,
            _pn = _el.parentNode;

        while (_pn)
        {
            if (_pn.nodeName == "LI")
            {
                var iIndex = 0;
                for (var i = 0; i < _this.topUL.childNodes.length; i++)
                {
                    if (_this.topUL.childNodes[i].nodeType == 1)
                    {
                        if (_this.topUL.childNodes[i] == _pn && _this.subNavDivs[iIndex].style.display != "block")
                        {
                            _this._closeAll();
                            _this.subNavDivs[iIndex].style.display = "block";
                            break;
                        }
                        iIndex++;
                    }
                }
                break;
            }
            _pn = _pn.parentNode;
        }
    };

    var facebookPoster = {};
    facebookPoster.postLink = function (link, callBack)
    {
        var 
            webService = new indigo.communication.webService(WEBSITE_BASE_URL + "/plugins/facebook/dataservice.asmx");

        if (typeof FB != "undefined" && FB)
        {
            FB.login(function (response)
            {
                var postResult = false;
                if (response.session)
                {
                    if (response.perms)
                        webService.getScalar("PostLinkToFeed", "FaceBookUserID=" + response.session.uid.toString().urlEncode() + "&FaceBookAccessToken=" + response.session.access_token.toString().urlEncode() + "&Link=" + link.urlEncode(), false, function (result) { postResult = result; });
                }
                if (callBack)
                    callBack(postResult);
            },
            {
                perms: "email,publish_stream,offline_access"
            });
        }
    };

