function hasPath(sPath) {
  re = new RegExp("\/" + sPath + "(\/|$)");
  return re.test(window.location)
}

if (hasPath("galleries")) {
  YD.addClass(document.body, "galleries");
}

if (hasPath("featured")) {
  YD.addClass(document.body, "featured");
}

YE.onContentReady('categoryTitle', function() {this.innerHTML = "<img src='/photos/58171390-O.png'>"});
YE.onContentReady('featuredTitle', function() {this.innerHTML = "<img src='/photos/85534063-O.png'>"});


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=Bhl3oSIF5zVho";
          }
      }
}
YE.onAvailable('footer', AddReferralCode);

function hackBreadcrumb() {
  re1 = /href="(http:\/\/(\S+.smugmug.com))?(\/)?"/;
  re2 = /David Parry/;
  //bc = $('breadcrumb');
  this.innerHTML = this.innerHTML.replace(re1, "href='/galleries/'");
  this.innerHTML = this.innerHTML.replace(re2, "Galleries");
}

YE.onContentReady('breadcrumb', function() {
 for (var i in this.childNodes) {
   if (this.childNodes[i].tagName == "A") {
     this.childNodes[i].href="/galleries"; 
     break;
   }
  }
});


function navSelect(sValue) {
  if (!DP.smugmug.isHomepage) {
    window.location = "/" + sValue;
    return;
  }

  YD.removeClass(document.body, "galleries");
  YD.removeClass(document.body, "featured");
  YD.removeClass(document.body, "about");

  if (sValue == "")
    return;

  YD.addClass(document.body, sValue);
}