function setPageTitles() {  // Set displayed page titles for specific categories
  if (YD.hasClass(document.body, "category_Cars")) {
    document.title = "Automotive Photography by Bill Gerrard"
    YE.onAvailable('subCatGalleryTitle', function() {this.innerHTML = 'Calendars'});
    YE.onAvailable('galleryTitle', function() {this.innerHTML = 'Automotive Photography Galleries'});
  }
  if (YD.hasClass(document.body, "category_Temple_Vista")) {
    document.title = "Temple Vista - LDS Temple and Historical Site Prints and Gifts";
  }
  if (YD.hasClass(document.body, "category_Family")) {
    document.title = "Family Galleries";
  }
}

// Set displayed page title
document.title = "Primary Colors / Photography by Bill Gerrard";

// change 'featured galleries' to 'recent galleries'
//YE.onAvailable('featuredTitle', function() {this.innerHTML = 'Recent Galleries <a //class="nav" href="/recent">more...</a>'});

// Change most popoular galleries link to force a style
YE.onAvailable('popularTitle', function() {this.innerHTML = 'Most Popular Photos <a class="nav" href="http://gallery.primarycolors.com/popular">more...</a>'});

// old link for above broken by security change
//href="http://gallery.primarycolors.com/homepage/templatechange.mg?TemplateID=7&origin=http://gallery.primarycolors.com/popular">more...</a>'});

// Change 'this gallery requires a password to continue' text

if (YD.hasClass(document.body, "passwordPage")) {
  YE.onAvailable('title', function() {this.innerHTML = 'Please enter a password'});
}

rightClickWarning = "This photo is copyright by Bill Gerrard/Primary Colors Photography. All rights reserved. Unauthorized use is prohibited."


// Add referral code to smugmug link
function AddReferralCode()  {
   var footerDiv = YD.get("footer");
   if (footerDiv)  {
     var links = footerDiv.getElementsByTagName("A");
     if (links && (links.length != 0)) {
       var smugLink = links.item(0);
       smugLink.href = "http://www.smugmug.com/?referrer=1MN7Nsyj5gsqM";
     }
  }
}
YE.onAvailable('footer', AddReferralCode);

addEvent(window, "load", delHover);
function delHover() {
  imgTags = document.getElementsByTagName("img");
  for (i=0; i<imgTags.length; i++) {
    imgTags[i].title = "";
    imgTags[i].alt = "";
  }
}

// smartTruncate by Bill Gerrard, http://www.PrimaryColors.com
// Truncate to maximum of maxLen characters on nearest word boundary, append ellipsis
function smartTruncate(sText, maxLen) {
  if (sText.length <= maxLen) {
    return sText;
  } else {
    var words = sText.split(" ");
    var tmpText = "";
    var i = 0;

    while(i < words.length-1) {
      outText = tmpText;
      tmpText += words[i] + " "; 
      if (tmpText.length > maxLen) {
          break;
      }
      outText = tmpText;
      i++;
    }
    return outText.substring(0,outText.length-1) + "&nbsp;...";
  }
}

//
// expandGalleryDescription - Payne Cheng
//
function expandGalleryDescription() {
  re1 = /^([^:]*)\s*:\s*(.*)/;
  re2 = /^(.*)\s*\.\.\.\s*(.*)/;
  divTags = document.getElementsByTagName("div");
  for (i=0; i<divTags.length; i++)
  {
    if (divTags[i].className == "miniBox")
    {
      dTags = divTags[i].getElementsByTagName("div");
      pTags = divTags[i].getElementsByTagName("p");
      aTags = dTags[0].getElementsByTagName("a");
      iTags = aTags[0].getElementsByTagName("img");
      if ( re1.exec(iTags[0].getAttribute("title")) )
      {
        $desc = RegExp.$2;
      }
      if ( pTags[1] && re2.exec(pTags[1].innerHTML)             ) 
      {
        pTags[1].innerHTML = smartTruncate($desc + RegExp.$2, 150);
      }
    }
  }
}

if (YD.hasClass(document.body, 'homepage')) { expandGalleryDescription(); }

function springClean() {
  if (YD.hasClass(document.body, 'loggedIn'))
    return;

  if (YD.hasClass(document.body, 'category_Cars'))
    return;

  var mBox, gBox, bBox, scBox;

  scBox = YD.get('subcategoriesBox');
  gBox = YD.get('galleriesBox');

  if (scBox && gBox) {
    var oLst = YD.getElementsByClassName('miniBox', 'div', scBox);
    for (i = 0; i < oLst.length; i++) {
      mBox = oLst[i].parentNode.removeChild(oLst[i]);
      bBox = gBox.getElementsByTagName('div')[1];//childNodes[3];
      bBox.insertBefore(mBox, bBox.childNodes[bBox.childNodes.length-1]);
    }
    scBox.parentNode.removeChild(scBox);
  } else {
    YE.onAvailable('subCatGalleryTitle', function(){this.innerHTML = this.innerHTML.replace(/Sub\-Categories/, 'Galleries')});
  }
}


<!-- Hide Categories -->
function delCategory() {

  if (YD.hasClass(document.body, 'loggedIn')) // don't run when logged in
    return;

  re = /\/Family|Sessions$/i;

  var oList = YD.getElementsByClassName('miniBox', 'div', this);

  for (i = 0; i < oList.length; i++) {
    if (re.test(oList[i].getElementsByTagName('a')[0].href))
      oList[i].parentNode.removeChild(oList[i]);
  }
}
YE.onContentReady('categoriesBox', delCategory);
<!-- End Hide Categories -->


<!-- Hide Subcategories -->
function delsubCategory() {

  if (YD.hasClass(document.body, 'loggedIn')) // don't run when logged in
    return;

  re = /\/(Temple%20Vista\/776948)$/;

  var oList = YD.getElementsByClassName('miniBox', 'div', this);

  for (i = 0; i < oList.length; i++) {
    if (re.test(oList[i].getElementsByTagName('a')[0].href))
    oList[i].parentNode.removeChild(oList[i]);
  }
}
YE.onContentReady('subcategoriesBox', delsubCategory);
<!-- End Hide Subcategories -->


<!-- insert a download image button in Smugmug view when originals are enabled -->
onPhotoShow.subscribe(ProcessDownloadButton);

function IsSmugmugView()
{
	return(YD.hasClass(document.body, "smugmug"));
}


function ProcessDownloadButton()
{
    if (IsSmugmugView())
    {
        if (photoInfo[ImageID].albumOriginals && (photoInfo[ImageID].Format !== "MP4"))
        {
            InsertDownloadButton("cartButtonsWrapper");
        }
    }
}

function InsertDownloadButton(parentId)
{
    // now add the download button
    var parentDiv = document.getElementById(parentId);
    var downloadButton = document.getElementById("downloadButtonId");
    if (parentDiv && !downloadButton)
    {
        var downloadButtonInfo =
        {
            id: "downloadButtonId",
            label: "Download Image...",
            container: parentDiv,
            type: "button",
            className: "sm-button sm-button-small themesButton glyphButton",
            onclick: { fn: InitiateDownloadImage }
        };
        
        var dButtonObj = new YAHOO.widget.Button(downloadButtonInfo);
    }
}

function InitiateDownloadImage()
{
    // construct the download URL
    window.location = "/photos/" + ImageID + "_" + ImageKey + "-D.jpg";
}
<!-- end of insert a download image button in Smugmug view when originals are enabled -->

//-------------------------------------------------------------------------
// 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;
}
