function hasPath(sPath) {
re = new RegExp("\/" + sPath + "(\/|$)");
return re.test(window.location)
}

if (hasPath("find"))
YD.addClass(document.body, "find");  

function AddReferralCode() {
var links = this.getElementsByTagName("A");
if (links && (links.length != 0)) {
var smugLink = links.item(0);
smugLink.href = "http://www.smugmug.com/?referrer=DYNUJftajsrI6";
}
}
YE.onAvailable('footer', AddReferralCode);


rightClickWarning = "All photos are property and copyrigthed by Torben Gregersen. All rights reserved. Unauthorized use is prohibited."; 
// fix the pesky pipes

YE.onAvailable("cobrand_footer", function() {this.innerHTML = this.innerHTML.replace(/\what are feeds\?/gi, '');});

function ModifyText ()
{
  if (YD.hasClass(document.body, "gallery_7720220"))
  {
    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);

//-------------------------------------------------------------
// Clear links and thus clickability from photos in journal galleries
//-------------------------------------------------------------

YE.onDOMReady(ClearLinksFromMany);

function ClearLinksFromMany()
{
    var listOfGalleries = [
        "7750886",             /*  About Me*/
        "9999999",             /* Limited Edition Colour Portrait Collection*/
        "9999999",             /* Limited Edition Collection colour Landscape*/
        "9999999",             /* Limited Edition Animal Collection*/
        "9999999",             /* Limited Edition BW Portrait Collection*/
    ];
    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");
        }
    }
}

//------------------------------------------------------------------------------------
// Move share and slideshow buttons to the cart line
//-------------------------------------------------------------------------------------

YE.onContentReady("shareButton", MoveToCartDiv);
YE.onContentReady("slideshowButton", MoveToCartDiv);

function MoveToCartDiv()
{
	MoveObjToDiv(this, "cartButtonsWrapper");
}

function MoveObjToDiv(sourceObj, destDiv)
{
	var destDivObj = document.getElementById(destDiv);	// get the object for the dest div
	if (sourceObj && destDivObj)
	{
		sourceObj.parentNode.removeChild(sourceObj);	// remove object from it's current parent
		destDivObj.appendChild(sourceObj);				// add it to the new parent
	}	
}

// Change 'gallery comment' to 'guestbook comment' on the guestbook page
function ModifyText ()
{
  if (YD.hasClass(document.body, "gallery_7720230"))
  {
    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);

// e-mail
function norobotmail(aUser, aDomain) { document.location = "mailto:" + aUser + "@" + aDomain; }


