/* Code to change breadcrumbs, from nickname to Galleries */

// 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);

/* Code for separate galleries page without home slide show */

/* Code for the guest book  */


function ModifyText ()
{
  if (YD.hasClass(document.body, "gallery_9711638")) 
  {
    var objElement = YD.get("comment")
    if (objElement != null) 
    {
      var str = new String(objElement.innerHTML);
      str = str.replace(/\gallery/gi, 'guestbook');
      objElement.innerHTML = str;
    }
  }
}

YE.onAvailable("comment", ModifyText);

function hasPath(sPath)
{
re = new RegExp("\/" + sPath + "(\/|$)");
return re.test(window.location)
} 

if (hasPath("galleries"))
YD.addClass(document.body, "galleries");

//-------------------------------------------------------------------------
// Code to move the slideshow button to the same row 
// as the buy button
//-------------------------------------------------------------------------
function MyNewSlideshowInit(container, id, config)
{
    if (config && config.slideshowDiv && (config.slideshowDiv == "fsssButton"))
    {
        var cartDiv = YD.get("cartButtonsWrapper");
        if (cartDiv)
        {
            var ssDiv = YD.get("fsssButton");
            if (ssDiv)
            {
                ssDiv.parentNode.removeChild(ssDiv);
            }
            var newDiv = document.createElement("div");
            newDiv.id = "fsssButton";
            cartDiv.appendChild(newDiv);
            container = "cartButtonsWrapper";
        }
    }
    return (myOldSlideshowInit.apply(this, arguments));
}

var myOldSlideshowInit;
if (typeof(SM.buttons.slideshow) != "undefined")
{
    // hook the init function on the SM.buttons.slideshow object
    myOldSlideshowInit = SM.buttons.slideshow.prototype.init;
    SM.buttons.slideshow.prototype.init = MyNewSlideshowInit;
}
__________________

// 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);




