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"
});


}

function hasPath(sPath)
{
re = new RegExp("\/" + sPath + "(\/|$)");
return re.test(window.location)
}

if (hasPath("galleries"))
YD.addClass(document.body, "galleries");

function ModifyText ()
{
if (YD.hasClass(document.body, "7402940_GbkQf")) 
{
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);