function hasPath(sPath)
{
re = new RegExp("\/" + sPath + "(\/|$)");
return re.test(window.location)
}

if (hasPath("galleries"))
YD.addClass(document.body, "galleries");



   //-- Hide Categories 
function delCategory() {
  re = /\/(Rastia|Other|Archive|Playgroup)$/;
  var oList = YD.getElementsByClassName('miniBox', 'div', this);

  for (i = 0; i < oList.length; i++) {
    if (re.test(oList[i].getElementsByTagName('a')[0].href))
      oList[i].parentNode.removeChild(oList[i]);
  }
}
if (!YD.hasClass(document.body, "loggedIn"))
{
    YE.onContentReady('categoriesBox', delCategory);
}
     //-- End Hide Categories 

YE.onDOMReady(InsertStylePicker);

function SetNewGalleryStyle(type, args, menuItem)
{
    // this click handler is called as a method of the menuItem that was clicked on
    var styleValue = this.value;        // get the value of the menu item
    
    // because we are calling styleBarChange which is expecting to be passed a comboBox object,
    // we have to create a fake comboBox object that has the new value in it so that function
    // can fetch the value from our object
    var fakeComboItem = {value: styleValue};
    var fakeComboBox = {selectedIndex: 0, options: [fakeComboItem]};
    
    // call the function that changes the style just like the Smugmug comboBox would have
    styleBarChange("Template", fakeComboBox);
}

function InsertStylePicker()
{
    if (!YD.get("stylebar"))
    {
        return;        // if there wasn't supposed to be a stylebar in this page, the don't insert our version
    }
    // declare the data for our style picker
    // you can remove any of these lines that you don't want to offer your viewers
    // just make sure the last line does not have a comma after it and all others do have a comma (IE will choke if you don't do it right)
    var stylePickerData = [
        {text: "Smugmug", value: "3", onclick: { fn: SetNewGalleryStyle }},
        {text: "Traditional", value: "4", onclick: { fn: SetNewGalleryStyle }},
        {text: "All Thumbs", value: "7", onclick: { fn: SetNewGalleryStyle }},
        {text: "Slideshow", value: "8", onclick: { fn: SetNewGalleryStyle }},
        {text: "Journal", value: "9", onclick: { fn: SetNewGalleryStyle }},
        {text: "Filmstrip", value: "11", onclick: { fn: SetNewGalleryStyle }},
        {text: "Critique", value: "12", onclick: { fn: SetNewGalleryStyle }}
    ];
    
    // now put a checkmark by the currently selected style which we get from the galleryStyle variable
    if (galleryStyle)
    {
        var tempStyle = galleryStyle.toLowerCase();
        tempStyle = tempStyle.replace("_", " ");
        for (var i in stylePickerData)
        {
            if (stylePickerData[i].text.toLowerCase() == tempStyle)
            {
                stylePickerData[i].checked = true;
                break;
            }
        }
    }
    
    // declare the style menu button
    // You can change the button text, by changing the quoted string for the label line below
    // You can put it a different place in your page by changing the container object to a different DIV object in the page
    var styleMenu = new YAHOO.widget.Button({
        id: "customStylebarMenu",
        name: "customStylebarMenu",
        type: "menu",
        menu: stylePickerData,
        label: "Style",
        className: "sm-button sm-button-small themesButton glyphButton menuButton",
        container: "altViews"
    });
    
    
}

     // Change Guestbook Gallery to Guestbook Comments
function ModifyText ()
{
  if (YD.hasClass(document.body, "gallery_6556963"))
  {
    var objElement = YD.get("comment")
    if (objElement != null)
    {
      var str = new String(objElement.innerHTML);
      str = str.replace(/\gallery/gi, 'Guestbook');
      objElement.innerHTML = str;
    }
  }
}

YE.onAvailable("comment", ModifyText);



    // Page turner
YE.addListener(document, "keyup", pageNav);

function pageNav(e) {
  if (!e) 
    e = window.event;

  if (!YD.hasClass(document.body, "galleryPage"))
    return;

  switch (e.keyCode) {
    case 37:
      chk = "&lt;";
      break;

    case 39:
      chk = "&gt;";
      break;

    default:
      return;
  }
  
  oList = YD.getElementsByClassName("nav", "a", YD.get("albumNav_top"));
  for (var i=0; i < oList.length ; i++) {
    if (oList[i].innerHTML == chk) {
      window.location = oList[i].href;
      break;
    }
  }
}

function norobotmail(aUser, aDomain) { document.location = "mailto:" + aUser + "@" + aDomain; }

rightClickWarning = "All photos are property of Stewart Lines and Between The Lines Photography. All rights reserved. Unauthorized use is prohibited."; 


  // Non clickable link in Guestbook 6556963
function doOnLoad() {
  if (window.AlbumID && (window.AlbumID == "6556963")) //
  removeLinkFromImg();
}

function removeLinkFromImg()

{

    var links = document.getElementsByTagName("A");

    for (var i = 0; i < links.length; i++)

    {

        var link = links[i];

        var divElm = link.parentNode;

        if (!divElm)

            continue;

        divElm = divElm.parentNode;

        if (!divElm)

            continue;

        if (divElm.className.indexOf("photo")<0)

            continue;

        link.href = "javascript:void(0);";

    }

} 




 



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)

 "Photography" : "Windows On the World",
 "Landscapes" : "Sunrises & Sunsets, Bush & the Outback...",
 "Travel" : "Images from around the world",
 "Northern Territory": "The Tropical North"
 };
 
 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);
