YE.onAvailable('featuredTitle', function() {this.innerHTML = 'Current Galleries'}); 
YE.onAvailable('categoryTitle', function() {this.innerHTML = 'S.D. Mack Photo Galleries and Archives'});

document.onkeyup = pageNav;

function pageNav(e)
{
 if (!e) 
   e = window.event;

 if (e.keyCode == 37)
 {
   if (!YAHOO.util.Dom.hasClass(document.body, "galleryPage"))
     return;

   oNavBar = document.getElementById("albumNav_top");
   oNavList = YAHOO.util.Dom.getElementsByClassName("nav", "a", oNavBar);
   for (var i=0; i < oNavList.length ; i++)
   {
     if (oNavList[i].innerHTML == "&lt;")
       window.location = oNavList[i].href;
   }
 }

 if (e.keyCode == 39)
 {
   if (!YAHOO.util.Dom.hasClass(document.body, "galleryPage"))
     return;

   oNavBar = document.getElementById("albumNav_top");
   oNavList = YAHOO.util.Dom.getElementsByClassName("nav", "a", oNavBar);
   for (var i=0; i < oNavList.length ; i++)
   {
     if (oNavList[i].innerHTML == "&gt;")
       window.location = oNavList[i].href;
   }
 }
}

function addRecentFeatured(text, days, thumbUrl) {
 if (YD.hasClass(document.body, "homepage")) {
   divTags = YD.getElementsByClassName("boxBottom", "div", YD.get("featuredBox"));

   for (i=0; i<divTags.length; i++) {
     miniBox = document.createElement("div");
     miniBox.className = "miniBox";

     photoBox = document.createElement("div");
     photoBox.className = "photo";
     miniBox.appendChild(photoBox);

     photoLink = document.createElement("a");
     photoLink.setAttribute("href", "javascript:showRecent(" + days + ");");
     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", "javascript:showRecent(" + days + ");");
     albumTitle.appendChild(albumLink);

     albumLinkText = document.createTextNode(text);
     albumLink.appendChild(albumLinkText);
     spacerDiv = document.createElement("div");
     spacerDiv.className = "spacer";
     miniBox.appendChild(spacerDiv);

     divTags[i].insertBefore(miniBox, divTags[i].childNodes[1]);

     break;
   }
 }
}

function showRecent(days) {
 endDate = new Date();
 oneDay = 1000*60*60*24;
 startDate = new Date(endDate.getTime() - (parseInt(days) * oneDay));

 sUrl = "/date/";
 sUrl += startDate.getFullYear() + "-" + padDate(startDate.getMonth() + 1) + "-" + padDate(startDate.getDate());
 sUrl += "/";
 sUrl += endDate.getFullYear() + "-" + padDate(endDate.getMonth() + 1) + "-" + padDate(endDate.getDate());

 window.location = sUrl;
}

function padDate(datePart) {
 if (datePart.toString().length != 1)
   return datePart

 return "0" + datePart;
}
