function hasPath(sPath)
{
re = new RegExp("\/" + sPath + "(\/|$)");
return re.test(window.location)
}

  
<!--
var debug = true;
function right(e) {
  if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)) return false;
  else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) {
    alert('Dui bu chi! Ni bu keyi!');
    return false;
  }

  return true;
}


YE.onAvailable('mapTitle', function() {this.innerHTML = 'Click a green icon below to view a photo & its corresponding location on the map!'}); 

YE.onAvailable('datesTitle', function() {this.innerHTML = 'Photo Timeline Search:'}); 

YE.onAvailable('subCatGalleryTitle', function() {this.innerHTML = ''});

YE.onAvailable('keywordsTitle', function() {this.innerHTML = 'Photo Keywords:'});

document.onmousedown=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
window.onmousedown=right;
//-->

function AddReferralCode()  {
  var links = this.getElementsByTagName("A");
  if (links && (links.length != 0)) {
    var smugLink = links.item(0);
    smugLink.href = "http://www.smugmug.com/?referrer=4U4iqv3FxrBgc";
  }
}
YE.onAvailable('footer', AddReferralCode);


//------------------------------------------------------------------------------------------
// Highlight the link in your navbar that matches the current page.
//
// See http://www.dgrin.com/showthread.php?t=141678 for documentation.
//------------------------------------------------------------------------------------------
YE.onContentReady("navcontainer", 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");
			}
		}
	}
});



// code to force any gallery page to Traditional view (even keyword and search pages)

function ForceTraditionalView()
{
    // if we're on a galleryPage, and the view isn't already traditional
    if (!YD.hasClass(document.body, "traditional"))
    {
        var url = window.location.toString();
        var re = new RegExp(/forceView=(\d+)/);
        var match = re.exec(url);
        var curTime = new Date();
        if (match && (match.length > 1))
        {
            var prevTime = new Date();
            prevTime.setTime(match[1]);
            // check to see if we've already done this in the last 60 seconds to avoid loops
            if (curTime - prevTime < (60*1000))
            {
                return;
            }
        }
        var postData = 'tool=setCookie&value=4&type=Template';
        var broken = function() {};
        var reloadPage = function() 
        {
            var newUrl;
            if (match)
            {
                newUrl = url.replace(/forceView=\d+/, "forceView=" + curTime.getTime());
            }
            else if (url.indexOf("?") != -1)
            {
                newUrl = url.replace("?", "?forceView=" + curTime.getTime() + "&");
            }
            else if (url.indexOf("#") != -1)
            {
                newUrl = url.replace("#", "?forceView=" + curTime.getTime() + "#");
            }
            else
            {
                newUrl = url + "?forceView=" + curTime.getTime();
            }
            window.location.replace(newUrl);
        };
        var callback = {
            success: reloadPage,
            failure: broken,
            scope: this
        };
        YAHOO.util.Connect.asyncRequest('POST','/rpc/settings.mg', callback, postData);
    }
}

// only trigger this function if there is a stylebar because that means the gallery isn't locked into a particular view
YE.onAvailable("viewingStylesButton", ForceTraditionalView);


// -------------------------------------------------------------------------------------------
// 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
// -------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------------------------------------------
// 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
// 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
// ------------------------------------------------------------------------------------------------------------------------------------

// This is a script to combine the categories with the gallery listing to have just one continuous listing of thumbs
YE.onContentReady("subcategoriesBox", CombineCategoriesWithGalleries);

function IsArrayEmpty(testVal)
{
    return(!testVal || (testVal.length == 0));
}

function CombineCategoriesWithGalleries()
{
    // get miniBoxes in the subcategoriesBox object
    var miniBoxes = YD.getElementsByClassName("miniBox", "div", this);
    // get target galleriesBox object
    var galleriesObj = document.getElementById("galleriesBox");
    var galleryMiniBoxes = new Array;

    // now find the right miniBox in the galleriesBox in order to insert the sub-categories
    if (galleriesObj)
    {
        galleryMiniBoxes = YD.getElementsByClassName("miniBox", "div", galleriesObj);
    }
    
    // if we don't have everything we need, then return without doing anything
    if (!galleriesObj || IsArrayEmpty(miniBoxes) || IsArrayEmpty(galleryMiniBoxes) || (window.location.hash == "#stop"))
    {
        this.style.display = "block";        
        return;
    }
    
    // move all the sub-categories over to the gallery listing
    for (var i in miniBoxes)
    {
        miniBoxes[i].parentNode.removeChild(miniBoxes[i]);
        galleryMiniBoxes[0].parentNode.insertBefore(miniBoxes[i], galleryMiniBoxes[0]);
    }
}

/*-------------------------- Hide Category --------------------------------*/
function delCategory() {
re = /\/(Portfolio|Unlisted)$/;
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);
