rightClickWarning = "© All images copyright Randi Eaton"; function hasPath(sPath)
{
re = new RegExp("\/" + sPath + "(\/|$)");
return re.test(window.location)
}

if (hasPath("galleries"))
YD.addClass(document.body, "galleries");

/*HIGHLIGHT CURRENT PAGE ON NAV BAR*/

//------------------------------------------------------------------------------------------
// 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");
			}
		}
	}
});

// 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 ModifyText ()
{
  if (YD.hasClass(document.body, "gallery_10195408"))
  {
    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);