if(typeof Pod1Catalog == 'undefined') {
        var Pod1Catalog = {};
}

/**************************** Configurabale Options **************************/
Pod1Catalog.ConfigOptions = Class.create();
Pod1Catalog.ConfigOptions.prototype = {

initialize: function(template, uppercase, attributeConfig) {
        this.template = new Template(template);
        this.attributeConfig = attributeConfig;
        this.uppercase = uppercase;
        this.superattr = $$('.super-attribute-select');
        this.superattr.each(this.initAttribute.bind(this));
},

initAttribute: function(attribute) {
        this.setLabel(attribute);
        attribute.stopObserving('change');
        attribute.observe('change', this.optionChange.bindAsEventListener(this));
},

optionChange: function(event) {
        this.attributeConfig.configureElement(Event.element(event));
        this.superattr.each(this.setLabel.bind(this));
},

setLabel: function(attribute) {
      var option = attribute.options[0];
      if(option) {
              var attributeId = attribute.identify().replace('attribute', '');
              var label = $('label'+attributeId);
              if(label) {
                      var template = this.template.evaluate({label: label.innerHTML}).stripTags();
                      option.update((true === this.uppercase ? template.toUpperCase() : template));
              }
      }
}

};


