function hasPath(sPath)
{
re = new RegExp("\/" + sPath + "(\/|$)");
return re.test(window.location)
}
 
if (hasPath("inicio"))
YD.addClass(document.body, "inicio");
 
if (hasPath("home"))
YD.addClass(document.body, "home");
rightClickWarning = "All photos are property of Photographie Jonathan Houle. All rights reserved. Unauthorized use is prohibited.";
function addCategoryTitleToBreadcrumb(description) 
{
    var breadCrumb = YD.get("breadcrumb");
    if (breadCrumb)
    {
        var divTag = document.createElement("div");
        divTag.className = "categoryDescription";
        divTag.appendChild(document.createTextNode(description));
        breadCrumb.parentNode.insertBefore(divTag, breadCrumb.nextSibling);
    }
}
 
function addCategoryTitleToThumbs(descriptionObject, boxObjectName) 
{
    var re = /\>([^\<]+)<\/a>/i;    // pattern to find the category name between the <a> and </a> tags
    var divTag = YD.get(boxObjectName);
    if (divTag) 
    {
        var divTags = YD.getElementsByClassName("albumTitle", "p", divTag);
        for (var i = 0; i < divTags.length; i++) 
        {
            var matches = re.exec(divTags[i].innerHTML);    // get just the category name
            // if we found a category name and the category name exists in our categoryDescription object, then add the description
            if (matches && (matches.length > 1) && descriptionObject[matches[1]] != undefined) 
            {
                var pTag = document.createElement("p");
                pTag.className = "categoryDescription";
                pTag.appendChild(document.createTextNode(descriptionObject[matches[1]]));
                divTags[i].parentNode.insertBefore(pTag, divTags[i].nextSibling);
            }
        }
    }
}
 
/* Category descriptions */
function addCategoryDescription() 
{
    var categoryDescription = {
        // list "categoryname" : "category title",
        // or "categoryname.subcategoryname" : "subcategory title",
        // Examples:
        // "Kenya"  : "Our vacation to Kenya",
        // "Kenya.Highlights" : "The highlights galleries from our vacation to Kenya",
        // VERY IMPORTANT.  This table must be formatted perfectly. 
        // quoted string : quoted string followed by a comma
        // except the last line of the table cannot have a comma after it (or it won't work in IE)
 
        "Ville de Qubec"  : "Ville de Québec",
        "Misc. Photos.Portfolio" : "Portfolio",
        "Le Canada" : "Canada",
        "Divers.Portfolio": "Portfolio",
        "Fotos de viajes"  : "Fotos de viajes",
        "Es.Portafolio"  : "Portafolio",
        "Clients": "Clients",
        "Galeries.La Vieille Capitale"  : "La Vieille Capitale",
"Galeries.Canada"  : "Canada",
"Galeries.Nouveau"  : "Nouveau",
"Divers"  : "Divers",
"Divers.Nature"  : "Nature",
"Divers.Europe 2007"  : "Europe 2007",
"Quebec City"  : "Quebec City",
"Galleries.All New"  : "All New",
"Misc Photos.Europe 2007"  : "Europe 2007",
"Misc Photos"  : "Misc. Photos",
"Misc Photos.Nature"  : "Nature",
"Misc Photos.Portfolio"  : "Portfolio",
"Canada"  : "Canada",
"Fotos de viajes.Ciudad de Quebec"  : "Ciudad de Quebec",
"Fotos de viajes.Canada"  : "Canada",
"Fotos de viajes.Novedades"  : "Novedades",
"Fotos de viajes.Naturaleza canadiense"  : "Naturaleza canadiense",
"Fotos de viajes.Panoramas"  : "Panoramas",
"Fotos de viajes.Europa 2007"  : "Europa 2007"
    };
    
    var re, matches, i;        // various local variables
 
    // now fix it so that it works automatically even if the category or sub-category name has spaces in it
    // we replace those spaces with underscores (which is what the classname does) and add those to our object so we can match those too
    for (i in categoryDescription) 
    {
        var newName = i.replace(/ /g, "_");
        categoryDescription[newName] = categoryDescription[i];    // add a property to the object that has only underscores in the name
    }
    // on the homepage, we want to check for category names and add a description if a match found
    // on a category page, we want to check to see if the category that the page is needs a description under the breadcrumb
    //      and, we need to see if any of the sub-category items on the page need us to add a description under the name
    // on a sub-category page, we want to check to see if the sub-category that the page is needs a description under the breadcrumb
    if (YD.hasClass(document.body, "category")) 
    {
        // fetch the category name
        re = /category_(\S+)/i;
        matches = re.exec(document.body.className);
        if (matches && (matches.length > 1)) 
        {
            var categoryName = matches[1];
            // now see if we have a subcategory too
            if (YD.hasClass(document.body, "subcategory")) 
            {
                re = /subcategory_(\S+)/i;
                matches = re.exec(document.body.className);
                if (matches && (matches.length > 1)) 
                {
                    var subcatName = matches[1];
                    // category and subcategory so we are on a subcategory page showing a list of galleries in this subcategory
                    // we need to just add a subcategory title to this page if the category-subcategory matches
                    var fullName = categoryName + "." + subcatName;
                    if (categoryDescription[fullName])
                    {
                        addCategoryTitleToBreadcrumb(categoryDescription[fullName]);
                    }
                }
            }
            // here we're on a category page
            // we need to add a category description for the category page
            // and potentially add subcategory descriptions to the subcategory names displayed on this page
            else 
            {
                if (categoryDescription[categoryName])
                {
                    addCategoryTitleToBreadcrumb(categoryDescription[categoryName]);
                }
                // now we need to build a temporary subcategoryDescription object that has only the subcategory names in it that are in this category
                var subcatDescriptions = {};
                re = new RegExp("^" + categoryName + "\\.(.+)$", "i");
                for (i in categoryDescription)
                {
                    matches = re.exec(i);
                    if (matches && (matches.length > 1))
                    {
                        subcatDescriptions[matches[1]] = categoryDescription[i];
                    }
                }
                addCategoryTitleToThumbs(subcatDescriptions, "subcategoriesBox");
            }
        }
    }
 
    // then see if we're on the homepage
    if (YD.hasClass(document.body, "homepage")) 
    {
        addCategoryTitleToThumbs(categoryDescription, "categoriesBox");
    }
}
 
YE.onDOMReady(addCategoryDescription);
 
// 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 AdjustBreadcrumbByCategory()
{
// these are the category identifiers and the top level name you want to have for that category
var topNameIndex = {
category_Ville_de_Qubec: "Accueil",
category_Divers: "Accueil",
category_Le_Canada: "Accueil",
category_Canada: "Home",
category_Quebec_City: "Home",
category_Misc_Photos: "Home",
category_Fotos_de_viajes: "Inicio"
};
 
var adjustArgs = new Array;
var newTopName = "www.jonathanhoule.com"; // use this as the name if no category is matched
 
for (var i in topNameIndex)
{
if (YD.hasClass(document.body, i))
{
newTopName = topNameIndex[i];
break;
}
}
adjustArgs.push(newTopName);
AdjustBreadcrumbInternal.apply(this, adjustArgs);
}
 
function AdjustBreadcrumbInternal(topName)
{
// 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 +="";
targetTag.href = str;
targetTag.innerHTML = topName;
}
 
YE.onContentReady("breadCrumbTrail", AdjustBreadcrumbByCategory);
 

