function roll_over(img_name, img_src)
   {
   document[img_name].src = img_src;
   }


YE.onContentReady("breadCrumbTrail", RemoveTopOfBreadCrumb);

function RemoveTopOfBreadCrumb() 
{
    var str = this.innerHTML;
    str = str.replace(/\n/g, " "); 
    this.innerHTML = str.replace(/^\s*<a .*?a>.*?</i, "<");
}



onPhotoShow.subscribe(ProcessDownloadButton);

function IsSmugmugView()
{
	return(YD.hasClass(document.body, "smugmug"));
}


function ProcessDownloadButton()
{
    if (IsSmugmugView())
    {
        if (photoInfo[ImageID].albumOriginals && (photoInfo[ImageID].Format !== "MP4"))
        {
            InsertDownloadButton("cartButtonsWrapper");
        }
    }
}

function InsertDownloadButton(parentId)
{
    // now add the download button
    var parentDiv = document.getElementById(parentId);
    var downloadButton = document.getElementById("downloadButtonId");
    if (parentDiv && !downloadButton)
    {
        var downloadButtonInfo =
        {
            id: "downloadButtonId",
            label: "Download Image...",
            container: parentDiv,
            type: "button",
            className: "sm-button sm-button-small themesButton glyphButton",
            onclick: { fn: InitiateDownloadImage }
        };
        
        var dButtonObj = new YAHOO.widget.Button(downloadButtonInfo);
    }
}

function InitiateDownloadImage()
{
    // construct the download URL
    window.location = "/photos/" + ImageID + "_" + ImageKey + "-D.jpg";
}

//====Splash-Page====

function makevisible(cur,which){
strength=(which==0)? 1 : 0.2

if (cur.style.MozOpacity)
cur.style.MozOpacity=strength
else if (cur.filters)
cur.filters.alpha.opacity=strength*100
}



// Here we can remove items from any drop-down menu by just passing:
//    the ID of the YUI button that holds the menu
//    the function that starts this all
//    The array of menu items to remove (it must be an exact text match)

YE.onContentReady("shareButton", RemoveMenuItemsFromButton, ["Be Social", "Social Bookmarking"]);

function RemoveMenuItemsFromButton(textItemsToRemoveArray)
{
    // 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 menu = YAHOO.widget.Button.getButton(this.id).getMenu();
    menu.beforeShowEvent.subscribe(RemoveMenuItems, textItemsToRemoveArray);
    
    function RemoveMenuItems(event, args, data)
    {
        // called in the context of the menu
        try
        {
            // for coding efficiency in lookup, lets change the passed in array to a hash table
            var textItemsToRemove = {};
            for (var j in data)
            {
                textItemsToRemove[data[j]] = true;
            }
            
            // 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 in menuItems)
            {
                // get the text value from the menu item
                var text = menuItems[i].cfg.config.text.value;
                // check to see if this menu item is in our remove table
                if (textItemsToRemove[text])
                {
                    // because of problems with lazy loading and deferred creation of objects, we cannot just remove the menu item here
                    // so, instead we just hide it
                    YD.setStyle(menuItems[i].id, 'display', 'none');
                }
            }
        } catch (e) {}        // catch any exceptions and ignore them - errors will just cause the styles not to get removed, but not affect any other scripts
    }
}
