function AddReferralCode() {
var links = this.getElementsByTagName("A");
if (links && (links.length != 0)) {
var smugLink = links.item(0);
smugLink.href = "http://www.smugmug.com/?referrer=tNsM3GGjqAVyQ";
}
}
YE.onAvailable('footer', AddReferralCode);

rightClickWarning = "All photos are property of toypix.net. All rights reserved. Unauthorized use is prohibited."; 

/*this makes double home-galleries*/
function hasPath(sPath)
{
re = new RegExp("\/" + sPath + "(\/|$)");
return re.test(window.location)
}

if (hasPath("galleries"))
YD.addClass(document.body, "galleries");




// 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 AdjustBreadcrumb()
{
    // 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 +="galleries";
    targetTag.href = str;
    targetTag.innerHTML = "Galleries";
}

YE.onContentReady("breadCrumbTrail", AdjustBreadcrumb);



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"
    });
    
    
}