function hasPath(sPath)
{
re = new RegExp("\/" + sPath + "(\/|$)");
return re.test(window.location)
}

if (hasPath("galleries"))
YD.addClass(document.body, "galleries");




YE.onContentReady("subcategoriesBox", swapBoxes);

if (YD.hasClass(document.body, "singleImage"))
  fixPhotoNav();


if (hasPath("featured"))
 YAHOO.util.Dom.addClass(document.body, "featured");



if (hasPath("keywordPage"))
 YAHOO.util.Dom.addClass(document.body, "keywordPage");




if (hasPath("galleries"))
  YAHOO.util.Dom.addClass(document.body, "galleries");





var objElement = document.getElementById("galleryTitle")
if (objElement != null)
objElement.innerHTML = objElement.innerHTML.replace('Galleries','Albums');





var objElement = document.getElementById("subCatGalleryTitle")
if (objElement != null)
objElement.innerHTML = objElement.innerHTML.replace('sub-categories','Categories');



var objElement = document.getElementById("subCatGalleryTitle")
if (objElement != null)
objElement.innerHTML = objElement.innerHTML.replace('Galleries','Albums');


var objElement = document.getElementById("categoryTitle")
if (objElement != null)
objElement.innerHTML = objElement.innerHTML.replace('Gallery','Jaki Good Photography');

var objElement = document.getElementById("categoryTitle")
if (objElement != null)
objElement.innerHTML = objElement.innerHTML.replace('Categories','Proofs');


function ModifyText ()
{
  if (YD.hasClass(document.body, "gallery_10572700")) 
  {
    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);







 
if (hasPath("find")) { 
YD.addClass(document.body, "find"); 
loadSmugMaps(); 
} 





YE.onDOMReady(AddItemsToBuyButton);

function AddItemsToBuyButton()
{
    var buyButton = YAHOO.widget.Button.getButton("buyButton");
    if (buyButton)
    {
        var newBuyItem = { text: "View Catalog", url: "http://smugmug.com/prints/catalog/B", target: "_blank"};
        buyButton.getMenu().addItem(newBuyItem);
	var newBuyItem2 = { text: "How to Order", url: "http://smugmug.com/prints/catalog/B#Help", target: "_blank"};
        buyButton.getMenu().addItem(newBuyItem2);
    }
}


YE.onDOMReady(ClearLinksFromMany);

function ClearLinksFromMany()
{
    var listOfGalleries = [
        "3215731",             /* Investment */
        "3215734",             /* About */
        "3215732",             /* Testimonials */
        "3042466"             /* Contact */
        

 
    ];
    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 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];
		}
	}
	// if there's a ?xxxx parameter, make sure that stays at the end
	var str = targetTag.href;
	var parms = "";
	var pos = str.search(/\?/);
	if (pos != -1)
	{
		parms = str.substr(pos);
		str = str.substr(0, pos);
	}
	// make sure URL ends with a slash
	if (str.search(/\/$/) == -1)
	{
		str += "/";
	}
	str +="";						// can be changed to point to a category
	str += parms;							// put parms back on
	targetTag.href = str;
	targetTag.innerHTML = "";		// can be changed to whatever you want the top level to be called
}

YE.onContentReady("breadCrumbTrail", AdjustBreadcrumb);




