YE.onDOMReady(ClearLinksFromMany);

function ClearLinksFromMany()
{
    var listOfGalleries = [
        "5316061",             /* Football Gallery*/
        "5315997",             /* Hockey Gallery*/
        
    ];
    if (window.AlbumID)
    {
        for (var i in listOfGalleries)
        {
            if (window.AlbumID == listOfGalleries[i])
            {
                removeLinkFromImg();
                break;
            }
        }
    }
}

function removeLinkFromImg() 
{
    var oList = YD.getElementsByClassName("photo", "div");
    for (var i=0; i < oList.length; i++)  
    {
        var aTags = oList[i].getElementsByTagName("a");
        for (var j=0; j < aTags.length; j++)
        {
            // get rid of the href on the <a> tag
            aTags[j].removeAttribute("href");
            // get rid of the alt and title tags on the <img> tag
            aTags[j].firstChild.removeAttribute("alt");
            aTags[j].firstChild.removeAttribute("title");
        }
    }
}






function RemoveGalleryWord()
{
    this.innerHTML = this.innerHTML.replace(/ Galleries$| Sub-Categories$/, "");
}

YE.onAvailable("subCatGalleryTitle", RemoveGalleryWord);
YE.onAvailable("galleryTitle", RemoveGalleryWord);





// Script to change the breadcrumb link to your homepage to point to your galleries page instead of your slideshow
// It also changes that link to say "Galleries" instead of your user name

function AdjustBreadcrumb()
{
    // there are something like six different forms of the breadcrumb including search and keyword and date and communities, categories and galleries that we have to make this work for
    var tags = YD.getElementsByClassName("nav", "a", this);        // get all the <a> tags with class "nav"
    var filteredTags = new Array;
    // filter out any that aren't at the top level in the breadCrumbTrail (this gets rid of the relatedDate tags)
    for (var i in tags)
    {
        if (tags[i].parentNode == this)
        {
            filteredTags.push(tags[i]);
        }
    }
    if (filteredTags.length == 0)
    {
        return;
    }
    // default to targeting the first filtered tag
    var targetTag = filteredTags[0];
    
    // see if we have a community here
    if (filteredTags.length > 1)
    {
        // if we have a community here, then the user top level is in the 2nd position
        if (filteredTags[0].href.search(/\/community\//) != -1)
        {
            targetTag = filteredTags[1];
        }
    }
    // make sure URL ends with a slash
    var str = targetTag.href;
    if (str.search(/\/$/) == -1)
    {
        str += "/";
    }
    str +="galleries";
    targetTag.href = str;
    targetTag.innerHTML = "Galleries";
}

YE.onContentReady("breadCrumbTrail", AdjustBreadcrumb);








function hasPath(sPath)
{
re = new RegExp("\/" + sPath + "(\/|$)");
return re.test(window.location)
}

if (hasPath("galleries"))
YD.addClass(document.body, "galleries");






// Here we can remove items from any drop-down menu by just passing:
//    the ID of the YUI button that holds the menu
//    the function that starts this all
//    The array of menu items to remove (it must be an exact text match)

YE.onContentReady("shareButton", RemoveMenuItemsFromButton, ["Get a Link", "Social Bookmarking"]);

function RemoveMenuItemsFromButton(textItemsToRemoveArray)
{
    // now that the object is created, we can register an interest in the beforeShowEvent
    // we can't modify the menu until then because of lazyLoading
    var menu = YAHOO.widget.Button.getButton(this.id).getMenu();
    menu.beforeShowEvent.subscribe(RemoveMenuItems, textItemsToRemoveArray);
    
    function RemoveMenuItems(event, args, data)
    {
        // called in the context of the menu
        try
        {
            // for coding efficiency in lookup, lets change the passed in array to a hash table
            var textItemsToRemove = {};
            for (var j in data)
            {
                textItemsToRemove[data[j]] = true;
            }
            
            // get the list of menu items in our menu
            var menuItems = this.getItems();
            
            // look through each menu item to see if it matches anything in our stylesToRemove array
            for (var i in menuItems)
            {
                // get the text value from the menu item
                var text = menuItems[i].cfg.config.text.value;
                // check to see if this menu item is in our remove table
                if (textItemsToRemove[text])
                {
                    // because of problems with lazy loading and deferred creation of objects, we cannot just remove the menu item here
                    // so, instead we just hide it
                    YD.setStyle(menuItems[i].id, 'display', 'none');
                }
            }
        } catch (e) {}        // catch any exceptions and ignore them - errors will just cause the styles not to get removed, but not affect any other scripts
    }
}
