--------------

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