  var galleryRedirectTable = 
 {
     3281935 : "http://redcross.smugmug.com/",
     3281945 : "http://castillo.smugmug.com/gallery/3280922",
     3281946 : "http://castillo.smugmug.com/gallery/3281140"
 };
 
 function CheckRedirects()
 {
  if (! YD.hasClass(document.body, 'loggedIn'))
     {
         // get the path from the current URL, 
         // convert it to lowercase and remove the leading slash
         var path = window.location.pathname.toLowerCase().substr(9); 
         
         var newURL = galleryRedirectTable[path];        // look it up in our table

         // if we found it in the table && newURL is different than where we are
         if (newURL && (newURL != window.location))
         {
             window.location.replace(newURL);        // go to the new URL
         }
     }
 }

function addKeywordFeatured(text, description, keyword, thumbUrl)
{
  if (IsClass("homepage"))
  {
    divTag = document.getElementById("categoriesBox");

    if (divTag)
    {
      divTags = divTag.getElementsByTagName("div");

      for (i=0; i<divTags.length; i++)
      {
        if (divTags[i].className == "boxBottom")
        {
          miniBox = document.createElement("div");
          miniBox.className = "miniBox";

          photoBox = document.createElement("div");
          photoBox.className = "photo";
          miniBox.appendChild(photoBox);

          photoLink = document.createElement("a");
          photoLink.setAttribute("href", "/keyword/" + keyword);
          photoBox.appendChild(photoLink);

          photoImg = document.createElement("img");
          photoImg.setAttribute("border", "0");
          photoImg.setAttribute("alt", text);
          photoImg.setAttribute("title", text);
          photoImg.src = thumbUrl;
          photoImg.className = "imgBorder";
          photoLink.appendChild(photoImg);

          albumTitle = document.createElement("p");
          albumTitle.className = "albumTitle";
          miniBox.appendChild(albumTitle);

          albumLink = document.createElement("a");
          albumLink.className = "nav";
          albumLink.setAttribute("href", "/keyword/" + keyword);
          albumTitle.appendChild(albumLink);

          albumLinkText = document.createTextNode(text);
          albumLink.appendChild(albumLinkText);
          
          albumDescription = document.createElement("p");
          albumDescription.className = "description";
          miniBox.appendChild(albumDescription);

          albumDescriptionText = document.createTextNode(description);
          albumDescription .appendChild(albumDescriptionText);

          spacerDiv = document.createElement("div");
          spacerDiv.className = "spacer";
          miniBox.appendChild(spacerDiv);

          divTags[i].insertBefore(miniBox, divTags[i].childNodes[1]);


          break;
        }
      }
    }
  }
}


function IsClass(sClass) 
{
  sClassName = document.body.className;

  re = new RegExp(sClass + "( |$)") 

  if (!sClassName)
    return false;
  return re.test(sClassName);
}
  
function OnLoadHandler()
{
    // modify the addKeywordFeatured function call to customize your keyword gallery
    // Variables are (in order): the title of your gallery, the description of your gallery, 
    //                           the keyword to find the pictures, the path to the thumbnail for the gallery.

  	addKeywordFeatured('Favorites', 'A few of my favorite pictures', 'favorites', 'photos/139855196-Ti.jpg');   
}
  

