function isClass(sClass) {
  sClassName = document.body.className;

  re = new RegExp(sClass + "(|$)") 

  if (!sClassName)
    return false;
  return re.test(sClassName);
}


// needed to display only a particular page e.g. "categories/galleries/featured"

function hasPath(sPath)
{
  re = new RegExp("\/" + sPath + "(\/|$)");
  return re.test(window.location)
}






// remove "with xx photos" from "xx galleries with xx photos" 

function changeCategoryInfo()
{
  re = /^([0-9]+ )(galler(y|ies))/;

  divTag1 = document.getElementById("categoriesBox");
  divTag2 = document.getElementById("subcategoriesBox");
  if ((divTag1)|| (divTag2))
  {
    if (divTag1)
      divTags = divTag1.getElementsByTagName("div");
    else
      divTags = divTag2.getElementsByTagName("div");

    for (i=0; i<divTags.length; i++)
    {
      if (divTags[i].className == "miniBox")
      {
        pTags = divTags[i].getElementsByTagName("p");
        re.exec(pTags[1].innerHTML);
        pTags[1].innerHTML = RegExp.$1 + RegExp.$2;
      }
    }
  }
}





// **********************************************
// 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);





