rightClickWarning = "Photos are Copyright Kyle Lamy - Kyle Lamy Photography. All rights reserved. Unauthorized use is prohibited."; /**********Change Comment Text on Guestbook page *********************/
function ModifyText () 
{
  if (YD.hasClass(document.body, "gallery_2421736")) 
  {
    var objElement = YD.get("comment")
    if (objElement != null) 
    {
      var str = new String(objElement.innerHTML);
      str = str.replace(/\gallery/gi, 'guestbook');
      objElement.innerHTML = str;
    }
  }

  if (YD.hasClass(document.body, "gallery_2421659")) 
  {
    var objElement = YD.get("comment")
    if (objElement != null) 
    {
      var str = new String(objElement.innerHTML);
      str = str.replace(/\gallery/gi, 'travel journal');
      objElement.innerHTML = str;
    }
  }
}

YE.onAvailable("comment", ModifyText);
/*******************End Change Comment ********************************/

//------------------------------------------------------------------------------------------
// Highlight the link in your navbar that matches the current page.
//
// See http://www.dgrin.com/showthread.php?t=141678 for documentation.
//------------------------------------------------------------------------------------------
YE.onContentReady("nav_ul", function ()
{
	function AddTrailingSlash(str)
	{
		if (str.search(/\/$/) == -1)
		{
			str = str + "/";
		}
		return(str);
	}
	
	function StripDomainAndHash(oldStr)
	{
		var str = oldStr.replace(/#.*$/, "");	// get rid of hash value
		str = AddTrailingSlash(str);		// make sure it always ends in a slash
		str = str.replace(/^https?:\/\/[^\/]*/, "");	// get rid of domain on the front
		return(str);
	}
	
	var links = this.getElementsByTagName("a");
	if (links && (links.length > 0))
	{
		var pageURL = StripDomainAndHash(window.location.href);
	
		var foundExactMatch = false;
		var partialIndex = -1;		// index of best partial match
		var partialLength = 0;		// length of the best partial match
		var galleriesIndex = -1;	// index of the /galleries link
		
		// check each link for an href match with our current page
		for (var i = 0; i < links.length; i++)
		{
			var testLink = StripDomainAndHash(links[i].href); // relative link will be turned into absolute link here
			if (testLink == pageURL)
			{
				YD.addClass(links[i], "navCurrentPage navCurrentPageExact");
				YD.addClass(links[i].parentNode, "navCurrentPageParent navCurrentPageParentExact");
				foundExactMatch = true;
				break;
			}
			// if testLink is not the top level (don't want to do partial matches for top level)
			else if (testLink != "/")
			{
				// if the testLink is contained within the pageURL 
				// (e.g. the current page link is longer than the navbar link and starts with it),
				// remember it as a partial match
				if (pageURL.indexOf(testLink) == 0)
				{
			// save the longest partial match (assuming it to be the most specific)
					if (testLink.length > partialLength)
					{
						partialIndex = i;
						partialLength = testLink.length;
					}
				}
				else if (testLink == "/galleries/")
				{
					galleriesIndex = i;
				}
			}
		}
		if (!foundExactMatch)
		{
			// since we had no exact match, check for partial matches
			if (partialIndex != -1)
			{
				YD.addClass(links[partialIndex], "navCurrentPage navCurrentPagePartial");
				YD.addClass(links[partialIndex].parentNode, "navCurrentPageParent navCurrentPageParentPartial");
			}
			// if no exact match and no partial matches 
			// and we did have a galleries link 
			// and we're on a gallery page or a category or subcategory page
			// then, mark the galleries link
			else if ((galleriesIndex != -1) && (YD.hasClass(document.body, "galleryPage") || YD.hasClass(document.body, "category")))
			{
				YD.addClass(links[galleriesIndex], "navCurrentPage navCurrentPageGallery");
				YD.addClass(links[galleriesIndex].parentNode, "navCurrentPageParent navCurrentPageParentGallery");
			}
		}
	}
});


// ----------------------------------------------------------------------------------------------
// 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];
		}
	}
	// 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 +="galleries";						// can be changed to point to a category
	str += parms;							// put parms back on
	targetTag.href = str;
	targetTag.innerHTML = "Galleries";		// can be changed to whatever you want the top level to be called
}

YE.onContentReady("breadCrumbTrail", AdjustBreadcrumb);

// END OF Galleries breadcrumb change

// -------------------------------------------------------------------------------------------
// Start of Code to auto-open a gallery that is all alone in a category
//
// If page is a category page or a sub-category page and there is only one 
// thumbnail on the page (whether it's a sub-category or a gallery thumb)
// we will auto-open it.
// -------------------------------------------------------------------------------------------
YE.onContentReady("category", function()
{
    try
    {
        // if there are any parameters following the category URL, then don't auto-open
        if (window.location.search.length != 0) return;
        var boxes = Sizzle(".boxBottom .miniBox", this);
        // if one and only one miniBox, then just open it
        if (boxes.length == 1)
        {
            var links = Sizzle("a", boxes[0]);
            window.location.replace(links[0].href + "?ao=0");
        }
    } catch (e) {}
});

// on a gallery page, add search params to each cat/sub-cat link in the breadcrumb 
// to prevent auto-open when we navigate back up the params
YE.onContentReady("breadCrumbTrail", function()
{
    if (YD.hasClass(document.body, "galleryPage"))
    {
        var navs = Sizzle("a.nav", this);
        for (var i = 1; i < navs.length; i++)
        {
            if (navs[i].href.indexOf("?") == -1)
            {
                navs[i].href += "?ao=0";
            }
        }
    }
});

// -------------------------------------------------------------------------------------------
// End of Code to auto-open a gallery that is all alone in a category
// -------------------------------------------------------------------------------------------



function AddReferralCode()  {
  var links = this.getElementsByTagName("A");
  if (links && (links.length != 0)) {
    var smugLink = links.item(0);
    smugLink.href = "http://www.smugmug.com/?referrer=EWOZztVttpmZY";
  }
}
YE.onAvailable('footer', AddReferralCode);

/*************Disable Guestbook Picture click *************************/

/*************************************************/
/* Disable hover/linking in the Guestbook Image  */
/*************************************************/
function RemoveGuestbookLink() {
  if (window.AlbumID && (window.AlbumID == "2421736")) //
  removeLinkFromImg();
}

function removeLinkFromImg() {
  oList = YD.getElementsByClassName("photo", "div");

  for (i=0; i < oList.length ; i++) {
    if (oList[i].childNodes) {
      oList[i].firstChild.removeAttribute("href");
      oList[i].firstChild.firstChild.removeAttribute("alt");
      oList[i].firstChild.firstChild.removeAttribute("title");
    }
  }
}

/*************End Disable Guestbook Picture Click**********************/



/******************Share Facebook Button *****************************/
var pos = window.document.URL.indexOf("gallery");

if (pos > 0 && SM) {
        var thisURL = window.document.URL ;
	SM.buttons.FacebookButton = new YAHOO.widget.Button({
		id: 'Share on Facebook',
		label: 'Share on Facebook',
		container: 'altViews',
		type: 'link',
		href: 'http://www.facebook.com/share.php?u='+thisURL+'&t=SmugMug+Album',
		target: '_blank',
		className: 'sm-button sm-button-small facebookButton glyphButton menuButton share_button'
	});

}

/**************End Share Facebook Button *****************************/