if (typeof Product == 'object') {
	if (typeof  Product.Config == 'function') {

		Product.Config.prototype.fillSelect = function(element){
			
		    var attributeId = element.id.replace(/[a-z]*/, '');
		    var options = this.getAttributeOptions(attributeId);
		    this.clearSelect(element);
		    
		    var emptyOptionText = this.config.chooseText
		    if (this.config.attributes[attributeId]) {
		    	if (this.config.attributes[attributeId].label) {
		    		emptyOptionText = this.config.attributes[attributeId].label;
		    	}
		    }
		    element.options[0] = new Option(emptyOptionText, '');
		
		    var prevConfig = false;
		    if(element.prevSetting){
		        prevConfig = element.prevSetting.options[element.prevSetting.selectedIndex];
		    }
		
		    if(options) {
		        var index = 1;
		        for(var i=0;i<options.length;i++){
		            var allowedProducts = [];
		            if(prevConfig) {
		                for(var j=0;j<options[i].products.length;j++){
		                    if(prevConfig.config.allowedProducts
		                        && prevConfig.config.allowedProducts.indexOf(options[i].products[j])>-1){
		                        allowedProducts.push(options[i].products[j]);
		                    }
		                }
		            } else {
		                allowedProducts = options[i].products.clone();
		            }
		
		            if(allowedProducts.size()>0){
		                options[i].allowedProducts = allowedProducts;
		                element.options[index] = new Option(this.getOptionLabel(options[i], options[i].price), options[i].id);
		                element.options[index].config = options[i];
		                index++;
		            }
		        }
		    }
		};
	}
}
