/*
$j(document).ready(function(){
	$j('#product-options-wrapper dl dd select:enabled').each(function(){
		replaceSelect($j(this).attr('id'));
	});
});

function replaceSelect(selectID) {
	// If there's more than just the 'select an option'
	if ( $j('select#'+selectID).children().length > 1 ) {
		// Create a new ul
		var optionTitle = $j('select#'+selectID).attr('rel');
		var addThis = '<h3 class='+selectID+'>Pick your '+optionTitle+'</h3><ul class="the-options '+optionTitle+'" rel="'+selectID+'" style="display:none;">';
		// Add each select option as a list node and hyperlink
		$j('select#'+selectID).children().each(function(){
			// Only use options with a value
			if ( $j(this).val().length > 0 ) {
				theClass = $j(this).text().toLowerCase();
				theClass = theClass.replace(/ /g,'-');
				addThis += '<li><a href="#" class="'+theClass+'" title="'+$j(this).text()+'" rel="'+$j(this).val()+'">'+$j(this).text()+'</a></li>';
			}
		})
		// Close the list
		addThis += '</ul>'
		// Append the list to the end of the fieldset
		$j('fieldset#product-options-wrapper').append(addThis);
		$j('ul[rel='+selectID+']').fadeIn('slow');
		$j('fieldset#product-options-wrapper ul.the-options li a').unbind('click');
		$j('fieldset#product-options-wrapper ul.the-options li a').click(function(){ clickOption($j(this)); });
	}
}

function in_array (needle, haystack) {
	var returnVal = false;
	for (var i=0; i<haystack.length;i++) 
		if (needle == haystack[i]) returnVal = true;
	return returnVal;
}

function clickOption(theOption) {
	var selectID = theOption.parents('ul').attr('rel');
	var optionID = theOption.attr('rel');
	
	// Make it look right
	$j('ul[rel='+selectID+'] li a').removeClass('current');
	theOption.addClass('current');
	
	// Change the select option to equal the one we clicked
	$j('select#'+selectID).val(optionID);
		
	// Update that dirty Prototype object
	spConfig.configureElement($(selectID));
	
	// Find all select boxes that were set to false / 0
	var wereDisabled = new Array(); var i=0;
	$j('#product-options-wrapper dl dd select:not(:first) option:first:selected').each(function(){
		wereDisabled[i]=$j(this).parent('select').attr('id'); i++;
		$j('h3.'+$j(this).parent('select').attr('id')).remove();
		$j('ul[rel='+$j(this).parent('select').attr('id')+']').remove();
	});
	
	replaceSelect($j(this).attr('id'));
	
	// Append the previously disabled 
	$j('#product-options-wrapper dl dd select:enabled').each(function(){
		if ( in_array($j(this).attr('id'),wereDisabled) ) {
			// And (re)append the new stuff
			replaceSelect($j(this).attr('id'));
		}
	});
	return false;
}*/
