function redirectPath() { 
  re = /((www.)?ralphmeznar.smugmug.com)/; 
  tmp = window.location.href; 
  if (re.test(tmp)) { 
    tmp = tmp.replace(re, 'www.ralphmeznar.com'); 
    window.location.href = tmp; 
  } 
}
redirectPath();  



// =====Guestbook comments text===


function ModifyText ()
{
 if (YD.hasClass(document.body, "gallery_9421931"))
 {
   var objElement = YD.get("comment")
   if (objElement != null)
   {
     var str = new String(objElement.innerHTML);
     str = str.replace(/\gallery/gi, 'guestbook');
     objElement.innerHTML = str;
   }
 }
} 

function ModifyText ()
{
  if (YD.hasClass(document.body, "gallery_9421931"))
  {
    var objElement = YD.get("comment")
    if (objElement != null)
    {
      var str = new String(objElement.innerHTML);
      str = str.replace(/Gallery Comments/, 'Guestbook Comments');
      objElement.innerHTML = str;
    }
  }
}

YE.onAvailable("comment", ModifyText);


// =====Start 2nd Home Page/Galleries Page===

function hasPath(sPath)
{
re = new RegExp("\/" + sPath + "(\/|$)");
return re.test(window.location)
}

if (hasPath("galleries"))
YD.addClass(document.body, "galleries");


//-------------------------------------------------------------
// Clear links and thus clickability from photos in journal galleries
//-------------------------------------------------------------

YE.onDOMReady(ClearLinksFromMany);

function ClearLinksFromMany()
{
    var listOfGalleries = [
        "9763280",             /*  services*/
        "9421931",            /* guestbook */
        "10016981",            /* pregnancy */
        "8122279",            /* How Do I Buy */
        "7831940"            /* FAQ - no comma after the last entry in the list */
    ];
    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");
        }
    }
}



// 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];
       }
   }
   // make sure URL ends with a slash
   var str = targetTag.href;
   if (str.search(/\/$/) == -1)
   {
       str += "/";
   }
   str +="galleries";
   targetTag.href = str;
   targetTag.innerHTML = "Galleries";
}

YE.onContentReady("breadCrumbTrail", AdjustBreadcrumb);

function RemoveGalleryWord()
{
   this.innerHTML = this.innerHTML.replace(/ Galleries$| Sub-Categories$/, "");
}

YE.onAvailable("subCatGalleryTitle", RemoveGalleryWord);
YE.onAvailable("galleryTitle", RemoveGalleryWord);

function delHover() {
   oLst = YD.getElementsBy(function(el) {return (YD.hasClass(el,'imgBorder') || YD.hasClass(el,'imgBorderOn'))},'img');
   for (i=0; i < oLst.length ; i++) {
       if (oLst[i].title && oLst[i].title != '') oLst[i].title = '';
       if (oLst[i].alt && oLst[i].alt != '') oLst[i].alt = '';
   }
}
YE.onContentReady('bodyWrapper', function() {if (!YD.hasClass(document.body, 'smugmug_ajax')) delHover()});
onPhotoShow.subscribe(function(){YE.onAvailable('mainImage', delHover)}); 

//------------------------------------------------------------------------------------
// Move share button to the cart line
//-------------------------------------------------------------------------------------

YE.onContentReady("shareButton", 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
   }    
}

//-------------------------------------------------------------------------
// Code to move the slideshow button to the same row
// as the buy button
//-------------------------------------------------------------------------
function MyNewSlideshowInit(container, id, config)
{
   if (config && config.slideshowDiv && (config.slideshowDiv == "fsssButton"))
   {
       var cartDiv = YD.get("cartButtonsWrapper");
       if (cartDiv)
       {
           var ssDiv = YD.get("fsssButton");
           if (ssDiv)
           {
               ssDiv.parentNode.removeChild(ssDiv);
           }
           var newDiv = document.createElement("div");
           newDiv.id = "fsssButton";
           cartDiv.appendChild(newDiv);
           container = "cartButtonsWrapper";
       }
   }
   return (myOldSlideshowInit.apply(this, arguments));
}

var myOldSlideshowInit;
if (typeof(SM.buttons.slideshow) != "undefined")
{
   // hook the init function on the SM.buttons.slideshow object
   myOldSlideshowInit = SM.buttons.slideshow.prototype.init;
   SM.buttons.slideshow.prototype.init = MyNewSlideshowInit;
}

