rightClickWarning = "Be advised these images are protected by a Copyright. If you would like to obtain a copy, contact the owner"; // script to replace a user's name in the breadcrumb with "Home"
YE.onContentReady("breadCrumbTrail", ReplaceTopOfBreadcrumbWithHome);

function ReplaceTopOfBreadcrumbWithHome()
{
    var str = this.innerHTML.replace(/\n/g, " ");
    this.innerHTML = str.replace(/\>[^\<]+<\/a>/i, ">Home</a>");
}


// script to remove word "galleries" from descriptions
function RemoveGalleryWord()
{
    this.innerHTML = this.innerHTML.replace(/ Galleries$| Sub-Categories$/, "");
}

YE.onAvailable("subCatGalleryTitle", RemoveGalleryWord);
YE.onAvailable("galleryTitle", RemoveGalleryWord);

// script to automatically redirect to the iphone interface from any 
// small screen webkit browser (e.g. iPhone, iPod Touch, Palm Pre, Android, etc...)

// Check if we are on a small screen
function CheckForSmallScreen(minWidth, minHeight)
{
    return(window.screen.height < minHeight || window.screen.width < minWidth);
}

// Check if the browser userAgent string is AppleWebKit
function CheckForWebKitUA()
{
    return(navigator.userAgent.search(/AppleWebKit/i) != -1);
}

// Check if the URL already has /iphone in it
function CheckForIPhoneURL()
{
    return(window.location.pathname.toString().search(/^\/iphone/i) != -1);
}

// Switch to the iphone UI if we're a webkit browser, are not already the /iPhone URL and are on a small screen
function RedirectIfSmallWebKitBrowser()
{
    var parms = window.location.search;
    if (parms.search(/autoPhoneRedirect=no|stripiPhoneCookie=yes/i) != -1)
    {
        SM.util.setCookie("autoPhoneRedirect", "no", 1);
    }
    else if (parms.search(/autoPhoneRedirect=yes/i) != -1)
    {
        SM.util.setCookie("autoPhoneRedirect", "yes", 1);
    }
    // check to see if redirection has been turned off via cookie
    var value = "";
    value = SM.util.getCookie("autoPhoneRedirect");
    if (value != "no")
    {
        if (CheckForWebKitUA() && !CheckForIPhoneURL() && CheckForSmallScreen(600,600))
        {
            window.location.replace("/iphone");
        }
    }
}

RedirectIfSmallWebKitBrowser();

//------------------------------------------------------------------------------------------------------------------------------------------
// Script to allow you to use CSS to hide any individual menu items in the Share or Style menus
// This script will add a class name to each top level menu item in the Share and Style menus.
// That class name will be of the form "buttonname_menuitemname_menuitem".
// The class name will be all lowercase and any spaces or other non-alpha numeric chars in it will be converted to underscores.
// Here are some examples of class names:
//    share_be_social_menuitem
//    share_social_bookmarking_menuitem
//    style_traditional_menuitem
//
// And some example CSS to hide a menu item would look like this:
//    .share_be_social_menuitem {display:none;}
//    .style_traditional_menuitem {display:none;}
//
// You can also hide menu items only in certain contexts using all the normal Smugmug CSS classifiers. 
// To hide social bookmarking only in your vacation category, you would use CSS like this:
//    .category_Vaction .share_be_social_menuitem {display:none;}
//------------------------------------------------------------------------------------------------------------------------------------------

YE.onContentReady("viewingStylesButton", TagMenuItemsSetup);
YE.onContentReady("shareButton", TagMenuItemsSetup);

function TagMenuItemsSetup()
{
    // now that the object is created, we can register an interest in the beforeShowEvent
    // we can't modify the menu until then because of lazyLoading
    var button = YAHOO.widget.Button.getButton(this.id);
    var menu = button.getMenu();
    var menuName = button.get("label");
    menu.beforeShowEvent.subscribe(TagMenuItems);
    
    function TagMenuItems(event, args, data)
    {
        // called in the context of the menu
        try
        {
            // get the list of menu items in our menu
            var menuItems = this.getItems();
            
            // look through each menu item to see if it matches anything in our stylesToRemove array
            for (var i = 0; i < menuItems.length; i++)
            {
                // get the text value from the menu item and make it into a new class name
                var newClassName = menuItems[i].cfg.config.text.value;
                newClassName = menuName + "_" + newClassName + "_menuitem";
                newClassName = newClassName.replace(/\s+|\&[a-z]+;|[^_a-zA-Z0-9-]/g, "_");    // replace illegal CSS chars with underscore
                // add the new class name to the menu item so we can hide/style it with pure CSS
                YD.addClass(menuItems[i].id, newClassName.toLowerCase());
                
                // if this item itself is a sub-menu, then register for it's show event too
                var submenu = menuItems[i].cfg.getProperty("submenu");
                if (submenu)
                {
                    submenu.beforeShowEvent.subscribe(TagMenuItems);
                }
            }
            // no need to call this again everytime we show the menu
            this.beforeShowEvent.unsubscribe(TagMenuItems);
        } catch (e) {}        // catch any exceptions and ignore them - errors will just cause the styles not to get removed, but not affect any other scripts
    }
}

// ------------------------------------------------------------------------------
// Code to modify the names of menu items in the viewing Style menu
// ------------------------------------------------------------------------------
YE.onContentReady("viewingStylesButton", function ()
{
    // list the menu items you want to change here
    var itemsToChange = {"SmugMug":"Default View"};
    
    var menuItems = YAHOO.widget.Button.getButton(this.id).getMenu().getItems();
    for (var i = 0; i < menuItems.length; i++)
    {
        var menuName = menuItems[i].cfg.getProperty("text");
        if (itemsToChange[menuName])
        {
            menuItems[i].cfg.setProperty("text", itemsToChange[menuName]);
        }
    }
});

