/*User Friendly Gallery URL w/Yahoo Panel Popup*/
/*2007/04/20 vA0.11*/
function checkGalleryURL() {
  if (YD.hasClass(document.body,"category")) {
    // Get the location path
    var path = window.location.pathname.toLowerCase();
    // Take the name of gallery
    var gallery = unescape(path.substr(path.lastIndexOf("/")+1));
    // replace underscore with space
    gallery = gallery.replace(/_/g," ");
    // RegExp matching
    re = new RegExp('(\\/gallery\\/\\d+).*'+gallery+'<\\/a>',"gi");
    // the albumTitle class
    divTags = YD.getElementsByClassName("albumTitle", "p");
    // loop through each gallery in this category
    for (i=0; i<divTags.length; i++) {
      results = re.exec(divTags[i].innerHTML.toLowerCase());
      if(results != null) {
        url = results[1];
        YAHOO.namespace("gallery.container");
        YAHOO.gallery.container.wait = new YAHOO.widget.Panel("wait",{ width:"240px", fixedcenter:true, close:false, draggable:false, modal:true,visible:false});
        YAHOO.gallery.container.wait.setHeader("Loading");
        YAHOO.gallery.container.wait.setBody("Gallery is loading, please wait...");
        YAHOO.gallery.container.wait.render(document.body);
        // Show the Panel
        YAHOO.gallery.container.wait.show();
        window.location.replace(url);
      }
    }
  }
}
YE.addListener(window, "load", checkGalleryURL);